| 1 |
<?php |
| 2 |
|
| 3 |
namespace IvyForms\Routes\Payment; |
| 4 |
|
| 5 |
use IvyForms\Controllers\Payment\GetPaymentController; |
| 6 |
use IvyForms\Controllers\Payment\SearchPaymentsController; |
| 7 |
use IvyForms\Vendor\DI\Container; |
| 8 |
use WP_REST_Server; |
| 9 |
|
| 10 |
class Payment |
| 11 |
{ |
| 12 |
public static function registerRoutes(Container $container, string $namespace): void |
| 13 |
{ |
| 14 |
register_rest_route( |
| 15 |
$namespace, |
| 16 |
'/payments', |
| 17 |
[ |
| 18 |
'methods' => WP_REST_Server::READABLE, |
| 19 |
'callback' => $container->get(SearchPaymentsController::class), |
| 20 |
'permission_callback' => static function () { |
| 21 |
return current_user_can('manage_options'); |
| 22 |
}, |
| 23 |
] |
| 24 |
); |
| 25 |
|
| 26 |
register_rest_route( |
| 27 |
$namespace, |
| 28 |
'/payment/entry/(?P<entryId>\d+)', |
| 29 |
[ |
| 30 |
'methods' => WP_REST_Server::READABLE, |
| 31 |
'callback' => $container->get(GetPaymentController::class), |
| 32 |
'permission_callback' => static function () { |
| 33 |
return current_user_can('manage_options'); |
| 34 |
}, |
| 35 |
] |
| 36 |
); |
| 37 |
} |
| 38 |
} |
| 39 |
|