Skip to content

Commit 2d0bf26

Browse files
authored
Merge pull request #59 from AuthorizeNet/testing
Testing
2 parents 2273f3d + 1b7eeb3 commit 2d0bf26

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import os, sys
2+
import imp
3+
4+
from authorizenet import apicontractsv1
5+
from authorizenet.apicontrollers import *
6+
constants = imp.load_source('modulename', 'constants.py')
7+
from decimal import *
8+
9+
def create_google_pay_transaction():
10+
11+
merchantAuth = apicontractsv1.merchantAuthenticationType()
12+
merchantAuth.name = constants.apiLoginId
13+
merchantAuth.transactionKey = constants.transactionKey
14+
15+
opaqueData = apicontractsv1.opaqueDataType()
16+
opaqueData.dataDescriptor = "COMMON.GOOGLE.INAPP.PAYMENT"
17+
opaqueData.dataValue = "1234567890ABCDEF1111AAAA2222BBBB3333CCCC4444DDDD5555EEEE6666FFFF7777888899990000"
18+
19+
paymentType = apicontractsv1.paymentType()
20+
paymentType.opaqueData = opaqueData
21+
22+
tax = apicontractsv1.extendedAmountType()
23+
tax.amount = Decimal('15.00')
24+
tax.name = "level2 tax name"
25+
tax.description = "level2 tax"
26+
27+
transactionrequest = apicontractsv1.transactionRequestType()
28+
transactionrequest.transactionType = apicontractsv1.transactionTypeEnum.authCaptureTransaction
29+
transactionrequest.amount = Decimal('151')
30+
transactionrequest.payment = paymentType
31+
transactionrequest.tax = tax
32+
33+
request = apicontractsv1.createTransactionRequest()
34+
request.merchantAuthentication = merchantAuth
35+
request.refId = "Sample"
36+
request.transactionRequest = transactionrequest
37+
38+
controller = createTransactionController(request)
39+
controller.execute()
40+
41+
response = controller.getresponse()
42+
43+
if response is not None:
44+
if response.messages.resultCode == "Ok":
45+
if hasattr(response.transactionResponse, 'messages') == True:
46+
print('Successfully created transaction with Transaction ID: %s' % response.transactionResponse.transId)
47+
print('Transaction Response Code: %s' % response.transactionResponse.responseCode)
48+
print('Message Code: %s' % response.transactionResponse.messages.message[0].code)
49+
print('Description: %s' % response.transactionResponse.messages.message[0].description)
50+
print('AUTH Code : %s' % response.authCode)
51+
else:
52+
print('Failed Transaction.')
53+
if hasattr(response.transactionResponse, 'errors') == True:
54+
print('Error Code: %s' % str(response.transactionResponse.errors.error[0].errorCode))
55+
print('Error message: %s' % response.transactionResponse.errors.error[0].errorText)
56+
else:
57+
print('Failed Transaction.')
58+
if hasattr(response, 'transactionResponse') == True and hasattr(response.transactionResponse, 'errors') == True:
59+
print('Error Code: %s' % str(response.transactionResponse.errors.error[0].errorCode))
60+
print('Error message: %s' % response.transactionResponse.errors.error[0].errorText)
61+
else:
62+
print('Error Code: %s' % response.messages.message[0]['code'].text)
63+
print('Error message: %s' % response.messages.message[0]['text'].text)
64+
else:
65+
print('Null Response.')
66+
67+
return response
68+
69+
if(os.path.basename(__file__) == os.path.basename(sys.argv[0])):
70+
create_google_pay_transaction()

0 commit comments

Comments
 (0)