|
| 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 | + lineItem = apicontractsv1.lineItemType() |
| 23 | + lineItem.itemId = "1" |
| 24 | + lineItem.name = "vase" |
| 25 | + lineItem.description = "Cannes logo" |
| 26 | + lineItem.quantity = 18 |
| 27 | + lineItem.unitPrice = 45.00 |
| 28 | + |
| 29 | + lineItemsArray = apicontractsv1.ArrayOfLineItem() |
| 30 | + print(lineItemsArray) |
| 31 | + # lineItemArray.lineItem |
| 32 | + |
| 33 | + # transactionrequest = apicontractsv1.transactionRequestType() |
| 34 | + # transactionrequest.transactionType = apicontractsv1.transactionTypeEnum.authCaptureTransaction |
| 35 | + # transactionrequest.amount = Decimal('151') |
| 36 | + # transactionrequest.payment = paymentType |
| 37 | + |
| 38 | + # request = apicontractsv1.createTransactionRequest() |
| 39 | + # request.merchantAuthentication = merchantAuth |
| 40 | + # request.refId = "Sample" |
| 41 | + # request.transactionRequest = transactionrequest |
| 42 | + |
| 43 | + # controller = createTransactionController(request) |
| 44 | + # controller.execute() |
| 45 | + |
| 46 | + # response = controller.getresponse() |
| 47 | + |
| 48 | + # if response is not None: |
| 49 | + # if response.messages.resultCode == "Ok": |
| 50 | + # if hasattr(response.transactionResponse, 'messages') == True: |
| 51 | + # print ('Successfully created transaction with Transaction ID: %s' % response.transactionResponse.transId) |
| 52 | + # print ('Transaction Response Code: %s' % response.transactionResponse.responseCode) |
| 53 | + # print ('Message Code: %s' % response.transactionResponse.messages.message[0].code) |
| 54 | + # print ('Description: %s' % response.transactionResponse.messages.message[0].description) |
| 55 | + # print ('AUTH Code : %s' % response.authCode) |
| 56 | + # else: |
| 57 | + # print ('Failed Transaction.') |
| 58 | + # if 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 ('Failed Transaction.') |
| 63 | + # if hasattr(response, 'transactionResponse') == True and hasattr(response.transactionResponse, 'errors') == True: |
| 64 | + # print ('Error Code: %s' % str(response.transactionResponse.errors.error[0].errorCode)) |
| 65 | + # print ('Error message: %s' % response.transactionResponse.errors.error[0].errorText) |
| 66 | + # else: |
| 67 | + # print ('Error Code: %s' % response.messages.message[0]['code'].text) |
| 68 | + # print ('Error message: %s' % response.messages.message[0]['text'].text) |
| 69 | + # else: |
| 70 | + # print ('Null Response.') |
| 71 | + |
| 72 | + # return response |
| 73 | + |
| 74 | +if(os.path.basename(__file__) == os.path.basename(sys.argv[0])): |
| 75 | + create_google_pay_transaction() |
0 commit comments