React Native Integration
Learn more about integrating Cashfree SDK in your react native app
Payment Gateway React Native Guide
Setting Up SDK
The React Native SDK is hosted on npm.org you can get the sdk here.
Our React Native SDK supports Android SDK version 19 and above and iOS minimum deployment target of 10.3 and above. Navigate to your project and run the following command.
iOS
Add this to your application’s info.plist
file.
Step 1: Creating an Order
The first step in the integration is to create an Order. You can add an endpoint to your server which creates this order and integrate this server endpoint with your frontend.
Here’s a sample request for creating an order using your desired backend language. Cashfree offers backend SDKs to simplify the integration process.
You can find the SDKs here.
After successfully creating an order, you will receive a unique order_id
and payment_session_id
that you need for subsequent steps.
You can view all the complete api request and response for /orders
here.
Step 2: Opening the Payment Page
Once the order is created, the next step is to open the payment page so the customer can make the payment. The React Native SDK offer below payment flow:
To complete the payment, we can follow the following steps:
- Create a
CFSession
object. - Set
payment callback
. - Initiate the payment
Create a Session
This object contains essential information about the order, including the payment session ID (payment_session_id
) and order ID (order_id
) obtained from Step 1. It also specifies the environment (sandbox or production).
Set payment callback
The SDK exposes an interface CFCallback to receive callbacks from the SDK once the payment flow ends.
Initiate the Payment
Sample Code
Step 4: Confirming the Payment
Once the payment is completed, you need to confirm whether the payment was successful by checking the order status. After payment user will be redirected back to your component.
To verify an order you can call our /pg/orders
endpoint from your backend. You can also use our SDK to achieve the same.
Testing
You should now have a working checkout button that redirects your customer to Cashfree Checkout.
- Click the checkout button.
- You’re redirected to the Cashfree Checkout payment page.
If your integration isn’t working:
Error Codes
To confirm the error returned in your android application, you can view the error codes that are exposed by the SDK.
Other Options
Was this page helpful?