Authorize.net(CIM)使用ruby on rails创建客户配置文件

时间:2017-11-15 06:50:28

标签: ruby-on-rails ruby xml authorize.net

使用API​​创建客户付款资料。 得到错误:

  

E00003

     

命名空间'AnetApi / xml / v1 / schema / AnetApiSchema.xsd'中的元素'paymentProfiles'不能包含文本。清单   可能的元素:'customerType,billTo,payment,   名称空间中的driversLicense,taxId,defaultPaymentProfile'   'AnetApi / XML / V1 /模式/ AnetApiSchema.xsd'

请求Authorize.net

<AuthorizeNet::API::CreateCustomerProfileRequest:0x007fc91d9e48a8 @merchantAuthentication=nil, @refId=nil, @profile=#<AuthorizeNet::API::CustomerProfileType:0x007fc91d9e4880 @merchantCustomerId="jdoe6607", @description="John2 Doe", @email="2686@mail.com", @paymentProfiles=[#<AuthorizeNet::API::CustomerPaymentProfileType:0x007fc91d9e4ab0 @customerType="individual", @billTo=#<AuthorizeNet::API::CustomerAddressType:0x007fc91d9e4c68 @firstName="Ellen", @lastName="Johnson", @company="Souveniropolis", @address="14 Main Street", @city="Pecan Springs", @state="TX", @zip="44628", @country="US", @phoneNumber="999-999-9999", @faxNumber="999-999-9999">, @payment=#<AuthorizeNet::API::PaymentType:0x007fc91d9e4d80 @creditCard=#<AuthorizeNet::API::CreditCardType:0x007fc91d9e4da8 @cardNumber="4111111111111111", @expirationDate="2020-05", @cardCode="111", @isPaymentToken=nil, @cryptogram=nil>, @bankAccount=nil, @trackData=nil, @encryptedTrackData=nil, @payPal=nil, @opaqueData=nil>, @driversLicense=nil, @taxId=nil>], @shipToList=[#<AuthorizeNet::API::CustomerAddressType:0x007fc91d9e4a60 @firstName="John", @lastName="Snow", @company="Night's Watch, Inc.", @address="Castle Black", @city="The Wall", @state="North Westeros", @zip="99499", @country="Westeros", @phoneNumber="999-999-9999", @faxNumber="999-999-9999">]>, @validationMode="liveMode">

代码:

transaction = Transaction.new(api_login_id, api_transaction_key, :gateway => :sandbox)
payment = PaymentType.new(CreditCardType.new)
payment.creditCard.cardNumber = '4111111111111111'
payment.creditCard.expirationDate = '2020-05'

billTo = CustomerAddressType.new
billTo.firstName = "Ellen"
billTo.lastName = "Johnson"
billTo.company = "Souveniropolis"
billTo.address = "14 Main Street"
billTo.city = "Pecan Springs"
billTo.state = "TX"
billTo.zip = "44628"
billTo.country = "US"
billTo.phoneNumber = "999-999-9999"
billTo.faxNumber = "999-999-9999"

paymentProfile = CustomerPaymentProfileType.new
paymentProfile.payment = payment
paymentProfile.billTo = billTo

shippingAddress = CustomerAddressType.new
shippingAddress.firstName = "John"
shippingAddress.lastName = "Snow"
shippingAddress.company = "Night's Watch, Inc."
shippingAddress.address = "Castle Black"
shippingAddress.city = "The Wall"
shippingAddress.state = "North Westeros"
shippingAddress.zip = "99499"
shippingAddress.country = "Westeros"
shippingAddress.phoneNumber = "999-999-9999"
shippingAddress.faxNumber = "999-999-9999"

request = CreateCustomerProfileRequest.new
request.profile = CustomerProfileType.new
request.profile.merchantCustomerId = 'jdoe' + rand(10000).to_s
request.profile.description = 'John2 Doe'
request.profile.email = rand(10000).to_s + '@mail.com'
request.profile.paymentProfiles = [paymentProfile]
request.profile.shipToList = [shippingAddress]    
request.validationMode = ValidationModeEnum::LiveMode    

response = transaction.create_customer_profile(request)

0 个答案:

没有答案