In IAP’s apple generate a receipt against each transaction containing a lot of information like a digital signature to validate the purchase, history of transactions including successful and unsuccessful transaction, the current status of the subscription, expiry date, and much more.
You have to validate the receipt by fetching from the Apple server to get all this information. you can check this to know how to fetch receipt data.
for validation, we can go with 2 techniques
- On-device validation(validation on the device locally if you’re not using server in your app)
- Server-side validation(Recommended)
you can read more about choosing receipt validation technique here.
When you fetch receipt it will give you a receiptData and you will convert it to base64EncodedString and hit API for receipt.
For SandBox use https://sandbox.itunes.apple.com/verifyReceipt and for production use https://buy.itunes.apple.com/verifyReceipt. pass it two parameters Receipt base64String and App-Specific Shared Secret you can find App-Specific Shared Secret on App store on the top right corner of your in-app purchases list.
You will receive a response containing all information about the subscription.
Check this video of title Engineering Subscriptions from WWDC 2018. This video is really helpful in understanding subscriptions.
CLICK HERE to find out more related problems solutions.