The Subscription Module Add-on with PayPal allows WP-Members to limit a user to a specific subscription period and allows you to charge for subscriptions using PayPal’s IPN.
Version 0.2 introduced an option for recurring payments and an improved admin interface. You also no longer need to add functions for wpmem_post_register_data and wpmem_payment_button filters. These are built into the plugin.
The new 0.3 release adds the option to delete pending users – those new registrations that have not completed payment. You can purge these users based on a value of “older than X days.” You may also export these users as a CSV when you delete them.
Registration and Payment Flow
The PayPal subscription extension utilizes the PayPal Instant Payment Notification (IPN) system to notify your site that a user has paid and to extend their subscription expiration date accordingly.
The registration flow when using the extension is as follows:
- User registers on your site, a new user account is created and login credentials are emailed
- Upon successful registration, the user is presented a PayPal button to take them to PayPal to complete payment
- Upon successful payment, the user is returned to your site
It is important to note that while a user account is created for the user, they are unable to view any restricted content until their payment is processed by PayPal and the IPN is successfully passed. The user is still able to login and view their profile which will indicate that they have not completed payment. This way, if they leave the registration process without completing payment, they can return to complete payment later. But in the meantime, if they try to access any restricted content, they will not only not be able to view the content, they will also be presented with a message indicating they need to complete payment and a PayPal payment button.
This extension installs as a plugin. You can download the installation package as a zip file. Then use the new plugin uploader or unzip the package and FTP transfer to your plugin’s folder.
Once the extension is installed, you can go to Plugins > Installed Plugins to activate.
Setting Up the Extension
The first thing you need to do to set up the PayPal Subscription extension is to go to the WP-Members Options tab and indicate that you are using time-based expiration. You will notice that with the inclusion of the extension, there are two additional settings available; one for time-based expiration and the other for offering a trial period. Select trial period only if you are offering a trial period for your subscription. These settings are highlighted in red in the image to the right.
The next step in setup is to configure the extension’s options. These are found in the Subscriptions tab.
First set the time period, price, and name for your trial period (if used) and regular subscription period. Indicate the currency the price is in, and the type of transaction you will use (basic/regular billing or automated recurring billing).
Next, you will need to indicate your PayPal User ID and whether this is live or sandbox. NOTE: if you are using the sandbox for testing, the PayPal User ID MUST be that of a sandbox user account, NOT your regular PayPal ID.
It is highly recommended that you test your setup with the PayPal sandbox prior to going live. This will allow you to make sure that PayPal can find your IPN listener and that the IPN listener if functioning correctly.
If you have difficulty getting transactions to work in the sandbox, you may wish to enable logging with the toggle in the settings. This will allow you to gain some additional information on what is being sent through the IPN. An additional testing step may include using the PayPal IPN simulator (more on this in the section on the PayPal developer tools below).
If you want to include a login page for the return from PayPal, set this page in the optional setting.
If you are not using a free trial, it is recommended that you set the extension’s settings to display the PayPal payment button in the successful registration message.
IPN Log File
You may enable basic logging for tracking problems with the IPN by checking “Enable logging” in the extensions settings tab. This will create a log file for you in the plugin’s folder. As data is written to the log, it will be displayed on the plugin’s settings tab below the settings. Essentially, it will indicated the time of the transaction, the status, and the action (which should indicate the user ID and that the user’s expiration date was moved forward).
It is not recommended that you continue to use the log file on a live system once you know you have things functioning. This is primarily for debugging potential IPN issues. You should use it when using the sandbox, and maybe when you first set up live transactions just to verify you are working.
You can clear the log file by checking the box “Clear Log File” and submitting.
When you are finished with the log file, you can delete it. Turning off logging will also remove the log file.
Individual User Profile
The extension adds a line to the WP-Members custom fields in the individual user profile to indicate the user’s subscription status.
When the user first signs up, they will be listed as pending until they complete payment.
Once the user completes payment, it will indicate their subscription status (subscription or trial) and their expiration date.
In all cases, you have the option of extending their expiration date or expiring the user. Expiring the user will set their expiration date to now minus one day.
Bulk User Actions
Users can be expired from the bulk users actions available on Users > All Users. You can also expire individual users from the user table as the extension adds an expiration link to the hover menu. Expiring the user will set their expiration date to now minus one day.
Delete Pending Users
You may also select to export the list of users that you delete as a CSV (select “Export deleted users as CSV”).
If you want your export file to include ALL pending users – those deleted and also those that are not deleted – select “Include all pending users in export.” Those users that are deleted will be marked as such in the export file.
Because this involves the deletion of users from the database, you must confirm that you intend to execute this action.
PayPal Developer Tools
It is highly recommended that you test your setup with the PayPal sandbox. You use this by going to http://developer.paypal.com and creating a developer account. Once you have an account, you can login and go to Applications > Sandbox Accounts.
In the sandbox, you will need to create at least two accounts, one for the merchant and one for the buyer. Use the merchant for the User ID in the extension’s settings when you are testing with the sandbox. Use the buyer account to “pay” for the subscription when testing the registration process. That test user should receive a valid transaction and have their expiration date set according to your subscription period. If so, good – you can go live. If not, then you should do additional testing to see why the transaction did not work.
You can also use Applications > IPN Simulator to send a simulated IPN transaction without actually registering a user. This will allow you to determine if PayPal can see your IPN and the IPN is properly functioning.
Get the IPN handler information from the extension’s settings tab under IPN Location. Paste that into the handler URL. Select Web Accept for the transaction type.
That will give you a large amount of other options in the form. You can leave all of these as-is. I recommend two tests:
- Send through the first test with just the defaults. You should get an indication of a valid IPN test if it finds the listener and the listener responds. If not, you may need to troubleshoot why it can’t find the listener. (NOTE: your test site MUST be out in the open for this to work and the domain must be valid. If you are testing on localhost or some test system that is not open, PayPal won’t be able to see it and you won’t be able to test it).
- Second, you should test with a user ID from your test system. That would be the numeric user_ID of a registered user on your test site. Enter that in the field at the bottom marked “custom”. If you get a successful IPN transaction, then take a look at the user’s expiration in their profile. You should see the expiration advance by one unit of time.
Once you’ve tested the IPN and it works, you can go live and use your regular PayPal ID (should be an email address – not a numeric merchant account number).
Get the Extension
You can download the extension on the downloads page.