def capture_previously_authorized_amount(): merchantAuth = apicontractsv1.merchantAuthenticationType() merchantAuth.name = constants.apiLoginId merchantAuth.transactionKey = constants.transactionKey transactionrequest = apicontractsv1.transactionRequestType() transactionrequest.transactionType = "priorAuthCaptureTransaction" transactionrequest.amount = Decimal ('2.55') transactionrequest.refTransId = "2245440574" createtransactionrequest = apicontractsv1.createTransactionRequest() createtransactionrequest.merchantAuthentication = merchantAuth createtransactionrequest.refId = "MerchantID-0001" createtransactionrequest.transactionRequest = transactionrequest createtransactioncontroller = createTransactionController(createtransactionrequest) createtransactioncontroller.execute() response = createtransactioncontroller.getresponse() if (response.messages.resultCode=="Ok"): print "Transaction ID : %s" % response.transactionResponse.transId print response.transactionResponse.messages.message[0].description else: print "response code: %s" % response.messages.resultCode return response
def create_chase_pay_transaction(): merchantAuth = apicontractsv1.merchantAuthenticationType() merchantAuth.name = constants.apiLoginId merchantAuth.transactionKey = constants.transactionKey creditCard = apicontractsv1.creditCardType() creditCard.cardNumber = "4111111111111111" creditCard.expirationDate = "2020-12" creditCard.cardCode="999" # Set the token specific info creditCard.isPaymentToken = True creditCard.cryptogram = "EjRWeJASNFZ4kBI0VniQEjRWeJA=" creditCard.tokenRequestorName="CHASE_PAY" creditCard.tokenRequestorId="12345678901" creditCard.tokenRequestorEci="07" payment = apicontractsv1.paymentType() payment.creditCard = creditCard transactionrequest = apicontractsv1.transactionRequestType() transactionrequest.transactionType = "authCaptureTransaction" transactionrequest.amount = Decimal ('1.50') transactionrequest.payment = payment createtransactionrequest = apicontractsv1.createTransactionRequest() createtransactionrequest.merchantAuthentication = merchantAuth createtransactionrequest.refId = "MerchantID-0001" createtransactionrequest.transactionRequest = transactionrequest createtransactioncontroller = createTransactionController(createtransactionrequest) createtransactioncontroller.execute() response = createtransactioncontroller.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) 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 ('Failed to get response.') 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) return response
def charge_customer_profile(customerProfileId, paymentProfileId, amount): merchantAuth = apicontractsv1.merchantAuthenticationType() merchantAuth.name = constants.apiLoginId merchantAuth.transactionKey = constants.transactionKey # create a customer payment profile profileToCharge = apicontractsv1.customerProfilePaymentType() profileToCharge.customerProfileId = customerProfileId profileToCharge.paymentProfile = apicontractsv1.paymentProfile() profileToCharge.paymentProfile.paymentProfileId = paymentProfileId transactionrequest = apicontractsv1.transactionRequestType() transactionrequest.transactionType = "authCaptureTransaction" transactionrequest.amount = amount transactionrequest.profile = profileToCharge createtransactionrequest = apicontractsv1.createTransactionRequest() createtransactionrequest.merchantAuthentication = merchantAuth createtransactionrequest.refId = "MerchantID-0001" createtransactionrequest.transactionRequest = transactionrequest createtransactioncontroller = createTransactionController(createtransactionrequest) createtransactioncontroller.execute() response = createtransactioncontroller.getresponse() if (response.messages.resultCode=="Ok"): print "Transaction ID : %s" % response.transactionResponse.transId else: print "response code: %s" % response.messages.resultCode return response
def charge(card_number, expiration_date, amount, merchant_id): creditCard = apicontractsv1.creditCardType() creditCard.cardNumber = card_number creditCard.expirationDate = expiration_date payment = apicontractsv1.paymentType() payment.creditCard = creditCard transactionrequest = apicontractsv1.transactionRequestType() transactionrequest.transactionType = "authCaptureTransaction" transactionrequest.amount = amount transactionrequest.payment = payment createtransactionrequest = apicontractsv1.createTransactionRequest() createtransactionrequest.merchantAuthentication = merchantAuth createtransactionrequest.refId = merchant_id createtransactionrequest.transactionRequest = transactionrequest createtransactioncontroller = createTransactionController( createtransactionrequest) createtransactioncontroller.execute() response = createtransactioncontroller.getresponse() if (response.messages.resultCode == "Ok"): print "Transaction ID : %s" % response.transactionResponse.transId else: print "response code: %s" % response.messages.resultCode
def authorize_credit_card(): merchantAuth = apicontractsv1.merchantAuthenticationType() merchantAuth.name = CONSTANTS.apiLoginId merchantAuth.transactionKey = CONSTANTS.transactionKey creditCard = apicontractsv1.creditCardType() creditCard.cardNumber = cardNumber creditCard.expirationDate = expirationDate payment = apicontractsv1.paymentType() payment.creditCard = creditCard transactionrequest = apicontractsv1.transactionRequestType() transactionrequest.transactionType = "authCaptureTransaction" transactionrequest.amount = Decimal(amount) transactionrequest.payment = payment createtransactionrequest = apicontractsv1.createTransactionRequest() createtransactionrequest.merchantAuthentication = merchantAuth createtransactionrequest.refId = "MerchantID-0001" createtransactionrequest.transactionRequest = transactionrequest createtransactioncontroller = createTransactionController( createtransactionrequest) createtransactioncontroller.execute() response = createtransactioncontroller.getresponse() if (response.messages.resultCode == "Ok"): print("Transaction ID : %s" % response.transactionResponse.transId) else: print("response code: %s" % response.messages.resultCode)
def creds(self, cardNumber, exp_date, amount_to_take): creditCard = apicontractsv1.creditCardType() creditCard.cardNumber = cardNumber creditCard.expirationDate = exp_date payment = apicontractsv1.paymentType() payment.creditCard = creditCard transactionrequest = apicontractsv1.transactionRequestType() transactionrequest.transactionType = "authCaptureTransaction" transactionrequest.amount = Decimal(amount_to_take) transactionrequest.payment = payment createtransactionrequest = apicontractsv1.createTransactionRequest() createtransactionrequest.merchantAuthentication = self.merchantAuth createtransactionrequest.refId = "MerchantID-0001" createtransactionrequest.transactionRequest = transactionrequest createtransactioncontroller = createTransactionController( createtransactionrequest) createtransactioncontroller.execute() response = createtransactioncontroller.getresponse() if (response.messages.resultCode == "Ok"): print("Transaction ID : %s" % response.transactionResponse.transId) else: print("response code: %s" % response.messages.resultCode)
def charge_customer_profile(self, paymentProfileId, amount, ref_id, invoice_number): # create a customer payment profile profileToCharge = apicontractsv1.customerProfilePaymentType() profileToCharge.customerProfileId = str( self.instance.authorizenet_customer_profile_id) profileToCharge.paymentProfile = apicontractsv1.paymentProfile() profileToCharge.paymentProfile.paymentProfileId = paymentProfileId order = apicontractsv1.orderType() order.invoiceNumber = str(invoice_number) transactionrequest = apicontractsv1.transactionRequestType() transactionrequest.transactionType = "authCaptureTransaction" transactionrequest.amount = amount transactionrequest.profile = profileToCharge transactionrequest.order = order createtransactionrequest = apicontractsv1.createTransactionRequest() createtransactionrequest.merchantAuthentication = self.merchantAuth createtransactionrequest.refId = str(ref_id) createtransactionrequest.transactionRequest = transactionrequest controller = createTransactionController(createtransactionrequest) controller.setenvironment(self.post_url) controller.execute() response = controller.getresponse() return Transaction(response)
def get_details(refTransId): merchantAuth = apicontractsv1.merchantAuthenticationType() merchantAuth.name = constants.apiLoginId merchantAuth.transactionKey = constants.transactionKey transactionrequest = apicontractsv1.transactionRequestType() transactionrequest.transactionType = apicontractsv1.transactionTypeEnum.getDetailsTransaction transactionrequest.refTransId = refTransId request = apicontractsv1.createTransactionRequest() request.merchantAuthentication = merchantAuth request.refId = "Sample" request.transactionRequest = transactionrequest controller = createTransactionController(request) controller.execute() response = controller.getresponse() if (response.messages.resultCode=="Ok"): print "SUCCESS" print "Message Code : %s" % response.messages.message[0]['code'].text print "Message text : %s" % response.messages.message[0]['text'].text if (response.transactionResponse.responseCode == "1" ): print "Payer Id : %s " % response.transactionResponse.secureAcceptance.PayerID print "Transaction ID : %s " % response.transactionResponse.transId else: print "ERROR" print "Message Code : %s" % response.messages.message[0]['code'].text print "Message text : %s" % response.messages.message[0]['text'].text return response
def test_capture_transaction(self): credit_card = CreditCard() order = OrderFactory() card = apicontractsv1.creditCardType() card.cardNumber = credit_card['card_number'] card.expirationDate = credit_card['expire_date'].strftime('%Y-%m') payment = apicontractsv1.paymentType() payment.creditCard = card transaction = apicontractsv1.transactionRequestType() transaction.transactionType = "authCaptureTransaction" transaction.amount = order['amount'] transaction.payment = payment request = apicontractsv1.createTransactionRequest() request.merchantAuthentication = self.merchant request.refId = order['ref_id'] request.transactionRequest = transaction controller = apicontrollers.CreateTransactionController(request) response = controller.execute() print(response)
def charge(card_number, expiration_date, amount, merchant_id): merchantAuth = apicontractsv1.merchantAuthenticationType() merchantAuth.name = '4K24xbCW' merchantAuth.transactionKey = '8m39rKgQ92C4MRvx' creditCard = apicontractsv1.creditCardType() creditCard.cardNumber = card_number creditCard.expirationDate = expiration_date payment = apicontractsv1.paymentType() payment.creditCard = creditCard transactionrequest = apicontractsv1.transactionRequestType() transactionrequest.transactionType = "authCaptureTransaction" transactionrequest.amount = Decimal(amount) transactionrequest.payment = payment createtransactionrequest = apicontractsv1.createTransactionRequest() createtransactionrequest.merchantAuthentication = merchantAuth createtransactionrequest.refId = merchant_id createtransactionrequest.transactionRequest = transactionrequest createtransactioncontroller = createTransactionController( createtransactionrequest) createtransactioncontroller.execute() response = createtransactioncontroller.getresponse() if (response.messages.resultCode == "Ok"): return (True, "Transaction ID : %s" % response.transactionResponse.transId) else: return (False, "response code: %s" % response.messages.resultCode)
def charge_customer_profile(customerProfileId, paymentProfileId, amount): merchantAuth = apicontractsv1.merchantAuthenticationType() merchantAuth.name = constants.apiLoginId merchantAuth.transactionKey = constants.transactionKey # create a customer payment profile profileToCharge = apicontractsv1.customerProfilePaymentType() profileToCharge.customerProfileId = customerProfileId profileToCharge.paymentProfile = apicontractsv1.paymentProfile() profileToCharge.paymentProfile.paymentProfileId = paymentProfileId transactionrequest = apicontractsv1.transactionRequestType() transactionrequest.transactionType = "authCaptureTransaction" transactionrequest.amount = amount transactionrequest.profile = profileToCharge createtransactionrequest = apicontractsv1.createTransactionRequest() createtransactionrequest.merchantAuthentication = merchantAuth createtransactionrequest.refId = "MerchantID-0001" createtransactionrequest.transactionRequest = transactionrequest createtransactioncontroller = createTransactionController( createtransactionrequest) createtransactioncontroller.execute() response = createtransactioncontroller.getresponse() if (response.messages.resultCode == "Ok"): print "Transaction ID : %s" % response.transactionResponse.transId else: print "response code: %s" % response.messages.resultCode return response
def payment(name, key, card_number, expiration_date, amount, merchant_id): merchantAuth = apicontractsv1.merchantAuthenticationType() merchantAuth.name = name merchantAuth.transactionKey = key creditCard = apicontractsv1.creditCardType() creditCard.cardNumber = card_number creditCard.expirationDate = expiration_date payment = apicontractsv1.paymentType() payment.creditCard = creditCard transactionrequest = apicontractsv1.transactionRequestType() transactionrequest.transactionType = "authCaptureTransaction" transactionrequest.amount = Decimal(amount) transactionrequest.payment = payment createtransactionrequest = apicontractsv1.createTransactionRequest() createtransactionrequest.merchantAuthentication = merchantAuth createtransactionrequest.refId = merchant_id createtransactionrequest.transactionRequest = transactionrequest createtransactioncontroller = createTransactionController( createtransactionrequest) createtransactioncontroller.execute() response = createtransactioncontroller.getresponse() if (response.messages.resultCode == "Ok"): return response.transactionResponse.transId print("Transaction ID : %s" % response.transactionResponse.transId) else: return response.messages.resultCode print("response code: %s" % response.messages.resultCode)
def charge_credit_card(card, amount): merchant_auth = apicontractsv1.merchantAuthenticationType() merchant_auth.name = settings.get_api_login_id() merchant_auth.transactionKey = settings.get_transaction_id() credit_card = apicontractsv1.creditCardType() credit_card.cardNumber = card.number credit_card.expirationDate = card.expiration_date credit_card.cardCode = card.code payment = apicontractsv1.paymentType() payment.creditCard = credit_card transaction_request = apicontractsv1.transactionRequestType() transaction_request.transactionType = "authCaptureTransaction" transaction_request.amount = Decimal(amount) transaction_request.payment = payment request = apicontractsv1.createTransactionRequest() request.merchantAuthentication = merchant_auth request.refId = "MerchantID-0001" request.transactionRequest = transaction_request transaction_controller = createTransactionController(request) transaction_controller.execute() api_response = transaction_controller.getresponse() response = response_mapper(api_response) return response
def send(self, card_number, expiration, amount): """ send the payment and return the transactionID or Error""" merchantAuth = apicontractsv1.merchantAuthenticationType() merchantAuth.name = self.merchant_id merchantAuth.transactionKey = self.merchant_key creditCard = apicontractsv1.creditCardType() creditCard.cardNumber = card_number # 5424000000000015 creditCard.expirationDate = expiration payment = apicontractsv1.paymentType() payment.creditCard = creditCard transactionrequest = apicontractsv1.transactionRequestType() transactionrequest.transactionType ="authCaptureTransaction" transactionrequest.amount = Decimal(amount) transactionrequest.payment = payment createtransactionrequest = apicontractsv1.createTransactionRequest() createtransactionrequest.merchantAuthentication = merchantAuth createtransactionrequest.refId ="MerchantID-0001" createtransactionrequest.transactionRequest = transactionrequest createtransactioncontroller = createTransactionController(createtransactionrequest) createtransactioncontroller.execute() response = createtransactioncontroller.getresponse() if (response.messages.resultCode=="Ok"): return response.transactionResponse else: return response.messages.resultCode
def purchase(card, amount): authorization = apicontractsv1.merchantAuthenticationType() authorization.name = get_api_login_id() authorization.transactionKey = get_transaction_id() card_info = apicontractsv1.creditCardType() card_info.cardNumber = card.number card_info.expirationDate = card.expiration_date card_info.cardCode = card.code payment = apicontractsv1.paymentType() payment.creditCard = card_info request_info = apicontractsv1.transactionRequestType() request_info.transactionType = "authCaptureTransaction" request_info.amount = Decimal(amount) request_info.payment = payment request = apicontractsv1.createTransactionRequest() request.merchantAuthentication = authorization request.refId = "MerchantID-0001" request.transactionRequest = request_info controller = createTransactionController(request) controller.execute() api_response = controller.getresponse() response = response_options(api_response) return response
def get_details(refTransId): merchantAuth = apicontractsv1.merchantAuthenticationType() merchantAuth.name = constants.apiLoginId merchantAuth.transactionKey = constants.transactionKey transactionrequest = apicontractsv1.transactionRequestType() transactionrequest.transactionType = apicontractsv1.transactionTypeEnum.getDetailsTransaction transactionrequest.refTransId = refTransId request = apicontractsv1.createTransactionRequest() request.merchantAuthentication = merchantAuth request.refId = "Sample" request.transactionRequest = transactionrequest controller = createTransactionController(request) controller.execute() response = controller.getresponse() if (response.messages.resultCode == "Ok"): print "SUCCESS" print "Message Code : %s" % response.messages.message[0].code print "Message text : %s" % response.messages.message[0].text if (response.transactionResponse.responseCode == "1"): print "Payer Id : %s " % response.transactionResponse.secureAcceptance.PayerID print "Transaction ID : %s " % response.transactionResponse.transId else: print "ERROR" print "Message Code : %s" % response.messages.message[0].code print "Message text : %s" % response.messages.message[0].text return response
def testchargeCreditCard(self): creditCard = apicontractsv1.creditCardType() creditCard.cardNumber = "4111111111111111" creditCard.expirationDate = "2020-12" payment = apicontractsv1.paymentType() payment.creditCard = creditCard transactionrequest = apicontractsv1.transactionRequestType() transactionrequest.transactionType = "authCaptureTransaction" transactionrequest.amount = Decimal( str(round(random.random() * 100, 2))) transactionrequest.payment = payment createtransactionrequest = apicontractsv1.createTransactionRequest() createtransactionrequest.merchantAuthentication = self.merchantAuthentication createtransactionrequest.refId = "MerchantID-0001" createtransactionrequest.transactionRequest = transactionrequest createtransactioncontroller = createTransactionController( createtransactionrequest) createtransactioncontroller.execute() response = createtransactioncontroller.getresponse() if hasattr(response, 'messages') == True: if hasattr(response.messages, 'resultCode') == True: self.assertEquals('Ok', response.messages.resultCode) if hasattr(response, 'transactionResponse') == True: if hasattr(response.transactionResponse, 'transId') == True: createdTransactionId = response.transactionResponse.transId return str(createdTransactionId)
def void_transaction(refTransId): merchantAuth = apicontractsv1.merchantAuthenticationType() merchantAuth.name = constants.apiLoginId merchantAuth.transactionKey = constants.transactionKey transactionrequest = apicontractsv1.transactionRequestType() transactionrequest.transactionType = "voidTransaction" #set refTransId to transId of an unsettled transaction transactionrequest.refTransId = refTransId createtransactionrequest = apicontractsv1.createTransactionRequest() createtransactionrequest.merchantAuthentication = merchantAuth createtransactionrequest.refId = "MerchantID-0001" createtransactionrequest.transactionRequest = transactionrequest createtransactioncontroller = createTransactionController(createtransactionrequest) createtransactioncontroller.execute() response = createtransactioncontroller.getresponse() if (response.messages.resultCode=="Ok"): print "Transaction ID : %s" % response.transactionResponse.transId print response.transactionResponse.messages.message[0].description else: print "response code: %s" % response.messages.resultCode print response.transactionResponse.errors.error[0].errorText return response
def charge_credit_card(amount): merchantAuth = apicontractsv1.merchantAuthenticationType() merchantAuth.name = constants.apiLoginId merchantAuth.transactionKey = constants.transactionKey creditCard = apicontractsv1.creditCardType() creditCard.cardNumber = "4111111111111111" creditCard.expirationDate = "2020-12" payment = apicontractsv1.paymentType() payment.creditCard = creditCard transactionrequest = apicontractsv1.transactionRequestType() transactionrequest.transactionType = "authCaptureTransaction" transactionrequest.amount = amount transactionrequest.payment = payment createtransactionrequest = apicontractsv1.createTransactionRequest() createtransactionrequest.merchantAuthentication = merchantAuth createtransactionrequest.refId = "MerchantID-0001" createtransactionrequest.transactionRequest = transactionrequest createtransactioncontroller = createTransactionController( createtransactionrequest) createtransactioncontroller.execute() response = createtransactioncontroller.getresponse() if (response.messages.resultCode == "Ok"): print "Transaction ID : %s" % response.transactionResponse.transId else: print "response code: %s" % response.messages.resultCode return response
def creditCardPayment(request): creditCard = apicontractsv1.creditCardType() form = CreditCardForm() if request.method == 'POST': form = CreditCardForm(request.POST) if form.is_valid(): try: creditCard_num = form.cleaned_data['creditCard_num'] except (ValidationError): return render(request, 'new/card.html', { 'error_message': "Invalid Card", }) try: expirationDate = form.cleaned_data['expirationDate'] amount = form.cleaned_data['amount'] creditCard.cardNumber = str(creditCard_num) creditCard.expirationDate = str(expirationDate) payment = apicontractsv1.paymentType() payment.creditCard = creditCard transactionrequest = apicontractsv1.transactionRequestType() transactionrequest.transactionType = "authCaptureTransaction" transactionrequest.amount = amount transactionrequest.payment = payment #code from api createtransactionrequestapicontractsv1.createTransactionRequest( ) createtransactionrequest.merchantAuthentication = merchantAuth createtransactionrequest.refId = "MerchantID01" createtransactionrequest.transactionRequest = transactionrequest createtransactioncontroller = createTransactionController( createtransactionrequest) createtransactioncontroller.execute() response = createtransactioncontroller.getresponse() if (response.messages.resultCode == "Ok"): message = "Transaction ID : %s" % response.transactionResponse.transId else: message = "response code: %s" % response.messages.resultCode return render( request, 'new/card.html', {"message": message}, ) except (ValidationError): return render(request, 'new/card.html', { 'error_message': "Card Expired!", }) return render( request, 'new/card.html', )
def debit_bank_account(): amount = str(round(random.random()*100, 2)) merchantAuth = apicontractsv1.merchantAuthenticationType() merchantAuth.name = constants.apiLoginId merchantAuth.transactionKey = constants.transactionKey payment = apicontractsv1.paymentType() bankAccountType = apicontractsv1.bankAccountType() accountType = apicontractsv1.bankAccountTypeEnum bankAccountType.accountType = accountType.checking bankAccountType.routingNumber = "125000024" bankAccountType.accountNumber = "12345678" bankAccountType.nameOnAccount = "John Doe" transactionrequest = apicontractsv1.transactionRequestType() transactionrequest.transactionType = "authCaptureTransaction" transactionrequest.amount = Decimal (amount) transactionrequest.payment = payment transactionrequest.payment.bankAccount = bankAccountType createtransactionrequest = apicontractsv1.createTransactionRequest() createtransactionrequest.merchantAuthentication = merchantAuth createtransactionrequest.refId = "MerchantID-0001" createtransactionrequest.transactionRequest = transactionrequest createtransactioncontroller = createTransactionController(createtransactionrequest) createtransactioncontroller.execute() response = createtransactioncontroller.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); 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
def create_transaction_type(self, trans_type): """ Creates the transaction type instance with the amount """ transaction_type = apicontractsv1.transactionRequestType() transaction_type.transactionType = trans_type transaction_type.currencyCode = 'USD' return transaction_type
def capture_previously_authorized_amount(transactionId): merchantAuth = apicontractsv1.merchantAuthenticationType() merchantAuth.name = constants.apiLoginId merchantAuth.transactionKey = constants.transactionKey transactionrequest = apicontractsv1.transactionRequestType() transactionrequest.transactionType = "priorAuthCaptureTransaction" transactionrequest.amount = Decimal('2.55') transactionrequest.refTransId = transactionId createtransactionrequest = apicontractsv1.createTransactionRequest() createtransactionrequest.merchantAuthentication = merchantAuth createtransactionrequest.refId = "MerchantID-0001" createtransactionrequest.transactionRequest = transactionrequest createtransactioncontroller = createTransactionController( createtransactionrequest) createtransactioncontroller.execute() response = createtransactioncontroller.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) 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
def get_details(refTransId): merchantAuth = apicontractsv1.merchantAuthenticationType() merchantAuth.name = constants.apiLoginId merchantAuth.transactionKey = constants.transactionKey transactionrequest = apicontractsv1.transactionRequestType() transactionrequest.transactionType = apicontractsv1.transactionTypeEnum.getDetailsTransaction transactionrequest.refTransId = refTransId 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("Paypal Get Details Successful.") print('Transaction ID: %s' % response.transactionResponse.transId) print("Payer Id : %s " % response.transactionResponse.secureAcceptance.PayerID) print('Transaction Response Code: %s' % response.transactionResponse.responseCode) print('Message Code: %s' % response.transactionResponse.messages.message[0].code) 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
def capture_funds_authorized_through_another_channel(): amount = str(round(random.random()*100, 2)) merchantAuth = apicontractsv1.merchantAuthenticationType() merchantAuth.name = constants.apiLoginId merchantAuth.transactionKey = constants.transactionKey creditCard = apicontractsv1.creditCardType() creditCard.cardNumber = "4111111111111111" creditCard.expirationDate = "2020-12" payment = apicontractsv1.paymentType() payment.creditCard = creditCard transactionrequest = apicontractsv1.transactionRequestType() transactionrequest.transactionType = "captureOnlyTransaction" transactionrequest.amount = Decimal (amount) transactionrequest.payment = payment transactionrequest.authCode = "ROHNFQ" createtransactionrequest = apicontractsv1.createTransactionRequest() createtransactionrequest.merchantAuthentication = merchantAuth createtransactionrequest.refId = "MerchantID-0001" createtransactionrequest.transactionRequest = transactionrequest createtransactioncontroller = createTransactionController(createtransactionrequest) createtransactioncontroller.execute() response = createtransactioncontroller.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) 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
def capture_funds_authorized_through_another_channel(): amount = str(round(random.random()*100, 2)) merchantAuth = apicontractsv1.merchantAuthenticationType() merchantAuth.name = constants.apiLoginId merchantAuth.transactionKey = constants.transactionKey creditCard = apicontractsv1.creditCardType() creditCard.cardNumber = "4111111111111111" creditCard.expirationDate = "2035-12" payment = apicontractsv1.paymentType() payment.creditCard = creditCard transactionrequest = apicontractsv1.transactionRequestType() transactionrequest.transactionType = "captureOnlyTransaction" transactionrequest.amount = Decimal (amount) transactionrequest.payment = payment transactionrequest.authCode = "ROHNFQ" createtransactionrequest = apicontractsv1.createTransactionRequest() createtransactionrequest.merchantAuthentication = merchantAuth createtransactionrequest.refId = "MerchantID-0001" createtransactionrequest.transactionRequest = transactionrequest createtransactioncontroller = createTransactionController(createtransactionrequest) createtransactioncontroller.execute() response = createtransactioncontroller.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) 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
def charge_tokenized_credit_card(): merchantAuth = apicontractsv1.merchantAuthenticationType() merchantAuth.name = constants.apiLoginId merchantAuth.transactionKey = constants.transactionKey creditCard = apicontractsv1.creditCardType() creditCard.cardNumber = "4111111111111111" creditCard.expirationDate = "2020-12" # Set the token specific info creditCard.isPaymentToken = True creditCard.cryptogram = "EjRWeJASNFZ4kBI0VniQEjRWeJA=" payment = apicontractsv1.paymentType() payment.creditCard = creditCard transactionrequest = apicontractsv1.transactionRequestType() transactionrequest.transactionType = "authCaptureTransaction" transactionrequest.amount = Decimal ('1.5') transactionrequest.payment = payment createtransactionrequest = apicontractsv1.createTransactionRequest() createtransactionrequest.merchantAuthentication = merchantAuth createtransactionrequest.refId = "MerchantID-0001" createtransactionrequest.transactionRequest = transactionrequest createtransactioncontroller = createTransactionController(createtransactionrequest) createtransactioncontroller.execute() response = createtransactioncontroller.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) 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
def refund_transaction(refTransId): merchantAuth = apicontractsv1.merchantAuthenticationType() merchantAuth.name = constants.apiLoginId merchantAuth.transactionKey = constants.transactionKey creditCard = apicontractsv1.creditCardType() creditCard.cardNumber = "0015" creditCard.expirationDate = "XXXX" payment = apicontractsv1.paymentType() payment.creditCard = creditCard transactionrequest = apicontractsv1.transactionRequestType() transactionrequest.transactionType = "refundTransaction" transactionrequest.amount = Decimal ('2.55') #set refTransId to transId of a settled transaction transactionrequest.refTransId = refTransId transactionrequest.payment = payment createtransactionrequest = apicontractsv1.createTransactionRequest() createtransactionrequest.merchantAuthentication = merchantAuth createtransactionrequest.refId = "MerchantID-0001" createtransactionrequest.transactionRequest = transactionrequest createtransactioncontroller = createTransactionController(createtransactionrequest) createtransactioncontroller.execute() response = createtransactioncontroller.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); 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
def authorization_only_continued(): merchantAuth = apicontractsv1.merchantAuthenticationType() merchantAuth.name = constants.apiLoginId merchantAuth.transactionKey = constants.transactionKey paypal = apicontractsv1.payPalType() paypal.successUrl = "http://www.merchanteCommerceSite.com/Success/TC25262" paypal.cancelUrl = "http://www.merchanteCommerceSite.com/Success/TC25262" paypal.payerID = "LM6NCLZ5RAKBY" payment = apicontractsv1.paymentType() payment.payPal = paypal transactionrequest = apicontractsv1.transactionRequestType() transactionrequest.transactionType = apicontractsv1.transactionTypeEnum.authOnlyContinueTransaction transactionrequest.refTransId = "2245592542" transactionrequest.payment = payment 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 ("Payer Id : %s " % response.transactionResponse.secureAcceptance.PayerID) 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) 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
def create_an_apple_pay_transaction(): merchantAuth = apicontractsv1.merchantAuthenticationType() merchantAuth.name = constants.apiLoginId merchantAuth.transactionKey = constants.transactionKey opaquedata = apicontractsv1.opaqueDataType() opaquedata.dataDescriptor = "COMMON.APPLE.INAPP.PAYMENT" opaquedata.dataValue = "eyJkYXRhIjoiQkRQTldTdE1tR2V3UVVXR2c0bzdFXC9qKzFjcTFUNzhxeVU4NGI2N2l0amNZSTh3UFlBT2hzaGpoWlBycWRVcjRYd1BNYmo0emNHTWR5KysxSDJWa1BPWStCT01GMjV1YjE5Y1g0bkN2a1hVVU9UakRsbEIxVGdTcjhKSFp4Z3A5ckNnc1NVZ2JCZ0tmNjBYS3V0WGY2YWpcL284WkliS25yS1E4U2gwb3VMQUtsb1VNbit2UHU0K0E3V0tycXJhdXo5SnZPUXA2dmhJcStIS2pVY1VOQ0lUUHlGaG1PRXRxK0grdzB2UmExQ0U2V2hGQk5uQ0hxenpXS2NrQlwvMG5xTFpSVFliRjBwK3Z5QmlWYVdIZWdoRVJmSHhSdGJ6cGVjelJQUHVGc2ZwSFZzNDhvUExDXC9rXC8xTU5kNDdrelwvcEhEY1JcL0R5NmFVTStsTmZvaWx5XC9RSk4rdFMzbTBIZk90SVNBUHFPbVhlbXZyNnhKQ2pDWmxDdXcwQzltWHpcL29iSHBvZnVJRVM4cjljcUdHc1VBUERwdzdnNjQybTRQendLRitIQnVZVW5lV0RCTlNEMnU2amJBRzMiLCJ2ZXJzaW9uIjoiRUNfdjEiLCJoZWFkZXIiOnsiYXBwbGljYXRpb25EYXRhIjoiOTRlZTA1OTMzNWU1ODdlNTAxY2M0YmY5MDYxM2UwODE0ZjAwYTdiMDhiYzdjNjQ4ZmQ4NjVhMmFmNmEyMmNjMiIsInRyYW5zYWN0aW9uSWQiOiJjMWNhZjVhZTcyZjAwMzlhODJiYWQ5MmI4MjgzNjM3MzRmODViZjJmOWNhZGYxOTNkMWJhZDlkZGNiNjBhNzk1IiwiZXBoZW1lcmFsUHVibGljS2V5IjoiTUlJQlN6Q0NBUU1HQnlxR1NNNDlBZ0V3Z2ZjQ0FRRXd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Y5d1ltdTlVandhcjFQSFlTK0JcL29Hbm96NTkxd2phZ1hXUnowbk1vNXkzTzFLelgwZDhDUkhBVmE4OFNyVjFhNUpJaVJldjNvU3RJcXd2NXh1WmxkYWc2VHI4dz09In0=" paymentOne = apicontractsv1.paymentType() paymentOne.opaqueData = opaquedata transactionrequest = apicontractsv1.transactionRequestType() transactionrequest.transactionType = apicontractsv1.transactionTypeEnum.authCaptureTransaction transactionrequest.amount = Decimal('151') transactionrequest.payment = paymentOne 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
def create_an_apple_pay_transaction(): merchantAuth = apicontractsv1.merchantAuthenticationType() merchantAuth.name = constants.apiLoginId merchantAuth.transactionKey = constants.transactionKey opaquedata = apicontractsv1.opaqueDataType() opaquedata.dataDescriptor = "COMMON.APPLE.INAPP.PAYMENT" opaquedata.dataValue = "eyJkYXRhIjoiQkRQTldTdE1tR2V3UVVXR2c0bzdFXC9q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entType() paymentOne.opaqueData = opaquedata transactionrequest = apicontractsv1.transactionRequestType() transactionrequest.transactionType = apicontractsv1.transactionTypeEnum.authCaptureTransaction transactionrequest.amount = Decimal('151') transactionrequest.payment = paymentOne 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
def create_an_accept_transaction(): merchantAuth = apicontractsv1.merchantAuthenticationType() merchantAuth.name = constants.apiLoginId merchantAuth.transactionKey = constants.transactionKey opaquedata = apicontractsv1.opaqueDataType() opaquedata.dataDescriptor = "COMMON.ACCEPT.INAPP.PAYMENT" opaquedata.dataValue = "9471471570959063005001" paymentOne = apicontractsv1.paymentType() paymentOne.opaqueData = opaquedata transactionrequest = apicontractsv1.transactionRequestType() transactionrequest.transactionType = apicontractsv1.transactionTypeEnum.authCaptureTransaction transactionrequest.amount = Decimal('151') transactionrequest.payment = paymentOne 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
def authorization_only_continued(): merchantAuth = apicontractsv1.merchantAuthenticationType() merchantAuth.name = constants.apiLoginId merchantAuth.transactionKey = constants.transactionKey paypal = apicontractsv1.payPalType() paypal.successUrl = "http://www.merchanteCommerceSite.com/Success/TC25262" paypal.cancelUrl = "http://www.merchanteCommerceSite.com/Success/TC25262" paypal.payerID = "LM6NCLZ5RAKBY" payment = apicontractsv1.paymentType() payment.payPal = paypal transactionrequest = apicontractsv1.transactionRequestType() transactionrequest.transactionType = apicontractsv1.transactionTypeEnum.authOnlyContinueTransaction transactionrequest.refTransId = "2245592542" transactionrequest.payment = payment 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 ("Payer Id : %s " % response.transactionResponse.secureAcceptance.PayerID) 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); 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
def create_visa_checkout_transaction(): merchantAuth = apicontractsv1.merchantAuthenticationType() merchantAuth.name = constants.apiLoginId merchantAuth.transactionKey = constants.transactionKey # Populate the payment data opaqueData = apicontractsv1.opaqueDataType() opaqueData.dataDescriptor = "COMMON.VCO.ONLINE.PAYMENT" opaqueData.dataValue = "vJhm2AREOockvIeUeJXkzSzcSwQtnz6pTbkjuXsGRMoG/4CYVZhUaNxwA2AbPr/wWOr3GPBlIv/5sH31wQotfjCHyq+rP1X+9myn3MueaOYxhpfpfkfAZcm8upaUVl20McTiuhmhHulNNTRd5AFnq3qUS55TRkAODqwMrSL+gLab8fw4V5L355Ufu7+qjUpMFi71hQ92L7u0DjuGSDmXZzPvH3p21LphdixDLNJWvA0YQ5/jIH7WbrNkSw9O//Zsf5p256WAjdsCcvLjPCYDB2mMAs4E8ZpOpQ39GATRSscPP5550RpHeYrTDLzlLZB/P5989mcz6ReH6sIbqn9Z0W0j+aIpZ7HsSRx74ps8kYt1SZ/NTph5+rT1JhmLR+QQAYI5EeXH4amYyOxt9klHb9erkLNwDPhBNkRh08kVlxPFHK4AHj1nXnaKjSs4yQ8JighJyD5rc1ekvX/n/Ng+TFbdpEUxsCAyNeClclxyta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Tfv8OmYq4exJN6n5eo+dyuaKF3zVUBSw2oAF68kzSWvuA1ZQ0HJWTemGOu0rY/jzoicCHv0cC/MJaZ+nCqYfyhWUWgdTqPg+HOw1n1tZ7/geQTgHS2ZQlP5KYrKNDBNs9lRSKLjCE4vs+ZhA6YTMn/aPQKRyrkzQE/IQb2C4+ablq0RiVKdKegoiOHeQi9WlJIpu/SSn34pedLYfHXCLDkRoHyRy+0DhXWB7CYKC6AU0ZcaWzulSHhS6c1Sm0ZiET9CW63lZNsWS5y5s7hCIEYqWm7v+4nv2gERHxXWeX/+ZWvO8DRqfX5BVbUUKXSKpgddtdTn6VKyCs4/qnU4uP1qcqbStfZX33vzJPH8RGgL/T3E1exkVYV0FTtljhruYQ9TF2pg7T950RkGwlj3cWPjSqKqKyp8yu4w8xoS9Rel/LD0sABzE16d4tVRdNeJPCmOIzYhrDddfo4xW736BzgjYGKcdSUrl9YMeyVcYhvoGGM1YzkL+PTt3RO+moo9PYGQnY+7GkOpJoBwb5COQVvcCrkwcehsmVYBle+1uEocHAHv1Kc1BtXP+WT/wyWKMGnPJoPovglIhowODb2wU8ltnbRRhP14W6jwPCqtPWV4LXN0+7VKfyqBRUGkITjQWqsntlf3/egfG4uS3faPU4M" opaqueData.dataKey = "ZW6TOD05lWOtUYVunXhYmXRBA6d7UTVezRCwUYLrK/xHPK5LDuZe5Rk/sT223vO0NdD7iQXMPqnQrCS1myW+CFceOKiUuoA0zKJ6TZ84q/+msPG66DDdzDxeKKdE5Qjt" paymentType = apicontractsv1.paymentType() paymentType.opaqueData = opaqueData # Create the payment transaction request transactionRequest = apicontractsv1.transactionRequestType() transactionRequest.transactionType = apicontractsv1.transactionTypeEnum.authCaptureTransaction transactionRequest.callId = "1238408836021304101" transactionRequest.amount = Decimal('14.00') transactionRequest.payment = paymentType # Make the API Request request = apicontractsv1.createTransactionRequest() request.merchantAuthentication = merchantAuth request.transactionRequest = transactionRequest # Execute the API request controller = createTransactionController(request) controller.execute() # Get the response 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); 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
def _create_transaction_request_for_profile(self, transaction, customer_profile, payment_profile): """ Create an authorize.net transaction request object to a customer id :param transaction: A Silver transaction with a AuthorizeNet payment method. :param customer_profile: The authorize.net customer profile ID :param payment_profile: The authorize.net customer payment profile ID :return: An authorize.net TransactionRequest """ profile_to_charge = apicontractsv1.customerProfilePaymentType() profile_to_charge.customerProfileId = customer_profile profile_to_charge.paymentProfile = apicontractsv1.paymentProfile() profile_to_charge.paymentProfile.paymentProfileId = payment_profile payment = apicontractsv1.paymentType() payment.profile = profile_to_charge # Create order information order = apicontractsv1.orderType() order.invoiceNumber = transaction.document.series order.description = "\n".join(map(str, transaction.document.entries)) # Set the customer's identifying information customerData = apicontractsv1.customerDataType() customerData.type = "individual" customerData.id = transaction.customer.id # TODO: right id field? customerData.email = transaction.customer.email settings = self._create_transaction_settings() _tx_request = apicontractsv1.transactionRequestType() _tx_request.transactionType = "authCaptureTransaction" _tx_request.amount = transaction.amount _tx_request.payment = payment _tx_request.order = order # _tx_request.billTo = customerAddress _tx_request.customer = customerData _tx_request.transactionSettings = settings # _tx_request.lineItems = line_items _request = apicontractsv1.createTransactionRequest() _request.merchantAuthentication = self.merchantAuth _request.refId = self.merchantId _request.transactionRequest = _tx_request return _request
def charge_credit_card(amount): merchantAuth = apicontractsv1.merchantAuthenticationType() merchantAuth.name = constants.apiLoginId merchantAuth.transactionKey = constants.transactionKey creditCard = apicontractsv1.creditCardType() creditCard.cardNumber = "4111111111111111" creditCard.expirationDate = "2020-12" payment = apicontractsv1.paymentType() payment.creditCard = creditCard transactionrequest = apicontractsv1.transactionRequestType() transactionrequest.transactionType = "authCaptureTransaction" transactionrequest.amount = amount transactionrequest.payment = payment createtransactionrequest = apicontractsv1.createTransactionRequest() createtransactionrequest.merchantAuthentication = merchantAuth createtransactionrequest.refId = "MerchantID-0001" createtransactionrequest.transactionRequest = transactionrequest createtransactioncontroller = createTransactionController(createtransactionrequest) createtransactioncontroller.execute() response = createtransactioncontroller.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); 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
def credit(): merchantAuth = apicontractsv1.merchantAuthenticationType() merchantAuth.name = constants.apiLoginId merchantAuth.transactionKey = constants.transactionKey paypal = apicontractsv1.payPalType() payment = apicontractsv1.paymentType() payment.payPal = paypal transactionrequest = apicontractsv1.transactionRequestType() transactionrequest.transactionType = apicontractsv1.transactionTypeEnum.refundTransaction transactionrequest.refTransId = "2241762126" transactionrequest.payment = payment 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) 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
def charge_customer_profile(customerProfileId, paymentProfileId, amount): merchantAuth = apicontractsv1.merchantAuthenticationType() merchantAuth.name = constants.apiLoginId merchantAuth.transactionKey = constants.transactionKey # create a customer payment profile profileToCharge = apicontractsv1.customerProfilePaymentType() profileToCharge.customerProfileId = customerProfileId profileToCharge.paymentProfile = apicontractsv1.paymentProfile() profileToCharge.paymentProfile.paymentProfileId = paymentProfileId transactionrequest = apicontractsv1.transactionRequestType() transactionrequest.transactionType = "authCaptureTransaction" transactionrequest.amount = amount transactionrequest.profile = profileToCharge createtransactionrequest = apicontractsv1.createTransactionRequest() createtransactionrequest.merchantAuthentication = merchantAuth createtransactionrequest.refId = "MerchantID-0001" createtransactionrequest.transactionRequest = transactionrequest createtransactioncontroller = createTransactionController(createtransactionrequest) createtransactioncontroller.execute() response = createtransactioncontroller.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) 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
def authorization_and_capture_continued(refTransId, payerID): merchantAuth = apicontractsv1.merchantAuthenticationType() merchantAuth.name = constants.apiLoginId merchantAuth.transactionKey = constants.transactionKey paypal = apicontractsv1.payPalType() paypal.payerID = payerID payment = apicontractsv1.paymentType() payment.payPal = paypal transactionrequest = apicontractsv1.transactionRequestType() transactionrequest.transactionType = apicontractsv1.transactionTypeEnum.authCaptureContinueTransaction transactionrequest.refTransId = refTransId transactionrequest.payment = payment 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 ("Payer Id : %s " % response.transactionResponse.secureAcceptance.PayerID) 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) 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
def charge_customer_profile(customerProfileId, paymentProfileId, amount): merchantAuth = apicontractsv1.merchantAuthenticationType() merchantAuth.name = constants.apiLoginId merchantAuth.transactionKey = constants.transactionKey # create a customer payment profile profileToCharge = apicontractsv1.customerProfilePaymentType() profileToCharge.customerProfileId = customerProfileId profileToCharge.paymentProfile = apicontractsv1.paymentProfile() profileToCharge.paymentProfile.paymentProfileId = paymentProfileId transactionrequest = apicontractsv1.transactionRequestType() transactionrequest.transactionType = "authCaptureTransaction" transactionrequest.amount = amount transactionrequest.profile = profileToCharge createtransactionrequest = apicontractsv1.createTransactionRequest() createtransactionrequest.merchantAuthentication = merchantAuth createtransactionrequest.refId = "MerchantID-0001" createtransactionrequest.transactionRequest = transactionrequest createtransactioncontroller = createTransactionController(createtransactionrequest) createtransactioncontroller.execute() response = createtransactioncontroller.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); 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
def get_an_accept_payment_page(amount): merchantAuth = apicontractsv1.merchantAuthenticationType() merchantAuth.name = constants.apiLoginId merchantAuth.transactionKey = constants.transactionKey setting1 = apicontractsv1.settingType() setting1.settingName = apicontractsv1.settingNameEnum.hostedPaymentButtonOptions setting1.settingValue = "{\"text\": \"Pay\"}" setting2 = apicontractsv1.settingType() setting2.settingName = apicontractsv1.settingNameEnum.hostedPaymentOrderOptions setting2.settingValue = "{\"show\": false}" settings = apicontractsv1.ArrayOfSetting() settings.setting.append(setting1) settings.setting.append(setting2) transactionrequest = apicontractsv1.transactionRequestType() transactionrequest.transactionType = "authCaptureTransaction" transactionrequest.amount = amount paymentPageRequest = apicontractsv1.getHostedPaymentPageRequest() paymentPageRequest.merchantAuthentication = merchantAuth paymentPageRequest.transactionRequest = transactionrequest paymentPageRequest.hostedPaymentSettings = settings paymentPageController = getHostedPaymentPageController(paymentPageRequest) paymentPageController.execute() paymentPageResponse = paymentPageController.getresponse() if paymentPageResponse is not None: if paymentPageResponse.messages.resultCode == apicontractsv1.messageTypeEnum.Ok: print('Successfully got hosted payment page!') print('Token : %s' % paymentPageResponse.token) if paymentPageResponse.messages is not None: print('Message Code : %s' % paymentPageResponse.messages.message[0]['code'].text) print('Message Text : %s' % paymentPageResponse.messages.message[0]['text'].text) else: if paymentPageResponse.messages is not None: print('Failed to get batch statistics.\nCode:%s \nText:%s' % (paymentPageResponse.messages.message[0]['code'].text, paymentPageResponse.messages.message[0]['text'].text)) return paymentPageResponse
def void_transaction(self, transaction, payment_method=None): """ Void a transaction :param transaction: A Silver transaction with a AuthorizeNet payment method. :param payment_method: The payment method used to authorize the original transaction :returns True if the state transition was successful, False otherwise. """ payment_processor = get_instance(transaction.payment_processor) if not payment_processor == self: return False transId = str(transaction.data.get('authorizenet_id')) req = apicontractsv1.transactionRequestType() req.transactionType = "voidTransaction" req.refTransId = transId t_req = apicontractsv1.createTransactionRequest() t_req.merchantAuthentication = self.merchantAuth t_req.refId = self.merchantId t_req.transactionRequest = req controller = createTransactionController(t_req) try: controller.execute() except Exception as e: logger.warning('Error executing request to void transaction %s', { 'transaction_id': transId, 'exception': str(e) }) response = controller.getresponse() have_resp = response is not None if have_resp: status, resp_ok = self._get_authorizenet_transaction_status( response) return self._transition_silver_transaction_to( transaction, response, status, transaction.States.Canceled) else: logger.warning( 'Couldn\'t void transaction %s', { 'transaction_id': transId, 'messages': response.messages.message[0]['text'].text }) return False
def void(refTransId): merchantAuth = apicontractsv1.merchantAuthenticationType() merchantAuth.name = constants.apiLoginId merchantAuth.transactionKey = constants.transactionKey paypal = apicontractsv1.payPalType() payment = apicontractsv1.paymentType() payment.payPal = paypal transactionrequest = apicontractsv1.transactionRequestType() transactionrequest.transactionType = apicontractsv1.transactionTypeEnum.voidTransaction transactionrequest.refTransId = refTransId transactionrequest.payment = payment 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) 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
def get_hosted_payment_page(amount): merchantAuth = apicontractsv1.merchantAuthenticationType() merchantAuth.name = constants.apiLoginId merchantAuth.transactionKey = constants.transactionKey setting1 = apicontractsv1.settingType() setting1.settingName = apicontractsv1.settingNameEnum.hostedPaymentButtonOptions setting1.settingValue = "{\"text\": \"Pay\"}" setting2 = apicontractsv1.settingType() setting2.settingName = apicontractsv1.settingNameEnum.hostedPaymentOrderOptions setting2.settingValue = "{\"show\": false}" settings = apicontractsv1.ArrayOfSetting() settings.setting.append(setting1) settings.setting.append(setting2) transactionrequest = apicontractsv1.transactionRequestType() transactionrequest.transactionType = "authCaptureTransaction" transactionrequest.amount = amount paymentPageRequest = apicontractsv1.getHostedPaymentPageRequest() paymentPageRequest.merchantAuthentication = merchantAuth paymentPageRequest.transactionRequest = transactionrequest paymentPageRequest.hostedProfileSettings = settings paymentPageController = getHostedPaymentPageController(paymentPageRequest) paymentPageController.execute() paymentPageResponse = paymentPageController.getresponse() if paymentPageResponse is not None: if paymentPageResponse.messages.resultCode == apicontractsv1.messageTypeEnum.Ok: print('Successfully got hosted payment page!') print('Token : %s' % paymentPageResponse.token) if paymentPageResponse.messages: print('Message Code : %s' % paymentPageResponse.messages.message[0]['code'].text) print('Message Text : %s' % paymentPageResponse.messages.message[0]['text'].text) else: if paymentPageResponse.messages: print('Failed to get batch statistics.\nCode:%s \nText:%s' % (paymentPageResponse.messages.message[0]['code'].text,paymentPageResponse.messages.message[0]['text'].text)) return paymentPageResponse
def void_transaction(refTransId): merchantAuth = apicontractsv1.merchantAuthenticationType() merchantAuth.name = constants.apiLoginId merchantAuth.transactionKey = constants.transactionKey transactionrequest = apicontractsv1.transactionRequestType() transactionrequest.transactionType = "voidTransaction" #set refTransId to transId of an unsettled transaction transactionrequest.refTransId = refTransId createtransactionrequest = apicontractsv1.createTransactionRequest() createtransactionrequest.merchantAuthentication = merchantAuth createtransactionrequest.refId = "MerchantID-0001" createtransactionrequest.transactionRequest = transactionrequest createtransactioncontroller = createTransactionController(createtransactionrequest) createtransactioncontroller.execute() response = createtransactioncontroller.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); 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
def capture_previously_authorized_amount(transactionId): merchantAuth = apicontractsv1.merchantAuthenticationType() merchantAuth.name = constants.apiLoginId merchantAuth.transactionKey = constants.transactionKey transactionrequest = apicontractsv1.transactionRequestType() transactionrequest.transactionType = "priorAuthCaptureTransaction" transactionrequest.amount = Decimal ('2.55') transactionrequest.refTransId = transactionId createtransactionrequest = apicontractsv1.createTransactionRequest() createtransactionrequest.merchantAuthentication = merchantAuth createtransactionrequest.refId = "MerchantID-0001" createtransactionrequest.transactionRequest = transactionrequest createtransactioncontroller = createTransactionController(createtransactionrequest) createtransactioncontroller.execute() response = createtransactioncontroller.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) 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
def get_details(refTransId): merchantAuth = apicontractsv1.merchantAuthenticationType() merchantAuth.name = constants.apiLoginId merchantAuth.transactionKey = constants.transactionKey transactionrequest = apicontractsv1.transactionRequestType() transactionrequest.transactionType = apicontractsv1.transactionTypeEnum.getDetailsTransaction transactionrequest.refTransId = refTransId 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 ("Paypal Get Details Successful.") print ('Transaction ID: %s' % response.transactionResponse.transId); print ("Payer Id : %s " % response.transactionResponse.secureAcceptance.PayerID); print ('Transaction Response Code: %s' % response.transactionResponse.responseCode); print ('Message Code: %s' % response.transactionResponse.messages.message[0].code); 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
def testauthOnlyContinueTransaction(self): transactionrequesttype = apicontractsv1.transactionRequestType() transactionrequesttype.transactionType = "authCaptureTransaction" transactionrequesttype.amount = self.amount transactionrequesttype.payment = self.payment transactionrequesttype.order = self.order transactionrequesttype.customer = self.customerData transactionrequesttype.billTo = self.billTo createtransactionrequest = apicontractsv1.createTransactionRequest() createtransactionrequest.merchantAuthentication = self.merchantAuthentication createtransactionrequest.refId = self.ref_id createtransactionrequest.transactionRequest = transactionrequesttype createtransactioncontroller = createTransactionController(createtransactionrequest) createtransactioncontroller.execute() response = createtransactioncontroller.getresponse() self.assertIsNotNone(response.transactionResponse) self.assertIsNotNone(response.transactionResponse.transId)
def authorization_only_continued(): merchantAuth = apicontractsv1.merchantAuthenticationType() merchantAuth.name = constants.apiLoginId merchantAuth.transactionKey = constants.transactionKey paypal = apicontractsv1.payPalType() paypal.successUrl = "http://www.merchanteCommerceSite.com/Success/TC25262" paypal.cancelUrl = "http://www.merchanteCommerceSite.com/Success/TC25262" paypal.payerID = "LM6NCLZ5RAKBY" payment = apicontractsv1.paymentType() payment.payPal = paypal transactionrequest = apicontractsv1.transactionRequestType() transactionrequest.transactionType = apicontractsv1.transactionTypeEnum.authOnlyContinueTransaction transactionrequest.refTransId = "2245592542" transactionrequest.payment = payment request = apicontractsv1.createTransactionRequest() request.merchantAuthentication = merchantAuth request.refId = "Sample" request.transactionRequest = transactionrequest controller = createTransactionController(request) controller.execute() response = controller.getresponse() if (response.messages.resultCode=="Ok"): print "SUCCESS" print "Message Code : %s" % response.messages.message[0].code print "Message text : %s" % response.messages.message[0].text if (response.transactionResponse.responseCode == "1" ): print "Description : %s " % response.transactionResponse.messages.message[0].description print "Payer Id : %s " % response.transactionResponse.secureAcceptance.PayerID print "Transaction ID : %s " % response.transactionResponse.transId else: print "ERROR" print "Message Code : %s" % response.messages.message[0].code print "Message text : %s" % response.messages.message[0].text return response
def prior_authorization_capture(refTransId): merchantAuth = apicontractsv1.merchantAuthenticationType() merchantAuth.name = constants.apiLoginId merchantAuth.transactionKey = constants.transactionKey paypal = apicontractsv1.payPalType() paypal.successUrl = "http://www.merchanteCommerceSite.com/Success/TC25262" paypal.cancelUrl = "http://www.merchanteCommerceSite.com/Success/TC25262" paypal.payerID = "LM6NCLZ5RAKBY" payment = apicontractsv1.paymentType() payment.payPal = paypal transactionrequest = apicontractsv1.transactionRequestType() transactionrequest.transactionType = apicontractsv1.transactionTypeEnum.priorAuthCaptureTransaction transactionrequest.refTransId = refTransId transactionrequest.payment = payment request = apicontractsv1.createTransactionRequest() request.merchantAuthentication = merchantAuth request.refId = "Sample" request.transactionRequest = transactionrequest controller = createTransactionController(request) controller.execute() response = controller.getresponse() if (response.messages.resultCode=="Ok"): print "SUCCESS" print "Message Code : %s" % response.messages.message[0]['code'].text print "Message text : %s" % response.messages.message[0]['text'].text print "Auth code : %s " % response.transactionResponse.authCode if (response.transactionResponse.responseCode == "1" ): print "Description : %s " % response.transactionResponse.messages.message[0].description print "Transaction ID : %s " % response.transactionResponse.transId else: print "ERROR" print "Message Code : %s" % response.messages.message[0]['code'].text print "Message text : %s" % response.messages.message[0]['text'].text return response
def debit_bank_account(): amount = str(round(random.random()*100, 2)) merchantAuth = apicontractsv1.merchantAuthenticationType() merchantAuth.name = constants.apiLoginId merchantAuth.transactionKey = constants.transactionKey payment = apicontractsv1.paymentType() bankAccountType = apicontractsv1.bankAccountType() accountType = apicontractsv1.bankAccountTypeEnum bankAccountType.accountType = accountType.checking bankAccountType.routingNumber = "125000024" bankAccountType.accountNumber = "12345678" bankAccountType.nameOnAccount = "John Doe" transactionrequest = apicontractsv1.transactionRequestType() transactionrequest.transactionType = "authCaptureTransaction" transactionrequest.amount = Decimal (amount) transactionrequest.payment = payment transactionrequest.payment.bankAccount = bankAccountType createtransactionrequest = apicontractsv1.createTransactionRequest() createtransactionrequest.merchantAuthentication = merchantAuth createtransactionrequest.refId = "MerchantID-0001" createtransactionrequest.transactionRequest = transactionrequest createtransactioncontroller = createTransactionController(createtransactionrequest) createtransactioncontroller.execute() response = createtransactioncontroller.getresponse() if (response.messages.resultCode=="Ok"): print "Transaction ID : %s" % response.transactionResponse.transId print response.transactionResponse.messages.message[0].description else: print "response code: %s" % response.messages.resultCode return response
def authorization_and_capture_continue(refTransId, payerID): merchantAuth = apicontractsv1.merchantAuthenticationType() merchantAuth.name = constants.apiLoginId merchantAuth.transactionKey = constants.transactionKey paypal = apicontractsv1.payPalType() paypal.payerID = payerID payment = apicontractsv1.paymentType() payment.payPal = paypal transactionrequest = apicontractsv1.transactionRequestType() transactionrequest.transactionType = apicontractsv1.transactionTypeEnum.authCaptureContinueTransaction transactionrequest.refTransId = refTransId transactionrequest.payment = payment request = apicontractsv1.createTransactionRequest() request.merchantAuthentication = merchantAuth request.refId = "Sample" request.transactionRequest = transactionrequest controller = createTransactionController(request) controller.execute() response = controller.getresponse() if (response.messages.resultCode=="Ok"): print "SUCCESS" print "Message Code : %s" % response.messages.message[0]['code'].text print "Message text : %s" % response.messages.message[0]['text'].text if (response.transactionResponse.responseCode == "1" ): print "Description : %s " % response.transactionResponse.messages.message[0].description print "Payer Id : %s " % response.transactionResponse.secureAcceptance.PayerID print "Transaction ID : %s " % response.transactionResponse.transId else: print "ERROR" print "Message Code : %s" % response.messages.message[0]['code'].text print "Message text : %s" % response.messages.message[0]['text'].text return response
def refund_transaction(refTransId): merchantAuth = apicontractsv1.merchantAuthenticationType() merchantAuth.name = constants.apiLoginId merchantAuth.transactionKey = constants.transactionKey creditCard = apicontractsv1.creditCardType() creditCard.cardNumber = "0015" creditCard.expirationDate = "XXXX" payment = apicontractsv1.paymentType() payment.creditCard = creditCard transactionrequest = apicontractsv1.transactionRequestType() transactionrequest.transactionType = "refundTransaction" transactionrequest.amount = Decimal ('2.55') #set refTransId to transId of a settled transaction transactionrequest.refTransId = refTransId transactionrequest.payment = payment createtransactionrequest = apicontractsv1.createTransactionRequest() createtransactionrequest.merchantAuthentication = merchantAuth createtransactionrequest.refId = "MerchantID-0001" createtransactionrequest.transactionRequest = transactionrequest createtransactioncontroller = createTransactionController(createtransactionrequest) createtransactioncontroller.execute() response = createtransactioncontroller.getresponse() if (response.messages.resultCode=="Ok"): print "Transaction ID : %s" % response.transactionResponse.transId else: print "response code: %s" % response.messages.resultCode print "Message code: %s" % response.messages.message[0]['code'].text print "Message text: %s" % response.messages.message[0]['text'].text print "Transaction Error Code: %s" % response.transactionResponse.errors.error[0].errorCode print "Transaction Error Text: %s" % response.transactionResponse.errors.error[0].errorText return response
def authorization_only(): merchantAuth = apicontractsv1.merchantAuthenticationType() merchantAuth.name = constants.apiLoginId merchantAuth.transactionKey = constants.transactionKey paypal = apicontractsv1.payPalType() paypal.successUrl = "http://www.merchanteCommerceSite.com/Success/TC25262" paypal.cancelUrl = "http://www.merchanteCommerceSite.com/Success/TC25262" payment = apicontractsv1.paymentType() payment.payPal = paypal transactionrequest = apicontractsv1.transactionRequestType() transactionrequest.amount = Decimal('55.00') transactionrequest.transactionType = apicontractsv1.transactionTypeEnum.authOnlyTransaction transactionrequest.payment = payment request = apicontractsv1.createTransactionRequest() request.merchantAuthentication = merchantAuth request.refId = "Sample" request.transactionRequest = transactionrequest controller = createTransactionController(request) controller.execute() response = controller.getresponse() if (response.messages.resultCode=="Ok"): print "SUCCESS" print "Message Code : %s" % response.messages.message[0].code print "Message text : %s" % response.messages.message[0].text print "Secure acceptance URL : %s " % response.transactionResponse.secureAcceptance.SecureAcceptanceUrl print "Transaction ID : %s " % response.transactionResponse.transId else: print "ERROR" print "Message Code : %s" % response.messages.message[0].code print "Message text : %s" % response.messages.message[0].text return response
def make_payment(self, ccNumber, ccExpire, amount): #CC details creditCard = apicontractsv1.creditCardType() creditCard.cardNumber = ccNumber creditCard.expirationDate = ccExpire #Making the payment type payment = apicontractsv1.paymentType() payment.creditCard = creditCard #Setting the amount and transaction type transactionrequest = apicontractsv1.transactionRequestType() transactionrequest.transactionType = "authCaptureTransaction" transactionrequest.amount = Decimal (amount) transactionrequest.payment = payment #creating the transaction request createtransactionrequest = apicontractsv1.createTransactionRequest() createtransactionrequest.merchantAuthentication = self.merchantAuth createtransactionrequest.refId = "MerchantID-0001" createtransactionrequest.transactionRequest = transactionrequest createtransactioncontroller = createTransactionController(createtransactionrequest) createtransactioncontroller.execute() #Getting the response from the controller response = createtransactioncontroller.getresponse() #Checking the status code. if (response.messages.resultCode=="Ok"): #function to update print "avsResultCode=", response.transactionResponse.avsResultCode statusCode = {'error': False, 'resultcode': response.messages.resultCode} else: print "response code: %s" % response.messages.resultCode print "error =", response.transactionResponse.errors.error statusCode = {'error': True, 'resultcode': response.messages.resultCode} return statusCode
def testAuthOnlyContinueTransaction(self): transactionrequesttype = apicontractsv1.transactionRequestType() transactionrequesttype.transactionType = "authCaptureTransaction" transactionrequesttype.amount = self.amount transactionrequesttype.payment = self.payment transactionrequesttype.order = self.order transactionrequesttype.customer = self.customerData transactionrequesttype.billTo = self.billTo createtransactionrequest = apicontractsv1.createTransactionRequest() createtransactionrequest.merchantAuthentication = self.merchantAuthentication createtransactionrequest.refId = self.ref_id createtransactionrequest.transactionRequest = transactionrequesttype createtransactioncontroller = createTransactionController(createtransactionrequest) createtransactioncontroller.execute() response = createtransactioncontroller.getresponse() if hasattr(response, 'messages') == True: if hasattr(response.messages, 'resultCode') == True: self.assertEquals('Ok', response.messages.resultCode) if hasattr(response, 'transactionResponse') == True: self.assertIsNotNone(response.transactionResponse) if hasattr(response.transactionResponse, 'transId') == True: self.assertIsNotNone(response.transactionResponse.transId)
def credit(): merchantAuth = apicontractsv1.merchantAuthenticationType() merchantAuth.name = constants.apiLoginId merchantAuth.transactionKey = constants.transactionKey paypal = apicontractsv1.payPalType() payment = apicontractsv1.paymentType() payment.payPal = paypal transactionrequest = apicontractsv1.transactionRequestType() transactionrequest.transactionType = apicontractsv1.transactionTypeEnum.refundTransaction transactionrequest.refTransId = "2241762126" transactionrequest.payment = payment request = apicontractsv1.createTransactionRequest() request.merchantAuthentication = merchantAuth request.refId = "Sample" request.transactionRequest = transactionrequest controller = createTransactionController(request) controller.execute() response = controller.getresponse() if (response.messages.resultCode=="Ok"): print "SUCCESS" print "Message Code : %s" % response.messages.message[0].code print "Message text : %s" % response.messages.message[0].text if (response.transactionResponse.responseCode == "1" ): print "Transaction ID : %s " % response.transactionResponse.transId print "Description : %s " % response.transactionResponse.messages.message[0].description else: print "ERROR" print "Message Code : %s" % response.messages.message[0].code print "Message text : %s" % response.messages.message[0].text return response