Skip to content

Commit

Permalink
Merge branch 'ADP-2218-Observer-mode-after-330' into develop
Browse files Browse the repository at this point in the history
* ADP-2218-Observer-mode-after-330:
  Updated snippets for Flutter and Unity
  Polished
  • Loading branch information
Lutik-sun committed Feb 12, 2025
2 parents 6893671 + 4d12aee commit 19b076a
Showing 1 changed file with 45 additions and 31 deletions.
76 changes: 45 additions & 31 deletions versioned_docs/version-3.0/report-transactions-observer-mode.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ In Observer mode, the Adapty SDK can't track purchases made through your existin
<Tabs groupId="report-transactions-observer-mode">
<TabItem value="Swift" label="Swift" default>

Use `.reportTransaction()` to send the transaction data to Adapty.
Use `reportTransaction` to send the transaction data to Adapty.

:::warning

Expand All @@ -39,18 +39,18 @@ Parameters:

| Parameter | Presence | Description |
| ------------------- | -------- | ------------------------------------------------------------ |
| **withVariationId** | optional | The unique ID of the paywall variation. Retrieve it from the `variationId` property of the [`AdaptyPaywall`](sdk-models#adaptypaywall) object. |
| **withVariationId** | optional | The unique ID of the paywall variation. Retrieve it from the `variationId` property of the [AdaptyPaywall](sdk-models#adaptypaywall) object. |
| **transaction** | required | <p>For StoreKit 1: SKPaymentTransaction.</p><p>For StoreKit 2: Transaction.</p> |

</TabItem>
<TabItem value="kotlin" label="Kotlin" default>

Use `.restorePurchases()` to report the transaction to Adapty.
Use `restorePurchases` to report the transaction to Adapty.

:::warning

**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.
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.

:::

Expand All @@ -73,18 +73,18 @@ Parameters:

| Parameter | Presence | Description |
| ------------- | -------- | ------------------------------------------------------------ |
| variationId | required | The string identifier of the variation. You can get it using `variationId` property of the [`AdaptyPaywall`](sdk-models#adaptypaywall) object. |
| transactionId | required | String identifier (`purchase.getOrderId()`) of the purchase, where the purchase is an instance of the billing library [Purchase](https://developer.android.com/reference/com/android/billingclient/api/Purchase) class. |
| variationId | required | The string identifier of the variation. You can get it using `variationId` property of the [AdaptyPaywall](sdk-models#adaptypaywall) object. |
| transactionId | required | String identifier (`purchase.getOrderId`) of the purchase, where the purchase is an instance of the billing library [Purchase](https://developer.android.com/reference/com/android/billingclient/api/Purchase) class. |

</TabItem>
<TabItem value="java" label="Java" default>

Use `.restorePurchases()` to report the transaction to Adapty.
Use `restorePurchases` to report the transaction to Adapty.

:::warning

**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.
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.

:::

Expand All @@ -107,13 +107,13 @@ Parameters:

| Parameter | Presence | Description |
| ------------- | -------- | ------------------------------------------------------------ |
| variationId | required | The string identifier of the variation. You can get it using `variationId` property of the [`AdaptyPaywall`](sdk-models#adaptypaywall) object. |
| transactionId | required | <p>For iOS, StoreKit1: an [`SKPaymentTransaction`](https://developer.apple.com/documentation/storekit/skpaymenttransaction) object.</p><p>For iOS, StoreKit 2: [Transaction](https://developer.apple.com/documentation/storekit/transaction) object.</p><p>For Android: String identifier (`purchase.getOrderId()`) of the purchase, where the purchase is an instance of the billing library [Purchase](https://developer.android.com/reference/com/android/billingclient/api/Purchase) class.</p> |
| variationId | required | The string identifier of the variation. You can get it using `variationId` property of the [AdaptyPaywall](sdk-models#adaptypaywall) object. |
| transactionId | required | String identifier (`purchase.getOrderId`) of the purchase, where the purchase is an instance of the billing library [Purchase](https://developer.android.com/reference/com/android/billingclient/api/Purchase) class. |

</TabItem>
<TabItem value="Flutter" label="Flutter" default>

Use `.reportTransaction()` to send the transaction data to Adapty.
Use `reportTransaction` to send the transaction data to Adapty.

:::warning

Expand All @@ -122,11 +122,21 @@ If you don't call `reportTransaction`, Adapty won't recognize the transaction, i

:::

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.
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.

```javascript showLineNumbers
// 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 transasction.finish()
// every time when calling transaction.finish()
await Adapty().reportTransaction(
"YOUR_TRANSACTION_ID",
variationId: "PAYWALL_VARIATION_ID", // optional
Expand All @@ -141,26 +151,32 @@ Parameters:

| Parameter | Presence | Description |
| ------------------- | -------- | ------------------------------------------------------------ |
| variationId | optional | The string identifier of the variation. You can get it using `variationId` property of the [`AdaptyPaywall`](sdk-models#adaptypaywall) object. |
| YOUR_TRANSACTION_ID | required | <p>For iOS, StoreKit1: an [`SKPaymentTransaction`](https://developer.apple.com/documentation/storekit/skpaymenttransaction) object.</p><p>For iOS, StoreKit 2: [Transaction](https://developer.apple.com/documentation/storekit/transaction) object.</p><p>For Android: String identifier (`purchase.getOrderId()`) of the purchase, where the purchase is an instance of the billing library [Purchase](https://developer.android.com/reference/com/android/billingclient/api/Purchase) class.</p> |
| variationId | optional | The string identifier of the variation. You can get it using `variationId` property of the [AdaptyPaywall](sdk-models#adaptypaywall) object. |
|YOUR_TRANSACTION_ID| required | <p>For iOS, StoreKit 1: an [SKPaymentTransaction](https://developer.apple.com/documentation/storekit/skpaymenttransaction) object.</p><p>For iOS, StoreKit 2: [Transaction](https://developer.apple.com/documentation/storekit/transaction) object.</p><p>For Android: String identifier (purchase.getOrderId of the purchase, where the purchase is an instance of the billing library [Purchase](https://developer.android.com/reference/com/android/billingclient/api/Purchase) class.</p> |

</TabItem>
<TabItem value="Unity" label="Unity" default>

Use `.reportTransaction()` to send the transaction data to Adapty.
Use `reportTransaction` for both platforms and `restorePurchases` (additionally for Android) to send transaction data to Adapty.

:::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 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 `withVariationId` when reporting a transaction. This links the purchase to the paywall that triggered it, ensuring accurate paywall analytics.
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.

```csharp showLineNumbers
// 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
Expand All @@ -172,22 +188,22 @@ Parameters:

| Parameter | Presence | Description |
| -------------------- | -------- | ------------------------------------------------------------ |
| PAYWALL_VARIATION_ID | optional | The string identifier of the variation. You can get it using `variationId` property of the [`AdaptyPaywall`](sdk-models#adaptypaywall) object. |
| YOUR_TRANSACTION_ID | required | <p>For iOS, StoreKit1: an [`SKPaymentTransaction`](https://developer.apple.com/documentation/storekit/skpaymenttransaction) object.</p><p>For iOS, StoreKit 2: [Transaction](https://developer.apple.com/documentation/storekit/transaction) object.</p><p>For Android: String identifier (`purchase.getOrderId()`) of the purchase, where the purchase is an instance of the billing library [Purchase](https://developer.android.com/reference/com/android/billingclient/api/Purchase) class.</p> |
| PAYWALL_VARIATION_ID | optional | The string identifier of the variation. You can get it using `variationId` property of the [AdaptyPaywall](sdk-models#adaptypaywall) object. |
| YOUR_TRANSACTION_ID | required | <p>For iOS, StoreKit 1: an [SKPaymentTransaction](https://developer.apple.com/documentation/storekit/skpaymenttransaction) object.</p><p>For iOS, StoreKit 2: [Transaction](https://developer.apple.com/documentation/storekit/transaction) object.</p><p>For Android: String identifier (`purchase.getOrderId`) of the purchase, where the purchase is an instance of the billing library [Purchase](https://developer.android.com/reference/com/android/billingclient/api/Purchase) class.</p> |

</TabItem>
<TabItem value="RN" label="React Native (TS)" default>

Use `.reportTransaction()` to send the transaction data to Adapty.
Use `reportTransaction` for both platforms and `restorePurchases` (additionally for Android) to send transaction data to Adapty.

:::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 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 `withVariationId` when reporting a transaction. This links the purchase to the paywall that triggered it, ensuring accurate paywall analytics.
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.

```typescript showLineNumbers
if (Platform.OS === 'android') {
Expand All @@ -212,8 +228,8 @@ Parameters:

| Parameter | Presence | Description |
| ------------- | -------- | ------------------------------------------------------------ |
| variationId | optional | The string identifier of the variation. You can get it using `variationId` property of the [`AdaptyPaywall`](sdk-models#adaptypaywall) object. |
| transactionId | required | <p>For iOS, StoreKit1: an [`SKPaymentTransaction`](https://developer.apple.com/documentation/storekit/skpaymenttransaction) object.</p><p>For iOS, StoreKit 2: [Transaction](https://developer.apple.com/documentation/storekit/transaction) object.</p><p>For Android: String identifier (`purchase.getOrderId()`) of the purchase, where the purchase is an instance of the billing library [Purchase](https://developer.android.com/reference/com/android/billingclient/api/Purchase) class.</p> |
| variationId | optional | The string identifier of the variation. You can get it using `variationId` property of the [AdaptyPaywall](sdk-models#adaptypaywall) object. |
| transactionId | required | <p>For iOS, StoreKit 1: an [SKPaymentTransaction](https://developer.apple.com/documentation/storekit/skpaymenttransaction) object.</p><p>For iOS, StoreKit 2: [Transaction](https://developer.apple.com/documentation/storekit/transaction) object.</p><p>For Android: String identifier (`purchase.getOrderId`) of the purchase, where the purchase is an instance of the billing library [Purchase](https://developer.android.com/reference/com/android/billingclient/api/Purchase) class.</p> |

</TabItem>
</Tabs>
Expand All @@ -225,12 +241,12 @@ For accurate analytics, ensure the transaction is associated with the paywall wi

### Reporting transactions

For Android and Android-based cross-platforms, use `.restorePurchases()` to report a transaction to Adapty in Observer Mode, as explained on the [Restore Purchases in Mobile Code](restore-purchase) page.
For Android and Android-based cross-platforms, use `restorePurchases` to report a transaction to Adapty in Observer Mode, as explained on the [Restore Purchases in Mobile Code](restore-purchase) page.

:::warning

**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.
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.

:::

Expand Down Expand Up @@ -316,8 +332,6 @@ Request parameters:

| Parameter | Presence | Description |
|---------|--------|-----------|
| variationId | required | The string identifier of the variation. You can get it using `variationId` property of the [`AdaptyPaywall`](sdk-models#adaptypaywall) object. |
| transactionId | required | <p>For iOS, StoreKit1: an [`SKPaymentTransaction`](https://developer.apple.com/documentation/storekit/skpaymenttransaction) object.</p><p>For iOS, StoreKit 2: [Transaction](https://developer.apple.com/documentation/storekit/transaction) object.</p><p>For Android: String identifier (`purchase.getOrderId()`) of the purchase, where the purchase is an instance of the billing library [Purchase](https://developer.android.com/reference/com/android/billingclient/api/Purchase) class.</p> |

| variationId | required | The string identifier of the variation. You can get it using `variationId` property of the [AdaptyPaywall](sdk-models#adaptypaywall) object. |
| transactionId | required | <p>For iOS, StoreKit 1: an [SKPaymentTransaction](https://developer.apple.com/documentation/storekit/skpaymenttransaction) object.</p><p>For iOS, StoreKit 2: [Transaction](https://developer.apple.com/documentation/storekit/transaction) object.</p><p>For Android: String identifier (purchase.getOrderId of the purchase, where the purchase is an instance of the billing library [Purchase](https://developer.android.com/reference/com/android/billingclient/api/Purchase) class.</p> |

For accurate analytics, ensure the transaction is associated with the paywall within 3 hours of its creation.

0 comments on commit 19b076a

Please sign in to comment.