Add In App Purchases to Your App

Note: this feature is not available on all plans, and may cost extra.

After you have created your in app purchases for iOS and Android, it's time to add them to your app. Here's an overview:

  1. Create the purchase page and add it to your app menu.
  2. Add the in app purchase plugin to your site.
  3. Make sure you have the Cordova IAP plugin code in your custom config, then rebuild your app.

Create the Purchase Page

Begin by creating a new custom HTML page in your app customizer. Add this code to start:

Edit the price, terms, and description. Apple requires you to have a link to your privacy policy, and an exact description of what the user gets and how they are charged.

The <in-app-purchase> component outputs a form that includes an email, username, and password. After purchase, a user is created through our in app purchase plugin.

productId - (required) must match your iOS in app purchase product ID
productIdAndroid - (optional) only use this if product ID is different for Android, otherwise Android will use productId above
opens - (optional, default = 15) the amount of app opens until we check if subscription is still valid
secret - (required) the app shared secret for iOS
isSubscription - (optional) set to "false" if this is a one-time purchase
removeAds - (optional) set to "true" if this purchase should remove Admob Ad banners
noLogin - (optional) set to "true" if login, registration, and validation with WordPress are not required. For example, if this purchase is just to remove ads in the app. No user will be created in WordPress.

Save this page and add it to your menu.

Next, make sure you have the in app purchase plugin installed and activated.

Add this custom config code added to your app in the settings tab:

<preference name="phonegap-version" value="cli-8.0.0" />
<plugin spec="https://github.com/scottopolis/cordova-plugin-inapppurchase.git" />

Rebuild your app.

Testing Purchases

First, login to your WordPress site and visit the AppPresser settings. Click the "Log" tab, then check "enable logging." This will allow you to see the API calls if there is a problem.

If you setup test users as per our documentation, you can build the app with dev certs for iOS, and no key for Android. Download the app to your test device and try the purchase. 

For iOS, you will be prompted to login. Use your sandbox tester email and password.

For Android, you can add yourself as a tester in the Google Play Console under Settings => Manage Testers. You should be able to test the purchase with your normal account, or you can log in as a tester.

Test subscriptions do not match the normal schedule, you can look up the renewal times online.