Recurring billing with Rails and ActiveMerchant: Best practices, pitfalls, gotchas? - ruby-on-rails

We are prepping for the release of a large web application that has been in development for the past year. We are about to start the process of integrating ActiveMerchant to handle recurring subscription fees for the service.
I am looking for any advice regarding best practices considering our requirements (listed below) and any additional heads-up for common pitfalls or specific issues I should be giving special consideration. The payment gateway we will be using is PaymentExpress as it's one of the few supported gateways that has recurring billing and doesn't have any special conditions for companies operating outside of the USA. The business behind this application is based out of the UK.
Users of the application create an account with a sub-domain where they can access and customise the application and their data. Below are some of the requirements/features that might have an effect on how billing works:
All users get a 30 day trial
There are different plans, including a free one
Higher priced plans have larger limits on the amount of data (e.g. users, projects, etc) they can have in their account
Billing period will be monthly, beginning after trial
There will be discounts/coupon codes to get a percentage off the normal price for a year on plans, etc.
Plan pricing will change as features are added
Specific hurdles I can foresee will be things including the following:
How to handle downgrading when they violate the plan limits for lower level plans.
Behaviour when credit cards expire or payments don't go through (a read-only mode enforced, perhaps)
When plan pricing changes, we want to honour previous prices for existing users for a time period (such as 6 months), then start charging higher rates. If the plan price decreases, it will take effect immediately.
Other advice that would be helpful would be anything regarding flow of the application. How should billing forms be presented to the user? When should credit card information be required? How should invoices be sent, stored, and accessible?
I should disclose that we plan to base a lot of the code base off SaaSy. SaaSy is designed to be used as a separate Rails app that handles all the signup and account management side of things. However, this doesn't work for us since we never planned for this from the beginning and it would be a tedious process to adapt our application to work like that. Consequently, we'll be pulling code and ideas from SaaSy and merging them into our app, a considerably less tedious task.

One thing I wanted to add: keep in mind you don't need to use the recurring billing feature that is built into the gateway. In general these systems are legacy and very difficult to deal with, we get spoiled in the rails world.
You get a lot more flexibility just using them for one purpose (to bill a credit card, and perhaps also store credit cards for PCI compliance). Then roll your own recurring billing in your rails app with a cron job, a date field for when they are paid through, and amount each person is paying (in case they used a coupon) etc.
One small example: sometimes people will cancel a monthly subscription in the middle of the month. They want to make sure they don't forget to cancel before the next payment. Most gateway recurring billing that I've seen will instantly terminate the account (or send you a message indicating this). In reality, the user has paid through the end of the month and should be given 2 more weeks of access. You can do this if you have rolled your own recurring billing in rails, but not if you are using the gateway recurring billing. Just a small example.

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.

Peepcode has a PDF for sale(70 pages) that details various aspects of payment processing and industry practices for this. It may be worth checking out:
http://peepcode.com/products/activemerchant-pdf

I'm also in the middle of setting up a subscription based website and these are our current requirements. They may help you regarding best practice:
Users will be able to choose one of
the subscription plans.
Users will be required to enter their
credit card details to sign up to
their chosen plan.
All major credit and debit cards must
be accepted including Maestro and
American Express.
Each plan will have a 30-day free
trial so users' credit cards should
only be charged after the 30-day
period expires. However, the validity
of credits cards should be checked at
the time of sign up.
Users will be emailed a few days
before their credit card is charged
to notify them that they will be
charged soon unless they cancel their
account. If they cancel their account
within their 30 day free trial, their
credit card should not be charged.
After any free trial period, users
will be charged in advance for their
use of the system - ie they will
pre-pay.
Users will be charged automatically
every month for their chosen plan.
Each month, users will be sent an
email a few days in advance to notify
them that they will be charged. Once
payment has been made, users will be
emailed an invoice showing that their
payment has been received.
Users will be able to upgrade or
downgrade their accounts at any time.
When users upgrade/downgrade, their
next subscription charge will be at
the new rate. Users will only be able
to downgrade their accounts to a plan
that can handle their data. For
example, if they currently have 10
active projects they can't downgrade
to the Basic plan because the Basic
plan only allows 5 projects. They
will have to delete or archive 5
projects before you they can
downgrade to Basic.
Users will be able to log in to their
account and change or update their
credit card details.
Users will be able to cancel their
account at any time. There will be no
further subscription charges after a
user has canceled their account.
However, users will not be refunded
for part of the month they have
already paid for.
All parts of the payment system must
be 100% PCI DSS compliant; including
any 3rd party systems.
The payment system must support
automated notification and retry of
failed subscription renewals.
The payment system must support
discount vouchers with expiry dates.
Credit card details must not be
processed by or stored on our servers
they should always be processed/stored by our 3rd party
payment processing partner. We do not
want responsibility for securing
these details and complying with
legal rules and regulations.
Users will be able to log into their
accounts and see a full billing
history including dates and amounts
paid. We will also need to be
able to log in to a system to see
customer payment plans and payment
history. This will be essential for
customer service.
We've also been looking at http://chargify.com/ which looks like it could save a lot of coding time.

Related

International marketplace payment collection/distribution system guidance

I'm working on a Marketplace project and I am looking for a simple payment solution that would facilitate transactions made between Buyers and Sellers globally. There will have to be an Escrow system and the payments would go through only after the job has been marked complete.
I have done some research and I am aware of a few solutions available but there are some problems with these. BalancedPayements look really good but they are US only. Stripe Connect is also an option but they do not have an Escrow system.
The basic steps needed are:
Buyers use their credit cards to put the funds in escrow.
Sellers start providing their service. Once the job is done and
approved by the buyer, the funds are released to the seller (after
taking a cut for the marketplace itself)
For the level of flexibility I need, this is how I am planning to execute:
Have some kind of a virtual currency (Let's call it "coins") in place.
The Buyer pays the platform to buy the coins. example - $100 for 100
coins. Stripe can be used for this payment acceptance. Now, Since the coins are in our system and our control, we solve the escrow problem and ensure that the buyer has sufficient funds to fund a job.
And once the job is completed, the coins get transferred to the seller's
account. The seller can now checkout their coins. For this, we can use PayPal.
Does this Coin system seem like a good idea? Is there something that can be done better?

When using google wallet payments api can a user pre-authorise future transactions?

I am building a webapp which requires users to regularly top up their account. To allow for this I am exploring the google wallet inapp payments api and have got this working fine. However, I would like users to be given the option to auto-top up when their account balance becomes low. I have looked at the subscription documentation but cannot see whether this is possible or not - it seems you can only have a subscription which draws money at regular intervals.
Is there a way to have a user pre-authorise this kind of transaction, and if so could you please point me to any documentation that would allow for this?
I don't believe so. The subscription feature is probably your best bet and should (unless I'm missing something) get you to the "same place".
A "pre-authorization" somewhat says, you'll come back at some later time to charge (aka "capture") the pre-auth. There is no API command that does that (capture/charge) in Wallet for Digital Goods. The process is immediate...
There (is) used to be one in the Google Checkout API where you are given 7 calendar days to charge a pre-auth. However, this product will be retired in November.

How to accept credit card info (and send money to credit card) without PCI compliance?

Here are our requirements:
Send money to our users' credit cards. This is a unique requirement that many payment systems don't support. We essentially need to be able to grant a bonus/reward (sort of like a refund but without a preceding purchase).
Avoid stringent PCI compliance requirements. We're fine with paying a 3rd party to store the credit card info; we'd rather not deal with quarterly audits.
Credit card form must be translatable into English, Chinese, Korean, and Russian.
Credit card form must appear within our site and look like the rest of our site.
Fees must be reasonable.
Apparently Moneris satisfies everything except #3. But that might be a deal breaker for us.
Know of any other gateways I should explore?
Generally, you cannot 'refund' a credit card that you have not charged a higher amount. Sounds like you probably have a very uphill battle.
Anytime you try to remit money to a credit card, you will be asked to reference the previous CHARGE transaction or you will not be able to process the credit transaction.
Any chance the people you need to pay could all become paypal members so they can be paid? Paypal has a very slick little interface to allow you to pay other paypal members in batches - real fast, real easy, real easy to code. Most folks will rush to join paypal if it means that what they have to do to get paid - all you need to know to pay them is their paypal login email address.
Instead of issuing charges back to a customer's card, have you considered placing credits on their account instead? It ends up being cheaper for you (no transaction fees!), and it encourages to keep the customer with you longer.
A change in this requirement would make it very simple to use something like Recurly.com, whee I work.

Microsoft Translator API

I have some queries on Microsoft Translator API
1.If i use trial period before characters limit will be over am i going to get any emails from the configured email in datamarket.azure.com. I have seen that notifications will appear in our account when our subscription balance is 15% of our monthly limit and when our balance is completely finished, but i think these notifications will display in our www.datamarket.azure.com account. It's not good to check our account regular basis.So is there any other approach which is maintaining by Microsoft?
2.is there any specific limited characters or transactions per day for paid service also?
I referred this link but i didn't get much details
https://datamarket.azure.com/help-overview-purchasing-subcribing-data-apps#x_taxes
Please provide me the answers for the above queries.
Microsoft translator Support has sent a response for the above queries as follows
1.At this time the notification for low balances only appear in your Windows Azure Marketplace account. The email notification for low balances is a priority feature that we expect to be included in a future release of Marketplace. If you subscribe to a paid monthly subscription, a new feature for paid Translator API subscribers called ‘Auto-Refill’ was added last week and you may find this to be useful depending on your usage scenario.
If you enable this feature for your paid Translator API subscription, you allow Marketplace to automatically refill your subscription if your remaining balance reaches 10% or less of your monthly subscription limit. More information on Auto-Refill can be found here.
2.You are currently able to translate a maximum of 10000 characters per request, but we recommend keeping each request between 2000 and 5000 characters to optimize response times.

What the pros and cons of PayPal's recurring Subscribe button versus their other plans

I'm trying to get recurring payments to work on my Rails site.
I have two options:
Recurring Payments via the PayPal Subscribe button API (http://ianpurton.com/adding-paypal-subscription-to-your-rails-appl)
Recurring Payments via ActiveMerchant and PayPal Express (http://stackoverflow.com/questions/471936/recurring-billing-with-rails-and-activemerchant-best-practices-pitfalls-gotcha)
My monthly payments are going to be cheap (less than $5/mo). I only need one paid plan (a pro plan) and don't plan on adding additional plans. I also expect volume to be very modest ... and is meant to help cover some of my server expenses.
For me the biggest factors:
- Ease of adding this to my site.
- Least amount of surchages and monthly minimums
Thanks for any help!
If you ever need to transfer control of the subscriptions, it's hard to do since the subscriptions are tied to a specific paypal account / email account

Resources