diff --git a/services/nginx/app/classes/stripe.php b/services/nginx/app/classes/stripe.php index 7deef11f..6704f223 100644 --- a/services/nginx/app/classes/stripe.php +++ b/services/nginx/app/classes/stripe.php @@ -8,6 +8,7 @@ require_once WD . '/modules/stripe/endpoints/stripe_endpoint_payment_link.php'; require_once WD . '/modules/stripe/endpoints/stripe_endpoint_product.php'; require_once WD . '/modules/stripe/endpoints/stripe_endpoint_prices.php'; require_once WD . '/modules/stripe/endpoints/stripe_endpoint_invoice.php'; +require_once WD . '/modules/stripe/endpoints/stripe_endpoint_readers.php'; // Require all helper classes @@ -24,6 +25,7 @@ use stripe\endpoints\stripe_endpoint_invoice; use stripe\endpoints\stripe_endpoint_payment_link; use stripe\endpoints\stripe_endpoint_prices; use stripe\endpoints\stripe_endpoint_product; +use stripe\endpoints\stripe_endpoint_readers; use stripe\stripe_c; use Stripe\StripeClient; @@ -63,12 +65,18 @@ class stripe implements stripe_i * @var stripe_endpoint_invoice */ public stripe_endpoint_invoice $invoice; + /** + * Readers endpoint + * @var stripe_endpoint_readers + */ + public stripe_endpoint_readers $readers; /** * Stripe client * @var StripeClient */ protected StripeClient $client; + public function __construct() { $this->config = new stripe_c(); @@ -77,6 +85,7 @@ class stripe implements stripe_i $this->product = new stripe_endpoint_product(); $this->prices = new stripe_endpoint_prices(); $this->invoice = new stripe_endpoint_invoice(); + $this->readers = new stripe_endpoint_readers(); } /** diff --git a/services/nginx/app/modules/stripe/endpoints/stripe_endpoint_readers.php b/services/nginx/app/modules/stripe/endpoints/stripe_endpoint_readers.php new file mode 100644 index 00000000..8340a848 --- /dev/null +++ b/services/nginx/app/modules/stripe/endpoints/stripe_endpoint_readers.php @@ -0,0 +1,26 @@ +terminal->readers->all(); + } + + +} \ No newline at end of file diff --git a/services/nginx/app/routes/moduleStripeRoute.php b/services/nginx/app/routes/moduleStripeRoute.php index fa785374..a4abe256 100644 --- a/services/nginx/app/routes/moduleStripeRoute.php +++ b/services/nginx/app/routes/moduleStripeRoute.php @@ -139,5 +139,23 @@ class moduleStripeRoute 'modules_stripe_invoice_send' => 'Send invoice' ] ); + + self::get('/modules/stripe/terminals', function () { + global $response; + self::requirePermission('modules_stripe_terminals_list'); + $user = (new authentication())->get_user(); + if ($user) { + (new logs_o())->add('modules_stripe', 'global', 1, 0, 'MODULES_STRIPE', 'User accessed the terminals list'); + $result = (new stripe())->readers->list(); + $response->success((object)$result); + } else { + (new logs_o())->add('modules_stripe', 'global', 0, 0, 'MODULES_STRIPE', 'User tried to access the terminals list without a valid session'); + $response->error('Invalid session', 400); + } + }, + [ + 'modules_stripe_terminals_list' => 'List all Stripe payment terminals' + ] + ); } } \ No newline at end of file