1. Setup the Server
Follow the Server Setup section.2. Build Checkout Page on the Client
2.1 Load Vaultera Switch Loader
Use Vaultera switch SDK to ensure PCI compliant means of accepting payment details from your customer and sending it directly to the Vaultera Switch server. Always load Vaultera switch SDK fromhttps://sdk.test.switch.vaultera.co to ensure compliance. Please refrain from including the script in a bundle or hosting it yourself.
2.2 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. Add one empty placeholder div to your checkout form for each Widget that you’ll mount. HyperLoader inserts an iframe into each div to securely collect the customer’s email address and payment information.2.3 Initialize Vaultera Switch SDK
Initialize Vaultera Switch SDK onto your app with your publishable key using the Hyper constructor. You’ll use HyperLoader to create the Unified Checkout and complete the payment on the client. To get a Publishable Key, please find it here.Unified Checkout
2.4 Fetch the Payment and Create the Unified Checkout
Immediately make a request to the endpoint on your server to create a new Payment as soon as your checkout page loads. TheclientSecret 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.
Following this, create a unifiedCheckout and mount 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. The form automatically collects the associated payment details for the selected payment method type.
3. Complete Payment on the Client
3.1 Handle the Submit Event and Complete the Payment
Note: This step is not required if sdk is handling the payment button click, this is how it will be if you have followed the previous steps. Listen to the form’s submit event to know when to confirm the payment through the Switch API. CallconfirmPayment(), passing along the unifiedCheckout and a return_url to indicate where Switch 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.