Prerequisites
- Sign up for a Razorpay account.
- Generate the API Keys on Dashboard.
Workflow
1
[Enable Flash Checkout on Dashboard](#step-1-enable-flash-checkout-...
2
[Create a Customer](#step-2-create-a-customer).
3
[Save Card Details on Checkout](#step-3-save-the-card-details-on-ch...
4
[Fetch all Tokens of Customer](#step-4-fetch-all-tokens-of-customer).
5
[Create Payments using Saved Card](#step-5-create-payments-using-sa...
Step 1: Enable Flash Checkout on Dashboard
Flash Checkout enables you to save customer card details right on Standard Checkout. Authentication is done using PCI DSS compliant technology to ensure that all the card information is stored with maximum possible security. Read more: Learn more about Flash Checkout. Watch this video to see how to enable or disable Flash Checkout:Step 2: Create a Customer
Create a customer whose card details should be saved, from the Dashboard or using the Customers API. You can create customers with basic details such asemail and contact using the following endpoint:
The following endpoint creates or add a customer with basic details such as name and contact details. You can use this API for various Razorpay Solution offerings.
/customers
Curl
Success Response
Request Parameters
name optional
: string Customer’s name. Alphanumeric value with period (.), apostrophe (’), forward slash (/), at (@) and parentheses are allowed. The name must be between 3-50 characters in length. For example, Gaurav Kumar.
contact optional
: string The customer’s phone number. A maximum length of 15 characters including country code. For example, +919876543210.
email optional
: string The customer’s email address. A maximum length of 64 characters. For example, gaurav.kumar@example.com.
fail_existing optional
: string Possible values:
1(default): If a customer with the same details already exists, throws an error.0: If a customer with the same details already exists, fetches details of the existing customer.
gstin optional
: string Customer’s GST number, if available. For example, 29XAbbA4369J1PA.
notes optional
: object This is a key-value pair that can be used to store additional information about the entity. It can hold a maximum of 15 key-value pairs, 256 characters (maximum) each. For example, "note_key": "Beam me up Scotty”.
Read More: Learn more about Customers API.
Step 3: Save the Card Details on Checkout
While making the payment, the customer enters the card details in the Checkout form. If the card details should be saved by Razorpay, passcustomer_id and save=1 along with the other parameters into the Checkout form.
Custom Checkout
Request Parameters
customer_id mandatory
: string Unique identifier of the customer. This can be obtained from the response of the previous step.
save mandatory
: integer Specifies if the card details should be stored as tokens. Possible values are:
1: Saves the card details.0(default): Does not save the card details.
card
: The details of the card that should be entered while making the payment.
number mandatory
: integer Unformatted card number.
name mandatory
: string The name of the cardholder.
expiry_month mandatory
: integer Expiry month for card in MM format.
expiry_year mandatory
: integer Expiry year for card in YY format.
cvv mandatory
: integer CVV printed on the back of the card.
Handy Tips
- CVV is not required by default for tokenised cards across all networks.
- CVV is optional for tokenised card payments. Do not pass dummy CVV values.
- To implement this change, skip passing the
cvvparameter entirely, or pass anullor empty value in the CVV field. - We recommend removing the CVV field from your checkout UI/UX for tokenised cards.
- If CVV is still collected for tokenised cards and the customer enters a CVV, pass the entered CVV value to Razorpay.
Step 4: Fetch all Tokens of Customer
To display all the tokens created for a customer, fetch them as follows: /customers/:customer_id/tokensRequest
Path Parameter
customer_id
: string Unique identifier of the customer.
Step 5: Create Payments using Saved Card
After the card is saved, for every online transaction thereafter, customers can quickly complete the payment by entering only thecvv. If the card details should be saved by Razorpay, the following additional parameters should be passed into the Checkout form.
Custom Checkout
Request Parameters
customer_id
: string Unique identifier of the customer.
token
: string Token of the saved method. This is generated by Razorpay.
card[cvv]
: integer cvv for the card.
Handy Tips
- CVV is not required by default for tokenised cards across all networks.
- CVV is optional for tokenised card payments. Do not pass dummy CVV values.
- To implement this change, skip passing the
cvvparameter entirely, or pass anullor empty value in the CVV field. - We recommend removing the CVV field from your checkout UI/UX for tokenised cards.
- If CVV is still collected for tokenised cards and the customer enters a CVV, pass the entered CVV value to Razorpay.
Delete Tokens
In situations where your customers want to remove the saved cards from their respective accounts, you can do the same by deleting the tokens at your end. /customers/:customer_id/tokens/:token_idRequest
Path Parameters
customer_id
: string Unique identifier of the customer.
token
: string Token of the saved method that needs to be deleted.
Customers can delete their card details by visiting this link and following the on-screen instructions.