Search code examples
iosin-app-purchasein-app-billingin-app-subscription

Apple payment notifications - how to get latest pending_renewal_info from notification?


Good day!

I have a server that verifies receipts that come from user device or apple server and when I do that I can see an object like this:

 "pending_renewal_info": [
    {
        "expiration_intent": "1",
        "auto_renew_product_id": "test......",
        "is_in_billing_retry_period": "0",
        "product_id": "product.name.1",
        "original_transaction_id": "100000000000000",
        "auto_renew_status": "0"
    }
],

I can see that it is an array, but I get only one value in it all the time.

So the question is - is there always one element in that array? If no than how do I find out latest p_r_i for my subscription?

Documentation is a bit confusing -

In the JSON file, pending_renewal_info is an array in which each element contains the pending renewal information for each auto-renewable subscription identified by the product_id.

As far as I know I cannot sell more than one product under one original_transaction_id - so why there is an array of p_r_i ?

Can I be sure that there will be only one element in that array?

Thank you.


Solution

  • If your App provides multiple subscriptions (like one for content of category A and one for category B) then this would contain an entry for subA and one for subB. Whereby, A and B have to be in different subscription groups.

    So, you can be sure that there is only one as long as you do not have multiple subscription groups.