How to use braintree with rails and activist

I have a simple site with rails to which I must add a payment gateway now. I see railscast by integrating activemerchant with paypal , but instead I wanted to use braintree.

I cannot find any tutorials that show how to integrate the interface for the rails application at the end. I see that people have good things to say about Braintree, but what about a tutorial?

Has anyone used this payment gateway for their rail application? It would be like railscasts with paypal ... just replace paypal with braintree?

+5
source share
2 answers

The Braintree guys created their own stone based on their API. It is very easy to set up and perform real transactions. You can view the code on Github and you can find a quick example here . Complete Rails integration projects are located here .

+6
source

Merchant - , . , Active Merchant, API BT. , . , " " → " " → " 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
+16

All Articles