Autorenewable IAP breaks in both sandbox and production after TWO YEARS of working correctly

My app has been in production for over two years with no changes to the autorenewable IAP mechanism. Suddenly, the flow broke for production and sandbox. In my request, I make sure to include 'exclude-old-transactions'. Instead of going to SKPaymentTransactionStatePurchased when adding a new payment to queue, it goes straight to SKPaymentTransactionStateRestored despite the fact that the latest SANDBOX receipt has 'purchase_date' of February 5th, 2019. Sandbox purchases only last a few minutes! How is this possible? Interestingly, this latest receipt has 'original_purchase_date' set to today (June 12th).


The request returns status 0, and I assume this is why it goes straight to the restored state. The problem is; when I verify the receipt and check the expiration date, it is negative and thus the app is broken. Instead of allowing the purchase to go thru, it attempts a restore for an expired receipt and understandably fails.


PLEASE HELP!!!! THIS IS BROKEN IN PRODUCTION AND I NEED HELP ASAP. I have no idea what broke; this code has worked for two years.

>I make sure to include 'exclude-old-transactions'.


Unclear what this means. But see change #2.


There are two recent changes in IAPs. 1) The calls to productRequests and purchaseRequests are off the main queue so you need to add

   dispatch_async(dispatch_get_main_queue(), ^{
       //code here
    });

to display any UI element like a UIAlertViewController. 2) The order of the IAP receipts in the receipt is no longer in time order - you need to check expires_date and select the latest one.




>Sandbox purchases only last a few minutes!

This is a feature not a bug. Subscription times in the sandbox are all shortened so that they can be tested.

Autorenewable IAP breaks in both sandbox and production after TWO YEARS of working correctly
 
 
Q