Reply
Member
Posts: 2
Registered: ‎07-17-2018

Python - Can't create customer profile data

Hi,

I'm trying to find examples of how to do this, which I think should be VERY simple to do but I am struggling. All I want to do is set the customer name to whatever they put as the account holder name in my form. In my reports there is a "customer" field that should show a name but it is blank right now. My question is, where do I set that in my code? It isn't clear to me how customer data is supposed to work so I've been trying different things. This code generates a profileResponse error (the payment transaction goes through fine). What else do I need to add to capture the data and have it show in my transaction reports?

 

<profileResponse>

<messages>

<resultCode>Error</resultCode>

<message>

<code>E00039</code>

<text>A duplicate record with ID 1504872533 already exists.</text>

</message>

</messages>

</profileResponse>

 

merchantAuth = apicontractsv1.merchantAuthenticationType()
merchantAuth.name = settings.API_LOGIN_ID
merchantAuth.transactionKey = settings.TRANSACTION_KEY
creditCard = apicontractsv1.creditCardType()
creditCard.cardNumber = number
creditCard.expirationDate = expiration
creditCard.cardCode = card_code

line_items = []

for line in items:
line_item = apicontractsv1.lineItemType()
line_item.quantity = 1
line_item.itemId = line['itemId']
line_item.unitPrice = line['amount']
line_item.description = line['description']
line_item.name = line['description']
line_items.append(line_item)
print(line['itemId'], line['amount'], line['description'])


order = apicontractsv1.orderType()
order.description = description
order.invoiceNumber = invoice_number

# Set the customer's identifying information
customerData = apicontractsv1.customerDataType()
customerData.type = "individual"
customerData.id = str(family.family_id)
customerData.email = family.user.email

createcustomerprofile = apicontractsv1.customerProfilePaymentType()
createcustomerprofile.createProfile = True

payment = apicontractsv1.paymentType()
payment.creditCard = creditCard

transactionrequest = apicontractsv1.transactionRequestType()
transactionrequest.transactionType = "authCaptureTransaction"
transactionrequest.amount = amount
transactionrequest.payment = payment
transactionrequest.profile = createcustomerprofile
transactionrequest.order = order
transactionrequest.customer = customerData
# transactionrequest.billTo = customerAddress
transactionrequest.lineItems = apicontractsv1.ArrayOfLineItem(*line_items)

createtransactionrequest = apicontractsv1.createTransactionRequest()
createtransactionrequest.merchantAuthentication = merchantAuth
createtransactionrequest.refId = "MerchantID-0001"

createtransactionrequest.transactionRequest = transactionrequest
createtransactioncontroller = createTransactionController(createtransactionrequest) 

 

Member
Posts: 2
Registered: ‎07-17-2018

Re: Python - Can't create customer profile data

3,158 views and no response? 

Authorize.Net Expert
Posts: 21
Registered: ‎12-06-2017

Re: Python - Can't create customer profile data

To map the account holder's name to an API field, have you tried using the billTo firstName and lastName fields?

 

e.g.

    billto.firstName = "John"

    billto.lastName = "Smith"

 

These get mapped to the paymentProfile object.

 

https://developer.authorize.net/api/reference/index.html#customer-profiles-create-customer-profile

 

Authorize.Net has two levels of profiles. There's a parent "customer profile", which has ID, email and description. Each customer profile can have associated "payment profiles" (with billing information including accountholder name) and "shipping profiles" (with shipping information).

 

When you pass just the createProfile flag in your transaction, as you are doing, it attempts to create a new Customer Profile and add the associated billing/shipping information to payment and shipping profiles under that Customer Profile. For the Customer Profile to be created successfully, at least one of ID, email or description has to be unique; I presume this is not the case in your transaction.

 

</payment>
<profile>
<createProfile>true</createProfile>
</profile>

<customer>
<id>99999456654</id>
</customer>
<billTo>

 

If you want to add a payment/shipping profile to an existing Customer Profile (e.g. when it's the same customer using a new payment method or shipping address), you have to not just specify the createProfile field in the transaction but also the customerProfileId; this lets the system know that the customer profile is existing, and it just needs to create the payment/shipping profiles and add them to that particular customer profile. Also, make sure you don't again include the customer fields (ID, email, description) in this transaction.

 

</payment>
<profile>
<createProfile>true</createProfile>
<customerProfileId>1915171911</customerProfileId>
</profile>
<billTo>

 

Hope this answers both your questions.