3

我使用 ActiveMerchant 和 Braintree 作为我的支付处理器。我想利用 Braintree 的客户保险库功能来存储信用卡信息。

存储没问题,但我想不出用customer_vault_id. 根据Braintree 文档,这似乎非常简单,但我不确定如何通过 ActiveMerchant 传递它。如果我发送带有空数据的信用卡,我会从 Braintree 收到验证错误,如果我尝试发送来自 ActiveMerchant 的错误nil。唯一看起来很明显的是发送customer_vault_id散列purchase_options,例如:

GATEWAY.purchase(self.price_in_cents, self.credit_card, 
                 :ip => self.ip_address,
                 :customer_vault_id => 12345)

这是使用存储的客户保险库的正确方法吗?

如果是这样,如果我想使用存储的客户保险库作为付款方式,那么此行的正确第二个参数是什么?

谢谢。

4

2 回答 2

2

我发现您可以将购买方法中customer_vault_id的字符串替换为字符串。ActiveMerchant::Billing::CreditCard文档真的没有任何迹象表明这一点:(

于 2009-06-29T16:11:52.623 回答
0

在网关上调用#store 后,您将收到响应,您需要存储授权。

根据 wiki 中的文档:https ://github.com/activemerchant/active_merchant/wiki/Patterns-&-Standards

store 至关重要的是,store 返回一个可用于购买和授权的令牌。目前的标准是在 Response#authorization 字段中返回令牌。

支付方式 字符串/令牌:通过商店标记化的支付方式的表示

例如

gateway = ActiveMerchant::Billing::BraintreeGateway.new(login: login, password: password)
credit_card = ActiveMerchant::Billing::CreditCard.new(
                :first_name         => 'Bob',
                :last_name          => 'Bobsen',
                :number             => '4242424242424242',
                :month              => '8',
                :year               => Time.now.year+1,
                :verification_value => '000')
response = gateway.store(credit_card)
=> #<ActiveMerchant::Billing::Response:0x00007f8efb3df1a8
 @authorization="1508682289#1508160804#cim_store",
 @avs_result={"code"=>nil, "message"=>nil, "street_match"=>nil, "postal_match"=>nil},
 @cvv_result={"code"=>nil, "message"=>nil},
 @emv_authorization=nil,
 @error_code=nil,
 @fraud_review=false,
 @message="Successful",
 @params=
  {"message_code"=>"1",
   "message_text"=>"Successful",
   "result_code"=>"Ok",
   "test_request"=>nil,
   "customer_profile_id"=>"1508682289",
   "customer_payment_profile_id"=>"1508160804",
   "direct_response"=>nil},
 @success=true,
 @test=true>

response.authorization
=> "1508682289#1508160804#cim_store"
gateway.purchase(100, response.authorization)
=> #<ActiveMerchant::Billing::Response:0x00007f8ede0027c8
 @authorization="40036062888#XXXX4242#cim_purchase",
 @avs_result=
  {"code"=>"Y", "message"=>"Street address and 5-digit postal code match.", "street_match"=>"Y", "postal_match"=>"Y"},
 @cvv_result={"code"=>"P", "message"=>"CVV not processed"},
 @emv_authorization=nil,
 @error_code=nil,
 @fraud_review=false,
 @message="This transaction has been approved.",
 @params=
  {"message_code"=>"1",
   "message_text"=>"Successful",
   "result_code"=>"Ok",
   "test_request"=>nil,
   "customer_profile_id"=>nil,
   "customer_payment_profile_id"=>nil,
   "direct_response"=>
    "1,1,1,This transaction has been approved.,T91GL2,Y,40036062888,,,1.00,CC,auth_capture,2852040810cf440a4a13,Bob,Bobsen,,,,n&#47;a,,,,,,,,,,,,,,,,,,,,P,2,,,,,,,,,,,XXXX4242,Visa,,,,,,,,,,,,,,,,,",
   "response_code"=>1,
   "response_subcode"=>"1",
   "response_reason_code"=>"1",
   "response_reason_text"=>"This transaction has been approved.",
   "approval_code"=>"T91GL2",
   "avs_result_code"=>"Y",
   "transaction_id"=>"40036062888",
   "invoice_number"=>"",
   "order_description"=>"",
   "amount"=>"1.00",
   "method"=>"CC",
   "transaction_type"=>"auth_capture",
   "customer_id"=>"2852040810cf440a4a13",
   "first_name"=>"Bob",
   "last_name"=>"Bobsen",
   "company"=>"",
   "address"=>"",
   "city"=>"",
   "state"=>"n&#47;a",
   "zip_code"=>"",
   "country"=>"",
   "phone"=>"",
   "fax"=>"",
   "email_address"=>"",
   "ship_to_first_name"=>"",
   "ship_to_last_name"=>"",
   "ship_to_company"=>"",
   "ship_to_address"=>"",
   "ship_to_city"=>"",
   "ship_to_state"=>"",
   "ship_to_zip_code"=>"",
   "ship_to_country"=>"",
   "tax"=>"",
   "duty"=>"",
   "freight"=>"",
   "tax_exempt"=>"",
   "purchase_order_number"=>"",
   "md5_hash"=>"",
   "card_code"=>"P",
   "cardholder_authentication_verification_response"=>"2",
   "account_number"=>"XXXX4242",
   "card_type"=>"Visa",
   "split_tender_id"=>"",
   "requested_amount"=>"",
   "balance_on_card"=>""},
 @success=true,
 @test=true>
于 2019-08-06T22:40:43.990 回答