ActiveMerchantを使用してAuthorize.netCIMと統合しています。私は自動テストを作成している最中です。テストを実行するたびに実際にAuthorize.netにアクセスしないように、Webmock呼び出しを導入し始めました。
生のリクエストデータの応答からXMLファイルを作成しましたが、ほとんどの場合、正常に機能しています。ただし、成功した応答をモックアップすると、何らかの理由でActiveMerchantからResponse.success?真実ではない。
私の機能
if self.cim_customer_profile_id.nil?
ActiveMerchant::Billing::Base.mode = :test
customer_profile_information = {
:profile => {
:merchant_customer_id => self.customer.username.first(20),
:email => self.customer.email
}
}
gateway = ActiveMerchant::Billing::AuthorizeNetCimGateway.new(
:login => AUTHORIZE_NET_API_LOGIN_ID,
:password => AUTHORIZE_NET_API_TRANSACTION_KEY
)
response = gateway.create_customer_profile(customer_profile_information)
if response.success?
self.cim_customer_profile_id = response.authorization
else
raise StandardError, response.message
end
end
そして、私の頑固な応答は次のとおりです。
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
<?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>10793616</customerProfileId>
<customerPaymentProfileIdList/>
<customerShippingAddressIdList/>
<validationDirectResponseList/>
</createCustomerProfileResponse>
ActiveMerchantが正常なスタブされたリクエストで機能しない理由はありますか?または、応答が実際に成功したことを登録するためにActiveMerchantが必要とするものが不足していますか?