Hello VISA Team,
We are calling the CyberSource Payments API for generating card token and received error "Token not created: One or more fields in the request contain invalid data. Resend the request with the correct information."
Step 1: Generate Key
API: https://sandbox.api.visa.com/cybersource/payments/flex/v1/keys?apikey={api key as provided under developer program}
Request Header: x-pay-token
JSON Request:
{
"encryptionType": "None"
}
Response (StatusCode received - OK):
{
"keyId":"089zbmzKl3aaaJyKTLhvsqAKIe4MyG5y",
"der":{
"format":"X.509",
"algorithm":"RSA",
"publicKey":"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAlwsZYkb/WjJFWGGk8WBAm/IkFyZooG64O7e8TcVcueCsAbC4Lwu03GvT/QP3GxXE/SB2/VK3FAbprZxkSoqHYO3lyOlQVn454WRs5A8XSi/9mCDRmUY5/MKEiOZ1XVhDsOQCAkGRaTxcr2lHwvjBV+PgiVl2r6jYq/feCDtzydoh7/5giBpZZs9tTfMJgBhDfdtTX969zgVVpJaAHnJ928rXLr16iiYalpL3ghEBDhDVIruCWL0YAfvEM4oFfQNVcGewYBhBoL3ct2xE1K27OX6prsFMf4yuyPWBe1w1GIe28BfBVTztQTTc2mAfXQgtOYe4L/qgpyp73SBEBkii8QIDAQAB"
},
"jwk":null
}
Step 2: Tokenize Card
API: https://sandbox.api.visa.com/cybersource/payments/flex/v1/tokens?apikey={api key as provided under developer program}
JSON Request:
{
"keyId":"089zbmzKl3aaaJyKTLhvsqAKIe4MyG5y",
"cardInfo":{
"cardNumber":"4111111111111111",
"cardType":"001"
}
}
The "keyId" mentioned in the above request is generated in step 1.
The card number (4111111111111111) is a test card number mentioned on the website https://www.simplify.com/commerce/docs/testing/test-card-numbers
The card type is taken from the website http://apps.cybersource.com/library/documentation/dev_guides/CC_Svcs_SO_API/html/#t=Topics%2Fapp_car...
Response (StatusCode received - 400)
{
"responseStatus":{
"status":400,
"reason":"TOKENIZATION_ERROR",
"message":"Token not created: One or more fields in the request contain invalid data. Resend the request with the correct information.",
"correlationId":null,
"details":[],"
_embedded":{
"icsReply":{
"requestId":"5765013542476500004004",
"_links":{
"self":{
"href":"/cybersource/flex/search/v1/logs/tokenProvider/5765013542476500004004"
}
}
}
}
},
"_links":{
"self":null,
"documentation":[],
"next":[]
}
}
Please advise what incorrect data we are sending in the request.
Hey @VikasA,
CyberSource Secure Acceptance Flexible Token v1 APIs was deprecated, therefore, you will not be able to use the Flex API. You will need to move to v2 CyberSource Rest APIs going forward.
For more details , please refer to Cybersource API reference page @ below link.
https://developer.visa.com/capabilities/cybersource/reference#cybersource__cybs_payments_v2
Currently, the only method to properly query the CyberCource Payments sandbox is creating a merchant account directly with CyberSource: https://developer.cybersource.com
Luckily, their site also provides an easy to use method to test their account credentials:
https://developer.cybersource.com/api/reference/api-reference.html
Additionally, here are the following links for sample code: https://github.com/CyberSource/cybersource-rest-samples-java/blob/master/src/main/java/samples/payme...