Check Mobile App
Read now
Start a Project

In-App Subscription Receipt Validation in iOS using swift.

Save

I have already shared a blog where I implemented In-App Subscription in iOS. If you have not read yet then click here.

In this blog, I am going to show how we validate the Subscription? I will start with Step 11 from the previous blog.

Step 1: Call the receiptValidation() Method from the updatedTransactions. Note that only receiptValidation() call only when Transaction State is purchased.

 

Step 2: Now handle the receiptValidation() method.

There is two verifyReceiptURL for gathering the information from iTunes for both sandbox and live.

The verifyReceiptURL API having 2 params. One is receipt-data which content local receipt stored data and the second one is the password where you have to pass Shared Secret.

Step 3:  Now get the expire date from the response data.

Call the getExpirationDateFromResponse() after the data received from the API.

Conclusion

So please follow the above steps to validate the subscription and And if you have any issue or suggestion you can leave your message in the comment section I will try to solve this.

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


5 comments

  • Mark
    I get error “Cannot find ‘self’ in scope from line 15 in recieptValidation. Not sure how to fix this?
    • Mark
      Omitting the [weak self] avoids the syntax issue, but the result of this script results in status = 21002 which means “The data in the receipt-data property was malformed or missing.” I have found lots of scripts like this one that always end up having this result. Also, it seems that many others have similar issues. Any ideas what is the cause?
      • Debabrata Roy (Moderator)
        We can try with different encoding option.
        Please try with .endLineWithCarriageReturn option, just replace
        let recieptString = receiptData?.base64EncodedString(options: NSData.Base64EncodingOptions(rawValue: 0))

        To

        let recieptString = receiptData?.base64EncodedString(options: .endLineWithCarriageReturn)

        Thanks

  • css.php

    Very good company, we did get app extension for Magento 2 website. The support was very good they help us through the process. Webkul team is very supportive, I would recommend them.

    Yasser Mohamed

    Yasser Mohamed

    Talk to Sales

    Global

    Live Chat
    Start a Project

      Message Sent!

      If you have more details or questions, you can reply to the received confirmation email.

      Back to Home