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

In App Purchases & Subscriptions

Dal Rupnik
February 20, 2018

In App Purchases & Subscriptions

In App Purchases and Subscriptions implementation on Apple iOS.

Dal Rupnik

February 20, 2018
Tweet

More Decks by Dal Rupnik

Other Decks in Programming

Transcript

  1. let request = SKProductsRequest(Set([…])) * Bonus questions: Why can’t I

    just display our product? Should I keep a reference to it? Where should the set come from? Blub Blub inc.
  2. Yay, now I have a list of:
 SKProduct which we

    can display with localized price! Blub Blub inc.
  3. Lets purchase something! self.paymentQueue = SKPaymentQueue.default() let payment = SKMutablePayment()

    payment.productIdentifier = … paymentQueue.add(payment) Blub Blub inc.
  4. switch (entry->type) { case 2: bundle_id = &entry->value; break; case

    3: bundle_version = &entry->value; break; case 4: opaque = &entry->value; break; case 5: hash = &entry->value; break; } }
 } /* The GUID returned by copy_mac_address() is a CFDataRef. Use CFDataGetBytePtr() and CFDataGetLength() to get a pointer to the bytes that make up the GUID and to get its length. */ UInt8 *guid = NULL; size_t guid_sz; /* Declare and initialize an EVP context for OpenSSL. */ EVP_MD_CTX evp_ctx; EVP_MD_CTX_init(&evp_ctx); /* A buffer for result of the hash computation. */ UInt8 digest[20]; /* Set up the EVP context to compute a SHA-1 digest. */ EVP_DigestInit_ex(&evp_ctx, EVP_sha1(), NULL); /* Concatenate the pieces to be hashed. They must be concatenated in this order. */ EVP_DigestUpdate(&evp_ctx, guid, guid_sz); EVP_DigestUpdate(&evp_ctx, opaque->buf, opaque->size); EVP_DigestUpdate(&evp_ctx, bundle_id->buf, bundle_id->size); /* Compute the hash, saving the result into the digest variable. */ EVP_DigestFinal_ex(&evp_ctx, digest, NULL);
 Blub Blub inc.
  5. After parsing the receipt we get expiration and cancellation dates

    and product details. So we can unlock the application. Blub Blub inc.
  6. What happens with receipt if/when: Subscription is automatically renewed? Subscription

    was refunded? Subscription was cancelled? Billing had failed for the user? Apple updates iOS? Blub Blub inc.
  7. 1. Create a sandbox tester in iTunes Connect. 2. Logout

    in device Settings under App Store. 3. Start the app and start purchase. 4. Login with new sandbox tester. 5. Enter password. 6. Reenter password. 7. Reenter password. Blub Blub inc.
  8. You clearly and conspicuously disclose to users the following information

    regarding Your auto- renewing subscription: • Title of publication or service • Length of subscription (time period and/or content/services provided during each subscription period) • Price of subscription, and price per unit if appropriate • Payment will be charged to iTunes Account at confirmation of purchase • Subscription automatically renews unless auto-renew is turned off at least 24-hours before the end of the current period • Account will be charged for renewal within 24-hours prior to the end of the current period, and identify the cost of the renewal • Subscriptions may be managed by the user and auto-renewal may be turned off by going to the user’s Account Settings after purchase • Links to Your Privacy Policy and Terms of Use • Any unused portion of a free trial period, if offered, will be forfeited when the user purchases a subscription to that publication, where applicable. Blub Blub inc.