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) or AdjustPlayStorePurchase
(Google Play Store) object representing the purchase.
Tip 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
(number
): The status code of the purchase.
message
(string
): Any message returned by the store.
Verify purchase and record event
verifyAndTrackAppStorePurchase : ( adjustEvent : AdjustEvent , callback : ( verificationResult : AdjustPurchaseVerificationResult ) => void ) => void
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:
adjustEvent
(AdjustEvent
): Your instantiated event object.
callback
(function
): 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.
var adjustEvent = new AdjustEvent ( "abc123" );
adjustEvent. setProductId ( "product-id" );
adjustEvent. setTransactionId ( "transaction-id" );
adjustEvent. setRevenue ( 6.66 , "CAD" );
Adjust. verifyAndTrackAppStorePurchase (adjustEvent, ( verificationResult ) => {
console. log ( `Verification status: ${ verificationResult . verificationStatus }` );
console. log ( `Code: ${ verificationResult . code }` );
console. log ( `Message: ${ verificationResult . message }` );
verifyAndTrackPlayStorePurchase : ( adjustEvent : AdjustEvent , callback : ( verificationResult : AdjustPurchaseVerificationResult ) => void ) => void
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:
adjustEvent
(AdjustEvent
): Your instantiated event object.
callback
(function
): 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.
var adjustEvent = new AdjustEvent ( "abc123" );
adjustEvent. setProductId ( "product-id" );
adjustEvent. setPurchaseToken ( "purchase-token" );
adjustEvent. setRevenue ( 6.66 , "CAD" );
Adjust. verifyAndTrackPlayStorePurchase (adjustEvent, ( verificationResult ) => {
console. log ( `Verification status: ${ verificationResult . verificationStatus }` );
console. log ( `Code: ${ verificationResult . code }` );
console. log ( `Message: ${ verificationResult . message }` );
Only verify purchase
verifyAppStorePurchase : ( purchase : AdjustAppStorePurchase , callback : ( verificationResult : AdjustPurchaseVerificationResult ) => void ) => void
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
(function
): 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.
var purchase = new AdjustAppStorePurchase ( "product-id" , "transaction-id" );
Adjust. verifyAppStorePurchase (purchase, ( verificationResult ) => {
console. log ( `Verification status: ${ verificationResult . verificationStatus }` );
console. log ( `Code: ${ verificationResult . code }` );
console. log ( `Message: ${ verificationResult . message }` );
verifyPlayStorePurchase : ( purchase : AdjustPlayStorePurchase , callback : ( verificationResult : AdjustPurchaseVerificationResult ) => void ) => void
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
(function
): 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.
var purchase = new AdjustPlayStorePurchase ( "product-id" , "purchase-token" );
Adjust. verifyPlayStorePurchase (purchase, ( verificationResult ) => {
console. log ( `Verification status: ${ verificationResult . verificationStatus }` );
console. log ( `Code: ${ verificationResult . code }` );
console. log ( `Message: ${ verificationResult . message }` );