2017-09-13 3 views
1

현재 고객에게 요금을 청구하고 그 요금을 기반으로 고객 프로파일을 만들려고합니다. 문제는 내가 시도하고 실제로 응답이 없다는 것을 말해, 실패 고객을 작성하고 대신`출력한다 때 여기 authorize.net 거래에서 고객 프로파일 만들기

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() 

응답을 시도 할 때 문제가 발생하는 것으로 보입니다. 실제로 코드를 실행하면되지만 개발자 문서 작동하지 않는 것을 반환 왜 트랜잭션이 확실하지 할 때 당신이 고객을 만들 수 있습니다 자신의 documentation 보여 주어

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, 
               }) 

에 제안한다.

또한 schema for the XML response을 확인하면 올바르게 설정 한 것 같습니다.

답변

0

C# SDK에서 같은 문제가 발생했습니다. 다이빙에 오류 메시지 : "고객 프로필 만들기가 실패했습니다.이 결제 방법은 프로필 작성을 지원하지 않습니다." 따라서 불투명 한 카드 데이터로 결제 프로필을 만들 수 없다고 생각합니다. :(

+0

유감스럽게도이 포럼의 토론 후 올바른 내용입니다. https://community.developer.authorize.net/t5/Integration-and-Testing/Make-customer-profile-when-charging-card/mp/59867 # M34438 그것은 불투명 한 데이터와 함께 작동하지 않는다고 말합니다 – nadermx