In-App Purchase: Best/Worst
                    Thing Ever
                                      Chris Adamson
           ...
What You’ll Learn Today

The many parts of I-AP
Using Store Kit in your app
Everything else you need to do in-app
purchase...
In-App Purchase


Added in iPhone OS 3.0
Allows user to make purchases within an
app, using their iTunes account
Apple kee...
I-AP Examples

Digital books
Magazine subscriptions
Data plans (e.g., map services)
Gaming:
  New levels
  Customizations
Item Shops
If VTM were an online game


Default clothing would be boring
You could purchase virtual VTM clothing
and other items to b...
Our fun VTM online game




  …minus the actual game
Getting ready for I-AP

Create an app in iPhone provisioning
portal and iTunes Connect
  Don’t submit it yet!
Create I-AP ...
App provisioning

Create an AppID
Enable it for in-app purchase
Create app on iTunes Connect
iTunes Connect warnings

Enter all data as if submitting the 1.0
version of the app
  You’ll need icon, screenshot,
  desc...
Store Kit
Store Kit



iPhone APIs for in-app purchase
8 classes, 3 protocols
Highly asynchronous
Store Kit concepts

Product: an item offered for sale
Payment: a request for purchase
Payment transaction: a payment being...
Before you start coding

I-AP doesn’t work on simulator; must
test on device
Apps installed by Xcode run in the I-AP
“sand...
First step: define some products

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//E...
Products



Identified by a unique product identifier
string
Can be embedded in your application, or
downloaded from the net...
Turning ids into products


[UIApplication sharedApplication].networkActivityIndicatorVisible =
                  YES;
SKP...
SKProductsRequestDelegate


-   (void)productsRequest:(SKProductsRequest *)request
!    didReceiveResponse:(SKProductsResp...
SKProductsRequestDelegate

Response includes SKProducts which
matched productIds in your request
  Ids not yet set up in i...
Creating with iTunes Connect
iTunes Connect Product Fields
Product Types

Non-consumable (aka, “durable”) —
purchase once, own forever
  eBooks, game levels, avatar bling
Consumable...
SKProduct properties



productIdentifier
price, priceLocale
localizedTitle, localizedDescription
Making purchases



// purchase the selected item
[[SKPaymentQueue defaultQueue] addPayment:
! [SKPayment paymentWithProdu...
Observing purchase progress
[[SKPaymentQueue defaultQueue] addTransactionObserver:self];



      Calls back to
      paym...
Handling purchases in-progress



- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)
transaction...
Handling purchase success


case SKPaymentTransactionStatePurchased: {
! NSLog (@"SKPaymentTransactionStatePurchased");
! ...
Handling purchase failure



case SKPaymentTransactionStateFailed: {
! [UIApplication sharedApplication].networkActivityIn...
Handling payment restoration

  -[SKPaymentQueue restoreCompletedTransactions]



case SKPaymentTransactionStateRestored: ...
Playing with purchases



Completed purchases give you only a
productIdentifier, not an SKProduct
  Your app needs some oth...
Beyond Store Kit
So much more than just Store Kit


  Goods delivery
  Persisting purchases
  Audit trail
  Purchase restoration
Delivering goods



Where is your product?
  In the bundle — unlock
  On a server — download
Persisting purchases


Purchases must be available on future
app launches. Where to persist?
  Local file system
  SQLite /...
Audit Trail

App communicates directly with Apple
Your business has no record of this
purchase
But if customer has a probl...
Purchase authentication


Completed transactions have a
transactionReceipt property
Can be verified via Apple web service a...
You’re a web developer now!

Send transactionReceipt to a web service
you write
Your web service sends the receipt,
base64...
Purchase restoration

Non-consumable and subscription
products are expected to be purchased
once and played on all a user’...
GOTCHA!

restoreCompletedTransactions only
works for non-consumables, not
subscriptions
  rdar://7470096
Also, no unique i...
Restoring subscriptions


Remember deviceId on server
  Doesn’t restore to other devices
Create a login on a server you co...
Erica’s Restoration Scheme

Neat idea from Erica Sadun:
  Sell a 99¢ non-consumable, hold on to
  its transactionId
  For ...
Beyond Store Kit: Takeaway

Expect to do server-side work
  Certain kinds of apps will have large
  server-side teams
  Sm...
In-App Purchase WINs and
                  FAILs
In-App Purchase WINs


Allows you to provide new content to old
apps
  New content that pays for itself
Highly resistant t...
In-App Purchase FAILs


Subscriptions are broken
I-AP requires extensive server-side
development
  You have to do almost e...
Earning their keep?

                      App Store   I-A P
 Product Hosting         √
    Audit Trail          √
   Purc...
In-App Purchase and Its
           Discontents
Stanza’s Bookstore…
… is a bunch of websites
So is Amazon Kindle Store
In-App Purchase Isn’t Required

 If you already sell goods over the web,
 you can keep doing so
   iPhone App can be a ric...
Running your own credit swipes



 PayPal API
 Amazon payments
 Others…
An animated comparison
Crunchyroll

Free app
Same login on
iPhone, web
Same videos
available on
iPhone, web
Anime Network Mobile

$6.99 for 30 days, I-AP
to extend, nothing free
Web, iPhone
memberships unrelated
Fewer videos avail...
Obvious questions

If Anime Network is already processing
payments and delivering goods, why are
they giving Apple a 30% c...
Should You Adopt I-AP?

How much of this server-side commerce
work are you already doing or
committed to?
  Selling the sa...
Good candidates for I-AP

iPhone-only apps
  Can use keychain to share between
  apps
Selling non-consumables
Number of pr...
Bad candidates for I-AP


Products also available via web
Large / infinite number of products
Products not pass review
Subs...
Q&A
Thanks!
                                      Chris Adamson
                                       @invalidname
Voices Tha...
In-App Purchase: Best/Worst Thing Ever [Voices That Matter: iPhone 2010]
In-App Purchase: Best/Worst Thing Ever [Voices That Matter: iPhone 2010]
In-App Purchase: Best/Worst Thing Ever [Voices That Matter: iPhone 2010]
Upcoming SlideShare
Loading in …5
×

In-App Purchase: Best/Worst Thing Ever [Voices That Matter: iPhone 2010]

6,612 views
6,493 views

Published on

In-App Purchase offers a great way for your users to enhance your application after the sale by purchasing additional material: new game levels, in-game goods, and subscriptions to new content. For the user, it's just a few taps, and an easy payment from their iTunes account. For the developer, however, In-App Purchase requires a major effort: creating and hosting digital products, developing and hosting authentication servers, managing products in iTunes Connect, and more. Don't let the small size of the Store Kit framework fool you: offering in-app purchases goes far beyond that. In this talk, we'll go through all the steps of selling products through I-AP, pointing out the unexpected benefits and problems that come with it. We'll also reveal iPhone frameworks that, while not technically part of I-AP, are vital for successful and secure purchase-based applications. Finally, we'll look at cases where you might want to use I-AP, and others where it makes better business sense not to.

Published in: Technology
0 Comments
7 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
6,612
On SlideShare
0
From Embeds
0
Number of Embeds
54
Actions
Shares
0
Downloads
0
Comments
0
Likes
7
Embeds 0
No embeds

No notes for slide

In-App Purchase: Best/Worst Thing Ever [Voices That Matter: iPhone 2010]

  1. 1. In-App Purchase: Best/Worst Thing Ever Chris Adamson @invalidname Voices That Matter: iPhone Developer Conference 2010
  2. 2. What You’ll Learn Today The many parts of I-AP Using Store Kit in your app Everything else you need to do in-app purchase Good reasons to use… and not to use… in-app purchase
  3. 3. In-App Purchase Added in iPhone OS 3.0 Allows user to make purchases within an app, using their iTunes account Apple keeps 30%
  4. 4. I-AP Examples Digital books Magazine subscriptions Data plans (e.g., map services) Gaming: New levels Customizations
  5. 5. Item Shops
  6. 6. If VTM were an online game Default clothing would be boring You could purchase virtual VTM clothing and other items to bling out your avatar This will be our example…
  7. 7. Our fun VTM online game …minus the actual game
  8. 8. Getting ready for I-AP Create an app in iPhone provisioning portal and iTunes Connect Don’t submit it yet! Create I-AP products to purchase Write code with Store Kit API Test in the sandbox
  9. 9. App provisioning Create an AppID Enable it for in-app purchase
  10. 10. Create app on iTunes Connect
  11. 11. iTunes Connect warnings Enter all data as if submitting the 1.0 version of the app You’ll need icon, screenshot, description, etc. SKU and version number cannot be changed Do not submit a binary yet!
  12. 12. Store Kit
  13. 13. Store Kit iPhone APIs for in-app purchase 8 classes, 3 protocols Highly asynchronous
  14. 14. Store Kit concepts Product: an item offered for sale Payment: a request for purchase Payment transaction: a payment being managed by Store Kit Payment queue: a persistent queue of transactions in varying states (pending, purchased, failed, restored)
  15. 15. Before you start coding I-AP doesn’t work on simulator; must test on device Apps installed by Xcode run in the I-AP “sandbox” Your iTunes account won’t be charged Must use an iTunes I-AP test account
  16. 16. First step: define some products <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/ DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> ! <key>product0</key> ! <dict> ! ! <key>description</key> ! ! <string>VTM t-shirt</string> ! </dict> ! <key>product1</key> ! <dict> ! ! <key>description</key> ! ! <string>VTM hoodie</string> ! </dict> </dict> </plist>
  17. 17. Products Identified by a unique product identifier string Can be embedded in your application, or downloaded from the network
  18. 18. Turning ids into products [UIApplication sharedApplication].networkActivityIndicatorVisible = YES; SKProductsRequest *request = [[SKProductsRequest alloc] ! ! ! ! ! initWithProductIdentifiers: ! ! ! ! ! [NSSet setWithArray:[productsPList allKeys]]]; [request setDelegate:self]; [request start];
  19. 19. SKProductsRequestDelegate - (void)productsRequest:(SKProductsRequest *)request ! didReceiveResponse:(SKProductsResponse *)response { ! NSLog (@"productsRequest response: %@", response); ! ! [products release]; ! products = [response.products retain]; ! [self.tableView reloadData]; ! [UIApplication sharedApplication].networkActivityIndicatorVisible= NO; }
  20. 20. SKProductsRequestDelegate Response includes SKProducts which matched productIds in your request Ids not yet set up in iTunes Connect fail Ids in iTunes Connect but not in your request will be absent
  21. 21. Creating with iTunes Connect
  22. 22. iTunes Connect Product Fields
  23. 23. Product Types Non-consumable (aka, “durable”) — purchase once, own forever eBooks, game levels, avatar bling Consumable — purchase, use up, purchase again Ammo, boosts, online event access Subscriptions
  24. 24. SKProduct properties productIdentifier price, priceLocale localizedTitle, localizedDescription
  25. 25. Making purchases // purchase the selected item [[SKPaymentQueue defaultQueue] addPayment: ! [SKPayment paymentWithProduct: [products objectAtIndex:indexPath.row]]];
  26. 26. Observing purchase progress [[SKPaymentQueue defaultQueue] addTransactionObserver:self]; Calls back to paymentQueue:updatedTransacations: Transactions persist until you remove from queue with finishTransaction: Get purchases made on other devices via restoreCompletedTransactions
  27. 27. Handling purchases in-progress - (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *) transactions { ! for (SKPaymentTransaction *transaction in transactions) { ! ! switch (transaction.transactionState) { ! ! ! case SKPaymentTransactionStatePurchasing: { ! ! ! ! [UIApplication sharedApplication]. networkActivityIndicatorVisible = YES; ! ! ! ! break; ! ! ! }
  28. 28. Handling purchase success case SKPaymentTransactionStatePurchased: { ! NSLog (@"SKPaymentTransactionStatePurchased"); ! [UIApplication sharedApplication].networkActivityIndicatorVisible = NO; ! [inventoryVC addProductIdentifier: transaction.payment.productIdentifier]; ! [queue finishTransaction:transaction]; ! AudioServicesPlaySystemSound (kachingSound); ! break; }
  29. 29. Handling purchase failure case SKPaymentTransactionStateFailed: { ! [UIApplication sharedApplication].networkActivityIndicatorVisible = NO; ! NSLog (@"SKPaymentTransactionStateFailed: %@", transaction); ! [queue finishTransaction:transaction]; ! break; }
  30. 30. Handling payment restoration -[SKPaymentQueue restoreCompletedTransactions] case SKPaymentTransactionStateRestored: { ! NSLog (@"SKPaymentTransactionStateRestored"); ! [UIApplication sharedApplication].networkActivityIndicatorVisible = NO; ! [inventoryVC addProductIdentifier: transaction.originalTransaction.payment.productIdentifier]; ! [queue finishTransaction:transaction]; ! break; }
  31. 31. Playing with purchases Completed purchases give you only a productIdentifier, not an SKProduct Your app needs some other way of identifying what has been purchased
  32. 32. Beyond Store Kit
  33. 33. So much more than just Store Kit Goods delivery Persisting purchases Audit trail Purchase restoration
  34. 34. Delivering goods Where is your product? In the bundle — unlock On a server — download
  35. 35. Persisting purchases Purchases must be available on future app launches. Where to persist? Local file system SQLite / Core Data Keychain
  36. 36. Audit Trail App communicates directly with Apple Your business has no record of this purchase But if customer has a problem, they’re calling you What do you do?
  37. 37. Purchase authentication Completed transactions have a transactionReceipt property Can be verified via Apple web service at http://buy.itunes.apple.com/verifyReceipt Your app does not use this web service…
  38. 38. You’re a web developer now! Send transactionReceipt to a web service you write Your web service sends the receipt, base64-encoded, in a JSON message to Apple If it validates, your web service records the successful transaction in its database
  39. 39. Purchase restoration Non-consumable and subscription products are expected to be purchased once and played on all a user’s devices -[SKPaymentQueue restoreCompletedTransactions] Only call in response to a user action (e.g., a “restore purchases” button)
  40. 40. GOTCHA! restoreCompletedTransactions only works for non-consumables, not subscriptions rdar://7470096 Also, no unique identifier for the iTunes user
  41. 41. Restoring subscriptions Remember deviceId on server Doesn’t restore to other devices Create a login on a server you control Ignore the problem and hope Apple doesn’t notice (they probably won’t)
  42. 42. Erica’s Restoration Scheme Neat idea from Erica Sadun: Sell a 99¢ non-consumable, hold on to its transactionId For future purchases, log purchase info plus this id on your server Restore gives you back this id. Query your server for it to get purchases
  43. 43. Beyond Store Kit: Takeaway Expect to do server-side work Certain kinds of apps will have large server-side teams Small apps may use Google App Engine or Amazon Web Services Avoid subscriptions if you can
  44. 44. In-App Purchase WINs and FAILs
  45. 45. In-App Purchase WINs Allows you to provide new content to old apps New content that pays for itself Highly resistant to piracy Some business models require I-AP
  46. 46. In-App Purchase FAILs Subscriptions are broken I-AP requires extensive server-side development You have to do almost everything yourself
  47. 47. Earning their keep? App Store I-A P Product Hosting √ Audit Trail √ Purchase UI √ Product Restoration √ (some) Purchase Storage √ Apple’s Cut 30% 30%
  48. 48. In-App Purchase and Its Discontents
  49. 49. Stanza’s Bookstore…
  50. 50. … is a bunch of websites
  51. 51. So is Amazon Kindle Store
  52. 52. In-App Purchase Isn’t Required If you already sell goods over the web, you can keep doing so iPhone App can be a rich client, not necessarily a store If you already do all the work, why give Apple 30%?
  53. 53. Running your own credit swipes PayPal API Amazon payments Others…
  54. 54. An animated comparison
  55. 55. Crunchyroll Free app Same login on iPhone, web Same videos available on iPhone, web
  56. 56. Anime Network Mobile $6.99 for 30 days, I-AP to extend, nothing free Web, iPhone memberships unrelated Fewer videos available on iPhone
  57. 57. Obvious questions If Anime Network is already processing payments and delivering goods, why are they giving Apple a 30% cut? Who would pay twice for web and iPhone versions? Why do iPhone users get less for the same price?
  58. 58. Should You Adopt I-AP? How much of this server-side commerce work are you already doing or committed to? Selling the same goods on web? Or for other devices? Can you live with Apple’s policies?
  59. 59. Good candidates for I-AP iPhone-only apps Can use keychain to share between apps Selling non-consumables Number of products is manageable Practical necessity (data plan payment)
  60. 60. Bad candidates for I-AP Products also available via web Large / infinite number of products Products not pass review Subscriptions(?)
  61. 61. Q&A
  62. 62. Thanks! Chris Adamson @invalidname Voices That Matter: iPhone Developer Conference 2010

×