Auto-renewable purchases failing randomly

Hello, it's several months we are experiencing this issue on an app we have on the store:


We have dozens of purchases every day for two autorenewable subscriptions (1 week and 1 month). Most of them work without any problem.

On all our test phones the purchases work in SandBox and in Production environment.


But some customers (about 4-5 every day at the moment) can't complete the transaction. Apple charges them (our customer care asks a copy of the iTunes email, and sometimes copy of the credit card statement), but on the logs we read this:


Error Domain=SKErrorDomain Code=0 "Cannot connect to iTunes Store" UserInfo={NSLocalizedDescription=Cannot connect to iTunes Store}

and thus we can't process the transaction because we never get a receipt to validate.


We analyzed the code several times.. there're no calls to our server during the purchase process... only a call at the end if the transactionState is "purchased"... but for some reason some users get a "failed" return code, but they have been charged...


Any idea?


Thank you!

One possibility is that your code does not correctly handle the case where a user begins to make a purchase but before they can make the purchase the App Store requires that they update their credit card information. After updating their credit card information the user is asked by the App Store if they still want to make the purchase. If they answer ‘yes’ then the App Store calls your updatedTransactions method twice; the first time with a failed transaction and then, almost immediately after, with a purchased transaction. If your app removes the transaction observer after the failed transaction it won’t see the purchased transactions. Can the user ‘restore’?

Thank you for your answer.


That's an interesting point, even because it seems we don't set-up and observer. Our code is a modified version of iapHandler.swift from github: https://gist.github.com/DejanEnspyra/54667682eaa3ab9e1d37bd45f2bc1f3a


I'll investigate with my coworker why we don't follow this:

https://developer.apple.com/documentation/storekit/in-app_purchase/setting_up_the_transaction_observer_and_payment_queue


About the restore: the procedure is available to the users and it works. But not for the users that are experiencing the problem with the purchase. For them the restore button doesn't work as well.

It sounds like you have processed the ‘failed’ transaction but failed to process the ‘purchased’ transaction in the aforementioned edge case.

Auto-renewable purchases failing randomly
 
 
Q