For the complete documentation index, see llms.txt. This page is also available as Markdown.

React Native with REST API Integration

Integrate Juspay Hyperswitch SDK to your React Native App using hyperswitch-node

Use this guide to integrate the Juspay Hyperswitch React Native SDK to your React Native app. You can use the following Demo App as a reference with your Hyperswitch credentials to test the setup.

Find the Demo App

Find the demo app here

Before proceeding with these steps, please ensure that your payment methods are configured here.

Requirements

1. Setup the server

Follow the Server Setup section.

2. Build checkout page on the client

2.1 Install the @juspay-tech/react-native-hyperswitch library

Install the packages and import it into your code

2.2 Peer Dependencies

Install the following dependencies

2.3 iOS Only

Run pod install in iOS folder

2.4 Initialize Hyperswitch

Initialize Hyperswitch once using your publishable key and profile ID. Reuse the same initialized instance throughout your application.

Keep the Hyperswitch secret API key on your backend only. The app should never handle it.

3. Complete the checkout on the client

3.1 Get sdk_authorization from your Backend

Call your payment-creation endpoint. Its JSON response must contain sdk_authorization.

3.2 Create a Payment Session

Pass the sdk_authorization returned by your backend to initPaymentSession.

3.3 Present the Payment Sheet

Call presentPaymentSheet() on the payment session and handle the returned result.

3.4 Handle the Result

result.status

Meaning

Recommended app behavior

completed

The Payment Sheet completed the payment flow.

Show a success state and ask the backend to verify the payment before fulfillment.

canceled

The customer closed or canceled the Payment Sheet.

Return to checkout and allow the customer to try again.

failed

The payment flow failed.

Display result.message when appropriate and allow a retry.

Important Notes

  • Initialize Hyperswitch once and reuse the same instance throughout the application.

  • Create a new payment session using the latest sdk_authorization returned by the backend.

  • Do not place the Hyperswitch secret API key in the React Native application.

Congratulations! Now that you have integrated the payment sheet

Last updated

Was this helpful?