Follow

Adding Amazon in-app purchasing

Our Pugpig SDK (and Pugpig Products) come with support for in-app purchases through the Amazon App Store when correctly configured. The Amazon 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.

Note: As of 20 Nov 2014 Amazon's In-App Purchasing (IAP) v1.0 was deprecated and replaced by IAP v2.0. Pugpig releases from December 2014 supported Amazon's IAP v2.0 (applies to Pugpig SDK v2.5+, Pugpig Products 1.3.1+ and Connectors; Wordpress 2.1.0, Drupal 7.X-2.1.0 and Standalone 2.3.0+) 

Enabling in-app purchases for your app

You must ensure your app is setup and configured to support in-app purchasing in Amazon's mobile app distribution portal (https://developer.amazon.com/myapps.html). The following guide for Submittting Your Apps and FAQ's describes what is required.

Pugpig requires that your single-entitlement product SKUs have a consistent format - they must all have a common prefix set up across all the app stores (iTunes, Amazon, Google Play, Windows).

For example, the following product IDs would be suitable:

  • com.companyname.publicationname.issue.100
  • com.companyname.publicationname.issue.101
  • com.companyname.publicationname.issue.102
  • com.companyname.publicationname.issue.103

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

At the moment Pugpig only supports a single subscription (with multiple durations, if required). The parent subscription SKU must not start with the same prefix as one of the single-item products. For example, com.companyname.publicationname.subscription would be suitable as your subscription SKU. You will probably want to add a few durations, e.g.

  • com.companyname.publicationname.subscription.7days
  • com.companyname.publicationname.subscription.1month

Configuring your CMS

You will need an Pugpig Amazon iAP authorisation endpoint, sometimes referred to as a receipt validator included on your server or in your CMS. Pugpig apps use 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.

The migration to support Amazon's IAP v2.0 whilst maintaining any live apps using old IAP v.1.0 required a second receipt validator endpoint. If you are developing your app post January 2015 you only need to worry about v2.0 support which is provided in the latest Pugpig releases (Pugpig SDK v2.5+, Pugpig Products 1.3.1+ andand Connectors; Wordpress 2.1.0, Drupal 7.X-2.1.0 and Standalone 2.3.0+) 

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

Add Amazon's library JAR to your Pugpig project, as described here. You will also need to include the Pugpig Android in-app purchasing JAR (available in SDK v2.5 upwards)

In your AndroidManifest.xml, register the Amazon response receiver:

<receiver android:name="com.amazon.device.iap.ResponseReceiver" >
<intent-filter>
<action android:name="com.amazon.inapp.purchasing.NOTIFY" android:permission="com.amazon.inapp.purchasing.Permission.NOTIFY"/>
</intent-filter>
</receiver>

Pugpig needs to know your Pugpig Amazon iAP authorisation endpoint, and how to identify your product. In your AppDelegate.java, 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.
// singleAuth = new AmazonAuthorisation("http://", "");
// dm.addAuthorisation(singleAuth);
// subsAuth = new AmazonSubscriptionAuthorisation("http://", "");
// dm.addAuthorisation(subsAuth);
...
}

Uncomment the modes you wish to support (you can have both at the same time). For both of the providers, the initial URL parameter must point to your Pugpig Amazon 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 be com.companyname.publicationname.issue. For the subscription authorisation provider, the second parameter is the parent subscription id for your subscription products 1). As mentioned, Pugpig only supports a single parent subscription id at this time.

1) Make sure you add the authorisation objects in the mentioned order, first the single and then the subscription authorisation object otherwise in-app purchases won't work

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

Comments

Powered by Zendesk