Recurring Billing with Rails and Activemerchant: Best Practices, Pitfalls, Gotchas

Recurring billing with Rails and ActiveMerchant: Best practices, pitfalls, gotchas?

RailsKits has a Software as a Service kit that should do what you need. It has built-in support for free trials, upgrading, downgrading, plan limits, etc., and it supports PaymentExpress (and some others).

I've researched it a bit for a project I'm doing, but I haven't purchased it yet so I can't vouch for it. However, I have seen a few blog posts praising this kit.

While the RailsKit is relatively inexpensive when compared what it would cost you to implement all of its features yourself, there are a couple open source versions out there that aim to accomplish the same thing. The one I remember off the top of my head is called Freemium.

EDIT: I forgot to mention that Ryan Bates said in his most recent Railscast that his next episode or two will deal with recurring billing, so keep an eye out for that. He usually does one episode per week, and the five he's done since December 22 all cover handling payments of different types.

Recurring billing in activemerchant using Moneris Canada

AFAIK Moneris at this time doesn't support access to reporting via API so there's no programmatic way of checking that a recurring payment was successful or not, neither through webooks or through reportings.

This answer suggests another solution...

Looking for some one who has implemented Moneris recurring payments for a website subcription

...which is basically just storing the credit cards on Moneris in exchange for a token, presumably, (what the poster refers to as "the vault") and then setting up your own scheduler to request payments as needed and getting real-time feedback on success or failure of payments.

ActiveMerchant recurring payment - cycles parameters has no effects?

I have found it by digging into ActiveMerchant source... The good parameters name is :total_billing_cycles, not :cycles as stated in the documentation that I have...

Work like a charm now :-)

What are the associations between the models in a subscription/recurring billing Rails app?

class Subscription < ActiveRecord::Base
belongs_to :user
belongs_to :plan
end

class User < ActiveRecord::Base
belongs_to :plan
has_many :subscriptions (or has_one, if a user only has 1 subscription at a time)
has_many :transactions
end

class Transaction < ActiveRecord::Base
belongs_to :user
belongs_to :plan
end

class Plan < ActiveRecord::Base
has_many :subscriptions
has_many :users
end

ActiveMerchant: How to authorise cards when using gateways that do not support the void operation?

It turns out that at least with PaymentExpress, they automatically do an authorisation action as part of their card storing process. If the authorisation fails, it simply won't store the card, returning "INVALID CARD" instead. This is seen in their transaction search web app -- when storing cards, $1.00 is authorised on the card, and invalidated automatically a week later.

Recurring payment or special category. Question about billing

First you want to capture card details up front, but not make any charge.

That can be done with most payment service providers (PSPs). Usually you will redirect from your site to a site hosted by the PSP which captures the card details. Once the user leaves that page they will redirect back to your site, and you will receive a payment Token, which is essentially a GUID which can be used in future transactions instead of a card number.

Each time you want to take payment from that card you can submit your Token Id and payment value to the PSP for authorisation and settlement. Bear in mind that its entirely possible that the authorization could fail or be declined.

This is technically known as a recurring payment in that there are potential complications which your PSP should handle for you, such as credit cards expiring, or being replaced. Decent PSPs will make use of the Visa Account Updater service, or the equivalent Mastercard Automated Billing Updater to ensure that behind the scenes the card number is automatically updated. Worth checking that your chosen PSP provides this capability.

How do I handle recurring/subscription billing in a Rails App?

You can look into Saasy. It's a stand alone Rails app (not a plugin) that you host on a subdomain and communicate with it using SSO/REST protocols. Probably won't fit your need as it is, but you may be able to extend it or get a general idea of how it works.



Related Topics



Leave a reply



Submit