If you’ve enabled purchase verification, you can use the Adjust SDK to request purchase verification. There are two ways to verify purchases with the Adjust SDK:
- Create an
AdjustEvent
object that represents your purchase and configure purchase properties for the target store. - Create an
AdjustAppStorePurchase
(Apple App Store) orAdjustPlayStorePurchase
(Google Play Store) object representing the purchase.
If you use revenue events to measure your purchases in Adjust, you should use the AdjustEvent
class. If you only want to verify a purchase but don’t want to associate it with an event, use the AdjustAppStorePurchase
or AdjustPlayStorePurchase
class.
When you send purchase information with the Adjust SDK, Adjust does the following:
- Sends the information to the relevant store and waits for a status response.
- Forwards the status response to the Adjust SDK.
You can access the purchase verification status by using a callback. Results are returned as AdjustPurchaseVerificationResult
objects containing the following properties:
VerificationStatus
(string
): The status of the purchase.Code
(int
): The status code of the purchase.Message
(string
): Any message returned by the store.
Verify purchase and record event
public static void VerifyAndTrackAppStorePurchase(AdjustEvent adjustEvent, Action<AdjustPurchaseVerificationResult> callback);
To send a revenue event for verification and listen for the purchase verification status, follow these steps:
- Instantiate an
AdjustEvent
object with the your event token and set the following parameters:ProductId
(string
): The product identifier of the item that was successfully purchased.TransactionId
(string
): The ID of the transaction you want to verify.
- Call the
Adjust.VerifyAndTrackPlayStorePurchase
method with the following arguments:event
(AdjustEvent
): Your instantiated event object.callback
(Action
): A delegate callback function that receives anAdjustPurchaseVerificationResult
object as an argument.
In this example, the purchase verification response is output to the logging daemon.
AdjustEvent adjustEvent = new AdjustEvent("abc123");adjustEvent.SetRevenue(6.66, "CAD");adjustEvent.TransactionId = "transaction-id";adjustEvent.ProductId = "product-id";Adjust.VerifyAndTrackPlayStorePurchase(adjustEvent, verificationResult =>{ Debug.Log("Verification status: " + verificationResult.VerificationStatus); Debug.Log("Code: " + verificationResult.Code); Debug.Log("Message: " + verificationResult.Message);});
public static void VerifyAndTrackPlayStorePurchase(AdjustEvent adjustEvent,Action<AdjustPurchaseVerificationResult> verificationResultCallback);
To send a revenue event for verification and listen for the purchase verification status, follow these steps:
- 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.
- Call the
Adjust.VerifyAndTrackPlayStorePurchase
method with the following arguments:ajustEvent
(AdjustEvent
): Your instantiated event object.callback
(Action
): A delegate callback function that receives anAdjustPurchaseVerificationResult
object as an argument.
In this example, the purchase verification response is output to the logging daemon.
AdjustEvent adjustEvent = new AdjustEvent("abc123");adjustEvent.SetRevenue(6.66, "CAD");adjustEvent.ProductId = "product-id";adjustEvent.PurchaseToken = "purchase-token";Adjust.VerifyAndTrackPlayStorePurchase(adjustEvent, verificationResult =>{ Debug.Log("Verification status: " + verificationResult.VerificationStatus); Debug.Log("Code: " + verificationResult.Code); Debug.Log("Message: " + verificationResult.Message);});
Only verify purchase
public static void VerifyAppStorePurchase(AdjustAppStorePurchase purchase, Action<AdjustPurchaseVerificationResult> callback);
To send a standalone App Store purchase and listen for the purchase verification status, follow these steps:
- Instantiate an
AdjustAppStorePurchase
object with the following arguments:ProductId
(string
): The product identifier of the item that was successfully purchased.TransactionId
(string
): The ID of the transaction you want to verify.
- Call the
Adjust.VerifyAppStorePurchase
method with the following arguments:purchase
(AdjustAppStorePurchase
): Your instantiated event object.callback
(Action
): A delegate callback function that receives anAdjustPurchaseVerificationResult
object as an argument.
In this example, the purchase verification response is output to the logging daemon.
AdjustAppStorePurchase purchase = new AdjustAppStorePurchase("product-id", "transaction-id");Adjust.VerifyAppStorePurchase(purchase, (verificationResult) =>{ Debug.Log("Verification status: " + verificationResult.VerificationStatus); Debug.Log("Code: " + verificationResult.Code); Debug.Log("Message: " + verificationResult.Message);});
public static void VerifyPlayStorePurchase(AdjustPlayStorePurchase purchase,Action<AdjustPurchaseVerificationResult> verificationResultCallback);
To send a standalone Play Store purchase and listen for the purchase verification status, follow these steps:
- 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.
- Call the
Adjust.VerifyPlayStorePurchase
method with the following arguments:purchase
(AdjustPlayStorePurchase
): Your instantiated purchase object.verificationResultCallback
(Action
): A delegate callback function that receives anAdjustPurchaseVerificationResult
object as an argument.
In this example, the purchase verification response is output to the logging daemon.
AdjustPlayStorePurchase purchase = new AdjustPlayStorePurchase("product-id", "purchase-token");Adjust.VerifyPlayStorePurchase(purchase, (verificationResult) =>{ Debug.Log("Verification status: " + verificationResult.VerificationStatus); Debug.Log("Code: " + verificationResult.Code); Debug.Log("Message: " + verificationResult.Message);});
If you’ve enabled purchase verification, you must send additional information with your purchase events to verify them. When Adjust’s servers receive this information in an event object, they forward it to Apple or Google to verify the purchase depending on what information is included.
See Send event information for more information on the AdjustEvent
class.
To verify an App Store purchase, instantiate an AdjustEvent
object with your event token and set the following properties:
productId
(string
): The product identifier of the item that was successfully purchased.transactionId
(string
): The ID of the transaction you want to verify.receipt
(string
): The in-app purchase receipt.
AdjustEvent adjustEvent = new AdjustEvent("abc123");adjustEvent.setRevenue(6.0, "EUR");adjustEvent.setProductId("product-id");adjustEvent.setTransactionId("transaction-id");adjustEvent.setReceipt("receipt");Adjust.trackEvent(adjustEvent);
To verify a Play Store purchase, instantiate an AdjustEvent
object with your event token and set 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.
AdjustEvent adjustEvent = new AdjustEvent("abc123");adjustEvent.setRevenue(6.0, "EUR");adjustEvent.setProductId("product-id");adjustEvent.setPurchaseToken("purchase-token");Adjust.trackEvent(adjustEvent);