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.
Adding iTunes subscriptions
Pugpig comes with support for auto-renewing subscriptions 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.
If you intend to support the purchase of single products, they will need product IDs that do not conflict with any of your subscriptions. Pugpig expects your product IDs to conform to a regular pattern. Please see Adding in-app purchasing through iTunes for more information on supporting other in-app purchases, and more troubleshooting information.
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 subscription purchasing
Pugpig needs to know your Pugpig iTunes authorisation endpoint, how to identify your subscription, and how long your subscription should run for. 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:@""] autorelease]; // [dm addAuthorisation:appStoreSingleAuth]; self.appStoreSubsAuth = [[[KGAppStoreSubscriptionAuthorisation alloc] initWithEndpointURL:appStoreAuthURL productIdentifier:@"example.subscription.productid" duration:(31*24*60*60)] autorelease]; [dm addAuthorisation:appStoreSubsAuth]; ... }
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 productIdentifier parameter of the initWithEndpointURL function. Theduration parameter should be set to the length of your subscription, in seconds (so, the above example is 31 days, or 1 month).
Please note that while you are testing your subscriptions in the iTunes Connect sandbox, the duration parameter should be set to the length of time that the test subscription will be valid for, which is not the same as the actual length of the subscription. The “Testing Your In-App Purchase” section of The iTunes Connect Developer Guide explains the process in detail.
Comments
0 comments
Please sign in to leave a comment.