Skip to content

Commit 7e00de2

Browse files
committed
Merge pull request AuthorizeNet#6 from srmisra/master
Sample codes for Customer Profiles. Thanks @srmisra
2 parents 2fe1f4c + e9e2cc6 commit 7e00de2

11 files changed

+280
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
from authorizenet import apicontractsv1
2+
from authorizenet.apicontrollers import *
3+
4+
merchantAuth = apicontractsv1.merchantAuthenticationType()
5+
merchantAuth.name = '5KP3u95bQpv'
6+
merchantAuth.transactionKey = '4Ktq966gC55GAX7S'
7+
8+
creditCard = apicontractsv1.creditCardType()
9+
creditCard.cardNumber = "4111111111111111"
10+
creditCard.expirationDate = "2020-12"
11+
12+
payment = apicontractsv1.paymentType()
13+
payment.creditCard = creditCard
14+
15+
profile = apicontractsv1.customerPaymentProfileType()
16+
profile.payment = payment
17+
18+
createCustomerPaymentProfile = apicontractsv1.createCustomerPaymentProfileRequest()
19+
createCustomerPaymentProfile.merchantAuthentication = merchantAuth
20+
createCustomerPaymentProfile.paymentProfile = profile
21+
createCustomerPaymentProfile.customerProfileId = '36731856'
22+
23+
createCustomerPaymentProfileController = createCustomerPaymentProfileController(createCustomerPaymentProfile)
24+
createCustomerPaymentProfileController.execute()
25+
26+
response = createCustomerPaymentProfileController.getresponse()
27+
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
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from authorizenet import apicontractsv1
2+
from authorizenet.apicontrollers import *
3+
4+
merchantAuth = apicontractsv1.merchantAuthenticationType()
5+
merchantAuth.name = '5KP3u95bQpv'
6+
merchantAuth.transactionKey = '4Ktq966gC55GAX7S'
7+
8+
createCustomerProfileFromTransaction = apicontractsv1.createCustomerProfileFromTransactionRequest()
9+
createCustomerProfileFromTransaction.merchantAuthentication = merchantAuth
10+
createCustomerProfileFromTransaction.transId = '2238147175'
11+
12+
createCustomerProfileFromTransactionController = createCustomerProfileFromTransactionController(createCustomerProfileFromTransaction)
13+
createCustomerProfileFromTransactionController.execute()
14+
15+
response = createCustomerProfileFromTransactionController.getresponse()
16+
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
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from authorizenet import apicontractsv1
2+
from authorizenet.apicontrollers import *
3+
import random
4+
5+
merchantAuth = apicontractsv1.merchantAuthenticationType()
6+
merchantAuth.name = '5KP3u95bQpv'
7+
merchantAuth.transactionKey = '4Ktq966gC55GAX7S'
8+
9+
10+
createCustomerProfile = apicontractsv1.createCustomerProfileRequest()
11+
createCustomerProfile.merchantAuthentication = merchantAuth
12+
createCustomerProfile.profile = apicontractsv1.customerProfileType('jdoe' + str(random.randint(0, 10000)), 'John2 Doe', 'jdoe@mail.com')
13+
14+
createCustomerProfileController = createCustomerProfileController(createCustomerProfile)
15+
createCustomerProfileController.execute()
16+
17+
response = createCustomerProfileController.getresponse()
18+
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
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from authorizenet import apicontractsv1
2+
from authorizenet.apicontrollers import *
3+
4+
merchantAuth = apicontractsv1.merchantAuthenticationType()
5+
merchantAuth.name = '5KP3u95bQpv'
6+
merchantAuth.transactionKey = '4Ktq966gC55GAX7S'
7+
8+
deleteCustomerPaymentProfile = apicontractsv1.deleteCustomerPaymentProfileRequest()
9+
deleteCustomerPaymentProfile.merchantAuthentication = merchantAuth
10+
deleteCustomerPaymentProfile.customerProfileId = "10000"
11+
deleteCustomerPaymentProfile.customerPaymentProfileId = "20000"
12+
13+
deleteCustomerPaymentProfileController = deleteCustomerPaymentProfileController(deleteCustomerPaymentProfile)
14+
deleteCustomerPaymentProfileController.execute()
15+
16+
response = deleteCustomerPaymentProfileController.getresponse()
17+
18+
if (response.messages.resultCode=="Ok"):
19+
print "Successfully deleted customer payment profile with customer profile id %s" % deleteCustomerPaymentProfile.customerProfileId
20+
else:
21+
print response.messages.message[0].text
22+
print "Failed to delete customer paymnet profile with customer profile id %s" % deleteCustomerPaymentProfile.customerProfileId
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from authorizenet import apicontractsv1
2+
from authorizenet.apicontrollers import *
3+
4+
merchantAuth = apicontractsv1.merchantAuthenticationType()
5+
merchantAuth.name = '5KP3u95bQpv'
6+
merchantAuth.transactionKey = '4Ktq966gC55GAX7S'
7+
8+
deleteCustomerProfile = apicontractsv1.deleteCustomerProfileRequest()
9+
deleteCustomerProfile.merchantAuthentication = merchantAuth
10+
deleteCustomerProfile.customerProfileId = "36152115"
11+
12+
deleteCustomerProfileController = deleteCustomerProfileController(deleteCustomerProfile)
13+
deleteCustomerProfileController.execute()
14+
15+
response = deleteCustomerProfileController.getresponse()
16+
17+
if (response.messages.resultCode=="Ok"):
18+
print "Successfully deleted customer with customer profile id %s" % deleteCustomerProfile.customerProfileId
19+
else:
20+
print response.messages.message[0].text
21+
print "Failed to delete customer profile with customer profile id %s" % deleteCustomerProfile.customerProfileId
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from authorizenet import apicontractsv1
2+
from authorizenet.apicontrollers import *
3+
4+
merchantAuth = apicontractsv1.merchantAuthenticationType()
5+
merchantAuth.name = '5KP3u95bQpv'
6+
merchantAuth.transactionKey = '4Ktq966gC55GAX7S'
7+
8+
getCustomerPaymentProfile = apicontractsv1.getCustomerPaymentProfileRequest()
9+
getCustomerPaymentProfile.merchantAuthentication = merchantAuth
10+
getCustomerPaymentProfile.customerProfileId = "36731856"
11+
getCustomerPaymentProfile.customerPaymentProfileId = "33211899"
12+
13+
getCustomerPaymentProfileController = getCustomerPaymentProfileController(getCustomerPaymentProfile)
14+
getCustomerPaymentProfileController.execute()
15+
16+
response = getCustomerPaymentProfileController.getresponse()
17+
18+
if (response.messages.resultCode=="Ok"):
19+
print "Successfully retrieved a payment profile with profile id %s and customer id %s" % (getCustomerPaymentProfile.customerProfileId, getCustomerPaymentProfile.customerProfileId)
20+
else:
21+
print "response code: %s" % response.messages.resultCode
22+
print "Failed to get payment profile information with id %s" % getCustomerPaymentProfile.customerPaymentProfileId
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from authorizenet import apicontractsv1
2+
from authorizenet.apicontrollers import *
3+
4+
merchantAuth = apicontractsv1.merchantAuthenticationType()
5+
merchantAuth.name = '5KP3u95bQpv'
6+
merchantAuth.transactionKey = '4Ktq966gC55GAX7S'
7+
8+
getCustomerProfileIds = apicontractsv1.getCustomerProfileIdsRequest()
9+
getCustomerProfileIds.merchantAuthentication = merchantAuth
10+
11+
getCustomerProfileIdsController = getCustomerProfileIdsController(getCustomerProfileIds)
12+
getCustomerProfileIdsController.execute()
13+
14+
response = getCustomerProfileIdsController.getresponse()
15+
16+
if (response.messages.resultCode=="Ok"):
17+
print "Successfully retrieved customer ids:"
18+
for identity in response.ids.numericString:
19+
print identity
20+
else:
21+
print "response code: %s" % response.messages.resultCode
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from authorizenet import apicontractsv1
2+
from authorizenet.apicontrollers import *
3+
4+
merchantAuth = apicontractsv1.merchantAuthenticationType()
5+
merchantAuth.name = '5KP3u95bQpv'
6+
merchantAuth.transactionKey = '4Ktq966gC55GAX7S'
7+
8+
getCustomerProfile = apicontractsv1.getCustomerProfileRequest()
9+
getCustomerProfile.merchantAuthentication = merchantAuth
10+
getCustomerProfile.customerProfileId = '36152115'
11+
12+
getCustomerProfileController = getCustomerProfileController(getCustomerProfile)
13+
getCustomerProfileController.execute()
14+
15+
response = getCustomerProfileController.getresponse()
16+
17+
if (response.messages.resultCode=="Ok"):
18+
print "Successfully retrieved a customer with profile id %s and customer id %s" % (getCustomerProfile.customerProfileId, response.profile.merchantCustomerId)
19+
for paymentProfile in response.profile.paymentProfiles:
20+
print "Payment Profile ID %s" % paymentProfile.customerPaymentProfileId
21+
for ship in response.profile.shipToList:
22+
print "Shipping Details:"
23+
print "First Name %s" % ship.firstName
24+
print "Last Name %s" % ship.lastName
25+
print "Address %s" % ship.address
26+
print "Customer Address ID %s" % ship.customerAddressId
27+
else:
28+
print "response code: %s" % response.messages.resultCode
29+
print "Failed to get customer profile information with id %s" % getCustomerProfile.customerProfileId
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
from authorizenet import apicontractsv1
2+
from authorizenet.apicontrollers import *
3+
4+
merchantAuth = apicontractsv1.merchantAuthenticationType()
5+
merchantAuth.name = '5KP3u95bQpv'
6+
merchantAuth.transactionKey = '4Ktq966gC55GAX7S'
7+
8+
creditCard = apicontractsv1.creditCardType()
9+
creditCard.cardNumber = "4111111111111111"
10+
creditCard.expirationDate = "2020-12"
11+
12+
payment = apicontractsv1.paymentType()
13+
payment.creditCard = creditCard
14+
15+
paymentProfile = apicontractsv1.customerPaymentProfileExType()
16+
paymentProfile.billTo = apicontractsv1.customerAddressType()
17+
paymentProfile.billTo.firstName = "John"
18+
paymentProfile.billTo.lastName = "Doe"
19+
paymentProfile.billTo.address = "123 Main St."
20+
paymentProfile.billTo.city = "Bellevue"
21+
paymentProfile.billTo.state = "WA"
22+
paymentProfile.billTo.zip = "98004"
23+
paymentProfile.billTo.country = "USA"
24+
paymentProfile.billTo.phoneNumber = "000-000-000"
25+
paymentProfile.payment = payment
26+
paymentProfile.customerPaymentProfileId = "34823065"
27+
28+
updateCustomerPaymentProfile = apicontractsv1.updateCustomerPaymentProfileRequest()
29+
updateCustomerPaymentProfile.merchantAuthentication = merchantAuth
30+
updateCustomerPaymentProfile.paymentProfile = paymentProfile
31+
updateCustomerPaymentProfile.customerProfileId = "36731856"
32+
updateCustomerPaymentProfile.validationMode = apicontractsv1.validationModeEnum.liveMode
33+
34+
updateCustomerPaymentProfileController = updateCustomerPaymentProfileController(updateCustomerPaymentProfile)
35+
updateCustomerPaymentProfileController.execute()
36+
37+
response = updateCustomerPaymentProfileController.getresponse()
38+
39+
if (response.messages.resultCode=="Ok"):
40+
print "Successfully updated customer payment profile with id %s" % updateCustomerPaymentProfile.paymentProfile.customerPaymentProfileId
41+
else:
42+
print response.messages.message[0].text
43+
print "Failed to update customer with customer payment profile id %s" % updateCustomerPaymentProfile.paymentProfile.customerPaymentProfileId
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
from authorizenet import apicontractsv1
2+
from authorizenet.apicontrollers import *
3+
4+
merchantAuth = apicontractsv1.merchantAuthenticationType()
5+
merchantAuth.name = '5KP3u95bQpv'
6+
merchantAuth.transactionKey = '4Ktq966gC55GAX7S'
7+
8+
updateCustomerProfile = apicontractsv1.updateCustomerProfileRequest()
9+
updateCustomerProfile.merchantAuthentication = merchantAuth
10+
updateCustomerProfile.profile = apicontractsv1.customerProfileExType()
11+
12+
updateCustomerProfile.profile.customerProfileId = "36152115"
13+
updateCustomerProfile.profile.merchantCustomerId = "mycustomer"
14+
updateCustomerProfile.profile.description = "john doe"
15+
updateCustomerProfile.profile.email = "email@email.com"
16+
17+
updateCustomerProfileController = updateCustomerProfileController(updateCustomerProfile)
18+
updateCustomerProfileController.execute()
19+
20+
response = updateCustomerProfileController.getresponse()
21+
22+
if (response.messages.resultCode=="Ok"):
23+
print "Successfully updated customer with customer profile id %s" % updateCustomerProfile.profile.customerProfileId
24+
else:
25+
print response.messages.message[0].text
26+
print "Failed to update customer profile with customer profile id %s" % updateCustomerProfile.profile.customerProfileId

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy