0

Authorize.net 提供了一些使用 CIM 和 ruby​​ 的示例代码,但它使用 XML。我想使用类似于以下由 authorize.net 提供的 AIM 交易代码的类似 rails 的方法来做到这一点

transaction = AuthorizeNet::AIM::Transaction.new(API_LOGIN_ID, TRANSACTION_KEY, :gateway =>  :sandbox)
credit_card = AuthorizeNet::CreditCard.new('4111111111111111', '1120')
response = transaction.authorize(bid.amount, credit_card)

我已经搜索但找不到任何示例代码。谁能提供一个链接或一些示例代码来创建客户、存储信用卡、检索客户和编辑?

谢谢

4

2 回答 2

0

我发现 ActiveMerchant gem 它有一个通往 CIM 的网关。

http://activemerchant.org/

于 2012-03-18T03:09:47.720 回答
0

CIM API 提供两种格式: - XML 调用 - SOAP 调用

我展示了一个简单的 SOAP 调用示例,用于通过 CIM api 方法创建客户配置文件。我使用 SAVON 制作肥皂客户端。

1.用wsdl文件初始化savon客户端对象,用于网关提供的CIM服务

客户端 = Savon.client(wsdl: " https://apitest.authorize.net/soap/v1/Service.asmx?WSDL ",ssl_verify_mode: :none)

  1. 使用网关提供的事务 ID 拨打电话

response = client.call(:create_customer_profile,:message => {:merchantAuthentication => {"name" => "-----------","transactionKey" => '------ -----'},:profile => {:email =>"arunsharmar321@gmail.com"} })

  1. 将响应解析为 json 输出

JSON.parse((response.body).to_json)

json 中的响应输出 => {"create_customer_profile_response"=>{"create_customer_profile_result"=>{"result_code"=>"Ok", "messages"=>{"messages_type_message"=>{"code"=>"I00001", " text"=>"成功。"}}, "customer_profile_id"=>"36538428", "customer_payment_profile_id_list"=>nil, "customer_shipping_address_id_list"=>nil, "validation_direct_response_list"=>nil}, "@xmlns"=>" https ://api.authorize.net/soap/v1/ "}}

于 2015-08-09T07:38:08.927 回答