1

I am using auto renewal in-app purchase in one of my project.

For checking expiry date I am parsing receipt and comparing subscription date with today's date. For latest subscription I am picking up last object from latest_receipt_info key, but now I noticed that the sequence/sorting of latest_receipt_info is reverse in my receipt validation response, I mean latest subscription coming at 0 index (First and not last).

in_app key is also returning data in same manner.

I have couple of questions, can anyone help me out

  1. anyone faced this issue before?
  2. What is the right approach to check the latest subscription date
  3. latest_receipt key is also blank

I know the work around to have my own sorting on response, but looking for right approach.

Below is my receipt's response, I am only including required keys.

{
  "status": 0,
  "environment": "Production",
  "receipt": {
  //other keys/values
  "in_app": [
  {
    "product_id": "MyTestMontlyPlan",
    **"expires_date": "2020-06-29 14:47:20 Etc/GMT",**
    //other keys/values
  },
  {
    "product_id": "MyTestMontlyPlan",
    **"expires_date": "2020-05-29 14:47:20 Etc/GMT",**
   //other keys/values
  }]},
  "latest_receipt_info": [
  {
    "product_id": "MyTestMontlyPlan",
    **"expires_date": "2020-06-29 14:47:20 Etc/GMT",**
  },
  {
    "product_id": "MyTestMontlyPlan",
    **"expires_date": "2020-05-29 14:47:20 Etc/GMT",**
  }],
  "latest_receipt": "...", //idk why it is blank, in sandbox we receive receipt data here
  "pending_renewal_info": [
  {
    "auto_renew_product_id": "MyTestMontlyPlan",
    "original_transaction_id": "#############",
    "product_id": "MyTestMontlyPlan",
    "auto_renew_status": "1"
  }]
}
Joakim Danielson
  • 43,251
  • 5
  • 22
  • 52
Mayank Jain
  • 5,663
  • 7
  • 32
  • 65

1 Answers1

1

These are now sorted by pruchase_date_* for safety, you should sort this array yourself to protect against any future changes. Filter out transactions that have a previous expiration date and are upgraded.

Hitch22
  • 365
  • 1
  • 9