Ian Purton Home

Adding paypal subscriptions to your rails application

23 November 10

I looked at some of the solutions for adding Paypal subscriptions to my site and there are a few. My main issue was that some seem to add models and controllers, others are plugins, and still others actually just don't work. I wanted a 1 controller solution.

So here's a very simple controller that handles the Paypal IPN for subscriptions.

To use this controller you'll need to create a subscription button. I did this via the Paypal admin by going to "Profile" and selecting "My Saved Button". This will then create you some button code that looks like he following.

You'll note I've added my own custom attribute called "custom" which I use to store the plan the customer has selected. I had to create 3 buttons 1 for each plan. You don't need the notify_url as you can set this in your Paypal admin. I've heard anecdotal evidence that Paypal is not the way to go for SaaS sites, but for me during I found it be a reasonable way to sign up. It would be interstiong to see a usability study comparing paypal to other subscription methods.

You'll also need to switch on IPN in your Paypal admin to get this to work. Again this is under profile / admin. The controller code is then simply.