aMember and Drupal – Recurring Subscriptions with Bundled Products

amember drupal integrationA few years back I did an interesting integration of aMember with Drupal. aMember is a flexible membership and subscription management PHP script that allows you to set up paid-membership areas on your site. In this case, the protected area was a Drupal community website with various features like forums, profiles, private messaging, and archived content. With its Drupal integration, aMember allows you to link various subscription products with Drupal roles and thus control access to the different parts of your Drupal site (or different types of content). In this case, subscription payments were handled by 1ShoppingCart, a separate 3rd party payment processing system which integrates with aMember. Subscriptions were 30 days long with recurring payments handled by 1ShoppingCart at the end of those 30 days. Here was the interesting part: With a pre-existing member community, this client wanted to sell a new separate product (unrelated to the current community) but bundle it together with a subscription to the current aMember/Drupal community site. To make things more complicated, they wanted the new subscription to start 60 days after their purchase date (and thus start recurring billing 30 days after that). When you use 1ShoppingCart to handle your payment processing with aMember, you need to specify a 1ShoppingCart product ID number when you add the product. This is how the subscriptions are linked, and this is how 1ShoppingCart knows how to handle the recurring billing for this product (ex: how many days it is good for, how much it costs, etc.). 1ShoppingCart allows you to sell bundled products as a “bundle offer” — which is good. However, the product ID for a bundle offer and the product ID for a singular product are totally different. Also, they use completely different payment page URLs so the functionality to handle this is not built into aMember. I looked all around the Internet for a way to sell a product in aMember that was actually a bundled product in 1ShoppingCart, and to have 1ShoppingCart know how to handle the recurring billing for the subscription (90 days in the future no less). There were several discussions that all seemed to indicate that it was “possible”, but nobody knew how to do it. 1ShoppingCart support seemed to have “heard rumors” of someone having achieved such a feat, but they had no idea how to do it either. After much digging around I found a (very hack-ish) solution! First, in 1ShoppingCart I created two new products. The first was for the new product priced at $200. I listed it as a singular product, with no link to recurring billing or aMember, with the title “Product 1.” Selling this product earns commission for our affiliates, and using 1ShoppingCart affiliate settings in the system works well. Then, I made a second product priced at $0.00. This listing was linked to aMember with the title “Product 2″ and I set the recurring options for this product to be the normal $100/month price. Because we do not want this subscription product to be active yet we set the recurring cycle to 30 days and the recurring start duration to be 60 days (so their subscription won’t start for multiple amember products drupal60 days). I then set other affiliate commission information. With these settings, you can bundle together the 2 products and the customer will pay a total of $200 now for Product 1, and then they will get subscription access for Product 2 starting in 60 days with recurring billing of $100 every 30 days after that. The next step was to create a new aMember product titled “Product 1 with free Product 2″. I set the price to $200, the duration to 30 days, the trial 1 price to $0.00, and the trial 1 duration to 60 days. I checked recurring billing and set the “Fixed subscription start date” to an exact date 60 days after we started allowing new signups (in this case our sign-ups only lasted a few days so this was acceptable, and it made all subscriptions start on a specific date. If you allow signups over a longer period of time you will need to update this setting every day/every few days or set up a cron job to update the database field directly on a daily basis). I set the rest of the fields per our needs, and then for the 1ShoppingCart product ID number, I put the ID for Product 2. If you look in your “/amember/plugins/payment/1shoppingcart” directory, there is a file called “”. Look for “function do_bill” near line 59. This is the function that turns the 1ShoppingCart product ID number for the aMember product into the 1ShoppingCart URL for payment. Normally, you do not need to modify this URL as all regular 1ShoppingCart products use the same URL format. The bundled products, however, use a totally different format. You can do something like this to intercept the ID and use a different URL for this product: function do_bill($amount, $title, $products, $u, $invoice){ global $config; $_SESSION['_amember_payment_id'] = $invoice; if ($products[0]['1shoppingcart_id'] == PRODUCT2ID) { $vars = array( 'mid' => 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX', 'gid' => '1a111111aaaa1111aaa111aa111aa11a', 'AMemberID' => $invoice, 'PostBackURL' => $config['root_url'] . "/plugins/payment/1shoppingcart/ipn.php", 'bn' => 1, ); return $this->encode_and_redirect("", $vars); } else { $vars = array( 'MerchantID' => $this->config['merchant_id'], 'ProductID' => $products[0]['1shoppingcart_id'], 'AMemberID' => $invoice, 'PostBackURL' => $config['root_url'] . "/plugins/payment/1shoppingcart/ipn.php", ); return $this->encode_and_redirect("", $vars); } In this case, the “PRODUCT2ID” is the 1ShoppingCart ID of Product 2 (the format is like 1234567890). You can find the values for ‘mid’, ‘gid’, and ‘bn’ in 1ShoppingCart by going to your bundled product and looking at the “1 Step Checkout Link”. Hooray!

Loading Facebook Comments ...
Comment on this blog postorContact FRUITION.

Leave a Reply