如何将 Braintree 与 Rails 和 Activemerchant 结合使用

发布于 2024-11-19 20:09:58 字数 350 浏览 2 评论 0原文

我有一个简单的 Rails 网站,现在需要添加支付网关。我看到 railscast 将 activemerchant 与 paypal 集成,但我想改用 Braintree。

我找不到任何教程来展示 Braintree 如何端到端集成到 Rails 应用程序中。我看到人们对 Braintree 有很多好话要说,但是教程怎么样?

有人在他们的 Rails 应用程序中使用过这个支付网关吗?它会类似于带有 paypal 的 Railscast...只需将 paypal 替换为 Braintree 吗?

I have a simple rails website to which I need to add a payments gateway now. I see a railscast on integrating activemerchant with paypal but I wanted to use braintree instead.

I am unable to find any tutorials that show how braintree can be integrated to a rails app end to end. I see that people have good things to say about braintree but how about a tutorial?

Has someone used this payment gateway for their rails application? Would it be similar to the railscasts with paypal...just replace paypal with braintree?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

暖树树初阳… 2024-11-26 20:09:58

Active Merchant 是一个更加灵活的选择,因为它使您的公司可以自由地更改网关,而无需进行重大代码更改。最初的问题是如何将其与 Active Merchant 集成,而不是如何使用 BT 的专有 API。这是我在深入研究代码后找到的答案。您可以在“账户”->“账户”下找到您的公钥、私钥和商户ID。 “我的用户”-> “API 密钥”。

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

Active Merchant is a much more flexible choice since it gives your company the freedom to change gateways without significant code changes. The original question was how to integrate it with Active Merchant, not how to use BT's proprietary API. Here's the answer I found after some digging through the code. You can find your public key, private key and merchant id under "Account" -> "My User" -> "API Keys".

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
挥剑断情 2024-11-26 20:09:58

Braintree 的人根据他们的 API 创建了他们自己的 gem。设置和进行实际交易非常容易。您可以在 Github 上查看代码,并可以在 此处。集成 Rails 的完整项目位于此处

The guys at Braintree created their own gem based on their API. It's very easy to setup and do actual transactions with. You can view the code on Github and a quick example can be found here. Full projects with Rails integration are located here.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文