| 1 |
<?php |
| 2 |
/** |
| 3 |
* GatewayAdapter — single contract for client-side payment-intent creation. |
| 4 |
* |
| 5 |
* Each payment gateway (Stripe, PayPal, Square, Razorpay, …) optionally |
| 6 |
* implements this interface so both the traditional /checkout/ page (vanilla JS) |
| 7 |
* and the embedded React checkout can share one REST endpoint |
| 8 |
* (`POST /storeengine/v1/checkout/payment-intent/{gateway_id}`) for |
| 9 |
* pre-confirmation client-side flows (Stripe PaymentIntents, PayPal order |
| 10 |
* creation, etc.). |
| 11 |
* |
| 12 |
* For gateways that don't need a client-confirmation step (offline / COD), |
| 13 |
* implementing this interface is unnecessary — the place_order endpoint runs |
| 14 |
* gateway->process_payment() directly. |
| 15 |
* |
| 16 |
* @since 1.8.2 |
| 17 |
*/ |
| 18 |
|
| 19 |
namespace StoreEngine\Interfaces; |
| 20 |
|
| 21 |
use StoreEngine\Classes\Cart; |
| 22 |
use StoreEngine\Classes\Order; |
| 23 |
use WP_Error; |
| 24 |
|
| 25 |
if ( ! defined( 'ABSPATH' ) ) { |
| 26 |
exit; |
| 27 |
} |
| 28 |
|
| 29 |
interface GatewayAdapterInterface { |
| 30 |
|
| 31 |
/** |
| 32 |
* Create the gateway's client-side intent for the given order. |
| 33 |
* |
| 34 |
* @return array|WP_Error Normalised payload the React adapter / vanilla-JS client |
| 35 |
* understands. Common keys (any may be omitted): |
| 36 |
* - client_secret string Stripe/Square style. |
| 37 |
* - intent_id string PaymentIntent / Order id. |
| 38 |
* - redirect_url string Hosted-page redirect (PayPal redirect flow, etc.). |
| 39 |
* - requires_action array Gateway-specific extra step. |
| 40 |
*/ |
| 41 |
public function create_intent( Order $order, Cart $cart ); |
| 42 |
} |
| 43 |
|