Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Apple In App Purchase

Apple In App Purchase

Sing Jie Lee

May 22, 2015
Tweet

More Decks by Sing Jie Lee

Other Decks in Technology

Transcript

  1. 5 types of IAP • Consumable • Non Consumable •

    Auto Renewable Subscription • Non-Renewing Subscription • Free Subscription
  2. Products • Products are identified by ProductID • e.g. com.garena.fishfood.100

    productID - Product Name (Localized) - Product Price (Tier) - Product Description
  3. Request for SKProduct ProductID (NSString) 1 2 typedef void(^PaymentBlock)(BOOL success);

    - (void)buyProductID:(NSString *)productID
 onCompletion:(PaymentBlock)onCompletion; { NSSet *identifiers = [NSSet setWithObject:productID]; SKProductsRequest *request = [[SKProductsRequest alloc] initWithProductIdentifiers:identifiers]; request.delegate = self; [request start]; self.paymentBlock = onCompletion; }
  4. - (void)productsRequest:(SKProductsRequest *)request 
 didReceiveResponse:(SKProductsResponse *)response { SKProduct *product =

    [response.products firstObject]; SKPayment *payment = [SKPayment paymentWithProduct:product]; [[SKPaymentQueue defaultQueue] addPayment:payment]; } Add SKProduct to Payment Queue 3
  5. Request for SKProduct Add SKProduct to Payment Queue Verify Transaction

    Finish Transaction ProductID (NSString) 1 2 3 4 5
  6. iOS Client, receive receipt Our Server Apple Server Encrypted receipt

    Encrypted receipt Decrypted receipt OK/Not OK Verification
  7. Verification { "receipt": { "original_purchase_date_pst": "2015-05-20 03:26:29 America/Los_Angeles" "unique_identifier": "c1b17ca2d3ceb9b77797fc2c4826ba4aece18370",

    "original_transaction_id": "340000068545339", "bvrs": "1.1", "app_item_id": "530942747", "transaction_id": "340000068545339", "quantity": "1", "unique_vendor_identifier": "D39AC063-4817-4DCE-B061-EB5EEE073A5B", "product_id": "com.singjie.btt.full.package", "item_id": "532592602", "version_external_identifier": "11626777", "bid": "com.singjie.BTT", "purchase_date_ms": "1432117589538", "purchase_date": "2015-05-20 10:26:29 Etc/GMT", "purchase_date_pst": "2015-05-20 03:26:29 America/Los_Angeles", "original_purchase_date": "2015-05-20 10:26:29 Etc/GMT", "original_purchase_date_ms": "1432117589538" }, "status": 0 }
  8. Verification { "receipt": { "original_purchase_date_pst": "2012-07-12 05:54:35 America/Los_Angeles" "purchase_date_ms": "1342097675882",

    "original_transaction_id": "170000029449420", "original_purchase_date_ms": "1342097675882", "app_item_id": "450542233", "transaction_id": "170000029449420", "quantity": "1", "bvrs": "1.4", "version_external_identifier": "9051236", "bid": "com.zeptolab.ctrexperiments", "product_id": "com.zeptolab.ctrbonus.superpower1", "purchase_date": "2012-07-12 12:54:35 Etc/GMT", "purchase_date_pst": "2012-07-12 05:54:35 America/Los_Angeles", "original_purchase_date": "2012-07-12 12:54:35 Etc/GMT", "item_id": "534185042" }, "status": 0 }
  9. Verification { "receipt": { "original_purchase_date_pst": "2015-05-20 03:26:29 America/Los_Angeles" "unique_identifier": "c1b17ca2d3ceb9b77797fc2c4826ba4aece18370",

    "original_transaction_id": "340000068545339", "bvrs": "1.1", "app_item_id": "530942747", "transaction_id": "340000068545339", "quantity": "1", "unique_vendor_identifier": "D39AC063-4817-4DCE-B061-EB5EEE073A5B", "product_id": "com.singjie.btt.full.package", "item_id": "532592602", "version_external_identifier": "11626777", "bid": "com.singjie.BTT", "purchase_date_ms": "1432117589538", "purchase_date": "2015-05-20 10:26:29 Etc/GMT", "purchase_date_pst": "2015-05-20 03:26:29 America/Los_Angeles", "original_purchase_date": "2015-05-20 10:26:29 Etc/GMT", "original_purchase_date_ms": "1432117589538" }, "status": 0 }
  10. Q&A