Skip to main content
Pesaswap is designed to facilitate the integration and management of payment-related functionalities in a decoupled or headless architecture with flexibility to customize your checkout UI.

Customize the Payment Experience Using Headless Functions

1. Initialize the Pesaswap SDK

Initialize Pesaswap Headless SDK onto your app with your publishable key. To get a Publishable Key please find it here.
// Source Hyperloader on your HTML file using the <script /> tag
hyper = Hyper.init("YOUR_PUBLISHABLE_KEY", {
    customBackendUrl: "YOUR_BACKEND_URL",
    // You can configure this as an endpoint for all the API calls such as session, payments, confirm call.
});

2. Create a Payment Intent

Make a request to the endpoint on your server to create a new payment. The clientSecret returned by your endpoint is used to initialize the payment session.
Make sure to never share your API key with your client application as this could potentially compromise your security.

3. Initialize your Payment Session

Initialize a payment session by passing the clientSecret to the initPaymentSession.
paymentSession?.initPaymentSession(paymentIntentClientSecret: paymentIntentClientSecret)

Options (Required)

ParameterDescription
clientSecretRequired. Identifier of the payment (string).

4. Craft a Customized Payments Experience

Using the paymentSession object, you can fetch the customer’s default payment method data and confirm the payment using confirmWithCustomerDefaultPaymentMethod.
private var handler: PaymentSessionHandler?

func initSavedPaymentMethodSessionCallback(handler: PaymentSessionHandler) -> Void {
    self.handler = handler
}

@objc func launchHeadless(_ sender: Any) {
    hyperViewModel.paymentSession?.getCustomerSavedPaymentMethods(initSavedPaymentMethodSessionCallback)
    getDefault.isEnabled = true
    getLast.isEnabled = true
    getData.isEnabled = true
}

@objc func getCustomerDefaultSavedPaymentMethodData(_ sender: Any) {
    let paymentMethod = self.handler?.getCustomerDefaultSavedPaymentMethodData()
}

Payload for confirmWithCustomerDefaultPaymentMethod(payload)

Options (Required)

ParameterDescription
confirmParamsObject containing parameters that will be passed to the Hyper API.
redirect(web only) Can be either 'always' or 'if_required'. If set to 'always', user is redirected after confirmation. 'if_required' only redirects if needed.

ConfirmParams Object

ParameterDescription
return_url(web only) URL your customer will be directed to after payment.