Report transactions in Observer Mode in Android SDK
Install agent tools
Run the whole Adapty SDK integration from your AI coding tool. Learn more
Installs into any agent that supports skills. To update later, run npx skills update.
Skills cover SDK integration, building flows and paywalls, pre-publish audits, placement migration, and more. Describe the task in plain language and your agent picks the skill.
In Observer mode, the Adapty SDK can’t track purchases made through your existing purchase system on its own. You need to report transactions from your app store. It’s crucial to set this up before releasing your app to avoid errors in analytics.
Use reportTransaction to explicitly report each transaction for Adapty to recognize it.
Don’t skip transaction reporting!
If you don’t call reportTransaction, Adapty won’t recognize the transaction, it won’t appear in analytics, and it won’t be sent to integrations.
If you use Adapty flows & paywalls, include the variationId when reporting a transaction. This links the purchase to the flow or paywall that triggered it, ensuring accurate analytics.
val transactionInfo = TransactionInfo.fromPurchase(purchase)
Adapty.reportTransaction(transactionInfo, variationId) { result ->
if (result is AdaptyResult.Success) {
// success
}
}Parameters:
| Parameter | Presence | Description |
|---|---|---|
| transactionInfo | required | The TransactionInfo from the purchase, where the purchase is an instance of the billing library Purchase class. |
| variationId | optional | The string identifier of the variation. You can get it using variationId property of the AdaptyPaywall object. |
TransactionInfo transactionInfo = TransactionInfo.fromPurchase(purchase);
Adapty.reportTransaction(transactionInfo, variationId, result -> {
if (result instanceof AdaptyResult.Success) {
// success
}
});Parameters:
| Parameter | Presence | Description |
|---|---|---|
| transactionInfo | required | The TransactionInfo from the purchase, where the purchase is an instance of the billing library Purchase class. |
| variationId | optional | The string identifier of the variation. You can get it using variationId property of the AdaptyPaywall object. |
In Observer mode, the Adapty SDK can’t track purchases made through your existing purchase system on its own. You need to report transactions from your app store or restore them. It’s crucial to set this up before releasing your app to avoid errors in analytics.
Use restorePurchases to report the transaction to Adapty.
Don’t skip purchase restoring!
If you don’t call restorePurchases, Adapty won’t recognize the transaction, it won’t appear in analytics, and it won’t be sent to integrations.
If you use Adapty flows & paywalls, link your transaction to the flow or paywall that led to the purchase using the setVariationId method. This attributes the purchase correctly for accurate analytics.
Adapty.restorePurchases { result ->
if (result is AdaptyResult.Success) {
// success
}
}
Adapty.setVariationId(transactionId, variationId) { error ->
if (error == null) {
// success
}
}Parameters:
| Parameter | Presence | Description |
|---|---|---|
| transactionId | required | String identifier (purchase.getOrderId) of the purchase, where the purchase is an instance of the billing library Purchase class. |
| variationId | required | The string identifier of the variation. You can get it using variationId property of the AdaptyPaywall object. |
Adapty.restorePurchases(result -> {
if (result instanceof AdaptyResult.Success) {
// success
}
});
Adapty.setVariationId(transactionId, variationId, error -> {
if (error == null) {
// success
}
});Parameters:
| Parameter | Presence | Description |
|---|---|---|
| transactionId | required | String identifier (purchase.getOrderId) of the purchase, where the purchase is an instance of the billing library Purchase class. |
| variationId | required | The string identifier of the variation. You can get it using variationId property of the AdaptyPaywall object. |
Reporting transactions
Use restorePurchases to report a transaction to Adapty in Observer Mode, as explained on the Restore Purchases in Mobile Code page.
Don’t skip transaction reporting!
If you don’t call restorePurchases, Adapty won’t recognize the transaction, it won’t appear in analytics, and it won’t be sent to integrations.
Associating flows & paywalls to transactions
Adapty SDK cannot determine the source of purchases, as you are the one processing them. Therefore, if you intend to use flows, paywalls, and/or A/B tests in Observer mode, you need to associate the transaction coming from your app store with the corresponding flow or paywall in your mobile app code. This is important to get right before releasing your app, otherwise, it will lead to errors in analytics.
Adapty.setVariationId(transactionId, variationId) { error ->
if (error == null) {
// success
}
}Request parameters:
| Parameter | Presence | Description |
|---|---|---|
| transactionId | required | String identifier (purchase.getOrderId of the purchase, where the purchase is an instance of the billing library Purchase class. |
| variationId | required | The string identifier of the variation. You can get it using variationId property of the AdaptyPaywall object. |
Adapty.setVariationId(transactionId, variationId, error -> {
if (error == null) {
// success
}
});
| Parameter | Presence | Description |
|---|---|---|
| transactionId | required | String identifier (purchase.getOrderId of the purchase, where the purchase is an instance of the billing library Purchase class. |
| variationId | required | The string identifier of the variation. You can get it using variationId property of the AdaptyPaywall object. |