Follow

Adding in-app purchasing through iTunes

Pugpig comes with support for in-app purchases through iTunes when correctly configured.

Enabling in-app purchases for your app

You must ensure that your app has “In App Purchase” enabled on the iOS provisioning portal here, and that you are using the correct provisioning profile.

Adding products to iTunes

Your app must be configured in iTunes connect. You will also need to create your products here. The iTunes Connect Developer's Guidedescribes how to do this. It is your responsibility to test in-app purchasing, so you will need to create test iTunes users to do so. The Developer's Guide gives more details on the process. This article gives more information on things that can go wrong. It's also worth reading the Apple Tech notes on "Adding In-App Purchase to your iOS and Mac Applications".

Pugpig requires that your product ids have a consistent format - the must all have a common prefix. 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.

If you intend to support subscriptions, they will need their own unique prefix. This must be different from the standard in-app purchases. For example, these would be fine with the product ids above:

com.companyname.publicationname.subscription.1month
com.companyname.publicationname.subscription.3month

Please see Adding iTunes subscriptions for more information on supporting subscriptions.

Configuring your CMS

Your CMS must include a Pugpig iTunes 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 CMS connectors, this functionality should already be available; you should just need to configure it correctly.

Configuring Pugpig to support in-app purchasing

Pugpig needs to know your Pugpig iTunes authorisation endpoint, and how to identify your product. Your Pugpig iTunes authorisation endpoint is not the Apple iTunes endpoint (*.apple.com/verifyReceipt). In your AppDelegate.m, look for code similar to this:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
...
  // TODO: If you need to support paid content, this is where you set up your authorisation providers.
  NSURL *appStoreAuthURL = [NSURL URLWithString:@"http://example.endpoint.com/itunes/auth"];
  self.appStoreSingleAuth = [[[KGAppStoreAuthorisation alloc] initWithEndpointURL:appStoreAuthURL identifierPrefix:@"example.productid.prefix"] autorelease];
  [dm addAuthorisation:appStoreSingleAuth];
...
}

The lines will be commented out in the template - uncomment them to enable in-app purchasing. You must provide your authorisation endpoint in the appStoreAuthURL variable, and your product id prefix as the indentiferPrefix parameter of the initWithEndpointURL function. As an example, using the example product ids above would require a product id prefix of com.companyname.publicationname.issue.

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

Comments

Powered by Zendesk