@@ -13,6 +13,9 @@ def create_an_accept_payment_transaction(amount):
1313 merchantAuth = apicontractsv1 .merchantAuthenticationType ()
1414 merchantAuth .name = constants .apiLoginId
1515 merchantAuth .transactionKey = constants .transactionKey
16+
17+ # Set the transaction's refId
18+ refId = "ref {}" format (time .time ())
1619
1720 # Create the payment object for a payment nonce
1821 opaqueData = apicontractsv1 .opaqueDataType ()
@@ -46,7 +49,7 @@ def create_an_accept_payment_transaction(amount):
4649 customerData .
email = "[email protected] " 4750
4851 # Add values for transaction settings
49- duplicateWindowSetting = apicontractsv1 .settingType ();
52+ duplicateWindowSetting = apicontractsv1 .settingType ()
5053 duplicateWindowSetting .settingName = "duplicateWindow"
5154 duplicateWindowSetting .settingValue = "600"
5255 settings = apicontractsv1 .ArrayOfSetting ()
@@ -65,9 +68,9 @@ def create_an_accept_payment_transaction(amount):
6568 # Assemble the complete transaction request
6669 createtransactionrequest = apicontractsv1 .createTransactionRequest ()
6770 createtransactionrequest .merchantAuthentication = merchantAuth
68- createtransactionrequest .refId = "MerchantID-0001"
71+ createtransactionrequest .refId = refId
6972 createtransactionrequest .transactionRequest = transactionrequest
70-
73+
7174 # Create the controller and get response
7275 createtransactioncontroller = createTransactionController (createtransactionrequest )
7376 createtransactioncontroller .execute ()
@@ -80,26 +83,27 @@ def create_an_accept_payment_transaction(amount):
8083 # Since the API request was successful, look for a transaction response
8184 # and parse it to display the results of authorizing the card
8285 if hasattr (response .transactionResponse , 'messages' ) == True :
83- print ('Successfully created transaction with Transaction ID: %s' % response .transactionResponse .transId );
84- print ('Transaction Response Code: %s' % response .transactionResponse .responseCode );
85- print ('Message Code: %s' % response .transactionResponse .messages .message [0 ].code );
86- print ('Description: %s' % response .transactionResponse .messages .message [0 ].description );
86+ print ('Successfully created transaction with Transaction ID: %s' % response .transactionResponse .transId )
87+ print ('Transaction Response Code: %s' % response .transactionResponse .responseCode )
88+ print ('Message Code: %s' % response .transactionResponse .messages .message [0 ].code )
89+ print ('Auth Code: %s' % response .transactionResponse .authCode )
90+ print ('Description: %s' % response .transactionResponse .messages .message [0 ].description )
8791 else :
88- print ('Failed Transaction.' );
92+ print ('Failed Transaction.' )
8993 if hasattr (response .transactionResponse , 'errors' ) == True :
90- print ('Error Code: %s' % str (response .transactionResponse .errors .error [0 ].errorCode ));
91- print ('Error message : %s' % response .transactionResponse .errors .error [0 ].errorText );
94+ print ('Error Code: %s' % str (response .transactionResponse .errors .error [0 ].errorCode ))
95+ print ('Error Message : %s' % response .transactionResponse .errors .error [0 ].errorText )
9296 # Or, print errors if the API request wasn't successful
9397 else :
94- print ('Failed Transaction.' );
98+ print ('Failed Transaction.' )
9599 if hasattr (response , 'transactionResponse' ) == True and hasattr (response .transactionResponse , 'errors' ) == True :
96- print ('Error Code: %s' % str (response .transactionResponse .errors .error [0 ].errorCode ));
97- print ('Error message : %s' % response .transactionResponse .errors .error [0 ].errorText );
100+ print ('Error Code: %s' % str (response .transactionResponse .errors .error [0 ].errorCode ))
101+ print ('Error Message : %s' % response .transactionResponse .errors .error [0 ].errorText )
98102 else :
99- print ('Error Code: %s' % response .messages .message [0 ]['code' ].text );
100- print ('Error message : %s' % response .messages .message [0 ]['text' ].text );
103+ print ('Error Code: %s' % response .messages .message [0 ]['code' ].text )
104+ print ('Error Message : %s' % response .messages .message [0 ]['text' ].text )
101105 else :
102- print ('Null Response.' );
106+ print ('Null Response.' )
103107
104108 return response
105109
0 commit comments