def update_customer_payment_profile(customerProfileId, customerPaymentProfileId): 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 paymentProfile = apicontractsv1.customerPaymentProfileExType() paymentProfile.billTo = apicontractsv1.customerAddressType() paymentProfile.billTo.firstName = "John" paymentProfile.billTo.lastName = "Doe" paymentProfile.billTo.address = "123 Main St." paymentProfile.billTo.city = "Bellevue" paymentProfile.billTo.state = "WA" paymentProfile.billTo.zip = "98004" paymentProfile.billTo.country = "USA" paymentProfile.billTo.phoneNumber = "000-000-000" paymentProfile.payment = payment paymentProfile.customerPaymentProfileId = customerPaymentProfileId updateCustomerPaymentProfile = apicontractsv1.updateCustomerPaymentProfileRequest( ) updateCustomerPaymentProfile.merchantAuthentication = merchantAuth updateCustomerPaymentProfile.paymentProfile = paymentProfile updateCustomerPaymentProfile.customerProfileId = customerProfileId updateCustomerPaymentProfile.validationMode = apicontractsv1.validationModeEnum.liveMode controller = updateCustomerPaymentProfileController( updateCustomerPaymentProfile) controller.execute() response = controller.getresponse() if (response.messages.resultCode == "Ok"): print("Successfully updated customer payment profile with id %s" % updateCustomerPaymentProfile.paymentProfile. customerPaymentProfileId) else: print(response.messages.message[0]['text'].text) print("Failed to update customer with customer payment profile id %s" % updateCustomerPaymentProfile.paymentProfile. customerPaymentProfileId) return response
def update_customer_payment_profile(self, payment, customerPaymentProfileId, first_name, last_name, contact_dictionary, company_name, set_as_default, validation_mode): print('Updating customer payment profile', customerPaymentProfileId) address = contact_dictionary.get('address') city = contact_dictionary.get('city') state = contact_dictionary.get('state') zip_code = contact_dictionary.get('zip_code') country = 'US' phone = contact_dictionary.get('phone') paymentProfile = apicontractsv1.customerPaymentProfileExType() paymentProfile.billTo = CustomerProfile.make_billTo( first_name, last_name, company_name, address, city, state, zip_code, country, phone) paymentProfile.payment = payment paymentProfile.customerPaymentProfileId = customerPaymentProfileId action = apicontractsv1.updateCustomerPaymentProfileRequest() action.merchantAuthentication = self.merchantAuth action.paymentProfile = paymentProfile action.customerProfileId = str( self.instance.authorizenet_customer_profile_id) action.validationMode = validation_mode.name controller = updateCustomerPaymentProfileController(action) controller.setenvironment(self.post_url) controller.execute() response = controller.getresponse() if response.messages.resultCode == OK: msg = 'Successfully created a customer payment profile with id: {}' print(msg.format(customerPaymentProfileId)) if set_as_default: self.instance.authorizenet_default_payment_profile_id = int( customerPaymentProfileId) self.instance.save() return customerPaymentProfileId else: raise AuthorizeNetError(response.messages.message[0]['text'].text)
def update_customer_payment_profile(customerProfileId, customerPaymentProfileId): 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 paymentProfile = apicontractsv1.customerPaymentProfileExType() paymentProfile.billTo = apicontractsv1.customerAddressType() paymentProfile.billTo.firstName = "John" paymentProfile.billTo.lastName = "Doe" paymentProfile.billTo.address = "123 Main St." paymentProfile.billTo.city = "Bellevue" paymentProfile.billTo.state = "WA" paymentProfile.billTo.zip = "98004" paymentProfile.billTo.country = "USA" paymentProfile.billTo.phoneNumber = "000-000-000" paymentProfile.payment = payment paymentProfile.customerPaymentProfileId = customerPaymentProfileId updateCustomerPaymentProfile = apicontractsv1.updateCustomerPaymentProfileRequest() updateCustomerPaymentProfile.merchantAuthentication = merchantAuth updateCustomerPaymentProfile.paymentProfile = paymentProfile updateCustomerPaymentProfile.customerProfileId = customerProfileId updateCustomerPaymentProfile.validationMode = apicontractsv1.validationModeEnum.liveMode controller = updateCustomerPaymentProfileController(updateCustomerPaymentProfile) controller.execute() response = controller.getresponse() if (response.messages.resultCode=="Ok"): print ("Successfully updated customer payment profile with id %s" % updateCustomerPaymentProfile.paymentProfile.customerPaymentProfileId) else: print (response.messages.message[0]['text'].text) print ("Failed to update customer with customer payment profile id %s" % updateCustomerPaymentProfile.paymentProfile.customerPaymentProfileId) return response
from authorizenet import apicontractsv1 from authorizenet.apicontrollers import * merchantAuth = apicontractsv1.merchantAuthenticationType() merchantAuth.name = '5KP3u95bQpv' merchantAuth.transactionKey = '4Ktq966gC55GAX7S' creditCard = apicontractsv1.creditCardType() creditCard.cardNumber = "4111111111111111" creditCard.expirationDate = "2020-12" payment = apicontractsv1.paymentType() payment.creditCard = creditCard paymentProfile = apicontractsv1.customerPaymentProfileExType() paymentProfile.billTo = apicontractsv1.customerAddressType() paymentProfile.billTo.firstName = "John" paymentProfile.billTo.lastName = "Doe" paymentProfile.billTo.address = "123 Main St." paymentProfile.billTo.city = "Bellevue" paymentProfile.billTo.state = "WA" paymentProfile.billTo.zip = "98004" paymentProfile.billTo.country = "USA" paymentProfile.billTo.phoneNumber = "000-000-000" paymentProfile.payment = payment paymentProfile.customerPaymentProfileId = "34823065" updateCustomerPaymentProfile = apicontractsv1.updateCustomerPaymentProfileRequest() updateCustomerPaymentProfile.merchantAuthentication = merchantAuth updateCustomerPaymentProfile.paymentProfile = paymentProfile updateCustomerPaymentProfile.customerProfileId = "36731856"
from authorizenet import apicontractsv1 from authorizenet.apicontrollers import * merchantAuth = apicontractsv1.merchantAuthenticationType() merchantAuth.name = '5KP3u95bQpv' merchantAuth.transactionKey = '4Ktq966gC55GAX7S' creditCard = apicontractsv1.creditCardType() creditCard.cardNumber = "4111111111111111" creditCard.expirationDate = "2020-12" payment = apicontractsv1.paymentType() payment.creditCard = creditCard paymentProfile = apicontractsv1.customerPaymentProfileExType() paymentProfile.billTo = apicontractsv1.customerAddressType() paymentProfile.billTo.firstName = "John" paymentProfile.billTo.lastName = "Doe" paymentProfile.billTo.address = "123 Main St." paymentProfile.billTo.city = "Bellevue" paymentProfile.billTo.state = "WA" paymentProfile.billTo.zip = "98004" paymentProfile.billTo.country = "USA" paymentProfile.billTo.phoneNumber = "000-000-000" paymentProfile.payment = payment paymentProfile.customerPaymentProfileId = "34823065" updateCustomerPaymentProfile = apicontractsv1.updateCustomerPaymentProfileRequest( ) updateCustomerPaymentProfile.merchantAuthentication = merchantAuth updateCustomerPaymentProfile.paymentProfile = paymentProfile