Report transactions in Observer Mode
- Adapty SDK v3.4+ (current)
- Adapty SDK 3.3.x (legacy)
- Adapty SDK up to 3.2.x (legacy)
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.
- Swift
- Kotlin
- Java
- Flutter
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 paywalls, include the variationId
when reporting a transaction. This links the purchase to the paywall that triggered it, ensuring accurate paywall analytics.
do {
// every time when calling transasction.finish()
try await Adapty.reportTransaction(transaction, withVariationId: <YOUR_PAYWALL_VARIATION_ID>)
} catch {
// handle the error
}
Parameters:
Parameter | Presence | Description |
---|---|---|
transaction | required |
|
variationId | optional | The unique ID of the paywall variation. Retrieve it from the variationId property of the AdaptyPaywall object. |
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 paywalls, include the variationId
when reporting a transaction. This links the purchase to the paywall that triggered it, ensuring accurate paywall 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. |
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 paywalls, include the variationId
when reporting a transaction. This links the purchase to the paywall that triggered it, ensuring accurate paywall analytics.
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. |
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 paywalls, include the variationId
when reporting a transaction. This links the purchase to the paywall that triggered it, ensuring accurate paywall analytics.
try {
// every time when calling transaction.finish()
await Adapty().reportTransaction(
"YOUR_TRANSACTION_ID",
variationId: "PAYWALL_VARIATION_ID", // optional
);
} on AdaptyError catch (adaptyError) {
// handle the error
} catch (e) {
// handle the error
}
Parameters:
Parameter | Presence | Description |
---|---|---|
transactionId | required |
|
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.
- Swift
- Kotlin
- Java
- Flutter
- Unity
- React Native (TS)
Use reportTransaction
to send the transaction data to Adapty.
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 paywalls, include the withVariationId
when reporting a transaction. This links the purchase to the paywall that triggered it, ensuring accurate paywall analytics.
do {
// every time when calling transasction.finish()
try await Adapty.reportTransaction(transaction, withVariationId: <YOUR_PAYWALL_VARIATION_ID>)
} catch {
// handle the error
}
Parameters:
Parameter | Presence | Description |
---|---|---|
transaction | required |
|
variationId | optional | The unique ID of the paywall variation. Retrieve it from the variationId property of the AdaptyPaywall object. |
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 paywalls, link your transaction to the paywall that led to the purchase using the setVariationId
method. This ensures the purchase is correctly attributed to the triggering paywall for accurate analytics. This step is only necessary if you're using Adapty paywalls.
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. |
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 paywalls, link your transaction to the paywall that led to the purchase using the setVariationId
method. This ensures the purchase is correctly attributed to the triggering paywall for accurate analytics. This step is only necessary if you're using Adapty paywalls.
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. |
Use reportTransaction
on both platforms to explicitly report each transaction, and use restorePurchases
on Android as an additional step to ensure Adapty recognizes it.
Don't skip transaction reporting and purchase restoring! If you don't call these methods, Adapty won't recognize the transaction, it won’t appear in analytics, and it won’t be sent to integrations.
If you use Adapty paywalls, include the variationId
when reporting a transaction. This links the purchase to the paywall that triggered it, ensuring accurate paywall analytics.
// every time when calling transaction.finish()
if (Platform.isAndroid) {
try {
await Adapty().restorePurchases();
} on AdaptyError catch (adaptyError) {
// handle the error
} catch (e) {
}
}
try {
// every time when calling transaction.finish()
await Adapty().reportTransaction(
"YOUR_TRANSACTION_ID",
variationId: "PAYWALL_VARIATION_ID", // optional
);
} on AdaptyError catch (adaptyError) {
// handle the error
} catch (e) {
// handle the error
}
Parameters:
Parameter | Presence | Description |
---|---|---|
transactionId | required |
|
variationId | optional | The string identifier of the variation. You can get it using variationId property of the AdaptyPaywall object. |
Use reportTransaction
on both platforms to explicitly report each transaction, and use restorePurchases
on Android as an additional step to ensure Adapty recognizes it.
Don't skip transaction reporting and purchase restoring! If you don't call these methods, Adapty won't recognize the transaction, it won’t appear in analytics, and it won’t be sent to integrations.
If you use Adapty paywalls, include the PAYWALL_VARIATION_ID
when reporting a transaction. This links the purchase to the paywall that triggered it, ensuring accurate paywall analytics.
// every time when calling transasction.finish()
#if UNITY_ANDROID && !UNITY_EDITOR
Adapty.RestorePurchases((profile, error) => {
// handle the error
});
#endif
Adapty.ReportTransaction(
"YOUR_TRANSACTION_ID",
"PAYWALL_VARIATION_ID", // optional
(error) => {
// handle the error
});
Parameters:
Parameter | Presence | Description |
---|---|---|
transactionId | required |
|
variationId | optional | The string identifier of the variation. You can get it using variationId property of the AdaptyPaywall object. |
Use reportTransaction
on both platforms to explicitly report each transaction, and use restorePurchases
on Android as an additional step to ensure Adapty recognizes it.
Don't skip transaction reporting! If you don't call these methods, Adapty won't recognize the transaction, it won’t appear in analytics, and it won’t be sent to integrations.
If you use Adapty paywalls, include the variationId
when reporting a transaction. This links the purchase to the paywall that triggered it, ensuring accurate paywall analytics.
if (Platform.OS === 'android') {
try {
await adapty.restorePurchases();
} catch (error) {
// handle the error
}
}
...
const variationId = paywall.variationId;
try {
await adapty.reportTransaction(transactionId, variationId);
} catch (error) {
// handle the `AdaptyError`
}
Parameters:
Parameter | Presence | Description |
---|---|---|
transactionId | required |
|
variationId | optional | The string identifier of the variation. You can get it using variationId property of the AdaptyPaywall object. |
- iOS
- Android and Android-based cross-platforms
Reporting transactions
- Versions up to 3.1.x automatically listen for transactions in the App Store, so manual reporting is not required.
- Version 3.2 does not support Observer Mode.
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 paywalls to transactions
Adapty SDK cannot determine the source of purchases, as you are the one processing them. Therefore, if you intend to use paywalls and/or A/B tests in Observer mode, you need to associate the transaction coming from your app store with the corresponding paywall in your mobile app code. This is important to get right before releasing your app, otherwise, it will lead to errors in analytics.
- Swift
- Kotlin
- Java
- Flutter
- Unity
- React Native (TS)
let variationId = paywall.variationId
// There are two overloads: for StoreKit 1 and StoreKit 2
Adapty.setVariationId(variationId, forPurchasedTransaction: transactionId) { error in
if error == nil {
// successful binding
}
}
Request parameters:
Parameter | Presence | Description |
---|---|---|
variationId | required | The string identifier of the variation. You can get it using variationId property of the AdaptyPaywall object. |
transactionId | required | For StoreKit 1: an SKPaymentTransaction object. For StoreKit 2: Transaction object. |
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. |
final transactionId = transaction.transactionIdentifier
final variationId = paywall.variationId
try {
await Adapty().setVariationId('transactionId', variationId);
} on AdaptyError catch (adaptyError) {
// handle the error
} catch (e) {
}
Adapty.SetVariationForTransaction("<variationId>", "<transactionId>", (error) => {
if(error != null) {
// handle the error
return;
}
// successful binding
});
Parameter | Presence | Description |
---|---|---|
transactionId | required | For iOS, StoreKit 1: an SKPaymentTransaction object. For iOS, StoreKit 2: Transaction object. For Android: 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. |
const variationId = paywall.variationId;
try {
await adapty.setVariationId('transactionId', variationId);
} catch (error) {
// handle the `AdaptyError`
}
Request parameters:
Parameter | Presence | Description |
---|---|---|
transactionId | required | For iOS, StoreKit 1: an SKPaymentTransaction object. For iOS, StoreKit 2: Transaction object. For Android: 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. |