yog*_*shi 5 paypal ruby-on-rails payment-gateway braintree payment-processing
我有一个简单的rails网站,我现在需要添加一个支付网关.我看到有关将activemerchant与paypal集成的railscast,但我想使用braintree代替.
我无法找到任何教程,展示如何将braintree端到端地集成到rails应用程序中.我看到人们对braintree有好话,但教程怎么样?
有人使用此支付网关进行铁路应用吗?它会与使用paypal的railscast类似吗...只需用braintree替换paypal?
小智 16
Active Merchant是一个更灵活的选择,因为它使您的公司可以自由地更改网关而无需重大代码更改.最初的问题是如何将其与Active Merchant集成,而不是如何使用BT的专有API.这是我在深入研究代码后找到的答案.您可以在"帐户" - >"我的用户" - >"API密钥"下找到您的公钥,私钥和商家ID.
gateway = ActiveMerchant::Billing::BraintreeGateway.new(
:merchant_id => 'Your Merchant ID',
:public_key => 'Your Public Key',
:private_key => 'Your Private Key'
)
creditcard = ActiveMerchant::Billing::CreditCard.new(
:type => 'visa',
:number => '41111111111111111',
:month => 10,
:year => 2014,
:first_name => 'Bob',
:last_name => 'Bobsen'
)
response = gateway.purchase(1000, creditcard)
STDERR.puts response.success?
STDERR.puts response.message
STDERR.puts response.authorization
Run Code Online (Sandbox Code Playgroud)