The iOS purchase receipt server verification usually works like this:
User purchase on iPhone
Your app sent the purchase recipt to server
Server receive the recipt and send it to Apple to verify
Server gets the verify results from Apple .
Server sents the verify result to app
BUT what if only Step 1 is successful? For example, The app can't send request to the server in Step 2 or app can't get response from server in Step 5. The problem is user already paid. What is the best way to handle this problem?
To reset your iOS network settings and hopefully fixed the verification failed error, simply launch the “Settings” app, then go to “General > Reset > Reset Network Settings” and lastly, enter your password to complete the process. Once your network settings have been reset, you’ll have to connect to the Wi-Fi connection again.
When a user makes an in-app purchase, the AppStore creates a receipt. What is App Store Receipt? In-App Purchases provide you a convenient way to monetize in-app content and features within your app. To provide access to your content, you need to pass a receipt through the receipt validation ( verifyReceipt) endpoint.
To provide access to your content, you need to pass a receipt through the receipt validation ( verifyReceipt) endpoint. Receipt is an encrypted file signed with an Apple certificate. To validate purchases, you need to verify receipts on your server or the device.
Force Restart If Apple Verification Failed Again 1 Press the “Volume Up” button and release it quickly. 2 Press the “Volume Down” button and release it quickly. 3 Now, press and hold the “Side” button. Don’t release it until the Apple logo appears on the screen of your device.
If you are using SKPaymentQueue, then it's easy. All you have to do is to keep the transaction in SKPaymentQueue until 'step 5' when you get a success/failure verify result from your server.
If anything goes wrong in between step 1 to 5 your app still has access to the transaction in the SKPaymentQueue and can 'reprocess' it.
The reprocessing of incomplete transactions could kick in at start of your app (or some time interval as you prefer).
Just check SKPaymentQueue to get the pending/incomplete transactions and send them to your server (just like 'step 2'). If your server is still not accessible obviously you won't get to step 5, therefore you don't remove the transaction from the queue and this reprocessing happens again and again every time at the next app start (or next queue check time interval) until is fulfilled.
The implementation is also easy, you need to have a 'transaction observer class' of SKPaymentTransactionObserver.
At app start create an instance of the 'transaction observer class' and that should register itself by call to:
[[SKPaymentQueue defaultQueue] addTransactionObserver:self]
Then 'transaction observer class' gets the transactions in method:
(void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
This method is where you can handle and reprocess all incomplete transactions.
Note that your server must be idempotent (i.e able to handle repeated transactions if they already been processed)
Once the server processes and completes steps 2 to 4, then it comes to app with success/failure result and that's the only time when you want to remove that transaction from the queue by call to:
[[SKPaymentQueue defaultQueue] finishTransaction: transaction]
And finally give your user the premium feature they purchased at this point.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With