Re: sample Python code for direct Visa Payment authorization

chimmel
Regular Visitor

sample Python code for direct Visa Payment authorization

Does anyone have any sample code in Python for running the Authorization API?

 

Thank you in advance!

5 REPLIES 5
API_Managers
Visa Developer Support Specialist

Re: sample Python code for direct Visa Payment authorization

Hey @chimmel,

 

I'm happy to help. I'll check if there's Python sample code for Visa Payments Processing (VPP) Authorization API and I'll get back to you soon. Usually, you can find downloadable sample code under the Assets section of your Visa Developer Portal project dashboard but I'll check internally to see if there's any sample code in Python for you, since I didn't see Python code in my VPP project. 




Thanks,

Tee



Was your question answered? Don't forget to click on "Accept as Solution" to help other devs find the answer to the same question.

chimmel
Regular Visitor

Re: sample Python code for direct Visa Payment authorization

Thank you for the response Diana.

 

When I choose the Visa Payments Processing API upon creating a project, getting the Authorization API there is no Sample Code, unlike when I create a Visa Direct project.

 

When I created my own program (in Python) to exercise the API I am getting the response:

 

{"responseStatus":{"status":400,"code":"9125","severity":"ERROR","message":"Expected input credential was not present","info":""}}.

 

The payload used was just a "copy" of the sample body in the API reference. Below is the code, cert/key/user_id/password copied from the project:

 

Maybe you can help with what is missing?

 

import requests
import json

url='https://sandbox.api.visa.com/acs/v1/payments/authorizations'

cert='cert2.pem'
key='key_911f4cd5-2cc1-4557-bdbd-790d8308c435.pem'

headers={"content-type": "application/json",
'accept': 'application/json'}

user_id='8CWEM3PR8H1V8R0DM00Z215P2e8P7ogfiaeVzz4JNO4VUlJ54'
password='2vJZspJ68iN'

body={}

timeout=10

payload = json.loads('''

{
"acctInfo": {
"primryAcctNum": {
"panExpDt": "2019-12",
"pan": "4111111111111111"
}
},
"cardAcceptr": {
"clientId": "0123456789012345678901234567893"
},
"riskAssessmntData": {
"traExmptn": "true",
"delgtdAthntctn": "true",
"trustdMerchntExmptn": "true",
"scpExmptn": "true",
"lowVlExmptn": "true"
},
"freeFormDescrptnData": "Freeformdata",
"msgIdentfctn": {
"correlatnId": "14bc567d90f23e56a8f045",
"origId": "123451234567890"
},
"verfctnData": {
"billngAddr": {
"postlCd": "12345",
"addrLn": "PO Box 12345"
}
},
"msgTransprtData": "TransportData",
"transctn": {
"partialAuthInd": "true",
"eComData": {
"eciCd": "5",
"xid": "EEC4567F90123A5678B0123EA67890D2345678FF",
"digitalGoods": "true"
},
"posData": {
"envrnmnt": "eCom",
"panEntryMode": "OnFile",
"panSrce": "VCIND"
},
"localDtTm": "2020-09-10T05:57:28",
"tranAmt": {
"amt": "123.45",
"numCurrCd": "840"
},
"tranDesc": "Transactiondescription"
}
}
''')

r = requests.post(url,
#verify = ('put the CA certificate pem file path here'),
cert = (cert,key),
headers = headers,
auth = (user_id, password),
#data = body,
json=payload,
timeout=timeout)

print(r.text)

 

API_Managers
Visa Developer Support Specialist

Re: sample Python code for direct Visa Payment authorization

Hey @chimmel,

 

Thanks for providing information on the Python error you're experiencing and we're happy to help you resolve the issue. Please refer to the Visa Developer Error Codes page for cause/resolution to the error - https://developer.visa.com/pages/visa-developer-error-codes

 

I've also logged INC10066913 for the engineering team to investigate the issue and someone will get back to you soon. Please let us know if you have other questions and someone will be happy to assist.  




Thanks,

Tee



Was your question answered? Don't forget to click on "Accept as Solution" to help other devs find the answer to the same question.

API_Managers
Visa Developer Support Specialist

Re: sample Python code for direct Visa Payment authorization

Hey @chimmel,

 

Just a quick follow up, that there is no approved sample code for the Visa Payments Processing APIs. My apologies, please let us know if we can help with anything else or if you have further questions. The engineering team is still investigating your Python code for Visa Payments Processing and someone will get back soon.  




Thanks,

Tee



Was your question answered? Don't forget to click on "Accept as Solution" to help other devs find the answer to the same question.

API_Managers
Visa Developer Support Specialist

Re: sample Python code for direct Visa Payment authorization

Hey @chimmel,

 

Does the issue persist? Please let us know if of any questions. If we don't hear back from you, we'll close this incident INC10066913 as resolved.  




Thanks,

Tee



Was your question answered? Don't forget to click on "Accept as Solution" to help other devs find the answer to the same question.