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?
<text>A duplicate record with ID 1504872533 already exists.</text>
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']
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)
To map the account holder's name to an API field, have you tried using the billTo firstName and lastName fields?
billto.firstName = "John"
billto.lastName = "Smith"
These get mapped to the paymentProfile object.
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.
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.
Hope this answers both your questions.