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

前端 未结 4 513
离开以前
离开以前 2021-01-29 22:53

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 han

相关标签:
4条回答
  • 2021-01-29 23:06

    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.

    0 讨论(0)
  • 2021-01-29 23:12

    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.

    0 讨论(0)
  • 2021-01-29 23:15

    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.

    0 讨论(0)
  • 2021-01-29 23:23

    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

    0 讨论(0)
提交回复
热议问题