Skip to content

Instantly share code, notes, and snippets.

@labeneator labeneator/payment_request.py Secret

Last active Oct 10, 2018
Embed
What would you like to do?
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

This comment has been minimized.

Copy link

wankdanker commented Oct 10, 2018

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
You can’t perform that action at this time.