2012-03-17 70 views
0

Authorize.net提供了一些使用CIM与ruby但使用XML的示例代码。我想有更多的轨道像的方法类似于下面的AIM交易代码由authorize.netAuthorize.net CIM 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) 

我已经搜查,但找不到任何的示例代码提供的做到这一点。任何人都可以提供一个链接或一些示例代码来创建一个客户,存储一个信用卡,检索客户并编辑?

谢谢

回答

0

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

我已经表明SOAP调用的一个简单的例子,用于创建通过CIM API methods.I've一个客户档案使用SAVON来制作肥皂客户端。与CIM服务的WSDL文件

1.Initialize萨翁客户对象通过网关提供

客户= Savon.client(WSDL: “https://apitest.authorize.net/soap/v1/Service.asmx?WSDL”,ssl_verify_mode:无)

  • 使通过网关
  • 设置有事务ID的呼叫

    响应= client.call(:create_customer_profile,:消息=> {:merchantAuthentication => { “名称”=>“------- ----“,”transactionKey“=>'-----------'},:profile => {:email =>”arunsharmar321 @ gma il.com “}})

  • 解析响应作为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” =>“成功”。}},“customer_profile_id”=>“36538428”,“customer_payment_profile_id_list”=>无,“customer_shipping_address_id_list”=>无,“validation_direct_response_list”=>无},“@ xmlns”=>“https://api.authorize.net/soap/v1/”} }