| 1 |
<?php |
| 2 |
|
| 3 |
namespace IvyForms\Controllers\Square; |
| 4 |
|
| 5 |
use IvyForms\Common\Sanitizer\Sanitizer; |
| 6 |
use IvyForms\Controllers\Controller; |
| 7 |
use IvyForms\Services\Payment\SquarePaymentService; |
| 8 |
use IvyForms\Services\Translations\BackendStrings; |
| 9 |
use WP_REST_Request; |
| 10 |
use WP_REST_Response; |
| 11 |
|
| 12 |
class SquareLocationsController extends Controller |
| 13 |
{ |
| 14 |
private SquarePaymentService $squarePaymentService; |
| 15 |
|
| 16 |
public function __construct(SquarePaymentService $squarePaymentService) |
| 17 |
{ |
| 18 |
$this->squarePaymentService = $squarePaymentService; |
| 19 |
} |
| 20 |
|
| 21 |
public function handle(WP_REST_Request $data): WP_REST_Response |
| 22 |
{ |
| 23 |
Sanitizer::verifyNonce($data->get_header('X-WP-Nonce')); |
| 24 |
|
| 25 |
$locations = $this->squarePaymentService->getLocations(); |
| 26 |
|
| 27 |
return new WP_REST_Response(['locations' => $locations], 200); |
| 28 |
} |
| 29 |
} |
| 30 |
|