Integrate web client on your web app
Integrate web client for a seamless, blended and an unified payment experience
In this section, you will learn to integrate the web client on your web app
Assuming that the web client is hosted successfully, you can now integrate the web client on your HTML web app with the following steps.
If your web app is in other tech stack (for eg., React, Angular, etc.), you can follow our documentation for reference integrations.
1. Build checkout page on the client
1.1 Load HyperLoader
Use HyperLoader
to accept payment details from your customer and send them to the your hosted app server. Load HyperLoader
from https://{{YOUR_WEB_CLIENT_URL}}/HyperLoader.js
1.2 Define the payment form
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.
1.3 Initialize HyperLoader
Initialize HyperLoader
onto your app with your publishable key with the Hyper
constructor. You’ll use HyperLoader
to create the Unified Checkout and complete the payment on the client.
1.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. The clientSecret
returned by your endpoint is used to complete the payment.
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.
2. Complete payment on the client
2.1 Handle the submit event and complete the payment
Listen to the form’s submit event to know when to confirm the payment through the hyper API.
Call confirmPayment()
, 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
.
Also if there are any immediate errors (for example, your customer’s card is declined), HyperLoader
returns an error. Show that error message to your customer so they can try again.
2.2 Display a payment status message
When Hyper redirects the customer to the return_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.
That's it! You have successfully integrated your hosted web client on your web app. Now you can collect payments from your customers in a secure way.
The web client allows you to customize the appearance according to your web app for a better blended UI. Please check the customization options for more details.
Next step:
Last updated