| | |
| | | Route::for('square/process-payment') |
| | | ->post([$this, 'handlePaymentProcessing']) |
| | | ->auth('public') |
| | | ->rateLimit(2); |
| | | ->rateLimit(2) |
| | | ->register(); |
| | | |
| | | Route::for('square/saved-cards') |
| | | ->post([$this, 'getSavedCards']) |
| | | ->auth('user') |
| | | ->rateLimit(5); |
| | | ->rateLimit(5) |
| | | ->register(); |
| | | |
| | | Route::for('square/order-history') |
| | | ->get([$this, 'getOrderHistory']) |
| | | ->auth('user') |
| | | ->rateLimit(5); |
| | | ->rateLimit(5) |
| | | ->register(); |
| | | |
| | | Route::for(Route::pattern('square/order-status/{order_id}')) |
| | | ->get([$this, 'getOrderStatus']) |
| | | ->auth('public') |
| | | ->rateLimit(20); |
| | | ->rateLimit(20) |
| | | ->register(); |
| | | } |
| | | |
| | | //TODO: Are we processing this through our server at all? Or is it in the javascript going straight to square? |
| | |
| | | { |
| | | $data = $request->get_json_params(); |
| | | |
| | | |
| | | // Generate idempotency key from cart_id + timestamp |
| | | // This ensures retries use SAME key |
| | | $cart_id = $data['cart_id'] ?? ''; |
| | |
| | | public function getSavedCards(WP_REST_Request $request):WP_REST_Response |
| | | { |
| | | $data = $request->get_params(); |
| | | error_log('Getting Saved Cards: '.print_r($data, true)); |
| | | $user_id = absint($data['user']??0); |
| | | if ($user_id === 0) { |
| | | return $this->validationError(['message' => 'Not logged in']); |
| | | return $this->success(['cards' => []]); |
| | | } |
| | | |
| | | $square = JVB()->connect('square'); |