In App Purchase Plugin Setup

For In App Purchases to work, you need 2 plugins active on your site.

1. The core AppPresser In App Purchase plugin, download here
2. A custom membership integration plugin

The second plugin needs to have some custom code, since every membership site uses a different plugin, a different membership level, etc. We have some example code below, and you can email us for help with this.

The In App Purchase Plugin

The core In App Purchase plugin does not require any configuration. Just activate it and you are good to go.

It creates 4 WP-API endpoints: new purchase or restored purchase, receive iOS subscription notifications, validate Android receipts, and check subscription status.

A successful purchase adds this user meta: 
in_app_purchase, boolean 
in_app_purchase_transaction_id, string

A successful purchase calls this action:

do_action( 'iap_new_purchase', $user_id );

The subscription is validated through the iOS Subscription Notification API, and manually for Android. A valid subscription check calls this action:

do_action( 'iap_subscription_renew', $user_id );

You should use that hook to check if a member is in the appropriate level in your plugin, and add them if they are not. Note that this will be called for new purchases and renewals.

An invalid receipt for Android or iOS cancellation will call this action:

do_action( 'iap_subscription_cancel', $user_id );

You should use that action to remove a user from the premium membership level.

If there is a problem a user can always use the restore purchase checkbox in the app.

Example Membership Plugin Integrations

You need to create a custom plugin that has your membership integration code, and add it to your site.

Here is an example for Restrict Content Pro.

To use that plugin, save it to your computer. Edit line 15 to your subscription level ID, then upload it to your wp-content/plugins folder. Activate it as a normal plugin.

That plugin adds a user to your membership plugin when they purchase, and removes them when they cancel. This code can be modified for any plugin as needed.

Here are more examples, you need to edit the membership level ID in each one before using it.

MemberPress Example Code

WooCommerce Memberships Example Code

Testing Purchases

For testing you can turn on logging in the AppPresser settings under the "Log" tab. That will log any API calls. To leave the log on for more than 1 hour, add this code to your wp-config.php

define('APP_LOG_FORCE_ON', true);

Make sure to remove it when you are done to save server resources.