我使用 authorize.net 创建了一个开发者帐户,我正在尝试通过 activemerchant 创建一个客户资料。
> GATEWAY.create_customer_profile(:profile => { :merchant_customer_id => "123foobar", :email => "lol@lol.com" })
#<ActiveMerchant::Billing::Response:0x007fc3a2663e20 @params={"messages"=>
{"result_code"=>"Error", "message"=>{"code"=>"E00007", "text"=>"User authentication failed
due to invalid authentication values."}}}, @message="User authentication failed due to
invalid authentication values.", @success=false, @test=false, @authorization=nil,
@fraud_review=nil,
@avs_result={"code"=>nil, "message"=>nil, "street_match"=>nil, "postal_match"=>nil},
@cvv_result={"code"=>nil, "message"=>nil}>
我查看了那个错误代码,它说:
API Error Code: E00007
Error Code Text: User authentication failed due to invalid authentication values.
Description: The name/and or transaction key is invalid.
Other Tips: Try switching between production and developer test URL's. The test URL
requires a separate developer test account, which can be set up by filling out the following form: http://developer.authorize.net/testaccount.
可以肯定的是,我验证了 api 登录密钥。当我检查网关对象时,我看到了登录名(api 登录密钥)、密码(交易密钥)和 :test => true
谁能告诉我交易是什么?
更新
所以我决定最好绝对验证问题出在 authorize.net --- 结果不是..如果我通过 curl 发出请求,它是成功的:
curl -H "Accept: application/xml" -H "Content-Type: application/xml" -X POST -d '<?xml version="1.0" encoding="utf-8"?>
<createCustomerProfileRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
<merchantAuthentication>
<name>myTestLogin</name>
<transactionKey>myTransactionKey</transactionKey>
</merchantAuthentication>
<profile>
<merchantCustomerId>custId123</merchantCustomerId>
<description>some description</description>
<email>foo@bar.com</email>
</profile>
</createCustomerProfileRequest>' https://apitest.authorize.net/xml/v1/request.api
<?xml version="1.0" encoding="utf-8"?><createCustomerProfileResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"><messages><resultCode>Ok</resultCode><message><code>I00001</code><text>Successful.</text></message></messages><customerProfileId>10521778</customerProfileId><customerPaymentProfileIdList /><customerShippingAddressIdList /><validationDirectResponseList /></createCustomerProfileResponse>
...
所以,这意味着问题出在 ActiveMerchant........ 我可以通过 activemerchant 使用我的真实帐户创建客户资料,但由于某种原因,我无法对开发人员测试帐户进行此操作。 ..
有一件事让我怀疑:
尽管网关说它处于测试模式: 1.9.3p194 :007 > GATEWAY => #, :password=>, :test=>true}>
实际上询问它是否处于测试模式返回一个意外的响应............
1.9.3p194 :008 > GATEWAY.test?
=> false
嗯嗯嗯嗯嗯……