adjust-icon

Android Purchase verification migration guide

This guide shows you how to migrate from Adjust’s Purchase verification SDK to SDK v5’s built-in purchase verification features. The SDK v5 purchase verification workflow is a streamlined approach to purchase verification.

With the Purchase Verification SDK, verification is split into three steps:

  1. Initialize the Purchase Verification SDK.
String yourAppToken = "{YourAppToken}";
String environment = ADJPConstants.ENVIRONMENT_SANDBOX;
ADJPConfig config = new ADJPConfig(yourAppToken, environment);
AdjustPurchase.init(config);
  1. Verify your purchase.
AdjustPurchase.verifyPurchase(purchase.getSku(),
purchase.getToken(),
purchase.getDeveloperPayload(),
new OnADJPVerificationFinished() {
@Override
public void onVerificationFinished(ADJPVerificationInfo info) {
// process ADJPVerificationInfo
}
});
  1. Depending on the outcome of the verification, configure an AdjustEvent object and send it to Adjust.
AdjustEvent adjustEvent = new AdjustEvent("abc123");
adjustEvent.setRevenue(6.0, "EUR");
adjustEvent.setProductId("product-id");
adjustEvent.setPurchaseToken("purchase-token");
Adjust.trackEvent(adjustEvent);

In SDK v5, this workflow is simplified. The Adjust.verifyAndTrackPlayStorePurchase() method allows you to send an event to Adjust’s servers and receive the verification status as a callback. Adjust records the event and the verification status automatically.

Guide

Follow the steps in this guide to migrate from the Purchase Verification SDK to SDK v5 built-in purchase verification.

1. Uninstall the Purchase Verification SDK

To get started, uninstall the Adjust Purchase Verification SDK.

2. Remove Purchase Verification SDK code

Once you’ve uninstalled the Adjust Purchase Verification SDK, you must remove all Purchase Verification code from your project.

3. Migrate to SDK v5 purchase verification

Once you’ve removed the existing purchase verification code, you can replace it with SDK v5’s built-in purchase verification methods. There are two ways to verify purchases with the Adjust SDK:

  1. Create an AdjustEvent object that represents your purchase and add the following properties:
    • productId (String): The product identifier of the item that was successfully purchased.
    • purchaseToken (String): The purchase token generated for your successfully completed in-app purchase.
  2. Create an AdjustPlayStorePurchase object with your product ID and purchase token.

Record event and verify purchase

To send a revenue event for verification and listen for the purchase verification status, follow these steps:

  1. Instantiate an AdjustEvent object with the your event token and set the following parameters:
    • productId (String): The ID of the product that has been purchased.
    • purchaseToken (String): The purchase token associated with the purchase.
  2. Call the Adjust.verifyAndTrackPlayStorePurchase method with the following arguments:
    • event (AdjustEvent): Your instantiated event object.
    • callback (OnPurchaseVerificationFinishedListener): A delegate callback function that receives an AdjustPurchaseVerificationResult object as an argument.

In this example, the purchase verification response is output to the logging daemon.

Only verify purchase

To send a standalone purchase and listen for the purchase verification status, follow these steps:

  1. Instantiate an AdjustPlayStorePurchase with the following arguments:
    • productId (String): The ID of the product that has been purchased.
    • purchaseToken (String): The purchase token associated with the purchase.
  2. Call the Adjust.verifyPlayStorePurchase method with the following arguments:
    • purchase (AdjustPlayStorePurchase): Your instantiated purchase object.
    • callback (OnPurchaseVerificationFinishedListener): A delegate callback function that receives an AdjustPurchaseVerificationResult object as an argument.

In this example, the purchase verification response is output to the logging daemon.