Create In App Purchases for Android

Overview

  • Create your Google Play Store listing
  • Get your billing key
  • Create a manifest.json file, add billing key, and add to your app on myapppresser.com
  • Build your app with a release key on PhoneGap Build
  • Create a beta release on Google Play and upload your app .apk
  • Create your in app purchase

For Android you must first create a store listing for your app on the Google Play store.

Get Your Billing Key

From the Google Play dashboard, click your app. Go to Development Tools => Services and APIs.

Under Licensing and in-app billing, copy the billing key. You will need this later.

If you do not see a billing key, you may need to setup your billing profile first.

Manifest.json File

Create a new file called manifest.json. Add this code:

{ "play_store_key": "MIIBIjANBgkqhkXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" }

Replace the key with your billing key. This file needs to go in the root www folder of your app before you upload to PhoneGap Build. We can help you with this.

Upload .apk to Google Play store with billing permissions

You must upload an .apk with billing permissions, to do that you just need to add the In App Purchase plugin to your app and rebuild for the app store.

Add this code to your custom config in the Settings tab of your app customizer: 

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

Note: the cli-8.0.0 line will be removed in a future release

Build your app, it needs to be hooked up to PhoneGap Build.

Build your app with a release key in PhoneGap Build.

Download the apk file, this is what you will upload to the Google Play Store.

Create a Beta Release

In the Google Play store, click on your app, then go to Release Management => App Releases. Under Beta, click create release or manage releases. Create a new closed beta release, add your email to the list of testers, and upload your apk there.

You can test the app by downloading it from the QR code in PhoneGap Build or in myapppresser.com.

Create the In App Purchase

Go to your publishing dashboard, and click on your app. Expand "Store Presence" and click on In App Products.

You may be prompted to setup a billing profile, you will need to be approved before you can add a purchase.

To create a subscription, you must click the "Subscriptions" tab. Click the blue button to create a purchase or subscription.

For Product ID, it's easiest if you use the same ID as iOS. For example, "membersubscription" like we used above.  It's ok if you used a different ID, just make sure you setup the form correctly in the app with 2 different IDs.

Fill out the fields and set the purchase to Active.

When you are testing in app purchases, you do not need to use the release version of your app. You can go to PhoneGap Build and change the signing key back to "No key selected."

Proceed to add the purchase form in your app.