Google provides receipt validation through the Google Play Developer API, within the API are two endpoints you will be most interested in: Purchases.products: get and Purchases.subscriptions: get.

Purchases.products: get can be used to verify a non-auto-renewing product purchase, where Purchases.subscriptions: get is for verifying and re-verifying auto-renewing product subscriptions.

To use either endpoint you must know the packageName, productId, purchaseToken all of these can be found in the payload you received on purchase. You also need an access_token which you can get by creating a Google API service account.

To get started with a service account first go to the Google play Developer console API access settings page and click the Create new project button:

You should now see a new Linked Project and a few new sections, in the the Service Account section, click the Create service account button.

You will be presented with an info box with instructions to create your service account. Click the link to Google Developers Console and a new tab will spawn.

Now click Create new Client ID, select Service account from the options and click Create Client ID.

A JSON file will download, this is your JSON Web Token you will use to exchange for an access_token so keep it safe.

Next, switch tabs back to the Google play Developer console and click Done in the info box. You should see your new service account in the list. Click on Grant access next to the service account email.

Next under the Choose a role for this user, select Finance and click Add user.

You have now set up your service account and it has all the necessary access to perform receipt validations. Next up is exchanging your JWT for an access_token.

The access_token expires after one hour of exchange you so need some server code to handle this and Google have provided several libraries in many languages to handle this (list not exhaustive):

  • Ruby: https://github.com/google/google-api-ruby-client
  • Node.js: https://github.com/google/google-api-nodejs-client
  • Java: https://github.com/google/google-api-java-client
  • Python: https://github.com/google/google-api-python-client
  • C#: https://github.com/googleapis/google-api-dotnet-client

I won't go into detail because there is plenty of documentation on how to use these libraries, but I will mention you want to use the https://www.googleapis.com/auth/androidpublisher as the OAuth2 scope, the client_email from the JWT as the issuer and the public key you can get from the private_key and the passphrase notasecret will be used for the signing_key.

Once you have the access_token you're good to go (at least for the next hour at which point you will want to request a new one following the same process in the above paragraph).

To check the status of a consumable (non-auto-renewing) purchase make a http get request to: https://www.googleapis.com/androidpublisher/v2/applications/com.example.app/purchases/products/exampleSku/tokens/rojeslcdyyiapnqcynkjyyjh?access_token=your_access_token

If you get a 200 http response code, everything went as planed and your purchase was valid. A 404 will mean your token is invalid so the purchase was most likely a fraud attempt. A 401 will mean your access token is invalid and a 403 will mean your service account has insufficient access, check that you have enabled Finance for the access account in the Google Play Developer console.

The response from a 200 will look similar to this:

{
  "kind": "androidpublisher#productPurchase",
  "purchaseTimeMillis": long,
  "purchaseState": integer,
  "consumptionState": integer,
  "developerPayload": string
}

For an explanation of each property see https://developers.google.com/android-publisher/api-ref/purchases/products.

Subscriptions are similar however the endpoint looks like this:

https://www.googleapis.com/androidpublisher/v2/applications/packageName/purchases/subscriptions/subscriptionId/tokens/token?access_token=you_access_token

And the response should contain these properties:

{
  "kind": "androidpublisher#subscriptionPurchase",
  "startTimeMillis": long,
  "expiryTimeMillis": long,
  "autoRenewing": boolean
}

See https://developers.google.com/android-publisher/api-ref/purchases/subscriptions for the property descriptions and note that startTimeMillis and expiryTimeMillis will be subject to change depending on the duration of the subscription.

Happy validating!

Answer from Marc Greenstock on Stack Overflow
🌐
Google Support
support.google.com › store › answer › 13714320
Find your Google Store receipt & order number - Google Store Help
After you place an order on the Google Store, you get a confirmation email that has your order number and receipt. You can find your Google Store invoice online at the Google payments center. If you
🌐
Google Support
support.google.com › googleplay › answer › 2850369
Review your order history - Google Play Help
When you make a purchase on Google Play, we'll send a confirmation email with your order information to the Google Account you use when making your purchase. You can always see your order history on G
🌐
Jam City
jamcity.helpshift.com › hc › en › 11-panda-pop › faq › 702-how-do-i-obtain-my-google-play-order-number-and-receipt
How do I obtain my Google Play order number and receipt? — Panda Pop Help Center
After making a purchase on Google Play, a confirmation email containing your order information is sent to the Google account you used for the purchase. Look for an order number that begins with "GPA" followed by a series of numbers, for example: GPA.1234-1234-1234-12345.
🌐
Disney
appsupport.disney.com › hc › en-us › articles › 360000777083-How-do-I-find-my-receipt-for-Google-Play-Store
How do I find my receipt for Google Play Store? – Games and Apps Support
You can locate your Google Play receipt with the steps below: Go to wallet.google.com/manage · Sign in with your Google Play account · Under Payments in the upper-left corner, select Transactions · Click on the transaction line to view the ...
🌐
TimePassages Support
support.astrograph.com › support › solutions › articles › 66000530386-how-to-find-your-google-play-receipt
How to Find Your Google Play Receipt :
Open the Google Play Store app. Tap your profile icon in the top right corner. Select Payments & subscriptions → Budget & history. Tap Purchase History to view your recent purchases. Tap a purchase to view the receipt.
Top answer
1 of 5
273

Google provides receipt validation through the Google Play Developer API, within the API are two endpoints you will be most interested in: Purchases.products: get and Purchases.subscriptions: get.

Purchases.products: get can be used to verify a non-auto-renewing product purchase, where Purchases.subscriptions: get is for verifying and re-verifying auto-renewing product subscriptions.

To use either endpoint you must know the packageName, productId, purchaseToken all of these can be found in the payload you received on purchase. You also need an access_token which you can get by creating a Google API service account.

To get started with a service account first go to the Google play Developer console API access settings page and click the Create new project button:

You should now see a new Linked Project and a few new sections, in the the Service Account section, click the Create service account button.

You will be presented with an info box with instructions to create your service account. Click the link to Google Developers Console and a new tab will spawn.

Now click Create new Client ID, select Service account from the options and click Create Client ID.

A JSON file will download, this is your JSON Web Token you will use to exchange for an access_token so keep it safe.

Next, switch tabs back to the Google play Developer console and click Done in the info box. You should see your new service account in the list. Click on Grant access next to the service account email.

Next under the Choose a role for this user, select Finance and click Add user.

You have now set up your service account and it has all the necessary access to perform receipt validations. Next up is exchanging your JWT for an access_token.

The access_token expires after one hour of exchange you so need some server code to handle this and Google have provided several libraries in many languages to handle this (list not exhaustive):

  • Ruby: https://github.com/google/google-api-ruby-client
  • Node.js: https://github.com/google/google-api-nodejs-client
  • Java: https://github.com/google/google-api-java-client
  • Python: https://github.com/google/google-api-python-client
  • C#: https://github.com/googleapis/google-api-dotnet-client

I won't go into detail because there is plenty of documentation on how to use these libraries, but I will mention you want to use the https://www.googleapis.com/auth/androidpublisher as the OAuth2 scope, the client_email from the JWT as the issuer and the public key you can get from the private_key and the passphrase notasecret will be used for the signing_key.

Once you have the access_token you're good to go (at least for the next hour at which point you will want to request a new one following the same process in the above paragraph).

To check the status of a consumable (non-auto-renewing) purchase make a http get request to: https://www.googleapis.com/androidpublisher/v2/applications/com.example.app/purchases/products/exampleSku/tokens/rojeslcdyyiapnqcynkjyyjh?access_token=your_access_token

If you get a 200 http response code, everything went as planed and your purchase was valid. A 404 will mean your token is invalid so the purchase was most likely a fraud attempt. A 401 will mean your access token is invalid and a 403 will mean your service account has insufficient access, check that you have enabled Finance for the access account in the Google Play Developer console.

The response from a 200 will look similar to this:

{
  "kind": "androidpublisher#productPurchase",
  "purchaseTimeMillis": long,
  "purchaseState": integer,
  "consumptionState": integer,
  "developerPayload": string
}

For an explanation of each property see https://developers.google.com/android-publisher/api-ref/purchases/products.

Subscriptions are similar however the endpoint looks like this:

https://www.googleapis.com/androidpublisher/v2/applications/packageName/purchases/subscriptions/subscriptionId/tokens/token?access_token=you_access_token

And the response should contain these properties:

{
  "kind": "androidpublisher#subscriptionPurchase",
  "startTimeMillis": long,
  "expiryTimeMillis": long,
  "autoRenewing": boolean
}

See https://developers.google.com/android-publisher/api-ref/purchases/subscriptions for the property descriptions and note that startTimeMillis and expiryTimeMillis will be subject to change depending on the duration of the subscription.

Happy validating!

2 of 5
31

Marc's answer is excellent. I will only add that the Google Play Developer API Client Library for Java makes it much simpler when connecting from your server to the Google Play servers. The library automatically handles refreshing the auth token and also provides a typesafe API so you don't have to muck around with URLs.

Here's how you setup the Publisher singleton:

httpTransport = GoogleNetHttpTransport.newTrustedTransport();
jsonFactory = JacksonFactory.getDefaultInstance();      
credential = GoogleCredential.fromStream(getClass().getResourceAsStream("/path/to/your/key.json")).createScoped(Collections.singleton(AndroidPublisherScopes.ANDROIDPUBLISHER));
publisher = new AndroidPublisher.Builder(httpTransport, jsonFactory, credential).setApplicationName(APP_NAME).build();

The following code queries a product purchase:

ProductPurchase product = publisher.purchases().products().get(PACKAGE_NAME, sku, token).execute();
Integer purchaseState = product.getPurchaseState();
product.getPurchaseTimeMillis();
product.getConsumptionState();
product.getDeveloperPayload();

You can similarly query for subscriptions:

SubscriptionPurchase sub = publisher.purchases().subscriptions().get(PACKAGE_NAME, sku, token).execute();
sub.getAutoRenewing();
sub.getCancelReason();
...
🌐
Oqupie
rom.oqupie.com › portals › 2486 › articles › 57645
[Google] How can I check my Google Play Store order number? | ROM: Remember Of Majesty
[How to check the order number in the Google Payment Center] Access the Google Payment Center (payments.google.com). Log in with your Google account. Go to Subscriptions and Services > View Purchase History > Select the order, then check the transaction ID on the receipt.
Find elsewhere
🌐
YouTube
youtube.com › watch
How to download receipts for Google Play purchases | Download vat invoices on Play | Techno Logic - YouTube
How to download receipts for Google Play purchases | Download vat invoices on Play | Techno LogicHello everyone, welcome to Techno Logic. In this video, we'l...
Published   October 13, 2020
🌐
Google Support
support.google.com › store › video › 13570845
How to find your receipt on the Google Store - Google Store Help
Learn how to find your receipt on the Google Store. For more help, visit "Understand your Google Store charges & receipts": https://support.google.com/store/answer/13037491?visit_id=638085593776392671-142228614&rd=1
🌐
JustAnswer
justanswer.com › software › mocxy-i-m-looking-google-play-receipts-game.html
How to Retrieve Google Play Receipts for Game Reinstatement | JustAnswer
To retrieve Google Play receipts ... Ultra, open the Google Play Store app, tap your profile icon, then select 'Payments & subscriptions' > 'Budget & history.' Here, you can view purchase details but not official receipts. For formal receipts, visit pay.google.com and log in with your Google account...
🌐
Splinterlands
support.splinterlands.com › hc › en-us › articles › 4412510627476-Retrieving-your-Google-Play-Receipt
Retrieving your Google Play Receipt – Splinterlands
Retrieving your Google Play Receipt Step 1: Open the Google Play Store on your device by clicking the area circled in red below. Step 2: Next, click Payments & subscriptions. Step 3: Go ...
🌐
YouTube
youtube.com › shorts › 89dTmqw-7JU
How to find your Google Store receipts - YouTube
You can check your Google Store receipts in the Google payments center. In this video, we’ll show you how to access the Google payments center with your Goog...
Published   January 11, 2023
🌐
Google Account
myaccount.google.com › purchases
Google Account
When you sign in to your account, you can see your payment info, transactions, recurring payments, and reservations
🌐
Help Center
support.beautyplus.com › hc › en-us › articles › 1500009797481-How-to-Find-My-Receipt-and-Order-Number-in-Google-Play-Store
How to Find My Receipt and Order Number in Google Play Store?
When you purchase items on the Google Play Store, you usually receive a confirmation email which includes your order number. If you are unable to find the confirmation email, you can find your o...
🌐
MementoMori FAQ
mementomori.zendesk.com › hc › en-us › articles › 46698034901913-How-do-I-check-the-order-number-on-my-receipt-from-Google-Play
How do I check the order number on my receipt from Google Play? – MementoMori FAQ
2. From your registered email address, check if you received a receipt email at the time of purchasing the product in question. If you received one, take a screenshot of the receipt contents. ▼How to check from your phone or PC ==== 1. Access the following link: https://payments.google.com/ 2.