authorize.net 从交易中创建客户资料
authorize.net creating customer profile from transaction
我目前正在向客户收费,然后尝试根据该收费创建客户资料。问题是,当我尝试实际创建客户时,它失败了,告诉我没有响应,而是打印出 `
AttributeError: no such child:
{AnetApi/xml/v1/schema/AnetApiSchema.xsd}customerProfileId
这是代码,在这个块下面是更多的解释以及我正在做什么来解析响应。
merchantAuth = apicontractsv1.merchantAuthenticationType()
merchantAuth.name = app_config.AUTHORIZE_KEYS['apiLoginId']
merchantAuth.transactionKey = app_config.AUTHORIZE_KEYS['transactionKey']
# Create the payment object for a payment nonce
opaqueData = apicontractsv1.opaqueDataType()
opaqueData.dataDescriptor = request.form['dataDesc']
opaqueData.dataValue = request.form['dataValue']
# Add the payment data to a paymentType object
paymentOne = apicontractsv1.paymentType()
paymentOne.opaqueData = opaqueData
# Create order information
order = apicontractsv1.orderType()
order.invoiceNumber = "invoice_%s" % user.id
order.description = "Awesome"
# Set the customer's identifying information
customerData = apicontractsv1.customerDataType()
customerData.type = "individual"
customerData.id = "cus_%s" % user.id
customerData.email = email
# Giving the credit card info
# Setting billing information
billto = apicontractsv1.nameAndAddressType()
billto.firstName = request.form['firstName']
billto.lastName = request.form['lastName']
billto.address = address1
billto.city = city
billto.state = state
billto.zip = zipcode
billto.country = country
item = request.form['item']
if item == 'dollar':
amount = "3.00"
if item == "monthly":
amount = "5.00"
length = 1
if item == "annual":
amount = "50.00"
length = 12
# Create order information
order = apicontractsv1.orderType()
order.invoiceNumber = "invoice_%s" % user.id
order.description = "Awesomeness"
# # Set the customer's Bill To address
customerAddress = apicontractsv1.customerAddressType()
customerAddress.firstName = request.form['firstName']
customerAddress.lastName = request.form['lastName']
customerAddress.address = address1
customerAddress.city = city
customerAddress.state = state
customerAddress.zip = zipcode
customerAddress.country = country
# Create customer profile on transaction
createcustomerprofile = apicontractsv1.customerProfilePaymentType()
createcustomerprofile.createProfile = True
# Create a transactionRequestType object and add the previous objects to it.
transactionrequest = apicontractsv1.transactionRequestType()
transactionrequest.transactionType = "authCaptureTransaction"
transactionrequest.amount = amount
transactionrequest.payment = paymentOne
transactionrequest.order = order
transactionrequest.billTo = customerAddress
transactionrequest.customer = customerData
transactionrequest.profile = createcustomerprofile
# Assemble the complete transaction request
createtransactionrequest = apicontractsv1.createTransactionRequest()
createtransactionrequest.merchantAuthentication = merchantAuth
createtransactionrequest.refId = refId
createtransactionrequest.transactionRequest = transactionrequest
# Create the controller
createtransactioncontroller = createTransactionController(createtransactionrequest)
createtransactioncontroller.setenvironment(app_config.AUTH_NET_ENVIRONMENT)
createtransactioncontroller.execute()
这个问题好像是在我尝试prase响应的时候出现的。但是当我实际上 运行 开发人员文档
中建议的代码时
response = createtransactioncontroller.getresponse()
logging.debug("%s" % response)
if response is not None:
# Check to see if the API request was successfully received and acted upon
if response.messages.resultCode == "Ok":
# Since the API request was successful, look for a transaction response
# and parse it to display the results of authorizing the card
if hasattr(response.transactionResponse, 'messages') == True:
if hasattr(response.profileResponse, 'messages') == True:
print('made it here')
models.Payment(user=user, payment_date=datetime.utcnow(),
authorize={'email': email, 'updated': False,
'address': u'%s %s' % (address1, address2),
'messages': {'transId':'%s' % response.transactionResponse.transId,
'responseCode':'%s' % response.transactionResponse.responseCode,
'auth_code':'%s' % response.transactionResponse.messages.message[0].code,
'Description':'%s' % response.transactionResponse.messages.message[0].description,
'email':email},
# 'customerProfileId': '%s' % response.profileResponse.customerProfileId,
# 'customerPaymentProfileIdList': '%s' % response.profileResponse.customerPaymentProfileIdList,
})
鉴于他们的 documentation 表明您可以在进行交易时创建客户,但不确定为什么返回它不起作用。
另外,当我检查 schema for the XML response 时,我似乎设置正确。
在 C# SDK 中遇到同样的问题。深入研究它会指出一条错误消息:"Customer profile creation failed. This payment method does not support profile creation." 所以我猜您无法根据不透明的卡数据制作付款资料! :(
我目前正在向客户收费,然后尝试根据该收费创建客户资料。问题是,当我尝试实际创建客户时,它失败了,告诉我没有响应,而是打印出 `
AttributeError: no such child: {AnetApi/xml/v1/schema/AnetApiSchema.xsd}customerProfileId
这是代码,在这个块下面是更多的解释以及我正在做什么来解析响应。
merchantAuth = apicontractsv1.merchantAuthenticationType()
merchantAuth.name = app_config.AUTHORIZE_KEYS['apiLoginId']
merchantAuth.transactionKey = app_config.AUTHORIZE_KEYS['transactionKey']
# Create the payment object for a payment nonce
opaqueData = apicontractsv1.opaqueDataType()
opaqueData.dataDescriptor = request.form['dataDesc']
opaqueData.dataValue = request.form['dataValue']
# Add the payment data to a paymentType object
paymentOne = apicontractsv1.paymentType()
paymentOne.opaqueData = opaqueData
# Create order information
order = apicontractsv1.orderType()
order.invoiceNumber = "invoice_%s" % user.id
order.description = "Awesome"
# Set the customer's identifying information
customerData = apicontractsv1.customerDataType()
customerData.type = "individual"
customerData.id = "cus_%s" % user.id
customerData.email = email
# Giving the credit card info
# Setting billing information
billto = apicontractsv1.nameAndAddressType()
billto.firstName = request.form['firstName']
billto.lastName = request.form['lastName']
billto.address = address1
billto.city = city
billto.state = state
billto.zip = zipcode
billto.country = country
item = request.form['item']
if item == 'dollar':
amount = "3.00"
if item == "monthly":
amount = "5.00"
length = 1
if item == "annual":
amount = "50.00"
length = 12
# Create order information
order = apicontractsv1.orderType()
order.invoiceNumber = "invoice_%s" % user.id
order.description = "Awesomeness"
# # Set the customer's Bill To address
customerAddress = apicontractsv1.customerAddressType()
customerAddress.firstName = request.form['firstName']
customerAddress.lastName = request.form['lastName']
customerAddress.address = address1
customerAddress.city = city
customerAddress.state = state
customerAddress.zip = zipcode
customerAddress.country = country
# Create customer profile on transaction
createcustomerprofile = apicontractsv1.customerProfilePaymentType()
createcustomerprofile.createProfile = True
# Create a transactionRequestType object and add the previous objects to it.
transactionrequest = apicontractsv1.transactionRequestType()
transactionrequest.transactionType = "authCaptureTransaction"
transactionrequest.amount = amount
transactionrequest.payment = paymentOne
transactionrequest.order = order
transactionrequest.billTo = customerAddress
transactionrequest.customer = customerData
transactionrequest.profile = createcustomerprofile
# Assemble the complete transaction request
createtransactionrequest = apicontractsv1.createTransactionRequest()
createtransactionrequest.merchantAuthentication = merchantAuth
createtransactionrequest.refId = refId
createtransactionrequest.transactionRequest = transactionrequest
# Create the controller
createtransactioncontroller = createTransactionController(createtransactionrequest)
createtransactioncontroller.setenvironment(app_config.AUTH_NET_ENVIRONMENT)
createtransactioncontroller.execute()
这个问题好像是在我尝试prase响应的时候出现的。但是当我实际上 运行 开发人员文档
中建议的代码时response = createtransactioncontroller.getresponse()
logging.debug("%s" % response)
if response is not None:
# Check to see if the API request was successfully received and acted upon
if response.messages.resultCode == "Ok":
# Since the API request was successful, look for a transaction response
# and parse it to display the results of authorizing the card
if hasattr(response.transactionResponse, 'messages') == True:
if hasattr(response.profileResponse, 'messages') == True:
print('made it here')
models.Payment(user=user, payment_date=datetime.utcnow(),
authorize={'email': email, 'updated': False,
'address': u'%s %s' % (address1, address2),
'messages': {'transId':'%s' % response.transactionResponse.transId,
'responseCode':'%s' % response.transactionResponse.responseCode,
'auth_code':'%s' % response.transactionResponse.messages.message[0].code,
'Description':'%s' % response.transactionResponse.messages.message[0].description,
'email':email},
# 'customerProfileId': '%s' % response.profileResponse.customerProfileId,
# 'customerPaymentProfileIdList': '%s' % response.profileResponse.customerPaymentProfileIdList,
})
鉴于他们的 documentation 表明您可以在进行交易时创建客户,但不确定为什么返回它不起作用。
另外,当我检查 schema for the XML response 时,我似乎设置正确。
在 C# SDK 中遇到同样的问题。深入研究它会指出一条错误消息:"Customer profile creation failed. This payment method does not support profile creation." 所以我猜您无法根据不透明的卡数据制作付款资料! :(