CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Subscription to a content type and recurring billing
Pages: [1]

Author Topic: Subscription to a content type and recurring billing  (Read 7306 times)

mr.andrey

  • Guest
Subscription to a content type and recurring billing
August 05, 2008, 03:10:44 pm
Hello there,

We have a yoga studio and record videos there every week. We want to be able to have people subscribe $10/month to access these, and have the billing be automatically renewed every month unless the person chooses to stop it.

Is this possible to do?

Right now we are using eCommerce, and when someone buys the "subscription", they get a role assigned to them until that "subscription" expires in a month or a year. Then members with that role can access the particular video class content type. The only problem is that there seems to be no way of automatic recurring billing in eCommerce Drupal module.

Is this possible to do in CiviCRM?

We're using Authorize.net, but it sounds like it won't work for recurring payments?

"Check this box if you want to give users the option to make recurring contributions. (This feature requires that you use 'PayPal Website Standard' OR 'PayJunction' as your payment processor.)"

Many thanks!
Andrey.

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Subscription to a content type and recurring billing
August 05, 2008, 04:10:12 pm
Recurring contributions are supported for Authorize.net as of 2.0:
http://issues.civicrm.org/jira/browse/CRM-2009

I have not tested this myself - and this is community contributed code - but I think folks are using it in production.

The "help" you've quoted is obsolete - and I've updated it for 2.1 to include Authorize.net in the statement.

That said - you'll need to do some custom work to keep people's drupal roles updated based on their payment status. There's a community developed civicrm_member_roles module that does this synchronization - and you might be able to stitch things together using that along with a modified version of the cron-driven script which keeps CiviMember membership statuses updated (bin/UpdateMembershipRecord.php). Do post back here w/ any solutions you've come up with as I think other folks would find this combination of functionality quite useful.
Protect your investment in CiviCRM by  becoming a Member!

mr.andrey

  • Guest
Re: Subscription to a content type and recurring billing
August 05, 2008, 04:19:13 pm
Thanks for the reply, Dave. I will look into this and check back here when I've made some progress.

Best,
Andrey.

mr.andrey

  • Guest
Re: Subscription to a content type and recurring billing
August 06, 2008, 01:14:45 pm
I think you meant CiviMember_Roles (rather than civicrm_member_roles). It syncs CiviCRM memberships to Drupal roles, and seems to be just the thing to make this possible.

So I'll outline what I'm trying to do here step by step, and see where this goes.

- Install Content Access and CiviMember Roles modules.
- Create a drupal role [subscribed] and a content type [video]
- Give view permissions for [video] to role [subscribed] (using Content Access module)
- Create membership type [Subscribed to Video]
- Sync [Subscribed to Video] with [subscribed] (using CiviMember Roles module)

Now whoever has the membership [Subscribed to Video] will be able to view the content type [video]

So far so good, now comes the tricky part. We need to set up recurring billing.

As far as I understand it, for someone to become a member, they have to go through a contribution page. The membership has a duration, so it can expire in 30 days. Contribution page supports recurring billing, so potentially there is a way to set it up to bill every 30 days automatically by using some HTML/CSS customization.

Does the membership get renewed once someone gets automatically billed?

I welcome your thoughts and ideas on this.

Thanks,
Andrey.

« Last Edit: August 06, 2008, 01:16:50 pm by mr.andrey »

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Subscription to a content type and recurring billing
August 07, 2008, 09:40:44 am
1. Recurring billing on contributions is currently only supported for PayPal Std and PayJunction processors.

2. There is no code yet which would automatically renew a membership based on a recurring contribution being received. However, as I said earlier - I think it would be possible to extend UpdateMembershipRecord.php (or create a new script) which checks for newly completed civicrm_contribution records (probably using a specific contribution_type by convention) and renews that contributors membership when found. Once decent approach to "mark" contribution records as "processed" is to create the link record in civicrm_membership_payment as you renew the membership. The script would then "know" that a renewal has been processed for that contribution record and ignore it on the next run.
Protect your investment in CiviCRM by  becoming a Member!

mr.andrey

  • Guest
Re: Subscription to a content type and recurring billing
August 11, 2008, 09:48:12 am
Quote
1. Recurring billing on contributions is currently only supported for PayPal Std and PayJunction processors.

According to Donald Lobo the following post, the help text is outdated and Authorize.net is supported for recurring billing in version 2.0 [http://forum.civicrm.org/index.php/topic,4251.msg18517.html#msg18517]

Or did I misunderstand it?

Quote
2. There is no code yet which would automatically renew a membership based on a recurring contribution being received. However, as I said earlier - I think it would be possible to extend UpdateMembershipRecord.php (or create a new script) which checks for newly completed civicrm_contribution records (probably using a specific contribution_type by convention) and renews that contributors membership when found. Once decent approach to "mark" contribution records as "processed" is to create the link record in civicrm_membership_payment as you renew the membership. The script would then "know" that a renewal has been processed for that contribution record and ignore it on the next run.

How does UpdateMembershipRecord.php get run?

UPDATE: A cron job with wget seems to be the way.

I found the UpdateMembershipRecord.php.txt file in /bin, it said to put in an email address on line 63. This is line 63:
Code: [Select]
$config->userFrameworkClass     = 'CRM_Utils_System_Soap';
I don't think the email goes here.

UPDATE: It's actually line 130 - look for the $from variable.

UPDATE: There is a how-to located here, under "Membership Status and Reminder Server Requirement": http://wiki.civicrm.org/confluence/display/CRMDOC/Membership+Types

Also, when I rename it to .php and run it manually from a web browser, I get the following error:
Quote
ERROR: You need to send a valid user name and password to execute this file

UPDATE: You now need to have a drupal username and password (with Edit Contact permission) as part of the URL, so it looks like this:
Code: [Select]
http://<drupal_root>/sites/all/modules/civicrm/bin/UpdateMembershipRecord.php?name=<username>&pass=<pw>
« Last Edit: August 11, 2008, 10:54:54 am by mr.andrey »

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Subscription to a content type and recurring billing
August 11, 2008, 11:42:02 am
Quote from: mr.andrey on August 11, 2008, 09:48:12 am
According to Donald Lobo the following post, the help text is outdated and Authorize.net is supported for recurring billing in version 2.0 [http://forum.civicrm.org/index.php/topic,4251.msg18517.html#msg18517]

I made a mistake. The code is there, but no one has upgraded/tested it for 2.0. Authorize.net is a community contributed and supported transaction processor. We need someone who is using it to step up, upgrade and test the code for 2.1 and submit a patch. In 2.1 we've turned off the "recurring" flag for authorize.net to avoid confusion

lobo

A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

mr.andrey

  • Guest
Re: Subscription to a content type and recurring billing
August 11, 2008, 03:32:15 pm
To tie ARB with membership renewal, we basically need to do the following in UpdateMembershipRecord.php:
- Check if a recurring billing has occurred.
- Check what membership was tied to that contribution page.
- Check the membership duration that was tied to that contribution page.
- Set the membership end date ahead.
- Check membership status, and set to current if was expired.

So step by step:

- Check if a recurring billing has occurred.
Contributions are stored in `civicrm_contribution` table. `receive_date` is where the date is stored, so we can store the last run date, and execute the script only if there are new contributions.
Q: Is there a place to store random variables in CiviCRM a la Drupal's `variables` table?


- Check what membership was tied to that contribution page.
Q: Where is the information stored about which membership ties to which contribution page?


- Check the membership duration that was tied to that contribution page.
`civicrm_membership_type` stores the duration of membership.
`civicrm_contribution_recur` stores the frequency of recurring contribution.


- Set the membership end date ahead.
This can be calculated from the `civicrm_membership_type` membership duration.
Alter `start_date` and `end_date` in `civicrm_membership`


- Check membership status, and set to current if was expired.
`civicrm_membership_status` stores the status values
`civicrm_membership`.`status_id` stores the actual status id for a particular membership. This can be checked and changed.

I welcome your feedback and ideas.

Quote
In 2.1 we've turned off the "recurring" flag for authorize.net to avoid confusion
I'm writing this on 2.0, so the Authorize.net should work for now. If nobody steps up, I'll probably put some attention to it.

Best,
Andrey.

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Subscription to a content type and recurring billing
August 11, 2008, 04:23:37 pm
Quote from: mr.andrey on August 11, 2008, 03:32:15 pm
I'm writing this on 2.0, so the Authorize.net should work for now. If nobody steps up, I'll probably put some attention to it.

recurring transaction in Authorize.net will not work in 2.0 unless someone fixes the code for this at bin/ProcessAuthorizeReport.php. That file was community sponsored and supported. It has not been upgraded since v1.7

lobo

A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

mr.andrey

  • Guest
Re: Subscription to a content type and recurring billing
August 12, 2008, 07:29:01 am
Someone posted a comment on the ARB for Authorize.net's project page:

Quote
Shailesh Lende - 30/Jul/08 12:46 PM
Tested and verified for 2.1 rev-16242.

http://issues.civicrm.org/jira/browse/CRM-2009

Also, on top of the page, it says:
Quote
Fix Version/s:      2.0, 1.8

I'm obviously not understanding something here. Does this mean that it still doesn't work on 2.0 or 2.1? Or that the file that comes by default with 2.0 and 2.1 is from version 1.7? It seems like it's been verified to work with 2.1 (and possibly 2.0)? Can I just replace the file (since patching it doesn't seem to work)?

Thanks,
Andrey.
« Last Edit: August 12, 2008, 07:31:33 am by mr.andrey »

mr.andrey

  • Guest
Re: Subscription to a content type and recurring billing
August 12, 2008, 10:28:25 am
In addition to the above question...

I'm working on getting the membership to renew with ARB.

Based on the contribution, we need to find the membership(s) that belong to it, and renew them
   * pull the contributions > $last_run_id
   * check if recurring
   - check which specific memberships belong to these contributions
     `civicrm_membership_block` tells which membership types belong to which contrib pages
     `civicrm_membership` stores the specific memberships and references membership types
     `civicrm_contribution` stores the specific contributions and references contrib pages

I don't see a way how to link a contribution to the membership. The contribution pages and membership types are linked through the `civicrm_membership_block` table, but how do you link a specific contribution to a specific membership to renew it? It could kind of be done through `membership_type_id` and `contact_id`, but that's a bit like trying to trick the system, plus there's the possibility of duplicates.

Any ideas on this?

Also, which are the functions that trigger the membership signup in the first place? Are they reusable or are they based on a specific form w/validation that would be too complicated to alter? Is there an API or some sort?

Thanks,
Andrey.
« Last Edit: August 12, 2008, 10:33:00 am by mr.andrey »

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Subscription to a content type and recurring billing
August 12, 2008, 11:05:09 am
I don't think we've defined an approach for linking "future recurring contributions" to a membership. However, there are some linkages in the data model which MIGHT be usable for this...

civicrm_membership_payment : currently used to link a contribution to the membership that the contributor is paying for (signup or renewal)
civcirm_contribution_recur : I believe this record is instantiated when a recurring contribution is initiated.
civicrm_contribution.contribution_recur_id : FK to civicrm_contribution_recur.id (not sure if existing recurring contrib code is populating this when recurring contributions are recorded ??)

One approach would be to create a civicrm_membership_payment record linking the membership to a recurring contribution record (if auto-renew billing is enabled). This record then becomes the link between incoming recurring contributions and the membership to be renewed.

You still have the issue of limiting processing to contributions > $last_run_id and I'm not aware of a random variables storage area (might check w/ folks in #civicrm IRC on this).

Protect your investment in CiviCRM by  becoming a Member!

mr.andrey

  • Guest
Re: Subscription to a content type and recurring billing
August 15, 2008, 05:31:28 pm
Thanks for the info on all this.

We are now leaning towards using Ubercart for the recurring billing now, since it suits our model quite well, and it already has the modules in place for ARB.

We can interface it with CiviCRM through the Ubercart CiviCRM Integration module.

Best,
Andrey.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Subscription to a content type and recurring billing

This forum was archived on 2017-11-26.