Receipt Validation for Android

  • Advertisers
  • Developers


You can perform receipt validation for in-app purchases in the Google Play Store.

Receipt Validation Flow

The Receipt Validation Flow is as follows:

1. User performs an in-app purchase

2. Google Play Store responds with success or fail (authentication)

3. Developer calls the SDK Receipt Validation function

public static void validateAndTrackInAppPurchase(Context context, 
String publicKey, String signature, String purchaseData, String price, 
String currency, HashMap<String, String> additionalParameters);
  • Signature and purchase data = The developer gets it from google api when purchase succeeded.
  • Signature = transaction signature
  • purchase data = is the actual product purchased in json format.
  • API Key = is the public key, the developer gets this from the Google portal

For example:

base64EncodedPublicKey, dataSignature, purchaseData, "0.99", "USD", null);

4. Developer must register to validate listener to receive the callbacks.

5. The SDK calls AppsFlyer's validation service with the receipt data

6. AppsFlyer's validation service validates the transaction with Google's servers

7. Google's servers respond with success or failure

8. AppsFlyer's validation service transfers the response to the SDK

9. The SDK transfers the receipt validation response to the App


Calling validateAndTrackInAppPurchase automatically generates an af_purchase in-app event. This saves you the need to send the event yourself from the SDK. If you validate the purchase as well as send the event yourself, the purchase is duplicated and so is the revenue.

Sample of a Receipt Validation Response

   AppsFlyerInAppPurchaseValidatorListener() {
     public void onValidateInApp() {
       Log.d(TAG, "Purchase validated successfully");
     public void onValidateInAppFailure(String error) {
       Log.d(TAG, "onValidateInAppFailure called: " + error);
Was this article helpful?
3 out of 3 found this helpful

Page Contents: