restaurant_id); if (!$woocommerceCheckout->enabled) return null; return [ 'id' => 'woocommerce', 'title' => $woocommerceCheckout->title, 'description' => $woocommerceCheckout->description, ]; } public function woocommerce_create() { $restaurant_id = intval($_REQUEST['restaurantId']); $booking_id = intval($_REQUEST['booking_id']); if ( ! $this->verify_nonce($restaurant_id) && ! $this->verify_nonce('stripe-'.$restaurant_id) ) { wp_send_json_error(['error' => __eva('Invalid nonce. Try to refresh the page.')]); } if (!defined('ALEXR_PRO_VERSION')) { wp_send_json_error(['error' => __eva('Need the PRO plugin enabled.')]); } if (!class_exists('Alexr\Payments\GatewayWoocommerce')) { wp_send_json_error(['error' => __eva('Need the WooCommerce addon enabled.')]); } $booking = \Alexr\Models\Booking::find($booking_id); if (!$booking) { wp_send_json_error(['error' => __eva('Invalid booking')]); } $amount = floatval($_REQUEST['amount']); $gateway = new \Alexr\Payments\GatewayWoocommerce($restaurant_id); $gateway_payment = $gateway->create_gateway_payment($booking, $amount); $success= $gateway_payment['success']; $data = $gateway_payment['data']; if (!$success) { wp_send_json_error(['error' => $data['error']]); } wp_send_json_success(['redirect' => $data['redirect']]); } }