This page describes the raw card flow, where your application collects the card number directly and is responsible for PCI DSS (Payment Card Industry Data Security Standard) compliance. To avoid handling raw card numbers, use the React Native Custom Card Component instead, which captures the card number inside an SDK-managed input field.
Prerequisites
Complete the following tasks before you start the integration:- Create a Cashfree Merchant Account.
- Log in to the Merchant Dashboard and generate an App ID and Secret Key. Learn how to generate API keys.
- Use Cashfree React Native SDK version 2.4.0 or above. Get it from npm.
- Set your Android application’s
minSdkVersionto API level 19 or higher. - Set your iOS minimum deployment target to 10.3 or higher.
Step 1
Create an order
Step 2
Open the payment page
Step 3
Confirm the payment
Step 1: Create an order Server-side
Create an order from your backend server before you process any payment.This API requires your secret key. Create orders through your server only. Do not call this API directly from your mobile application.
API request for creating an order
Here’s a sample request for creating an order using your desired backend language. Cashfree offers backend SDKs to simplify the integration process.order_id and payment_session_id that you need for subsequent steps.
You can view the complete API request and response for /orders in the Create Order API.
Step 2: Open the payment page Client-side
After you create the order, open the payment page so the customer can provide payment details.1. Set up the SDK
The React Native SDK is hosted on npm. You can get the SDK 2.4.0. The React Native SDK supports Android SDK version 19 and above and iOS minimum deployment target of 10.3 and above. Install the SDK in your React Native project:iOS configuration
To provide UPI payments on iOS, add the following to your application’sinfo.plist file:
2. Select a payment method
The Element SDK supports the following payment methods:- Card
- Net banking
- UPI Intent
In this flow, the customer enters their card details directly in your application UI. Your application receives the raw card number and passes it to the SDK, so your application remains in PCI DSS scope for card data. To avoid handling raw card numbers, use the React Native Custom Card Component instead. You can also charge a previously saved card by passing the saved card instrument ID and CVV.
3. Complete the payment
To complete the payment, follow these steps:- Set up the payment callback.
- Create a
CFSessionobject. - Create the payment object for the selected payment method.
- Initiate the payment using
makePayment().
Set up the payment callback
The SDK exposes aCFCallback interface to receive callbacks from the SDK once the payment flow ends. The callback supports two methods:
Create a session
TheCFSession object holds the session context for the payment. It accepts the payment_session_id and order_id obtained from Step 1, and the Cashfree environment (CFEnvironment.SANDBOX or CFEnvironment.PRODUCTION).
Create a payment object
The SDK provides a dedicated payment class for each supported payment method. Build only the object that corresponds to the payment method your customer has selected. Card objects can be of two types:Card for a new card payment, and SavedCard for a previously saved instrument.
- Card
- Saved card
- Net banking
- UPI Intent
Use the following code to create a card payment object. This is the raw card flow. Your application passes the full card number to the SDK.
Initiate the payment
CallmakePayment() to open the Cashfree payment flow for the selected method. Pass the payment object you created in the previous step (CFCardPayment, CFNBPayment, or CFUPIPayment).
doCardPayment() is deprecated. Use makePayment() for card, net banking, and UPI Element payments.Sample code
The following example shows a complete integration, including session creation, payment object setup for each method, and payment initiation.Element checkout sample
Element checkout sample
Sample GitHub code
You can explore a working integration example on GitHub: GitHub sample Sample UPI Test APKStep 3: Confirm the payment Server-side
After the SDK delivers a callback viaonVerify, confirm the payment status from your backend before taking any action. The SDK callback signals only that the payment flow has ended. It does not guarantee a successful payment.
To verify an order you can call our /pg/orders endpoint from your backend. You can also use our SDK to achieve the same.
Always verify the order status from your backend before you deliver goods or services to the customer. You can use the Get Order API for this. An order is successful when the
order_status is PAID.Testing
After you integrate a payment method, verify that it behaves as expected. Follow these steps to test:- Trigger a payment using each method you have integrated.
- Confirm that the SDK opens the correct payment screen for the method (Cashfree’s hosted card or net banking screen, or the selected UPI app).
- Confirm that
onVerifyoronErroris called when the payment flow ends.
Error codes
To confirm the error returned in your React Native application, you can view the error codes exposed by the SDK.Show error codes
Show error codes
The following are some of the error codes that are exposed by the SDK:
Affiliate partner program
As a developer building payment experiences for your clients, you can earn additional income while providing them with industry-leading payment solutions.
Join the Cashfree affiliate partner program and get rewarded every time your clients use Cashfree.
What you get:
- Earn up to 0.25% commission on every transaction.
- Become a trusted fintech partner for your clients.
- Access to a dedicated partner manager for expert support.
What your clients get:
- Instant activation and go live in minutes.
- Industry-best success rate across all payment modes.
- Effortless acceptance of international payments in 140+ currencies.
Get started today. Become a partner now.