Right now the core Recurly module has started to provide a mix of functionality, but is not a complete solution at hardly anything. Taking a look at our payment options through Recurly, we have 3 different options:
- Recurly.com Hosted Pages (currently separated out into the recurly_hosted module)
- RecurlyJS integrated payments (more on this later)
- Fully integrated credit card handling through Drupal Commerce (or potentially Ubercart), using the PHP SDK
However for all of these payment options, the central functionality of the module is the same. Users still need to do the following:
- View their subscriptions and invoices.
- Upgrade/Downgrade/Cancel subscriptions
This kind of functionality should be provided by the core Recurly module, because it's necessary no matter what mechanism you're using for payment. Each of the payment options should be separate modules, allowing users to choose the one that makes the most sense for their site.
This patch starts the functionality of the user-facing subscription management by adding a "Subscription" tab on user profile pages (or on node pages if managing subscriptions for OG or similar). It's not functionality-complete, but it stubs out the structure of the module so that we can bring in more collaboration into the project.
IMPORTANT CHANGE: If you're using this module currently, this patch significantly changes the database structure. Rather than using the database to store replicated data from Recurly, this takes the approach of using Recurly for the source of all information on all subscription pages via the API. By effect, "recurly_account" table becomes little more than a Recurly "account_code" to Drupal "user UID" mapping table. I wouldn't recommend updating to the latest dev versions of the module until things settle down a little bit.
| Comment | File | Size | Author |
|---|---|---|---|
| recurly_pages.patch | 34.94 KB | quicksketch |
Comments
Comment #1
quicksketchCommitted to the 7.x branch. Pretty significant changes are going to be coming in for the next few days/weeks. We'll have to evaluate what we want to do with the Drupal 6 branch, which for now is only going to significantly slow down the rate of development.
Comment #2
blasthaus commentedThis is great. I may just add one more consideration in that the subscription uuid, Recurly's unique subscription identifier may be worth considering storing locally. As Recurly supports multiple subscriptions. the uuid makes it easier to handle subscription change requests in the case of multiple subscriptions and is pivotal to keep track of a user's subscription when it comes to processing push notifications. Up until very recently, the payment push notifications did not include this uuid which is necessary if you want to act on anything like a failed payment. Currently, the Commerce Recurly stores only account_code, uuid, current_period_started, current_period_ends, created_on FYI.
Comment #3
quicksketchGood point @blasthaus. Really that means that storing the "status" column in the "recurly_account" table is inaccurate, since an account can have multiple subscriptions. I'm currently not using the "status" column for anything anyway, but it should probably be moved to a separate table, where the UUID for the subscription is also stored.
Comment #4
blasthaus commented@quicksketch Yes that's because like many things, the ability to have multiple subscriptions at Recurly was not possible when this module was first written, so the local 'status' column is definitely out, unless you are talking about the state of the account itself, then it's ok. Possible account states are a bit tricky however since an account can be in multiple states. From the docs:
Account states can be active or closed, however an account can be active and past due, meaning Recurly has at least one past-due invoice amongst the account's subscriptions. The subscription in question that has a past due invoice is not easy to get. Calling
$account = Recurly_Account::get('1');I believe will not produce a past_due state only 'active' or 'closed' (although we should double check this!), however a query to$accounts = Recurly_AccountList::getPastDue();will return accounts with at least one past due invoice. It may be worth putting in a request to Recurly to return an array of states, or at least the failing invoice(s) or subscription uuid(s) when this exists similar to the way they return a pending subscription if it exists. As mentioned, they are as of 2 weeks ago now including the uuid of any subscription when sending a failed payment notification so we know which subscription is failing and don't have to jump through hoops.I've created two new feature request now, one for the Include an Account page for managing accounts so we can resolve how and if this is even necessary (i.e. a user wants to update their name or email address at Recurly vs. we just use hook_user_update() and whether we show a state on the account itself and store it as "status" locally. The other request is Include a past due status on user-facing subscription page as I feel this is very much needed to bring to the user's attention.