Card Vault API

Know how to integrate Cashfree’s card vault API to avail the saved card feature.

Save Card

You need to first save the customer card on checkout after successful transaction. Saving the card for customers enables them to complete payments without having to enter the card details repeatedly for every transaction.

....
name="paymentOption" value="card"/>
name="card_number" value="4444333322221111"/>
name="card_holder" value="John Doe"/>
name="card_expiryMonth" value="09"/>
name="card_expiryYear" value="2020"/>
name="card_cvv" value="123"/>
name="card_save" value="1"/>

Add additional parameter ‘card_save’ and set it to 1 to save the card in seamless pro flow.

Card gets saved against the phone number provided in the above request. To fetch the card token you have to call the getCards API.

Use Saved Card

Use the below form to submit a saved card.

....
name="paymentOption" value="savedCard"/>
name="card_id" value="A83091283HDKASHKJDH2132"/>
name="card_cvv" value="123"/>

Please use the below endpoints to get Saved Cards

Endpoints

URL

Environment

https://test.cashfree.com/

TEST

https://api.cashfree.com/

PRODUCTION

Cashfree uses API keys to allow access to the API. Once you have signed up at our merchant site, you will be able to retrieve your AppId and SecretKey.

CashFree expects API key to be included in all API requests to the server. Use the endpoint /api/v1/credentials/verify to verify your credentials first.

Get Cards Associated with Customer

To display all cards associated with a customer, use the code below:

URL - POST /api/v1/vault/cards/getCards

Request and Response Parameters

Request Parameters
Response Parameters
Request Parameters

Parameter

Required

Description

appId

Yes

Your app id

secretKey

Yes

Your Secret Key

phone

Yes

String Phone number used to identify user

Response Parameters

Parameter

Required

Description

cardId

Yes

Your Card Id

maskedCard

Yes

Masked Card Number

cardScheme

Yes

Card scheme eg .Visa, Mastercard

Example:

Request
Response
Request
curl -X POST \
https://test.cashfree.com/api/v1/vault/cards/getCards \
-H 'Cache-Control: no-cache' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'appId=XXXX&secretKey=XXXX&phone=9895XXX649'
Response
[
{
"cardId":"63E6E4B4208A11E8B6EFB84A4B991DC5",
"maskedCard":"411111XXXXXX1132",
"cardScheme":"visa"
},
{
"cardId":"AC94D8B80D9011E8B6EFB84A4B991DC5",
"maskedCard":"411111XXXXXX1133",
"cardScheme":"visa"
}
]

Delete Card Associated with Customer

To delete a card associated with a customer, use the code below:

URL - POST /api/v1/vault/cards/deleteCard

Request and Response Parameters

Request Parameters
Response Parameters
Request Parameters

Parameter

Required

Description

appId

Yes

Your app id

secretKey

Yes

Your Secret Key

phone

Yes

Phone number used to identify user

cardId

Yes

Your Card Id

Response Parameters

Parameter

Required

Description

status

Yes

API call status, values - OK and ERROR

Example:

Request
Reponse
Request
curl -X POST \
https://test.cashfree.com/api/v1/vault/cards/deleteCard \
-H 'Cache-Control: no-cache' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d
'appId=XXXX&secretKey=XXX&phone=9895XXX649&cardId=B3BF498612E611E8A15B0AC95
3478514'
Reponse
{
“status”:”OK”
“message”: “Deleted Successfully”
}