In-App Purchase

3,136 views

Published on

What In-App Purchase is and how to add it to your application

1 Comment
2 Likes
Statistics
Notes
  • Thank you. I just found this blog and what a great resource! It is a good blog and their posts are effective. This is very nice post! I will bookmark this blog. Direct Carrier billing | direct billing
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total views
3,136
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
154
Comments
1
Likes
2
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • Easy to implement\nNo server cost\nApplication size rises.\nContent cannot be changed or updated\n
  • Get In-App Identifiers\nGet Product Info\nShow the UI\nMake the purchase\nProcess Transaction\nMake the feature avaible\nFinish Transaction\n
  • \n
  • \n
  • Get In-App Identifiers\nGet Product Info\nShow the UI\nMake the purchase\nProcess Transaction\nMake the feature avaible\nFinish Transaction\n
  • \n
  • \n
  • \n
  • \n
  • \n
  • When the payment is added to the payment queue, a persistent transaction is created to hold it. After the payment is processed, the transaction is updated with information about the payment collection. Your application implements an observer that receives messages when transactions are updated. The observer should provide purchased items to the user and then remove the transaction from the payment queue.\nSKPayment\nCollecting payment starts with a payment object. The payment object includes a product identifier and optionally includes the quantity of that product to be purchased. You can queue the same payment object more than once; each time a payment object is queued results in a separate request for payment.\nUsers can disable the ability to make purchases in the Settings application. Before attempting to queue a purchase, your application should first confirm that payment can be processed. You do this by calling the payment queue’s canMakePayments method.\nSKPaymentQueue\nThe payment queue is used to communicate with the App Store. When payments are added to the queue, Store Kit transmits the request to the App Store. Store Kit presents dialogs to ask the user to authorize payment. The completed transaction is returned to your application’s observer.\nSKPaymentTransaction\nA transaction is created for every payment added to the queue. Each transaction has properties that allow your application to determine the status of the transaction. When payment is collected, the transaction includes additional details about the successful transaction.\nAlthough your application can ask the payment queue for a list of pending transactions, it is more common for an application to wait until the payment queue notifies the payment queue’s observer with a list of updated transactions.\nSKPaymentTransactionObserver\nYour application implements the SKPaymentTransactionObserver protocol on an object and adds it as an observer to the payment queue. The observer’s primary responsibility is to examine completed transactions, deliver items that were successfully purchased, and remove those transactions from the payment queue.\nYour application should associate an observer with the payment queue when it launches, rather than wait until the user attempts to purchase an item. Transactions are not lost when an application terminates. The next time the application launches, Store Kit resumes processing transactions. Adding the observer during your application’s initialization ensures that all transactions are returned to your application.\n
  • \n
  • Dynamic content\nKeep application size under 10mb\nMore secure (out of band receipt verification)\n
  • Easy to implement\nNo server cost\nApplication size rises.\nContent cannot be changed or updated\n
  • NSBundle *bundle = [NSBundle mainBundle];NSDictionary *info = [bundle infoDictionary];if ([info objectForKey: @"SignerIdentity"] != nil){/* do something */}\n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • In-App Purchase

    1. 1. Presented by Max StottropIN-APP PURCHASE
    2. 2. What I will cover today• Introduction• Proccess of implementing In-App Purchase• StoreKit Framework• Business & Tips
    3. 3. With In-App Purchase you can…• … embed a store directly to your application• It uses the Storekit Framework.
    4. 4. In-App Purchase Types• Non-Consumable• Consumable• Auto-renewable subscription• Free subscription• Non-renewable subscription
    5. 5. Walkthrough Create Fetch Purchase RestoreProducts Products Products Products
    6. 6. Implementing In-App Purchase Setup SellDetermine Verify Restore Products in Products Product Product previous iTunes withOfferings Receipts Purchases Connect StoreKit
    7. 7. Products• Supported types: • Content • Functionality • Services • Subscriptions• Each product has a unique productIdentifier.• No real-world goods!
    8. 8. iTunes Connect Setup• Setup your Products• Create a Test User • One per country• Sign out of your Store Settings • Don‘t enter your Test User‘s Ids in the Settings
    9. 9. Store Kit Framework Validate In-App Purchase Access Retrieving product information Show the Store Interface Make the purchase Process Transaction Make the feature avaible Finish Transaction Verify the receipts Restore previous Purchases
    10. 10. Validate In-App Purchase Acces• Validate In-App Purchase Acces• Payment Queue class method canMakePurchase
    11. 11. Determine sellable products• Load Product IDs• Use SKProductsRequest to determine the sellable subset of the IDs NSSet* products = [NSSet setWithObject: @”productID1”, @“productID2“, nil]; SKProductsRequest *request= [[SKProductsRequest alloc] initWithProductIdentifiers: products]; [productRequest start]; (void)productsRequest:(SKProductsRequest *)request didReceiveResponse: (SKProductsResponse *)response { response.invalidProductsIdentifiers == nonsellable; response.products == sellable;
    12. 12. Show Store• UITableView Power? (void)productsRequest:(SKProductsRequest *)request didReceiveResponse: (SKProductsResponse *)response { for(SKProducts* aProduct in response.products) cell.textLabel.text = aProduct.localizedTitle; cell.textLabel.description = aProduct.localizedDescription; cell.textLabel.extra = aProduct.price; }
    13. 13. Request payment • SKPayment Class • Create payment object • Add it to the queue • Observe the payment queue SKPayment *payRequest = [SKPayment paymentWithObject:selected]; [[SKPaymentQueue defaultQueue] addPayment:payRequest]; - (void)addTransactionObserver:(id <SKPaymentTransactionObserver>) observer
    14. 14. Complete Transaction • updatedTransaction method • SKPaymentTransactionStatePurchased = Succes • SKPaymentTransactionStateRestored = Succes • finishTransaction method-(void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray*)transactions { if (atransaction.transactionState == SKPaymentTransactionStatePurchased ) { //Unlock content [queue finishTransaction:aTransaction]; }}
    15. 15. Collecting Payments
    16. 16. Feature Delivery• Self contained• Downloadable
    17. 17. Downloadable Content User sends iPhone Fetch Apple Server Apple payment sends Products returns verifies sends request to receipt tofrom Apple receipts receipt. product Apple server
    18. 18. In-App Content User purchasesEmbed content Application content and in your unlocks Apple verifies application. functionality. payment.
    19. 19. Remember Product Purchase • Use NSUserDefaults class and preference file • unsecure, easy to „hack“. • saves to Application Support directory • Use Keychain API • Secure • Saved to app Keychain Slice[[NSUserDefaults standartUserDefaults] setObject:bought forKey:@“boughtItems“];SecItemAdd ((CFDictionaryRef) boughtItems, NULL);
    20. 20. Verify Product Purchase Own iTunes Validation Server Server
    21. 21. Verify Product Purchase Post Base64 Check Server encodedTransaction verifies App unlocks transaction receipt transaction content to the server
    22. 22. Verify Product Purchase• Send JSON object with encoded transaction receipt • {“receipt - data“ : “7b4187e54587ert27e2“}• Post to iTunes verification service • http://buy.itunes.apple.com/verifyReceipt • http://sandbox.itunes.apple.com/verifyReceipt• Get a JSON object • {“status“ : 0, “receipt“ : { … } } • 0 == Succes, • everything else == BAD PIRATES AT WORK
    23. 23. Restore Previous Purchases• Free Subscription, Auto- Renewing Subscription, Non- Consumable items• [[SKPaymentQueue defaultQueue] restoreCompletedTransactions]• Subscription & Consumable need own mechanism Proccess „Already Customer Succesfull purchased“ signs in Payment Dialog
    24. 24. Business Model• Which Model to choose?• What to content sell? • Game • Everything else Extra Levels Social content In-game Currency Optional Content Money for time/Time
    25. 25. Tips• Product Ids are unique across apps!• Built Store with sellable products only!• Use MBBase64 category from the CocoaDev website• Auto-renewing Subscription only for apps with dynamic content.• Only show the button when Internet Connection is avaible.• To test In-App Purchase you must add the Binary - Reject it!• After you added your Products, wait a bit!• MKStoreKit: Open Source helper.
    26. 26. ONE LAST THING
    27. 27. StoreFront
    28. 28. StoreFront• Works via JSON to display Content, Downloads, Updates.• Allows to sell free content.• No additional server costs/bandwidth.• Restoring Auto-renewable Subscriptions - YAY
    29. 29. Q &A
    30. 30. THANKS!
    31. 31. Links• Receipt validation: http://bit.ly/zMuTKk, http://bit.ly/we2Pt0 & http://bit.ly/AB09Sv• Apple: http://bit.ly/xy7aGV, http://bit.ly/wyLec6 & http://bit.ly/weMm3p• MKStoreKit: https://github.com/MugunthKumar/MKStoreKit• StoreFront: http://urbanairship.com/docs/inapp_client.html• Dr. Touchs Purchase Button: http://bit.ly/zxGjcY

    ×