Demo App
[Link to demo app]1. Setup the Server
Follow the Server Setup section.2. Build Checkout Page on the Client
2.1 Define the Payment Form
This step is recommended for the Unified Checkout for an enhanced user experience. In case you are integrating Express Checkout (mentioned later below), this step is not required.
2.2 Fetch the Payment and Create the Checkout
clientSecret returned by your endpoint is used to complete the payment.
Important: Make sure to never share your API key with your client application as this could potentially compromise your payment flow.
UnifiedCheckout: Creates a unifiedCheckout and mounts it to the placeholder div in your payment form. This embeds an iframe with a dynamic form that displays configured payment method types available from the Payment, allowing your customer to select a payment method.
ExpressCheckout: The Express Checkout Element gives you a single integration for accepting payments through one-click payment buttons. Supported payment methods include ApplePay, GooglePay and PayPal. Create an expressCheckout and mount it to the placeholder div in your payment form.
In case you want the SDK to be loaded on a particular event (like button click), you can call the initialize function on that event.
2.3 Additional Callback Handling for Wallet Payment Process
This document outlines the details and functionality of optional callbacksonSDKHandleClick and completeDoThis that can be provided by merchants during the payment process. These callbacks allow merchants to hook into the payment flow at key stages and handle specific actions or events before continuing the normal flow.
onSDKHandleClick: This callback is triggered immediately after the user clicks any wallet button.
completeDoThis: This callback is triggered after the payment is completed, just before the SDK redirects to the walletReturnUrl provided. It allows the merchant to handle actions post-payment. If not provided, the SDK’s default flow will proceed.
Redirection Handling: The
completeDoThis callback should handle redirection or any steps needed after payment, as the SDK no longer does this automatically. You must ensure to implement the necessary redirection logic.Fallback: If no callbacks are provided by the merchant, the SDK will continue with its default behavior, including automatic redirection after payment completion.
Example Usage
3. Complete Payment on the Client
3.1 Handle the Submit Event and Complete the Payment
Note: This step is not required for ExpressCheckout. Listen to the form’s submit event to know when to confirm the payment through the Hyper API. CallconfirmPayment(), passing along the unifiedCheckout and a return_url to indicate where Hyper should redirect the user after they complete the payment. Hyper redirects the customer to an authentication page depending on the payment method. After the customer completes the authentication process, they’re redirected to the return_url.
3.2 Display a Payment Status Message
When Hyper redirects the customer to thereturn_url, the payment_intent_client_secret query parameter is appended by HyperLoader. Use this to retrieve the Payment to determine what to show to your customer.