activemerchant / active_merchant

Active Merchant is a simple payment abstraction library extracted from Shopify. The aim of the project is to feel natural to Ruby users and to abstract as many parts as possible away from the user to offer a consistent interface across all supported gateways.
http://activemerchant.org
MIT License
4.54k stars 2.5k forks source link

Bitcoin #688

Closed Sjors closed 11 years ago

Sjors commented 11 years ago

What would be involved to allow an active_merchant powered rails app to accept bitcoin payments? At minimum it should be able to create a payment request and verify that the transaction took place.

The most lazy variant would generate a link with the shop's bitcoin address and a unique invoice number, which then opens the user's bitcoin wallet client. It then checks blockhain.info every 10 seconds or so to see if the transaction has been received.

A less lazy variant would offer several ways to pay depending on the different clients out there and run it's own bitcoin node (perhaps using bitcoin-ruby) to verify receiving the transaction.

Another approach would be to integrate with a service like BitPay.

mnoack commented 11 years ago

Someone (perhaps you?) would need to contribute the code for this. See https://github.com/Shopify/active_merchant/wiki/contributing

I have contributed the Migs gateway and you can message me for advice if you want. When doing my contribution I found the best was to look at other gateways and see how it was done. I generally followed the standards as determined by looking at other gateways.

I'm happy to guide you via email if you have questions along the way.

Ultimately a gateway class looks something like:

class MyGateway
  self.url = 'http://theurl.com'
  self.supported_countries = %w(AU CA US)
  self.supported_cardtypes = [:visa, :master, :american_express, :diners_club, :jcb]
  self.money_format = :cents
  def initialize(options = {})
    requires!(options, :login, :password)
    super
  end

  def purchase(money, creditcard, options = {})
    requires!(options, :order_id)
    post = {:amount => money.format}
    add_creditcard(post, creditcard)
    data = ssl_post self.url, post_data(post)
    response_hash = parse(data)
    response_object(response_hash)
  end

  def response_object(response)
    Response.new(success?(response), response[:message], response,
      :authorization => response[:transaction_no]
    )
  end
end
Sjors commented 11 years ago

@mnoack thanks. I sent bitpay.com an application to open an account with them. Once I have figured out if that works and if I have the time, I'll try to contribute a gateway. Should we keep this ticket open so that other people who are interested can find each other?

ntalbott commented 11 years ago

https://coinbase.com/ would be another option.

I'd prefer to close this out, as Issues doesn't work well for tracking speculative work. Folks can still find it via search, and you'll still get notifications if people post to it.

Sjors commented 11 years ago

Ok, that's fine.

Coinbase doesn't do bank transfers outside the USA, but that's not necessarily a problem. I'll see which API I like best.

jordanmichaelrushing commented 8 years ago

Any progress on this at all? Would love to get Bitcoin processing on my site!