How I got PayPal Subscriptions to work

How I got PayPal Subscriptions to work

by Duane Dunston -
Number of replies: 12

I posted this to the wrong forum initially...

I wanted to be able to convert a course over to Moodle for a small business and they have a subscription AND trial period for their product.

Here's what I did to get most of it to work. In the file:

moodle/enrol/paypal/enrol.html

I added these tags:

Replaced:

<input type="hidden" name="cmd" value="_xclick" />

with:

<input type="hidden" name="cmd" value="_xclick-subscriptions" />

Added the lines below based on the PayPal document: https://cms.paypal.com/cms_content/US/en_US/files/developer/PP_WebsitePaymentsStandard_IntegrationGuide.pdf

The $0.00 trial period doesn't work because if you set a course to $0.00, it doesn't redirect to PayPal (since there is no charge for it). Another chicken and egg problem is that the subscription code, below, worked (redirected me to PayPal) because I set the course to cost $9.99 via the PayPal module in Moodle. However, if I set the trial-period cost to $0.00, the PayPal subscription completes, but the redirect back to Moodle still shows $0.00 was paid so the student doesn't get enrolled into the course. We had to change the model to require a $9.99 payment up front, which they can cancel after 7 days, if they wanted. After the subscription is processed, the PayPal message errors, BUT when they click the button "Return to Course page" from the PayPal window, they get enrolled into the course.

<!-- Trial period -->

<!-- Pay $9.99 (a1) during a 30 (p1) Day (t1) trial period -->

<input type="hidden" name="a1" value="9.99">

<input type="hidden" name="p1" value="30">
<input type="hidden" name="t1" value="D">

<!-- This is a hack because the customer can ask for a refund at the end of the 7 days (we have to advertise that though). -->

<!-- Regular Time period charge $9.99 (a3) each (p3) month (t3) -->

<input type="hidden" name="a3" value="9.99">

<input type="hidden" name="p3" value="1">

<input type="hidden" name="t3" value="M">

<!-- NOTE: This must be set to a3, p3, t3, etc. -->

<!-- PayPal has an a2, p2, t2, etc. option to allow secondary trial periods (see document link above)

We don't use that so we skip over those settings. -->

<!-- Charge until customer cancels (via their PayPal account) or the PayPal account holder for our business cancels the subscription -->

<input type="hidden" name="src" value="1">

All together without all the extra text:

<!-- Enable subscription -->
<input type="hidden" name="cmd" value="_xclick-subscriptions" />

<!-- Trial period -->

<input type="hidden" name="a1" value="9.99">
<input type="hidden" name="p1" value="30">
<input type="hidden" name="t1" value="D">

<!-- Regular Time period charge -->

<input type="hidden" name="a3" value="9.99">
<input type="hidden" name="p3" value="1">
<input type="hidden" name="t3" value="M">

<!-- Charge until it is canceled -->
<input type="hidden" name="src" value="1">

Maybe the PayPal module developers could include options for this in the future. Just thought I'd share what worked for me.

NOTE: It doesn't appear the enrol.html file changes on a regular basis, but for each upgrade of Moodle, I have a backup copy of my manual changes so I can add back after the upgrade.

Average of ratings: -
In reply to Duane Dunston

Re: How I got PayPal Subscriptions to work

by Walter Byrd -

For which versions of Moodle does this work?

In reply to Duane Dunston

Re: How I got PayPal Subscriptions to work

by Mike Finney -

Just an FYI... we will have one the does all the functionality of the regular Paypal plugin.. but with subscriptions... in the next week. Hopefully this will be helpful to everyone. I will post here when it is available.

In reply to Mike Finney

Re: How I got PayPal Subscriptions to work

by Mike Finney -

OK.. The Paypal Subscription plugin is done. It will allow you to choose between One Time Payment or Subscription. Will also allow you to set one price for initial payment and a different for ongoing subscription payment. It replaces your existing Paypal plugin. Unfortunately, we will have to recoup some costs for the moment, but here is the link if anyone is interested in purchasing it...

https://elightenment.qx.ly/b/Gi0A

 

In reply to Mike Finney

Re: How I got PayPal Subscriptions to work

by Richard Manigault -

Is there a working link to the plugin?

In reply to Richard Manigault

Re: How I got PayPal Subscriptions to work

by Mike Finney -

Sorry about that. This should work for you...

https://www.payloadz.com/go/sip?id=2222658

In reply to Mike Finney

Re: How I got PayPal Subscriptions to work

by Richard Manigault -

Is there anything special to do, just upload as a standard plugin? Is it tested with 2.2? Any info on the plugin?

In reply to Richard Manigault

Re: How I got PayPal Subscriptions to work

by Mike Finney -

So far 2.0 and higher should be fine. Not tested though on 1.9 and lower. If anyone does use it with those versions and it works, please let us know. It replaces your existing Paypal plugin. If you want to test it first, just backup your old paypal and you can replace it if you don't like it.

In reply to Mike Finney

Re: How I got PayPal Subscriptions to work

by Mike Finney -

If you run into ANY problems, don't hesitate to PM me and I can help.

In reply to Mike Finney

Re: How I got PayPal Subscriptions to work

by Richard Manigault -

Question- how do I setup a monthly subscription? I don't see any difference in my options.

In reply to Richard Manigault

Re: How I got PayPal Subscriptions to work

by Mike Finney -

Be glad to take a look. Also, will be happy to go over it with you and show you the features. You will need to do a new Paypal payment in the enrollment options.. here are the instructions for setting up the payments. Don't hesitate to PM me to help or to do a walk through with it.

In reply to Mike Finney

Re: How I got PayPal Subscriptions to work

by Richard Manigault -

Thanks Mike the plugin works perfect, saves a lot of time and hassel!