Server-Side: Create a Session
Create payment sessions from your backend using your API key. This returns a session ID and token that the client uses to open the payment modal.Request Parameters
Response
Client-Side: Launch the Payment Modal
Pass the session credentials to the SDK service to open the payment modal.What executePayment Does
The executePayment method handles the full payment lifecycle:
1
Creates the session
Calls your server’s
POST /api/payment-sessions endpoint with the amount and currency.2
Initializes the SDK
Loads the SDK bundle (if not already loaded) and initializes it with your merchant configuration.
3
Opens the modal
Calls
sdk.open() with the session ID and token. The customer sees the payment modal with wallet options.4
Returns the result
On success, returns the transaction hash and session details. On cancellation, throws a
CubePayClosedError.Using in a React Component
The SDK modal supports both mobile (drawer) and desktop (dialog) layouts automatically based on viewport size.