cacheCard
POST /ams/api/v1/paymentMethods/cacheCard
Use this API to generate a temporary card token to transmit information security.
Note:
- This API must be called before binging a card when the payment method is a mixed card or debit card.
Structure
A message consists of a header and body. The following sections are focused on the body structure. For the header structure, see:
Note: Set the data type of each field (except array) as String. This means that you must use double quotation marks (" ") to enclose the field value. Examples:
- If the data type of a field is Integer and its value is 20, set it as "20".
- If the data type of a field is Boolean and its value is
true
, set it as "true".
Request parameters
Field | Data type | Required | Description | Examples |
paymentMethodDetail | Yes | The detail of a payment method. | { "paymentMethodDetailType": "card", "card": { "cardNo": "1234561234561234", "brand": "VISA", "securityCode": "444", "expiryYear": "2019", "expiryMonth": "07", "instUserName": { "firstName": "xxx", "lastName": "xxx", }, "billingAddress": { "region": "China", "state": "Zhejiang", "city": "Hangzhou", "zipCode": "3100000", "address1": "xxx", "address2": "xxx", } } } |
Response parameters
Field | Data type | Required | Description | Examples |
result | Yes | The request result, which contains information such as status and error codes. | / | |
paymentMethodDetail | No | The details of this payment method. | { "paymentMethodDetailType":"card", "card": { "cardToken": "PYMT1342cf7ca558402cb2d77af09066d906", "mask":"123456******1234", "last4": "1234", "brand": "VISA", "expiryYear": "2019", "expiryMonth": "07", "instUserName": { "firstName": "xxx", "lastName": "xxx", }, "billingAddress": { "region": "China", "state": "Zhejiang", "city": "Hangzhou", "zipCode": "3100000", "address1": "xxx", "address2": "xxx", } } } | |
expiryTime | Datetime | No | The expiry time of card token. The value follows the ISO 8601 standard format. | "2019-11-27T12:01:01+08:30" |
Result processing logic
In the response, the result.resultStatus field indicates the result of the cacheCard request. The following table describes each result status:
Result status | Description |
S | The cacheCard request is accepted successfully. The corresponding result.resultCode is |
U | The status of the cacheCard request is unknown. The corresponding result.resultCode is |
F | The cacheCard request failed. The corresponding result.resultCode and result.resultMessage may vary based on different situations. For details, see the following Error codes section. |
Error codes
Result code | Result status | Result message | Further action |
SUCCESS | S | Success | / |
PROCESS_FAIL | F | A general business failure occurred. Don't retry. | Human intervention is usually needed. It is recommended that you contact the technical support team to troubleshoot the issue. |
PARAM_ILLEGAL | F | Illegal parameters. For example, non-numeric input, invalid date. | Check and verify whether the request fields, including the header fields and body fields, are correct and valid. For details on the fields of each API, see the specific API Structure section. |
UNKNOWN_EXCEPTION | U | API failed due to unknown reasons. | Call the interface again to resolve the issue. If the issue persists, contact Alipay Technical Support. |
REPEAT_REQ_INCONSISTENT | F | Repeat request inconsistent. | Ensure the fields in the requests are the same. |
USER_NOT_EXIST | F | The user does not exist. | Contact Alipay Technical Support for detailed reasons. |
USER_STATUS_ABNORMAL | F | The user status is abnormal. | Contact the digital wallet to check the user status. |
INVALID_API | F | API is invalid (or not active) | Check whether the API name, HTTP method, or request format is correct when sending the request. |
INVALID_CLIENT | F | Invalid client. | Check whether the client ID is correct, or contact Alipay Technical Support for detailed reasons. |
INVALID_SIGNATURE | F | Signature is invalid. | Check whether the private key used to sign a request matches the public key of Alipay Developer Center. |
INVALID_PAYMENTMETHOD_TOKEN | F | The payment method token is invalid. | Contact Alipay Technical Support for detailed reasons. |
METHOD_NOT_SUPPORTED | F | The server does not implement the requested HTTP method. | Ensure the HTTP method is POST. |
KEY_NOT_FOUND | F | Key is not found. | Check whether the private key or public key exists. If not, upload the private key in Alipay Developer Center. |
ACCESS_DENIED | F | Access denied. | Contact Alipay Technical Support for detailed reasons. |
REQUEST_TRAFFIC_EXCEED_LIMIT | U | Request traffic exceeds the limit. | Call the interface again to resolve the issue. If the issue persists, contact Alipay Technical Support. |
Samples
Request:
The merchant sends a request to DWS.
{
"paymentMethodDetail": {
"paymentMethodDetailType": "card",
"card": {
"cardNo": "1234561234561234",
"brand": "VISA",
"securityCode": "444",
"expiryYear": "2019",
"expiryMonth": "07",
"instUserName": {
"firstName": "xxx",
"lastName": "xxx",
},
"billingAddress": {
"region": "China",
"state": "Zhejiang",
"city": "Hangzhou",
"zipCode": "3100000",
"address1": "xxx",
"address2": "xxx",
}
}
}
}
Response:
DWS returns the request result.
{
"result":{
"resultStatus":"S",
"resultCode":"SUCCESS",
"resultMsg":"success"
},
"expiryTime":"2001-07-04T12:08:56+05:30",
"paymentMethodDetail": {
"paymentMethodDetailType":"card",
"card": {
"cardToken": "PYMT1342cf7ca558402cb2d77af09066d906",
"mask":"123456******1234",
"last4": "1234",
"brand": "VISA",
"expiryYear": "2019",
"expiryMonth": "07",
"instUserName": {
"firstName": "xxx",
"lastName": "xxx",
},
"billingAddress": {
"region": "China",
"state": "Zhejiang",
"city": "Hangzhou",
"zipCode": "3100000",
"address1": "xxx",
"address2": "xxx",
}
}
}
}