| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent f87c17f commit 2636aa0
54 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,12 @@ | |||
| 1 | + language: python | ||
| 2 | + sudo: false | ||
| 3 | + | ||
| 4 | + python: | ||
| 5 | + - "2.7" | ||
| 6 | + - "pypy" | ||
| 7 | + | ||
| 8 | + install: | ||
| 9 | + - pip install authorizenet | ||
| 10 | + | ||
| 11 | + script: | ||
| 12 | + python test-runner.py | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,40 +1,51 @@ | |||
| 1 | + import os, sys | ||
| 2 | + import imp | ||
| 3 | + | ||
| 1 | 4 | from authorizenet import apicontractsv1 | |
| 2 | 5 | from authorizenet.apicontrollers import * | |
| 6 | + constants = imp.load_source('modulename', 'constants.py') | ||
| 3 | 7 | from decimal import * | |
| 4 | 8 | ||
| 5 | - merchantAuth = apicontractsv1.merchantAuthenticationType() | ||
| 6 | - merchantAuth.name = '5KP3u95bQpv' | ||
| 7 | - merchantAuth.transactionKey = '4Ktq966gC55GAX7S' | ||
| 8 | - | ||
| 9 | - opaquedata = apicontractsv1.opaqueDataType() | ||
| 10 | - opaquedata.dataDescriptor = "COMMON.APPLE.INAPP.PAYMENT" | ||
| 11 | - opaquedata.dataValue = "eyJkYXRhIjoiQkRQTldTdE1tR2V3UVVXR2c0bzdFXC9qKzFjcTFUNzhxeVU4NGI2N2l0amNZSTh3UFlBT2hzaGpoWlBycWRVcjRYd1BNYmo0emNHTWR5KysxSDJWa1BPWStCT01GMjV1YjE5Y1g0bkN2a1hVVU9UakRsbEIxVGdTcjhKSFp4Z3A5ckNnc1NVZ2JCZ0tmNjBYS3V0WGY2YWpcL284WkliS25yS1E4U2gwb3VMQUtsb1VNbit2UHU0K0E3V0tycXJhdXo5SnZPUXA2dmhJcStIS2pVY1VOQ0lUUHlGaG1PRXRxK0grdzB2UmExQ0U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NVd0l3WURWUVFESGh3QVl3Qm9BRzBBWVFCcEFFQUFkZ0JwQUhNQVlRQXVBR01BYndCdGdoQmNsK1BmMytVNHBrMTNuVkQ5bndRUU1Ba0dCU3NPQXdJZEJRQURnWUVBYlVLWUNrdUlLUzlRUTJtRmNNWVJFSW0ybCtYZzhcL0pYditHQlZRSmtPS29zY1k0aU5ERkFcL2JRbG9nZjlMTFU4NFRId05SbnN2VjNQcnY3UlRZODFncTBkdEM4elljQWFBa0NISUkzeXFNbko0QU91NkVPVzlrSmsyMzJnU0U3V2xDdEhiZkxTS2Z1U2dRWDhLWFFZdVpMazJScjYzTjhBcFhzWHdCTDNjSjB4Z2VBd2dkMENBUUV3T3pBbk1TVXdJd1lEVlFRREhod0FZd0JvQUcwQVlRQnBBRUFBZGdCcEFITUFZUUF1QUdNQWJ3QnRBaEJjbCtQZjMrVTRwazEzblZEOW53UVFNQWtHQlNzT0F3SWFCUUF3RFFZSktvWklodmNOQVFFQkJRQUVnWUJhSzNFbE9zdGJIOFdvb3NlREFCZitKZ1wvMTI5SmNJYXdtN2M2VnhuN1phc05iQXEzdEF0OFB0eSt1UUNnc3NYcVprTEE3a3oyR3pNb2xOdHY5d1ltdTlVandhcjFQSFlTK0JcL29Hbm96NTkxd2phZ1hXUnowbk1vNXkzTzFLelgwZDhDUkhBVmE4OFNyVjFhNUpJaVJldjNvU3RJcXd2NXh1WmxkYWc2VHI4dz09In0=" | ||
| 12 | - | ||
| 13 | - paymentOne = apicontractsv1.paymentType() | ||
| 14 | - paymentOne.opaqueData = opaquedata | ||
| 15 | - | ||
| 16 | - transactionrequest = apicontractsv1.transactionRequestType() | ||
| 17 | - transactionrequest.transactionType = apicontractsv1.transactionTypeEnum.authCaptureTransaction | ||
| 18 | - transactionrequest.amount = Decimal('151') | ||
| 19 | - transactionrequest.payment = paymentOne | ||
| 20 | - | ||
| 21 | - request = apicontractsv1.createTransactionRequest() | ||
| 22 | - request.merchantAuthentication = merchantAuth | ||
| 23 | - request.refId = "Sample" | ||
| 24 | - request.transactionRequest = transactionrequest | ||
| 25 | - | ||
| 26 | - controller = createTransactionController(request) | ||
| 27 | - controller.execute() | ||
| 28 | - | ||
| 29 | - response = controller.getresponse() | ||
| 30 | - | ||
| 31 | - if (response.messages.resultCode=="Ok"): | ||
| 32 | - print "SUCCESS" | ||
| 33 | - print "Message Code : %s" % response.messages.message[0].code | ||
| 34 | - print "Message text : %s" % response.messages.message[0].text | ||
| 35 | - print "AUTH Code : %s" % response.authCode | ||
| 36 | - print "Transaction ID : %s" % response.transId | ||
| 37 | - else: | ||
| 38 | - print "ERROR" | ||
| 39 | - print "Message Code : %s" % response.messages.message[0].code | ||
| 40 | - print "Message text : %s" % response.messages.message[0].text | ||
| 9 | + def create_an_apple_pay_transaction(): | ||
| 10 | + | ||
| 11 | + merchantAuth = apicontractsv1.merchantAuthenticationType() | ||
| 12 | + merchantAuth.name = constants.apiLoginId | ||
| 13 | + merchantAuth.transactionKey = constants.transactionKey | ||
| 14 | + | ||
| 15 | + opaquedata = apicontractsv1.opaqueDataType() | ||
| 16 | + opaquedata.dataDescriptor = "COMMON.APPLE.INAPP.PAYMENT" | ||
| 17 | + opaquedata.dataValue = "eyJkYXRhIjoiQkRQTldTdE1tR2V3UVVXR2c0bzdFXC9qKzFjcTFUNzhxeVU4NGI2N2l0amNZSTh3UFlBT2hzaGpoWlBycWRVcjRYd1BNYmo0emNHTWR5KysxSDJWa1BPWStCT01GMjV1YjE5Y1g0bkN2a1hVVU9UakRsbEIxVGdTcjhKSFp4Z3A5ckNnc1NVZ2JCZ0tmNjBYS3V0WGY2YWpcL284WkliS25yS1E4U2gwb3VMQUtsb1VNbit2UHU0K0E3V0tycXJhdXo5SnZPUXA2dmhJcStIS2pVY1VOQ0lUUHlGaG1PRXRxK0grdzB2UmExQ0U2V2hGQk5uQ0hxenpXS2NrQlwvMG5xTFpSVFliRjBwK3Z5QmlWYVdIZWdoRVJmSHhSdGJ6cGVjelJQUHVGc2ZwSFZzNDh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ndRUU1Ba0dCU3NPQXdJZEJRQURnWUVBYlVLWUNrdUlLUzlRUTJtRmNNWVJFSW0ybCtYZzhcL0pYditHQlZRSmtPS29zY1k0aU5ERkFcL2JRbG9nZjlMTFU4NFRId05SbnN2VjNQcnY3UlRZODFncTBkdEM4elljQWFBa0NISUkzeXFNbko0QU91NkVPVzlrSmsyMzJnU0U3V2xDdEhiZkxTS2Z1U2dRWDhLWFFZdVpMazJScjYzTjhBcFhzWHdCTDNjSjB4Z2VBd2dkMENBUUV3T3pBbk1TVXdJd1lEVlFRREhod0FZd0JvQUcwQVlRQnBBRUFBZGdCcEFITUFZUUF1QUdNQWJ3QnRBaEJjbCtQZjMrVTRwazEzblZEOW53UVFNQWtHQlNzT0F3SWFCUUF3RFFZSktvWklodmNOQVFFQkJRQUVnWUJhSzNFbE9zdGJIOFdvb3NlREFCZitKZ1wvMTI5SmNJYXdtN2M2VnhuN1phc05iQXEzdEF0OFB0eSt1UUNnc3NYcVprTEE3a3oyR3pNb2xOdHY5d1ltdTlVandhcjFQSFlTK0JcL29Hbm96NTkxd2phZ1hXUnowbk1vNXkzTzFLelgwZDhDUkhBVmE4OFNyVjFhNUpJaVJldjNvU3RJcXd2NXh1WmxkYWc2VHI4dz09In0=" | ||
| 18 | + | ||
| 19 | + paymentOne = apicontractsv1.paymentType() | ||
| 20 | + paymentOne.opaqueData = opaquedata | ||
| 21 | + | ||
| 22 | + transactionrequest = apicontractsv1.transactionRequestType() | ||
| 23 | + transactionrequest.transactionType = apicontractsv1.transactionTypeEnum.authCaptureTransaction | ||
| 24 | + transactionrequest.amount = Decimal('151') | ||
| 25 | + transactionrequest.payment = paymentOne | ||
| 26 | + | ||
| 27 | + request = apicontractsv1.createTransactionRequest() | ||
| 28 | + request.merchantAuthentication = merchantAuth | ||
| 29 | + request.refId = "Sample" | ||
| 30 | + request.transactionRequest = transactionrequest | ||
| 31 | + | ||
| 32 | + controller = createTransactionController(request) | ||
| 33 | + controller.execute() | ||
| 34 | + | ||
| 35 | + response = controller.getresponse() | ||
| 36 | + | ||
| 37 | + if (response.messages.resultCode=="Ok"): | ||
| 38 | + print "SUCCESS" | ||
| 39 | + print "Message Code : %s" % response.messages.message[0].code | ||
| 40 | + print "Message text : %s" % response.messages.message[0].text | ||
| 41 | + print "AUTH Code : %s" % response.authCode | ||
| 42 | + print "Transaction ID : %s" % response.transId | ||
| 43 | + else: | ||
| 44 | + print "ERROR" | ||
| 45 | + print "Message Code : %s" % response.messages.message[0].code | ||
| 46 | + print "Message text : %s" % response.messages.message[0].text | ||
| 47 | + | ||
| 48 | + return response | ||
| 49 | + | ||
| 50 | + if(os.path.basename(__file__) == sys.argv[0].split('/')[-1]): | ||
| 51 | + create_an_apple_pay_transaction() | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,31 +1,41 @@ | |||
| 1 | + import os, sys | ||
| 2 | + import imp | ||
| 3 | + | ||
| 1 | 4 | from authorizenet import apicontractsv1 | |
| 2 | 5 | from authorizenet.apicontrollers import * | |
| 6 | + constants = imp.load_source('modulename', 'constants.py') | ||
| 7 | + | ||
| 8 | + def create_customer_payment_profile(customerProfileId): | ||
| 9 | + merchantAuth = apicontractsv1.merchantAuthenticationType() | ||
| 10 | + merchantAuth.name = constants.apiLoginId | ||
| 11 | + merchantAuth.transactionKey = constants.transactionKey | ||
| 12 | + | ||
| 13 | + creditCard = apicontractsv1.creditCardType() | ||
| 14 | + creditCard.cardNumber = "4111111111111111" | ||
| 15 | + creditCard.expirationDate = "2020-12" | ||
| 3 | 16 | ||
| 4 | - merchantAuth = apicontractsv1.merchantAuthenticationType() | ||
| 5 | - merchantAuth.name = '5KP3u95bQpv' | ||
| 6 | - merchantAuth.transactionKey = '4Ktq966gC55GAX7S' | ||
| 17 | + payment = apicontractsv1.paymentType() | ||
| 18 | + payment.creditCard = creditCard | ||
| 7 | 19 | ||
| 8 | - creditCard = apicontractsv1.creditCardType() | ||
| 9 | - creditCard.cardNumber = "4111111111111111" | ||
| 10 | - creditCard.expirationDate = "2020-12" | ||
| 20 | + profile = apicontractsv1.customerPaymentProfileType() | ||
| 21 | + profile.payment = payment | ||
| 11 | 22 | ||
| 12 | - payment = apicontractsv1.paymentType() | ||
| 13 | - payment.creditCard = creditCard | ||
| 23 | + createCustomerPaymentProfile = apicontractsv1.createCustomerPaymentProfileRequest() | ||
| 24 | + createCustomerPaymentProfile.merchantAuthentication = merchantAuth | ||
| 25 | + createCustomerPaymentProfile.paymentProfile = profile | ||
| 26 | + createCustomerPaymentProfile.customerProfileId = customerProfileId | ||
| 14 | 27 | ||
| 15 | - profile = apicontractsv1.customerPaymentProfileType() | ||
| 16 | - profile.payment = payment | ||
| 28 | + controller = createCustomerPaymentProfileController(createCustomerPaymentProfile) | ||
| 29 | + controller.execute() | ||
| 17 | 30 | ||
| 18 | - createCustomerPaymentProfile = apicontractsv1.createCustomerPaymentProfileRequest() | ||
| 19 | - createCustomerPaymentProfile.merchantAuthentication = merchantAuth | ||
| 20 | - createCustomerPaymentProfile.paymentProfile = profile | ||
| 21 | - createCustomerPaymentProfile.customerProfileId = '36731856' | ||
| 31 | + response = controller.getresponse() | ||
| 22 | 32 | ||
| 23 | - createCustomerPaymentProfileController = createCustomerPaymentProfileController(createCustomerPaymentProfile) | ||
| 24 | - createCustomerPaymentProfileController.execute() | ||
| 33 | + if (response.messages.resultCode=="Ok"): | ||
| 34 | + print "Successfully created a customer payment profile with id: %s" % response.customerPaymentProfileId | ||
| 35 | + else: | ||
| 36 | + print "Failed to create customer payment profile %s" % response.messages.message[0].text | ||
| 25 | 37 | ||
| 26 | - response = createCustomerPaymentProfileController.getresponse() | ||
| 38 | + return response | ||
| 27 | 39 | ||
| 28 | - if (response.messages.resultCode=="Ok"): | ||
| 29 | - print "Successfully created a customer payment profile with id: %s" % response.customerPaymentProfileId | ||
| 30 | - else: | ||
| 31 | - print "Failed to create customer payment profile %s" % response.messages.message[0].text | ||
| 40 | + if(os.path.basename(__file__) == sys.argv[0].split('/')[-1]): | ||
| 41 | + create_customer_payment_profile(constants.customerProfileId) | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,20 +1,30 @@ | |||
| 1 | + import os, sys | ||
| 2 | + import imp | ||
| 3 | + | ||
| 1 | 4 | from authorizenet import apicontractsv1 | |
| 2 | 5 | from authorizenet.apicontrollers import * | |
| 6 | + constants = imp.load_source('modulename', 'constants.py') | ||
| 7 | + | ||
| 8 | + def create_customer_profile_from_transaction(transactionId): | ||
| 9 | + merchantAuth = apicontractsv1.merchantAuthenticationType() | ||
| 10 | + merchantAuth.name = constants.apiLoginId | ||
| 11 | + merchantAuth.transactionKey = constants.transactionKey | ||
| 12 | + | ||
| 13 | + createCustomerProfileFromTransaction = apicontractsv1.createCustomerProfileFromTransactionRequest() | ||
| 14 | + createCustomerProfileFromTransaction.merchantAuthentication = merchantAuth | ||
| 15 | + createCustomerProfileFromTransaction.transId = transactionId | ||
| 3 | 16 | ||
| 4 | - merchantAuth = apicontractsv1.merchantAuthenticationType() | ||
| 5 | - merchantAuth.name = '5KP3u95bQpv' | ||
| 6 | - merchantAuth.transactionKey = '4Ktq966gC55GAX7S' | ||
| 17 | + controller = createCustomerProfileFromTransactionController(createCustomerProfileFromTransaction) | ||
| 18 | + controller.execute() | ||
| 7 | 19 | ||
| 8 | - createCustomerProfileFromTransaction = apicontractsv1.createCustomerProfileFromTransactionRequest() | ||
| 9 | - createCustomerProfileFromTransaction.merchantAuthentication = merchantAuth | ||
| 10 | - createCustomerProfileFromTransaction.transId = '2238147175' | ||
| 20 | + response = controller.getresponse() | ||
| 11 | 21 | ||
| 12 | - createCustomerProfileFromTransactionController = createCustomerProfileFromTransactionController(createCustomerProfileFromTransaction) | ||
| 13 | - createCustomerProfileFromTransactionController.execute() | ||
| 22 | + if (response.messages.resultCode=="Ok"): | ||
| 23 | + print "Successfully created a customer profile with id: %s from transaction id: %s" % {response.customerProfileId, createCustomerProfileFromTransaction.transId} | ||
| 24 | + else: | ||
| 25 | + print "Failed to create customer payment profile from transaction %s" % response.messages.message[0].text | ||
| 14 | 26 | ||
| 15 | - response = createCustomerProfileFromTransactionController.getresponse() | ||
| 27 | + return response | ||
| 16 | 28 | ||
| 17 | - if (response.messages.resultCode=="Ok"): | ||
| 18 | - print "Successfully created a customer profile with id: %s from transaction id: %s" % {response.customerProfileId, createCustomerProfileFromTransaction.transId} | ||
| 19 | - else: | ||
| 20 | - print "Failed to create customer payment profile from transaction %s" % response.messages.message[0].text | ||
| 29 | + if(os.path.basename(__file__) == sys.argv[0].split('/')[-1]): | ||
| 30 | + create_customer_profile_from_transaction(constants.transactionId) | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,22 +1,33 @@ | |||
| 1 | + import os, sys | ||
| 2 | + import imp | ||
| 3 | + | ||
| 1 | 4 | from authorizenet import apicontractsv1 | |
| 2 | 5 | from authorizenet.apicontrollers import * | |
| 6 | + constants = imp.load_source('modulename', 'constants.py') | ||
| 3 | 7 | import random | |
| 4 | 8 | ||
| 5 | - merchantAuth = apicontractsv1.merchantAuthenticationType() | ||
| 6 | - merchantAuth.name = '5KP3u95bQpv' | ||
| 7 | - merchantAuth.transactionKey = '4Ktq966gC55GAX7S' | ||
| 9 | + def create_customer_profile(): | ||
| 10 | + | ||
| 11 | + merchantAuth = apicontractsv1.merchantAuthenticationType() | ||
| 12 | + merchantAuth.name = constants.apiLoginId | ||
| 13 | + merchantAuth.transactionKey = constants.transactionKey | ||
| 14 | + | ||
| 15 | + | ||
| 16 | + createCustomerProfile = apicontractsv1.createCustomerProfileRequest() | ||
| 17 | + createCustomerProfile.merchantAuthentication = merchantAuth | ||
| 18 | + createCustomerProfile.profile = apicontractsv1.customerProfileType('jdoe' + str(random.randint(0, 10000)), 'John2 Doe', 'jdoe@mail.com') | ||
| 8 | 19 | ||
| 20 | + controller = createCustomerProfileController(createCustomerProfile) | ||
| 21 | + controller.execute() | ||
| 9 | 22 | ||
| 10 | - createCustomerProfile = apicontractsv1.createCustomerProfileRequest() | ||
| 11 | - createCustomerProfile.merchantAuthentication = merchantAuth | ||
| 12 | - createCustomerProfile.profile = apicontractsv1.customerProfileType('jdoe' + str(random.randint(0, 10000)), 'John2 Doe', 'jdoe@mail.com') | ||
| 23 | + response = controller.getresponse() | ||
| 13 | 24 | ||
| 14 | - createCustomerProfileController = createCustomerProfileController(createCustomerProfile) | ||
| 15 | - createCustomerProfileController.execute() | ||
| 25 | + if (response.messages.resultCode=="Ok"): | ||
| 26 | + print "Successfully created a customer profile with id: %s" % response.customerProfileId | ||
| 27 | + else: | ||
| 28 | + print "Failed to create customer payment profile %s" % response.messages.message[0].text | ||
| 16 | 29 | ||
| 17 | - response = createCustomerProfileController.getresponse() | ||
| 30 | + return response | ||
| 18 | 31 | ||
| 19 | - if (response.messages.resultCode=="Ok"): | ||
| 20 | - print "Successfully created a customer profile with id: %s" % response.customerProfileId | ||
| 21 | - else: | ||
| 22 | - print "Failed to create customer payment profile %s" % response.messages.message[0].text | ||
| 32 | + if(os.path.basename(__file__) == sys.argv[0].split('/')[-1]): | ||
| 33 | + create_customer_profile() | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,39 +1,49 @@ | |||
| 1 | + import os, sys | ||
| 2 | + import imp | ||
| 3 | + | ||
| 1 | 4 | # Gives error if an address is already present for the given customer Id | |
| 2 | 5 | from authorizenet import apicontractsv1 | |
| 3 | 6 | from authorizenet.apicontrollers import * | |
| 7 | + constants = imp.load_source('modulename', 'constants.py') | ||
| 8 | + | ||
| 9 | + def create_customer_shipping_address(customerProfileId): | ||
| 10 | + # Give merchant details | ||
| 11 | + merchantAuth = apicontractsv1.merchantAuthenticationType() | ||
| 12 | + merchantAuth.name = constants.apiLoginId | ||
| 13 | + merchantAuth.transactionKey = constants.transactionKey | ||
| 14 | + | ||
| 15 | + # Give address details | ||
| 16 | + officeAddress = apicontractsv1.customerAddressType(); | ||
| 17 | + officeAddress.firstName = "John" | ||
| 18 | + officeAddress.lastName = "Doe" | ||
| 19 | + officeAddress.address = "123 Main St." | ||
| 20 | + officeAddress.city = "Bellevue" | ||
| 21 | + officeAddress.state = "WA" | ||
| 22 | + officeAddress.zip = "98004" | ||
| 23 | + officeAddress.country = "USA" | ||
| 24 | + officeAddress.phoneNumber = "000-000-0000" | ||
| 25 | + | ||
| 26 | + # Create shipping address request | ||
| 27 | + shippingAddressRequest = apicontractsv1.createCustomerShippingAddressRequest(); | ||
| 28 | + shippingAddressRequest.address = officeAddress | ||
| 29 | + shippingAddressRequest.customerProfileId = customerProfileId | ||
| 30 | + shippingAddressRequest.merchantAuthentication = merchantAuth | ||
| 31 | + | ||
| 32 | + # Make an API call | ||
| 33 | + controller = createCustomerShippingAddressController(shippingAddressRequest) | ||
| 34 | + controller.execute() | ||
| 35 | + response = controller.getresponse(); | ||
| 36 | + | ||
| 37 | + if response.messages.resultCode == "Ok": | ||
| 38 | + print "SUCCESS" | ||
| 39 | + print "Transaction ID : %s " % response.messages.message[0].text | ||
| 40 | + print "Customer address id : %s" % response.customerAddressId | ||
| 41 | + else: | ||
| 42 | + print "ERROR" | ||
| 43 | + print "Message code : %s " % response.messages.message[0].code | ||
| 44 | + print "Message text : %s " % response.messages.message[0].text | ||
| 45 | + | ||
| 46 | + return response | ||
| 4 | 47 | ||
| 5 | - # Give merchant details | ||
| 6 | - merchantAuth = apicontractsv1.merchantAuthenticationType() | ||
| 7 | - merchantAuth.name = '5KP3u95bQpv' | ||
| 8 | - merchantAuth.transactionKey = '4Ktq966gC55GAX7S' | ||
| 9 | - | ||
| 10 | - # Give address details | ||
| 11 | - officeAddress = apicontractsv1.customerAddressType(); | ||
| 12 | - officeAddress.firstName = "John" | ||
| 13 | - officeAddress.lastName = "Doe" | ||
| 14 | - officeAddress.address = "123 Main St." | ||
| 15 | - officeAddress.city = "Bellevue" | ||
| 16 | - officeAddress.state = "WA" | ||
| 17 | - officeAddress.zip = "98004" | ||
| 18 | - officeAddress.country = "USA" | ||
| 19 | - officeAddress.phoneNumber = "000-000-0000" | ||
| 20 | - | ||
| 21 | - # Create shipping address request | ||
| 22 | - shippingAddressRequest = apicontractsv1.createCustomerShippingAddressRequest(); | ||
| 23 | - shippingAddressRequest.address = officeAddress | ||
| 24 | - shippingAddressRequest.customerProfileId = "36152165" | ||
| 25 | - shippingAddressRequest.merchantAuthentication = merchantAuth | ||
| 26 | - | ||
| 27 | - # Make an API call | ||
| 28 | - createCustomerShippingAddressController= createCustomerShippingAddressController(shippingAddressRequest) | ||
| 29 | - createCustomerShippingAddressController.execute() | ||
| 30 | - response = createCustomerShippingAddressController.getresponse(); | ||
| 31 | - | ||
| 32 | - if response.messages.resultCode == "Ok": | ||
| 33 | - print "SUCCESS" | ||
| 34 | - print "Transaction ID : %s " % response.messages.message[0].text | ||
| 35 | - print "Customer address id : %s" % response.customerAddressId | ||
| 36 | - else: | ||
| 37 | - print "ERROR" | ||
| 38 | - print "Message code : %s " % response.messages.message[0].code | ||
| 39 | - print "Message text : %s " % response.messages.message[0].text | ||
| 48 | + if(os.path.basename(__file__) == sys.argv[0].split('/')[-1]): | ||
| 49 | + create_customer_shipping_address(constants.customerProfileId) | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments