From 0d0d1767de36b58a077c385e90283ec137508b08 Mon Sep 17 00:00:00 2001 From: Gabriel Broadwin Date: Wed, 19 Jul 2023 22:22:14 +0530 Subject: [PATCH 1/2] Added CreateGooglePayTransaction --- .../create-google-pay-transaction.py | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 MobileInAppTransactions/create-google-pay-transaction.py diff --git a/MobileInAppTransactions/create-google-pay-transaction.py b/MobileInAppTransactions/create-google-pay-transaction.py new file mode 100644 index 0000000..b20486f --- /dev/null +++ b/MobileInAppTransactions/create-google-pay-transaction.py @@ -0,0 +1,75 @@ +import os, sys +import imp + +from authorizenet import apicontractsv1 +from authorizenet.apicontrollers import * +constants = imp.load_source('modulename', 'constants.py') +from decimal import * + +def create_google_pay_transaction(): + + merchantAuth = apicontractsv1.merchantAuthenticationType() + merchantAuth.name = constants.apiLoginId + merchantAuth.transactionKey = constants.transactionKey + + opaqueData = apicontractsv1.opaqueDataType() + opaqueData.dataDescriptor = "COMMON.GOOGLE.INAPP.PAYMENT" + opaqueData.dataValue = "1234567890ABCDEF1111AAAA2222BBBB3333CCCC4444DDDD5555EEEE6666FFFF7777888899990000" + + paymentType = apicontractsv1.paymentType() + paymentType.opaqueData = opaqueData + + lineItem = apicontractsv1.lineItemType() + lineItem.itemId = "1" + lineItem.name = "vase" + lineItem.description = "Cannes logo" + lineItem.quantity = 18 + lineItem.unitPrice = 45.00 + + lineItemsArray = apicontractsv1.ArrayOfLineItem() + print(lineItemsArray) + # lineItemArray.lineItem + + # transactionrequest = apicontractsv1.transactionRequestType() + # transactionrequest.transactionType = apicontractsv1.transactionTypeEnum.authCaptureTransaction + # transactionrequest.amount = Decimal('151') + # transactionrequest.payment = paymentType + + # request = apicontractsv1.createTransactionRequest() + # request.merchantAuthentication = merchantAuth + # request.refId = "Sample" + # request.transactionRequest = transactionrequest + + # controller = createTransactionController(request) + # controller.execute() + + # response = controller.getresponse() + + # if response is not None: + # if response.messages.resultCode == "Ok": + # if hasattr(response.transactionResponse, 'messages') == True: + # print ('Successfully created transaction with Transaction ID: %s' % response.transactionResponse.transId) + # print ('Transaction Response Code: %s' % response.transactionResponse.responseCode) + # print ('Message Code: %s' % response.transactionResponse.messages.message[0].code) + # print ('Description: %s' % response.transactionResponse.messages.message[0].description) + # print ('AUTH Code : %s' % response.authCode) + # else: + # print ('Failed Transaction.') + # if hasattr(response.transactionResponse, 'errors') == True: + # print ('Error Code: %s' % str(response.transactionResponse.errors.error[0].errorCode)) + # print ('Error message: %s' % response.transactionResponse.errors.error[0].errorText) + # else: + # print ('Failed Transaction.') + # if hasattr(response, 'transactionResponse') == True and hasattr(response.transactionResponse, 'errors') == True: + # print ('Error Code: %s' % str(response.transactionResponse.errors.error[0].errorCode)) + # print ('Error message: %s' % response.transactionResponse.errors.error[0].errorText) + # else: + # print ('Error Code: %s' % response.messages.message[0]['code'].text) + # print ('Error message: %s' % response.messages.message[0]['text'].text) + # else: + # print ('Null Response.') + + # return response + +if(os.path.basename(__file__) == os.path.basename(sys.argv[0])): + create_google_pay_transaction() From 1b7eeb30bea72d210ec910991f0af61bef308739 Mon Sep 17 00:00:00 2001 From: Gaidin Daishan Date: Wed, 19 Jul 2023 23:33:52 +0530 Subject: [PATCH 2/2] Added CreateGooglePayTransaction --- .../create-google-pay-transaction.py | 85 +++++++++---------- 1 file changed, 40 insertions(+), 45 deletions(-) diff --git a/MobileInAppTransactions/create-google-pay-transaction.py b/MobileInAppTransactions/create-google-pay-transaction.py index b20486f..19d5284 100644 --- a/MobileInAppTransactions/create-google-pay-transaction.py +++ b/MobileInAppTransactions/create-google-pay-transaction.py @@ -19,57 +19,52 @@ def create_google_pay_transaction(): paymentType = apicontractsv1.paymentType() paymentType.opaqueData = opaqueData - lineItem = apicontractsv1.lineItemType() - lineItem.itemId = "1" - lineItem.name = "vase" - lineItem.description = "Cannes logo" - lineItem.quantity = 18 - lineItem.unitPrice = 45.00 + tax = apicontractsv1.extendedAmountType() + tax.amount = Decimal('15.00') + tax.name = "level2 tax name" + tax.description = "level2 tax" - lineItemsArray = apicontractsv1.ArrayOfLineItem() - print(lineItemsArray) - # lineItemArray.lineItem + transactionrequest = apicontractsv1.transactionRequestType() + transactionrequest.transactionType = apicontractsv1.transactionTypeEnum.authCaptureTransaction + transactionrequest.amount = Decimal('151') + transactionrequest.payment = paymentType + transactionrequest.tax = tax - # transactionrequest = apicontractsv1.transactionRequestType() - # transactionrequest.transactionType = apicontractsv1.transactionTypeEnum.authCaptureTransaction - # transactionrequest.amount = Decimal('151') - # transactionrequest.payment = paymentType + request = apicontractsv1.createTransactionRequest() + request.merchantAuthentication = merchantAuth + request.refId = "Sample" + request.transactionRequest = transactionrequest - # request = apicontractsv1.createTransactionRequest() - # request.merchantAuthentication = merchantAuth - # request.refId = "Sample" - # request.transactionRequest = transactionrequest + controller = createTransactionController(request) + controller.execute() - # controller = createTransactionController(request) - # controller.execute() + response = controller.getresponse() - # response = controller.getresponse() + if response is not None: + if response.messages.resultCode == "Ok": + if hasattr(response.transactionResponse, 'messages') == True: + print('Successfully created transaction with Transaction ID: %s' % response.transactionResponse.transId) + print('Transaction Response Code: %s' % response.transactionResponse.responseCode) + print('Message Code: %s' % response.transactionResponse.messages.message[0].code) + print('Description: %s' % response.transactionResponse.messages.message[0].description) + print('AUTH Code : %s' % response.authCode) + else: + print('Failed Transaction.') + if hasattr(response.transactionResponse, 'errors') == True: + print('Error Code: %s' % str(response.transactionResponse.errors.error[0].errorCode)) + print('Error message: %s' % response.transactionResponse.errors.error[0].errorText) + else: + print('Failed Transaction.') + if hasattr(response, 'transactionResponse') == True and hasattr(response.transactionResponse, 'errors') == True: + print('Error Code: %s' % str(response.transactionResponse.errors.error[0].errorCode)) + print('Error message: %s' % response.transactionResponse.errors.error[0].errorText) + else: + print('Error Code: %s' % response.messages.message[0]['code'].text) + print('Error message: %s' % response.messages.message[0]['text'].text) + else: + print('Null Response.') - # if response is not None: - # if response.messages.resultCode == "Ok": - # if hasattr(response.transactionResponse, 'messages') == True: - # print ('Successfully created transaction with Transaction ID: %s' % response.transactionResponse.transId) - # print ('Transaction Response Code: %s' % response.transactionResponse.responseCode) - # print ('Message Code: %s' % response.transactionResponse.messages.message[0].code) - # print ('Description: %s' % response.transactionResponse.messages.message[0].description) - # print ('AUTH Code : %s' % response.authCode) - # else: - # print ('Failed Transaction.') - # if hasattr(response.transactionResponse, 'errors') == True: - # print ('Error Code: %s' % str(response.transactionResponse.errors.error[0].errorCode)) - # print ('Error message: %s' % response.transactionResponse.errors.error[0].errorText) - # else: - # print ('Failed Transaction.') - # if hasattr(response, 'transactionResponse') == True and hasattr(response.transactionResponse, 'errors') == True: - # print ('Error Code: %s' % str(response.transactionResponse.errors.error[0].errorCode)) - # print ('Error message: %s' % response.transactionResponse.errors.error[0].errorText) - # else: - # print ('Error Code: %s' % response.messages.message[0]['code'].text) - # print ('Error message: %s' % response.messages.message[0]['text'].text) - # else: - # print ('Null Response.') - - # return response + return response if(os.path.basename(__file__) == os.path.basename(sys.argv[0])): create_google_pay_transaction()