In-app purchases details

Hello! I have several questions about in-app purchases article and would be very pleased if you'll help me. If you have an answer for only one question or only subquestion don't be shy to answer, it will help much!

  1. How to distinguish a type of in-app purchase from the response?

I mean in response to /verifyReceipt query you send JSON object, which also contains (responseBody->Receipt) information about receipt, but there is no some kind of type field and I'm a little bit confused. Maybe there is a difference between non-consumable and auto-renewable subscription (for example non-consumable doesn't have latest_receipt actually) but how to distinguish non-consumable purchase from non-renewable subscriptions?

  1. Does in-app array change according to actual active purchases for user?

Determine which products the user purchased. Purchases for non-consumable products, auto-renewable subscriptions, and non-renewing subscriptions remain in the receipt indefinitely (from here)

Imagine user subscribe for auto-renewable subscriptionA and I get the receipt (receipt1) for this purchase. If subscriptionA auto-renewed then:

a. will in-app array contain information for new subscriptionA purchase (actually I need new expiration_date) if I'll send receipt1 request on /verifyReceipt? (Or more generally: Can I track subscriptionA status for some user using one of receipt?)

b. will in-app array contain 2 items in this case, or it'll just update date for old object? will multiple puchases of non-renewing subscription (with same productId) appear multiple times?

c. Even more generally (a): Can I track all in-app purchases of some user using this receipt1 and scanning in-app array?

Also I'm not sure about other APIs to track subscriptions. It would be very convenient to use a key like (app, user, sub) or (bundleId, _, productId) (didn't find any userId) and be able to get last transaction for this user in this app for this product for example

Accepted Answer

To distinguish the actual item being bought, I would refer to the product_id. This should tell you exactly what in-app was purchased, and therefore what type it is.

For the second block of questions, I would refer you to this paragraph in the verifyReceipt documentation

For auto-renewable subscription items, parse the response to get information about the currently active subscription period. When you validate the receipt for a subscription, latest_receipt contains the latest encoded receipt, which is the same as the value for receipt-data in the request, and latest_receipt_info contains all the transactions for the subscription, including the initial purchase and subsequent renewals but not including any restores._

Note that for auto renewable subscriptions, you must pass a password as well as the receipt data.

a. The latest_receipt_info will contain the current data about that subscription, even if that data comes from events that occurred after the receipt you sent us was generated.

b. It will contain all the transactions in the subscription, so both the original and the auto renewed transaction.

c. The description of the in_app array is

An array that contains the in-app purchase receipt fields for all in-app purchase transactions.

So this would contain all transactions excluding finished consumables, if using the app receipt. See https://developer.apple.com/documentation/appstorereceipts/responsebody/receipt/in_app

However, I would also direct you to the transaction history API as an alternative that only relies on an original transaction id. https://developer.apple.com/documentation/appstoreserverapi/get_transaction_history Among other improvements, it will return a type field directly.

For more APIs for different use cases see https://developer.apple.com/documentation/appstoreserverapi For example the subscription status API can tell you only the latest subscription information for a user.

Thank you very much for detailed answer!

In-app purchases details
 
 
Q