React Native with REST API Integration
Integrate Juspay Hyperswitch SDK to your React Native App using hyperswitch-node
Find the Demo App
Find the demo app here
Before proceeding with these steps, please ensure that your payment methods are configured here.
Requirements
Android 7.0 (API level 24) and above
Android Gradle Plugin 7.3.1
Gradle 7.5.1+
iOS 12.4 and above
CocoaPods
npm
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.
Retrieve the payment status from the Juspay Hyperswitch backend to determine the final (terminal) status of the transaction. Do not rely solely on the status returned by the SDK, as it may not always represent the definitive outcome of the payment.
Collect Billing Address From Wallet should be enabled in the Hyperswitch Dashboard for wallet payment methods to work.
Important Notes
Initialize Hyperswitch once and reuse the same instance throughout the application.
Create a new payment session using the latest
sdk_authorizationreturned 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?

