e.preventDefault(); // Prevent form submission input.blur(); // remove focus input.value = ""; // optional: clear the input

How to Verify iTunes, Android and Amazon Subscription Status from Backend Server?

Introduction

When your application has in-app purchase subscription, either auto-renewal or not, you might need to check the subscription status whether still active or it has expired. To check if the user still has a valid subscription when their subscription period is about to end, you will need to do re-validation on the purchase token.

Detect iTunes Subscription Status

The endpoint for the sandbox environment is https://sandbox.itunes.apple.com/verifyReceipt and for production it’s https://buy.itunes.apple.com/verifyReceipt

You need to send a JSON payload on iTunes endpoint:

  • receipt-data – The base64 encoded receipt data. This will get from the app on subscription and store it on your backend database.
  • Password – it will be your app’s shared secret
  • exclude-old-transactions – It is only used for iOS7 style apps. If the value is true, then the response includes only the latest renewal transaction.

Use cURL to call the App Store endpoint. Here’s a rough example, you’ll need to modify it for your particular environment and to fill in the required variables.

Here is an example how to get the subscription status in php:

Verify_iTunes_Andriod_Amazon_Subscription_Status_from_Backend_Server_01

In the response, it will return the subscription detail having expiry date and time.

For more information about error codes and response parameter see on official site

Detect Google Android Subscription Status

You can check the subscription status by sending a request with the purchase token from your server to the play store API. You can check the expiry/renewal field in the server response and see if the purchase has expired or not.

Here is an example how to get the subscription status in php:

Verify_iTunes_Andriod_Amazon_Subscription_Status_from_Backend_Server_02

Where:

  • $appId – your app package name, like com.yourapp.messenger
  • $refreshToken, $clientID, $clientSecret – Your account details for oauth2. Follow the step to generate it from the official site

Detect Amazon Receipt Verification for IAP Apps

The Receipt Verification Service (RVS) allows validation of purchases made by your app’s users through RVS endpoint.

Here is an example how to get the subscription status in php:

Verify_iTunes_Andriod_Amazon_Subscription_Status_from_Backend_Server_03

Here:

  • Shared_secret: Shared secret used to identify the developer. Your shared secret can get on the Shared Key page of your developer account with the Amazon Appstore.
  • More information about error and response see on official site

Conclusion

Finally, you are able to validate all three store purchase receipts with simple cURL implementation to call the server and response having receipt valid period.

Related Posts

Latest Posts

  • All Posts
  • Generative AI
  • manufacturing
  • News
  • Portfolio
    •   Back
    • Android
    • iOS
    • Java
    • PHP
    • MEAN
    • Ruby
    • DotNet
    • IoT
    • Cloud
    • Testing
    • Roku
    • CMS
    • Python

India

Plot No. 11/2, Phase 3, Hinjewadi Rajiv Gandhi Infotech Park, Pune, India – 411057.
info@tudip.com
+91-96-8990-0537

United States

1999 S. Bascom Ave Suite 700, Campbell CA. 95008, USA.
info@tudip.com
+1-408-216-8162

Canada

64 Caracas Road North York, Toronto Ontario M2K 1B1, Canada.
info@tudip.com

Mexico

Calle Amado Nervo #785 Interior B Colonia Ladron De Guevara 44600 Guadalajara, Jalisco, Mexico.
info@tudip.com

Colombia

Cra. 9 # 113-53 Of. 1405 Bogotá D.C., Colombia.
info@tudip.com

UAE

Tudip Information Technologies L.L.C Office No 109, ABU HAIL BUILDING 13, Abu Hail, Dubai, UAE.
info@tudip.com

Nigeria

22 Kumasi Crescent, Wuse 2, Abuja, Nigeria.
info@tudip.com