mermberfix logo x
The MemberFix Team’s got you covered.
Membership plugins

MemberMouse integration with PayKickStart

MemberMouse integration with PayKickStart

Overview

Many of our MemberFix customers use the MemberMouse membership plugin on their WordPress websites. Recently, one of our customers needed an integration solution for his WP website which uses the MemberMouse membership plugin to protect his content, and PayKickstart (PKS) as his checkout and funnels solution.

The important thing to remember is that in this case, PKS is the app which manages all of the members’ billing.

MemberMouse doesn’t manage the billing anymore, PKS just sends a notification to MemberMouse to continue or revoke access depending on if the payment came in or not. However, PKS didn’t have a simple way for our customer’s members to cancel their subscriptions.

The members were able to cancel their MemberMouse access to the members area, but MemberMouse didn’t send a notification back to PayKickstart to cancel their billing as well, which meant that our customer had to do this manually. In short, our customer needed a solution to allow members to cancel their MemberMouse  memberships inside of the members area on the website and be sure that PKS is notified about it and took the appropriate billing action (cancellation of the subscription).

The whole process to achieve this will consist of a few phases, to be easier to understand it, but first we will have some preliminary steps. During this process we will use Zapier to establish a connection between PayKickstart and MemberMouse.

Preliminary Steps

1 – Login to your PayKickstart account and click on left menu link Payments => Subscriptions

payments subscriptions - MemberMouse integration with PayKickStart

2 – You will land on a page with all the subscriptions. Select one subscription which is for a membership you offer on your website and click on the Details blue icon which corresponds to it, on the right side.

paykickstart subscription details - MemberMouse integration with PayKickStart

3 – On the pop-up window which opens you will see the subscription details. We will need Customer Email and Subscription ID which will be the parameters that we will use throughout the whole process.

paykickstart subscription detail - MemberMouse integration with PayKickStart

PHASE 1 – Send subscription ID from PayKickstart to WordPress database for every new order

1 – Login to your WordPress website and go to MemberMouse => Checkout Settings. Create a new custom field by clicking on “Create Custom Field” button and name it subscription_id.

membermouse custom field - MemberMouse integration with PayKickStart

2 – Login to your Zapier account, click here and accept the private invitation to PayKickstart Zapier integration.

zapier accept invite - MemberMouse integration with PayKickStart

3 – Then visit “Connected Accounts” inside of Zapier, type Pay in the top search box and you will be able to see “PayKickstart (1.0.0) By Invite”. Click on it.

paykickstart1 - MemberMouse integration with PayKickStart

4 – A pop-up window will appear. Add Your PayKickstart API Key in Zapier. Your API Key can be found in the top right navigation “Platform Settings” of PayKickstart. Note: You must be on the Professional or Premium plan to use this feature.

allow zapier - MemberMouse integration with PayKickStart

5 – On your Zapier account page click on top button “Make a Zap!”.

make a zap - MemberMouse integration with PayKickStart

6 – Choose a trigger app by clicking on PayKickstart icon or by typing “PayKickstart” in the search field if the icon is not visible. Then click on “Continue” button.

choose trigger app - MemberMouse integration with PayKickStart

7 – Choose New Order as trigger on the next page. Then click on “Continue” button.

choose trigger - MemberMouse integration with PayKickStart

8 – On the next page you will see the PayKickstart + Zapier connection. Click on “Continue”.

zapier connect account - MemberMouse integration with PayKickStart

9 – On the next page you will need to select the PayKickstart campaign and products.

pks campaign 1 - MemberMouse integration with PayKickStart

10 – On the next page you see the successful test.

pks test - MemberMouse integration with PayKickStart

11 – Next go to Action section of the Zap and choose “Webhooks” which it is listed under “Built-in Apps”.

choose action - MemberMouse integration with PayKickStart

12 – On the next page select GET and click on “Continue” button.

webhooks get - MemberMouse integration with PayKickStart

13 – The next page will need more work and I will explain this in more detail. You need access to your website FTP. Just duplicate the page.php file from your theme files and name it zapier-test-page.php. Open zapier-test-page.php and add this to the top of it:

<?php

/* Template Name: Zapier Test */

?>

We have just created a template WordPress file.

14 – Go to your WordPress Dashboard and click on Pages => Add New. Name the page “Zapier Test” and select Zapier Test as page template. So the link to the page will be yourdomain.com/zapier-test/.

zapier test page - MemberMouse integration with PayKickStart

15 – Go back to your Zapier page Action => Edit template and do the following settings:

edit template settings - MemberMouse integration with PayKickStart

So, for the URL section just add the address to the page we have created on WordPress ( https://yourdomain.com/zapier-test/ or http://yourdomain.com/zapier-test/ ). Then we will select Buyer Email as the first parameter which we will need to send and name it “buyer_email”. The second parameter is Subscription ID and we will name it “id”.

16 – Now we will need to add some php code to the page template which we have created. Open zapier-test-page.php and just below the opening <body> tag add the below code:

<?php

global $wpdb;

// get the two parameters from Zapier
$user_email = $_GET;
$subscription_id = $_GET;

// get user ID from wp_users table
$user_id = $wpdb>get_var(“SELECT ID FROM wp8c_users WHERE user_email = “$user_email“”);

//number of rows in mm_custom_field_data table
$custom_field_num_rows = $wpdb>get_var(“SELECT COUNT(*) FROM mm_custom_field_data”);

//check if there is a value for subscription_id MM custom field, which belongs to user_id
$subscription_id_value = $wpdb>get_results(“SELECT value FROM mm_custom_field_data WHERE user_id = “$user_id“”);
$subscription_id_valueNum = $wpdb->num_rows;

// date when record is added or updated in database
$date_added = date(“Y-m-d H:i:s”);

if ( $subscription_id_valueNum > 0 ) {
$wpdb>update(
“mm_custom_field_data”,
array(
“value” => $subscription_id,
“last_updated” => $date_added
),
array( “user_id” => $user_id ),
array(
%s,
%s
),
array( %d )
);

} else {

$wpdb>query( $wpdb>prepare(
“INSERT INTO mm_custom_field_data
( custom_field_id, user_id, value, date_added, last_updated )
VALUES ( %d, %s, %s, %s, %s )”
,array( 1, $user_id, $subscription_id, $date_added, $date_added )
) );

}
?>

So basically the code above is inserting into the database the subscription ID for every user whenever a new order happens on PayKickstart.

17 – We are done with the first phase! ?

PHASE 2 – Notify PayKickstart whenever an user cancels his subscription from MemberMouse members area

So now we have the subscription ID for every user, which corresponds to the PayKickstart subscription ID. Now we will need to let PayKickstart know when the uses cancel the subscription directly on MemberMouse members area on website.

1 – On your Zapier account page click on top button “Make a Zap!”.

make a zap - MemberMouse integration with PayKickStart

2 – Choose a trigger app by clicking on Email Parser which it is listed under Built-in apps. Then click on “Continue” button.

email parser - MemberMouse integration with PayKickStart

3 – Choose New Email as trigger on the next page. Then click on “Continue” button and you will land on Connect Email Parser page. Open https://parser.zapier.com/ in a new tab and click on “Create Mailbox” to create the email address to which the email will be sent. Just copy the email address which is generated on the next page. When you edit the email template, just select the subscription_id which it is what we will need for this step.

email parser - MemberMouse integration with PayKickStart

4 – Go back to the Connect Email Parser page, select the Parser account and click “Continue”.

connect email parser - MemberMouse integration with PayKickStart

5 – On the next page just select the mailbox which you have created and click “Continue”.

select mailbox - MemberMouse integration with PayKickStart

6 – We will create a Push Notification in MemberMouse to send an email to the Zapier mailbox which we have created. This email will be sent when a membership is canceled. Just go to the WordPress website and click on Developer Tools under MemberMouse left side menu. Click on Create Push Notification button and choose the settings like in the below image. The subscription_id parameter will be sent to the Parser template when you will select it, like we have discussed at step 3.

push notification 1 - MemberMouse integration with PayKickStart

7 – Now go back to Zapier. Click “Continue” on the next page too and you will go to a new page where you need to choose the action. Select “Webhooks” which it is listed under Built-in apps. Then click on “Continue” button.

webhooks - MemberMouse integration with PayKickStart

8 – On the next page select GET and click “Continue”.

get - MemberMouse integration with PayKickStart

9 – You will land on a page similar to the page from step 12 of Phase 1. Repeat steps 13, 14 and 15 from Phase 1 except that the php file you will create is zapier-test2-page.php. The parameters you will need are Parse Output Email and Parse Output Invoice. The URL will be yourdomain.com/zapier-test-2/.

get details - MemberMouse integration with PayKickStart

10 –  Now we will need to add some php code to the page template which we have created. Open zapier-test2-page.php and just below the opening <body> tag add the below code:

<?php

// get the parameter from Zapier

$subscription_id = $_GET;

$t=time();

//Set up API path and method
$base_url = “https://app.paykickstart.com/api/”;
$route = “subscriptions/cancel”;
$url = $base_url . $route;
$post = true;

//Create request data string
$data = http_build_query();

//Execute cURL request
$ch = curl_init();
if ($post) {
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
} else {
    $url = $url . “?” . $data;
}
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
$output = curl_exec($ch);
curl_close($ch);

?>

Add Your PayKickstart API Key for “auth_token”. Your API Key can be found in the top right navigation “Platform Settings” of PayKickstart. Note: You must be on the Professional or Premium plan to use this feature.

11 – Go to Zapier and test this step. We are done! 🙂

You may also enjoy...

WordPress based membership sites have certain requirements, and make use of certain applications that, in my experience, makes most of the popular hosting providers a poor choice.
Do you want to make your YouTube video disappear automatically after it finishes playing? This quick & dirty tutorial that will show you how!
Want to organize your Zoom call recordings in your Airtable base? This step by step tutorial will show you how to automatically send recording info to Airtable…
In this article, you’ll learn to integrate WordPress with Airtable to build a coupon code redemption system. It also has code snippets included!
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments