#1
  1. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    May 2004
    Location
    Boston, MA USA
    Posts
    589
    Rep Power
    52

    PHP / MySQL Subscription Business


    I have a web-based business management tool that my customers use to manage their businesses in a SaaS model. It has a credit card gateway where their customers can pay them for their products and services. (My system provides the gateway, they use their own merchant accounts with a credit card servicer)

    Currently, my customers are billed outside of the system and they pay me via check. (Seems kind of silly since I have both a gateway and a merchant account of my own)

    So... I want to develop a automatic subscription function and am looking for some advice.

    Does anyone have a resource that would be useful? Template application, white paper etc?

    I'm looking for best practices regarding automatic scripts which will execute one a month, as well as requirements for record keeping, etc.

    What's the best method for developing an auto-execute script? (I'd like to keep it in PHP ?MySQL / JavaScript)

    Should I "sell" a new (recurring) product every month and then charge against that or should I simply sell one "product" (a subscription) and simply execute a monthly charge.

    Any advice would be appreciated.
  2. #2
  3. Wiser? Not exactly.
    Devshed God 2nd Plane (6000 - 6499 posts)

    Join Date
    May 2001
    Location
    Bonita Springs, FL
    Posts
    6,288
    Rep Power
    4194
    The closest I've come to doing something like this is creating a payment plan system where people can pay off a bill in X installments of $Y.YY instead of the full price. We use Authorize.net for processing. To implement this we capture their credit card details when the plan is created and store the token given to us by Authorize.net. I then have a daily cron job that looks in the DB for payments due that day and attempts to charge their card for the necessary amount. If a charge fails the user is notified by email so they can update their payment details if necessary. Failures are retried up to 3 times before then gives up.

    For successful payments the item is marked in the DB as paid and the transaction ID is recorded for reference. Sometimes a payment may get rejected later so I have another script that runs daily and will check recent transactions to see if they ended up getting returned (ie, insufficient funds on an e-check transaction). It that happens the payment record is cancelled and an email with the details is sent to someone in the finance department to follow up manually.

    Authorize.net has a tool for doing recurring subscription payments and I would imagine other places do as well. With those tools you can usually setup a subscription for the customer and the gateway will automatically charge their card according to the schedule for the amount of the subscription. If your model fits the subscription service that'd probably be the best way to do it. Otherwise you could always just do it manually like I did for the payment plans.
    Last edited by kicken; May 12th, 2019 at 11:20 PM.
    If I helped you out, show some love with some reputation, or tip with Bitcoins to 1N645HfYf63UbcvxajLKiSKpYHAq2Zxud
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    May 2004
    Location
    Boston, MA USA
    Posts
    589
    Rep Power
    52
    Thanks for the reply... what did you use to create the chron job?
  6. #4
  7. Headless Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    16,977
    Rep Power
    9647
    Originally Posted by SeanF
    Thanks for the reply... what did you use to create the chron job?
    A cron job is just the system automatically running a command according to the schedule you set. You don't need a tool to create the cronjob itself, unless you're not comfortable with Linux, and the command is just having PHP run a script.

IMN logo majestic logo threadwatch logo seochat tools logo