Setting up a subscription site with Drupal and Ubercart in 15 minutes
I planned on just giving a high level overview of how I typically go about setting up a subscription based Drupal 6 website. I planned on just creating a primer for someone to look over, but I decided to give myself a challenge and see if I can create the entire site in 15 minutes.
Another thing to note is that I will start from nothing and build a simple subscription site in Drupal in 15 minutes with just the default Garland theme. I will also be writing this blog post at the same time with all the commands or actions I perform on the site. I am not sure if I will get it finished in 15 minutes, but I guess we will see.
Before we start I am going to lay out the road-map I am going to follow when building this very minimal subscription site. Like I said, this won't be fancy, but it will work.
|Create a fresh Drupal site with Aegir||2 min|
|Download/Install needed modules using drush||3 min|
|Configure Ubercart and payment gateway settings||5 min|
|Set up the site roles||1 min|
|Configure a simple subscription||3 min|
|Frantically scramble to make it usable||1 min|
Note: (last one before I start) Currently you will have to make a decision. If you want to use the included subscription module that comes with Ubercart Recurring, you will either need to apply a patch to Ubercart 6.x-2.4 version or just install the latest dev release of the module. More information on the patch route can be found in the README of the Ubercart Recurring module, but if your looking for the easy route, just download the latest dev release.
OK. Got my stopwatch... ready, set GO!
Create Drupal 6 site
OK set up a site called subscription.codekarate.com. Just waiting for the site to be created. Its on my dev environment so I need to add it to my hosts file.
Created site, logged in, changed admin username and password.
drush dl token pathauto uc_recurring
drush dl ubercart-6.x-2.x-dev
Now going to admin -> build -> modules to turn on the needed modules
- Conditional Actions
- Credit Card
- Test Gateway
- Recurring - Hosted Gateways
- Recurring Payments API
- Recurring Product Fees
- Subscription Manager
Ran into a tiny snag, took longer then expected.
Set up credit card encryption by creating a directory on my server outside the Drupal root. Was going to configure some other store settings but since I am behind I am going to skip it for now.
Admin -> Roles -> Created a site role called subscriber
At this point you would want to give this user extra permissions for subscribing to the site. I don't have any extra permissions yet so I am going to call this good.
Admin -> Subscription Manager
- Click Create Subscription
- Give it a title and description
- Add a payment option, I set 1 month, $5, and unlimited billing cycle
- Add roles, clicked subscriber to add on purchase then "ctrl" clicked on subscribe for revoked when a subscription ends
Now a quick test. Clicked on the title of the subscription in the subscription manager to get to the node page for the subscription. I edited it and added a menu item so I can get to it.
Now the link is there and I am ready to go. Purchase the subscription by adding it to my cart, proceeded to the checkout page, filled in my info, grabbed a test credit card number that I use for testing purposes, reviewed my order and finished my checkout.
Now if I go to "My Account" and recurring fees I can see that I have a $5 monthly recurring fee. Also you will notice that your user now has the "subscriber" role.
Wow... So I didn't make it in 15 minutes... maybe that was a little too ambitious. If I did it again and followed the same steps I am sure I could do it much faster.
There are still some things to note. First right now it is just set up to use the test gateway. This means that it is not completely functional yet. You will need to set up either Paypal or Authorize.net to get it completely working. Since this is just an example I didn't go through setting up the gateway. Setting up Authorize.net for recurring payments is relatively easy once you get the API keys. I have not had a lot of experience setting up Paypal but I am guessing it is fairly similar. The Ubercart recurring page has information about which gateways work with the modules.
Drupal makes building a simple subscription site quick and easy, however it is possible to extend this with some more time (and maybe some more modules) to make it very powerful and flexible. So if you want to provide a way for users to subscribe to specific sections of your site, content on your site, or services your site provides, you should be able to build it now.
This was thrown together very quickly so let me know if you run into any problems or have any extra suggestions. The test site I created is not live, so if you try to get to it, it will not work.