CFCard component captures and processes the card number entirely within the SDK, your application never receives the raw card number. This makes the integration suitable for non-PCI merchants, that is, merchants who are not certified to store, process, or transmit raw cardholder data, and who rely on the SDK to handle card data securely on their behalf.
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
Step 2
Step 3
Step 1: Create an order Server-side
Create an order from your backend server before you process any payment.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, set up the card component and open the payment page so the customer can provide their card 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:2. Complete the payment
To complete the payment, follow these steps:- Create a
CFSessionobject. - Set up the payment callback.
- Create a card number UI component (
CFCard). - Build an
ElementCardobject and calldoPayment()on the card component reference.
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).
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 card number UI component
Pass acfSession object and a cardListener callback to CFCard. Both parameters are mandatory. CFCard also accepts standard React Native TextInput props so you can style and control the input field.
doPayment() later:
CFCard component to your view:
Card listener response
ThecardListener callback is invoked on every key press. Until the customer enters 8 digits, the response contains only Luhn status and card length, because a minimum of 8 digits is required to identify the card BIN (Bank Identification Number).
tdr_info, card_bin_info, and card_network:
card_network value from the listener to update your UI. The following example shows how to map common networks:
Sample card form UI
Collect the remaining card fields (holder name, expiry, and CVV) in your own UI. The SDK manages only the card number throughCFCard.
Build the ElementCard object and initiate payment
When the customer enters all details and taps the pay button, create anElementCard object and call doPayment() on the card component reference.
ElementCard does not include the card number. The SDK retrieves the card number from the CFCard component, which keeps your application out of PCI scope for card data.
doPayment() on the creditCardRef object, not on CFPaymentGatewayService. This is different from the raw card flow described in the React Native Integration page.CFCard for rendering, then call doPaymentWithPaymentSessionId() with the updated session when the customer pays:
Sample code
The following example shows a complete custom card component payment flow, including session creation, card component setup, listener handling, and payment initiation.Custom card component payment sample
Custom card component payment sample
Sample GitHub code
You can explore a working integration example on GitHub: GitHub sampleStep 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.
order_status is PAID.Testing
After you integrate the custom card component, verify that it behaves as expected. Follow these steps to test:- Enter a test card number in the
CFCardfield and confirm thatcardListenerreturns BIN metadata after the 8th digit. - Enter the holder name, expiry, and CVV in your own input fields, then tap the pay button.
- 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
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.