Skip to content

Instantly share code, notes, and snippets.

@labeneator
Last active October 10, 2018 19:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save labeneator/1fdd6ea358c394684ee4caf4c2fb67ca to your computer and use it in GitHub Desktop.
Save labeneator/1fdd6ea358c394684ee4caf4c2fb67ca to your computer and use it in GitHub Desktop.
Failure on attempting to interact with the cybersource API sandbox
payment_request = {
"clientReferenceInformation": {
"code": "TC50171_3"
},
"processingInformation": {
"commerceIndicator": "internet"
},
"aggregatorInformation": {
"subMerchant": {
"cardAcceptorID": "1234567890",
"country": "US",
"phoneNumber": "650-432-0000",
"address1": "900 Metro Center",
"postalCode": "94404-2775",
"locality": "Foster City",
"name": "Visa Inc",
"administrativeArea": "CA",
"region": "PEN",
"email": "test@cybs.com"
},
"name": "V-Internatio",
"aggregatorID": "123456789"
},
"orderInformation": {
"billTo": {
"country": "US",
"lastName": "VDP",
"address2": "Address 2",
"address1": "201 S. Division St.",
"postalCode": "48104-2201",
"locality": "Ann Arbor",
"administrativeArea": "MI",
"firstName": "RTS",
"phoneNumber": "999999999",
"district": "MI",
"buildingNumber": "123",
"company": "Visa",
"email": "test@cybs.com"
},
"amountDetails": {
"totalAmount": "1.21",
"currency": "USD"
}
},
"paymentInformation": {
"card": {
"expirationYear": "2031",
"number": "4111111111111111",
"securityCode": "123",
"expirationMonth": "12",
"type": "002"
}
}
}
base_uri = 'cybersource/'
resource_path = 'v2/payments'
query_string = 'apikey=' + visa_api_client.config.get('VDP','apiKey')
response = visa_api_client.do_x_pay_request(
base_uri, resource_path ,
query_string, payment_request, 'Cybersource Payments Test', 'post')
print("Request URL: %s" % response.url)
print("Request Headers: %s" % response.request.headers)
print("Request Body: %s" % response.request.body)
print("-"*20)
print("Response status code: %s" % response.status_code)
print("Response body: %s" % response.text)
Request URL: https://sandbox.api.visa.com/cybersource/v2/payments?apikey=Jxxxxxxxxxxxxxxxxxxxxxx50
Request Headers: {'User-Agent': 'python-requests/2.18.4', 'Accept-Encoding': 'gzip, deflate', 'accept': 'application/json', 'Connection': 'keep-alive', 'content-type': 'application/json', 'x-pay-token': 'xv2:1519762768:be037f31933342c7eea1d458a3472c386a490f45d31d82c3662e355747b9b5e3', 'ex-correlation-id': '410940977950_SC', 'Content-Length': '1029'}
Request Body: b'{"clientReferenceInformation": {"code": "TC50171_3"}, "processingInformation": {"commerceIndicator": "internet"}, "aggregatorInformation": {"subMerchant": {"cardAcceptorID": "1234567890", "country": "US", "phoneNumber": "650-432-0000", "address1": "900 Metro Center", "postalCode": "94404-2775", "locality": "Foster City", "name": "Visa Inc", "administrativeArea": "CA", "region": "PEN", "email": "test@cybs.com"}, "name": "V-Internatio", "aggregatorID": "123456789"}, "orderInformation": {"billTo": {"country": "US", "lastName": "VDP", "address2": "Address 2", "address1": "201 S. Division St.", "postalCode": "48104-2201", "locality": "Ann Arbor", "administrativeArea": "MI", "firstName": "RTS", "phoneNumber": "999999999", "district": "MI", "buildingNumber": "123", "company": "Visa", "email": "test@cybs.com"}, "amountDetails": {"totalAmount": "1.21", "currency": "USD"}}, "paymentInformation": {"card": {"expirationYear": "2031", "number": "4111111111111111", "securityCode": "123", "expirationMonth": "12", "type": "002"}}}'
--------------------
Response status code: 404
Response body: Resource not found
@wankdanker
Copy link

Hey @labeneator,

I ran into this gist from here: https://community.developer.visa.com/t5/Getting-Started-with-Visa/error-500-id-null/m-p/7423

Did you ever get this working? I'm trying to call the cybersource REST API directly (https://apitest.cybersource.com instead of https://sandbox.api.visa.com). I am getting 500 errors as it seems to be you originally were.

Just curious if you were ever able to get it resolved.

Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment