From 9fc88200d98400bc9eb3c8deece2936bfa857d5f Mon Sep 17 00:00:00 2001 From: abansalm Date: Thu, 26 Nov 2015 15:32:58 +0530 Subject: [PATCH] Added sample codes for createCustomerShippingAddress, deleteCustomerShippingAddress , updateCustomerShippingAddress and getCustomerShippingAddress Signed off : Abhishek Bansal Reviewed by : Zeeshanul Haque --- .../create-customer-shipping-address.py | 39 +++++++++++++++++++ .../delete-customer-shipping-address.py | 27 +++++++++++++ .../get-customer-shipping-address.py | 32 +++++++++++++++ .../update-customer-shipping-address.py | 39 +++++++++++++++++++ 4 files changed, 137 insertions(+) create mode 100644 CustomerProfiles/create-customer-shipping-address.py create mode 100644 CustomerProfiles/delete-customer-shipping-address.py create mode 100644 CustomerProfiles/get-customer-shipping-address.py create mode 100644 CustomerProfiles/update-customer-shipping-address.py diff --git a/CustomerProfiles/create-customer-shipping-address.py b/CustomerProfiles/create-customer-shipping-address.py new file mode 100644 index 0000000..280937a --- /dev/null +++ b/CustomerProfiles/create-customer-shipping-address.py @@ -0,0 +1,39 @@ +# Gives error if an address is already present for the given customer Id +from authorizenet import apicontractsv1 +from authorizenet.apicontrollers import * + +# Give merchant details +merchantAuth = apicontractsv1.merchantAuthenticationType() +merchantAuth.name = '5KP3u95bQpv' +merchantAuth.transactionKey = '4Ktq966gC55GAX7S' + +# Give address details +officeAddress = apicontractsv1.customerAddressType(); +officeAddress.firstName = "John" +officeAddress.lastName = "Doe" +officeAddress.address = "123 Main St." +officeAddress.city = "Bellevue" +officeAddress.state = "WA" +officeAddress.zip = "98004" +officeAddress.country = "USA" +officeAddress.phoneNumber = "000-000-0000" + +# Create shipping address request +shippingAddressRequest = apicontractsv1.createCustomerShippingAddressRequest(); +shippingAddressRequest.address = officeAddress +shippingAddressRequest.customerProfileId = "36152165" +shippingAddressRequest.merchantAuthentication = merchantAuth + +# Make an API call +createCustomerShippingAddressController= createCustomerShippingAddressController(shippingAddressRequest) +createCustomerShippingAddressController.execute() +response = createCustomerShippingAddressController.getresponse(); + +if response.messages.resultCode == "Ok": + print "SUCCESS" + print "Transaction ID : %s " % response.messages.message[0].text + print "Customer address id : %s" % response.customerAddressId +else: + print "ERROR" + print "Message code : %s " % response.messages.message[0].code + print "Message text : %s " % response.messages.message[0].text diff --git a/CustomerProfiles/delete-customer-shipping-address.py b/CustomerProfiles/delete-customer-shipping-address.py new file mode 100644 index 0000000..e7911d7 --- /dev/null +++ b/CustomerProfiles/delete-customer-shipping-address.py @@ -0,0 +1,27 @@ +from authorizenet import apicontractsv1 +from authorizenet.apicontrollers import * + +# Give merchant details +merchantAuth = apicontractsv1.merchantAuthenticationType() +merchantAuth.name = '5KP3u95bQpv' +merchantAuth.transactionKey = '4Ktq966gC55GAX7S' + +# create delete request +deleteShippingAddress = apicontractsv1.deleteCustomerShippingAddressRequest() +deleteShippingAddress.merchantAuthentication = merchantAuth +deleteShippingAddress.customerProfileId = "36152165" +deleteShippingAddress.customerAddressId = "36413544" + +# Make the API call +deleteShippingAddressController = deleteCustomerShippingAddressController(deleteShippingAddress) +deleteShippingAddressController.execute() +response = deleteShippingAddressController.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 +else: + print "ERROR" + print "Message code : %s " % response.messages.message[0].code + print "Message text : %s " % response.messages.message[0].text diff --git a/CustomerProfiles/get-customer-shipping-address.py b/CustomerProfiles/get-customer-shipping-address.py new file mode 100644 index 0000000..4217f99 --- /dev/null +++ b/CustomerProfiles/get-customer-shipping-address.py @@ -0,0 +1,32 @@ +from authorizenet import apicontractsv1 +from authorizenet.apicontrollers import * + +# Give merchant details +merchantAuth = apicontractsv1.merchantAuthenticationType() +merchantAuth.name = '5KP3u95bQpv' +merchantAuth.transactionKey = '4Ktq966gC55GAX7S' + +# create get shipping address request +getShippingAddress = apicontractsv1.getCustomerShippingAddressRequest() +getShippingAddress.merchantAuthentication = merchantAuth +getShippingAddress.customerProfileId = "36152165" +getShippingAddress.customerAddressId = "36413544" + +# Make the API call +getShippingAddressController = getCustomerShippingAddressController(getShippingAddress) +getShippingAddressController.execute() +response = getShippingAddressController.getresponse() + +if response.messages.resultCode == "Ok": + print "SUCCESS" + print "The address is" + print response.address.firstName +" " + response.address.lastName + print response.address.address + print response.address.city + print response.address.state + print response.address.zip + print response.address.country +else: + print "ERROR" + print "Message code : %s " % response.messages.message[0].code + print "Message text : %s " % response.messages.message[0].text diff --git a/CustomerProfiles/update-customer-shipping-address.py b/CustomerProfiles/update-customer-shipping-address.py new file mode 100644 index 0000000..8595e31 --- /dev/null +++ b/CustomerProfiles/update-customer-shipping-address.py @@ -0,0 +1,39 @@ +from authorizenet import apicontractsv1 +from authorizenet.apicontrollers import * + +# Give merchant details +merchantAuth = apicontractsv1.merchantAuthenticationType() +merchantAuth.name = '5KP3u95bQpv' +merchantAuth.transactionKey = '4Ktq966gC55GAX7S' + +# Give updated address details +officeAddress = apicontractsv1.customerAddressExType() +officeAddress.firstName = "Sherlock" +officeAddress.lastName = "Holmes" +officeAddress.address = "221B Baker Street" +officeAddress.city = "London" +officeAddress.state = "WA" +officeAddress.zip = "98004" +officeAddress.country = "UK" +officeAddress.phoneNumber = "000-000-0000" +officeAddress.customerAddressId = "36413544" + +# Create update shipping address request +updateShippingAddressRequest = apicontractsv1.updateCustomerShippingAddressRequest() +updateShippingAddressRequest.address = officeAddress +updateShippingAddressRequest.customerProfileId = "36152165" +updateShippingAddressRequest.merchantAuthentication = merchantAuth + +# Make the API call +updateShippingAddressController = updateCustomerShippingAddressController(updateShippingAddressRequest) +updateShippingAddressController.execute() +response = updateShippingAddressController.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 +else: + print "ERROR" + print "Message code : %s " % response.messages.message[0].code + print "Message text : %s " % response.messages.message[0].text