我正在使用updateCustomerPaymentProfile
端点尝试更新付款资料。这很好用,除了存在一个字段:defaultPaymentProfile
.
有两个不同的问题。
1. Authorize.Net Ruby SDK 输入问题
文档说defaultPaymentProfile
是一个预期的字段,但在 ruby SDK 中该类型不允许它,请参阅官方源代码:
https://github.com/AuthorizeNet/sdk-ruby/blob/002019e03a94ef582aa82983edf6a7a1a22b2316/lib/authorize ..
我为此打开了一个 Github 问题。
然后我猴子修补了以下类型:
module AuthorizeNet::API
class CustomerPaymentProfileExType
xml_accessor :defaultPaymentProfile
end
end
之后,它接受发送请求,但我收到如下错误响应:
AuthorizeNetException: E00003: The element 'paymentProfile' in namespace
'AnetApi/xml/v1/schema/AnetApiSchema.xsd' has invalid child element
'defaultPaymentProfile' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd
哪个是第二个问题...
2. Authorize.Net APIdefaultPaymentProfile
在更新付款资料时不接受
作为记录,我在修补 SDK 以实际访问 API 后,转储了发送到 API 的原始 XML:
<updateCustomerPaymentProfileRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
<merchantAuthentication>
<name>REDACTED</name>
<transactionKey>REDACTED</transactionKey>
</merchantAuthentication>
<customerProfileId>REDACTED</customerProfileId>
<paymentProfile>
<customerType>individual</customerType>
<billTo>
<firstName>REDACTED</firstName>
<lastName>REDACTED</lastName>
<address>REDACTED</address>
<city>REDACTED</city>
<state>REDACTED</state>
<zip>REDACTED</zip>
<country>REDACTED</country>
<phoneNumber>REDACTED</phoneNumber>
</billTo>
<payment>
<creditCard>
<cardNumber>XXXX4242</cardNumber>
<expirationDate>2022-03</expirationDate>
</creditCard>
</payment>
<customerPaymentProfileId>REDACTED</customerPaymentProfileId>
<!-- This XML passes fine without the line below -->
<defaultPaymentProfile>true</defaultPaymentProfile>
</paymentProfile>
<validationMode>liveMode</validationMode>
</updateCustomerPaymentProfileRequest>
这看起来与官方 API 文档建议的请求完全相同,但是,服务器响应E00003
我已经在上面共享的错误。
笔记
作为参考,我正在使用的 ruby 代码块:
profile = AuthorizeNet::API::CustomerPaymentProfileExType.new
profile.customerPaymentProfileId = current_profile.customerPaymentProfileId
profile.billTo = billTo
profile.payment = AuthorizeNet::API::PaymentType.new(
AuthorizeNet::API::CreditCardType.new(
cc_data.cardNumber, cc_data.expirationDate
)
)
profile.taxId = user.tax_id if user.tax_id
profile.defaultPaymentProfile = true
profile.customerType = 'individual'
request = AuthorizeNet::API::UpdateCustomerPaymentProfileRequest.new
request.paymentProfile = profile
request.customerProfileId = customer_profile_id
request.validationMode = AuthorizeNet::API::ValidationModeEnum::LiveMode
response = transaction.update_customer_payment_profile(request)
我究竟做错了什么?