Report transactions in Observer Mode in Capacitor SDK

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.

Warning

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.

Warning

Pass the variationId of the AdaptyPaywallProduct the user bought, not AdaptyFlow.variationId. A flow’s own variation ID doesn’t link the purchase to the flow.

import { adapty } from '@adapty/capacitor';

const variationId = product.variationId; // the AdaptyPaywallProduct the user bought

try {
  await adapty.reportTransaction({ 
    transactionId: 'your_transaction_id',
    variationId: variationId 
  });
} catch (error) {
  console.error('Failed to report transaction:', error);
}

Parameters:

ParameterPresenceDescription
transactionIdrequired
  • For iOS: Identifier of the transaction.
  • For Android: String identifier (purchase.getOrderId) of the purchase, where the purchase is an instance of the billing library Purchase class.
variationIdoptionalThe string identifier of the variation. Pass the variationId of the AdaptyPaywallProduct the user bought. It’s the same value as the variationId of the AdaptyFlowPaywall that contains this product.
ios.jwsTransactionoptionaliOS only, SDK 4.3.0 or later. The signed StoreKit 2 transaction: the jwsRepresentation of its verification result, for the same transaction as transactionId. The SDK sends it to Adapty as is. Android ignores this parameter.

On iOS, if your purchase system gives you the StoreKit 2 transaction, pass its JWS representation in ios.jwsTransaction:

await adapty.reportTransaction({
  transactionId: 'your_transaction_id',
  variationId: variationId, // optional
  ios: { jwsTransaction: 'YOUR_JWS_REPRESENTATION' }, // iOS only, optional
});

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.

Warning

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.

import { adapty } from '@adapty/capacitor';

const variationId = paywall.variationId;

try {
  await adapty.reportTransaction({ 
    transactionId: 'your_transaction_id',
    variationId: variationId 
  });
} catch (error) {
  console.error('Failed to report transaction:', error);
}

Parameters:

ParameterPresenceDescription
transactionIdrequired
  • For iOS: Identifier of the transaction.
  • For Android: String identifier (purchase.getOrderId) of the purchase, where the purchase is an instance of the billing library Purchase class.
variationIdoptionalThe string identifier of the variation. You can get it using variationId property of the AdaptyPaywall object.