Adding Google Play store in-app purchasing

Pugpig comes with support for in-app purchases through the Google Play store when correctly configured. The Google in-app purchase API is described here. Pugpig manages most of the complexity for you, but you will still need to understand the basic concepts.

Enabling in-app purchases for your app

Pugpig requires that your single-entitlement product SKUs have a consistent format - they must all have a common prefix. For example, the following product IDs would be suitable:


All these products have common prefix com.companyname.publicationname.issue.

Subscriptions are supported in a similar way. A subscription prefix SKU must not start with the same prefix as one of the single-item products. You will probably want to add a few durations, e.g.


Configuring your CMS

Your CMS must include a Pugpig Google Play iAP authorisation endpoint. Pugpig uses this endpoint to confirm that you have permissions to download a specific document. You can find more information about authorisation endpoints in our api guide.

You will also need to configure your CMS to mark certain products as paid in the OPDS feed that Pugpig uses to track available content. You can find more information in our api guide.

If you are using one of our existing Pugpig Connectors, this functionality should already be available; you should just need to configure it correctly.

Configuring Pugpig to support in-app purchasing

You will need to include the Pugpig Google in-app purchasing JAR.

You can read about Google in-app purchasing in more detail on the Android developer site's iAP overview.

Pugpig needs to know your Pugpig Google iAP authorisation endpoint, how to identify your product and your Google Play public key. In your, look for code similar to this (it should be commented out):

 public void didFinishLaunching() {
    // TODO: If you need to support paid content, this is where you set up your authorisation providers.
    // We need to provide the base64-encoded Google Play store public key before we do anything else
    // Google recommend you obfuscate this
    // Register your in-app purchases 
    dm.addAuthorisation(new GoogleAuthorisation("http://.../", "com.companyname.publicationname.issue"));
    // Register your subscription SKUs
    dm.addAuthorisation(new GoogleSubscriptionAuthorisation("http://.../", "com.companyname.publicationname.subscription.7days"));
    dm.addAuthorisation(new GoogleSubscriptionAuthorisation("http://.../", "com.companyname.publicationname.subscription.1month"));

Uncomment the modes you wish to support (you can have both at the same time). You must first set your Google Play store public key. Google recommend you obfuscate this as described in For both of the providers, the initial URL parameter must point to your Pugpig Google iAP authorisation endpoint. For single-item authorisation (i.e. purchasing a single entitled item, usually a single issue) the second parameter is the product id prefix. In the example above, the prefix would becom.companyname.publicationname.issue. For the subscription authorisation provider, the second parameter is the subscription id for your subscription product. You can add several, each with a unique SKU.

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request


Powered by Zendesk