If you’ve enabled purchase verification, you can use the Adjust SDK to request purchase verification.
To use Purchase verification, you first need to set up your app for purchase verification in the Adjust suite. See Set up purchase verification for your app for instructions.
There are two ways to verify purchases with the Adjust SDK:
- Create an
ADJEvent
object that represents your purchase and add the following properties:transactionId
(NSString
): The ID of the transaction you want to verify.productId
(NSString
): The product identifier of the item that was successfully purchased.
- Create an
ADJAppStorePurchase
object with your transaction ID and product ID.
If you use revenue events to measure your purchases in Adjust, you should use the ADJEvent
class. If you only want to verify a purchase but don’t want to associate it with an event, use the ADJAppStorePurchase
class.
When you send purchase information with the Adjust SDK, Adjust does the following:
- Sends the information to the App 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 ADJPurchaseVerificationResult
objects containing the following properties:
verificationStatus
(NSString
): The status of the purchase.code
(int
): The status code of the purchase.message
(NSString
): Any message returned by the App Store.
Record event and verify purchase
To send a revenue event for verification and listen for the purchase verification status, follow these steps:
- Instantiate an
ADJEvent
object with the your event token and set the following parameters:transactionId
(NSString
): The ID of the transaction you want to verify.productId
(NSString
): The product identifier of the item that was successfully purchased.
- Call the
Adjust.verifyAndTrackPlayStorePurchase
method with the following arguments:event
(ADJEvent
): Your instantiated event object.callback
(ADJVerificationResultBlock
): A delegate callback function that receives anADJPurchaseVerificationResult
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:
- Instantiate an
ADJAppStorePurchase
with the following arguments:transactionId
(NSString
): The ID of the transaction you want to verify.productId
(NSString
): The product identifier of the item that was successfully purchased.
- Call the
Adjust.verifyAppStorePurchase
method with the following arguments:purchase
(ADJAppStorePurchase
): Your instantiated purchase object.callback
(ADJVerificationResultBlock
): A delegate callback function that receives anADJPurchaseVerificationResult
object as an argument.
In this example, the purchase verification response is output to the logging daemon.
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 ADJEvent
object, they forward it to Apple to verify the purchase.
To verify a purchase, instantiate an ADJEvent
object with your event token and set the following properties:
transactionId
(NSString
): ThetransactionIdentifier
value of the successfully completed purchaseproductId
(NSString
): The product identifier of the item that was successfully purchasedreceipt
(NSData
): The signed receipt containing the information about the successfully completed purchase
See Send event information for more information on the ADJEvent
class.