@capgo/native-purchases 8.9.11 → 8.9.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -23
- package/android/build.gradle +2 -0
- package/android/src/main/java/ee/forgr/nativepurchases/NativePurchasesPlugin.java +1 -1
- package/android/src/main/java/ee/forgr/nativepurchases/ProductPayloadMapper.java +29 -1
- package/dist/docs.json +2 -2
- package/dist/esm/definitions.d.ts +11 -7
- package/dist/esm/definitions.js.map +1 -1
- package/ios/Sources/NativePurchasesPlugin/NativePurchasesPlugin.swift +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2463,29 +2463,29 @@ which is useful for determining if users are entitled to features from earlier b
|
|
|
2463
2463
|
|
|
2464
2464
|
#### Product
|
|
2465
2465
|
|
|
2466
|
-
| Prop | Type | Description
|
|
2467
|
-
| --------------------------------- | ------------------------------------------------------------------------------------- |
|
|
2468
|
-
| **`identifier`** | <code>string</code> | <a href="#product">Product</a> Id. Android subscriptions note: - `identifier` is the base plan ID (`offerDetails.getBasePlanId()`). - `planIdentifier` is the subscription product ID (`productDetails.getProductId()`). Android one-time products note: - `identifier` is the Google Play product ID (`productDetails.getProductId()`). - When multiple offers exist, `getProducts()` returns one entry per eligible offer. If you group/filter Android subscription results by `identifier`, you are grouping by base plan.
|
|
2469
|
-
| **`description`** | <code>string</code> | Description of the product.
|
|
2470
|
-
| **`title`** | <code>string</code> | Title of the product.
|
|
2471
|
-
| **`price`** | <code>number</code> | Price of the product in the local currency.
|
|
2472
|
-
| **`priceString`** | <code>string</code> | Formatted price of the item, including its currency sign, such as €3.99. Android subscriptions: set from the standard recurring pricing phase (see `ProductPayloadMapper`). When the offer has an introductory phase, `introductoryPrice` describes that phase, so a pre purchase message should include both or defer confirmation to the store sheet.
|
|
2473
|
-
| **`currencyCode`** | <code>string</code> | Currency code for price and original price.
|
|
2474
|
-
| **`currencySymbol`** | <code>string</code> | Currency symbol for price and original price.
|
|
2475
|
-
| **`isFamilyShareable`** | <code>boolean</code> | Boolean indicating if the product is sharable with family
|
|
2476
|
-
| **`subscriptionGroupIdentifier`** | <code>string</code> | Group identifier for the product.
|
|
2477
|
-
| **`planIdentifier`** | <code>string</code> | Android subscriptions only: Google Play product identifier tied to the offer/base plan set.
|
|
2478
|
-
| **`offerToken`** | <code>string</code> | Android: offer token required when purchasing a specific subscription or one-time offer. Pass it to `purchaseProduct({ offerToken })` to buy this exact offer. It belongs to the query that returned it and goes stale, so read it from the same `getProducts()` / `getProduct()` call you purchase from.
|
|
2479
|
-
| **`offerId`** | <code>string \| null</code> | Android: offer identifier (null/undefined for base offers).
|
|
2480
|
-
| **`purchaseOptionId`** | <code>string</code> | Android one-time products only: purchase option identifier (for example `buy-option`).
|
|
2481
|
-
| **`fullPrice`** | <code>number</code> | Android one-time products only: full price before discount, in the local currency.
|
|
2482
|
-
| **`discountDisplayInfo`** | <code><a href="#onetimepurchaseofferdiscount">OneTimePurchaseOfferDiscount</a></code> | Android one-time products only: discount metadata for discounted offers.
|
|
2483
|
-
| **`pricingTerms`** | <code>SubscriptionPricingTerms[]</code> | iOS subscriptions only: StoreKit pricing terms by billing plan. For subscriptions with a monthly billing plan and 12-month commitment, this includes both the standard up-front plan and the monthly commitment plan. Display both `billingDisplayPrice` and `commitmentInfo.priceString` before starting a monthly commitment purchase.
|
|
2484
|
-
| **`subscriptionPeriod`** | <code><a href="#subscriptionperiod">SubscriptionPeriod</a></code> | Recurring billing period for subscription products.
|
|
2485
|
-
| **`subscriptionBillingCycles`** | <code>number</code> | Android subscriptions only: committed payment count for installment base plans when Play exposes it on the offer.
|
|
2486
|
-
| **`introductoryPrice`** | <code><a href="#skproductdiscount">SKProductDiscount</a> \| null</code> | Introductory price for this product line when the store exposes it. Pair with `priceString` for full subscription offer wording before purchase. iOS: from StoreKit introductory offers when available. Android base subscription offers (`offerId` null): from the first pricing phase when multiple phases exist (intro then recurring). Android promotional offer lines (`offerId` set):
|
|
2487
|
-
| **`introEligibility`** | <code><a href="#intro_eligibility_status">INTRO_ELIGIBILITY_STATUS</a></code> | Whether the current store account is eligible for an introductory offer on this subscription.
|
|
2488
|
-
| **`discounts`** | <code>SKProductDiscount[]</code> | The <a href="#product">Product</a> discounts list.
|
|
2466
|
+
| Prop | Type | Description | Since |
|
|
2467
|
+
| --------------------------------- | ------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- |
|
|
2468
|
+
| **`identifier`** | <code>string</code> | <a href="#product">Product</a> Id. Android subscriptions note: - `identifier` is the base plan ID (`offerDetails.getBasePlanId()`). - `planIdentifier` is the subscription product ID (`productDetails.getProductId()`). Android one-time products note: - `identifier` is the Google Play product ID (`productDetails.getProductId()`). - When multiple offers exist, `getProducts()` returns one entry per eligible offer. If you group/filter Android subscription results by `identifier`, you are grouping by base plan. | |
|
|
2469
|
+
| **`description`** | <code>string</code> | Description of the product. | |
|
|
2470
|
+
| **`title`** | <code>string</code> | Title of the product. | |
|
|
2471
|
+
| **`price`** | <code>number</code> | Price of the product in the local currency. | |
|
|
2472
|
+
| **`priceString`** | <code>string</code> | Formatted price of the item, including its currency sign, such as €3.99. Android subscriptions: set from the standard recurring pricing phase (see `ProductPayloadMapper`). When the offer has an introductory phase, `introductoryPrice` describes that phase, so a pre purchase message should include both or defer confirmation to the store sheet. | |
|
|
2473
|
+
| **`currencyCode`** | <code>string</code> | Currency code for price and original price. | |
|
|
2474
|
+
| **`currencySymbol`** | <code>string</code> | Currency symbol for price and original price. | |
|
|
2475
|
+
| **`isFamilyShareable`** | <code>boolean</code> | Boolean indicating if the product is sharable with family | |
|
|
2476
|
+
| **`subscriptionGroupIdentifier`** | <code>string</code> | Group identifier for the product. | |
|
|
2477
|
+
| **`planIdentifier`** | <code>string</code> | Android subscriptions only: Google Play product identifier tied to the offer/base plan set. | |
|
|
2478
|
+
| **`offerToken`** | <code>string</code> | Android: offer token required when purchasing a specific subscription or one-time offer. Pass it to `purchaseProduct({ offerToken })` to buy this exact offer. It belongs to the query that returned it and goes stale, so read it from the same `getProducts()` / `getProduct()` call you purchase from. | |
|
|
2479
|
+
| **`offerId`** | <code>string \| null</code> | Android: offer identifier (null/undefined for base offers). | |
|
|
2480
|
+
| **`purchaseOptionId`** | <code>string</code> | Android one-time products only: purchase option identifier (for example `buy-option`). | |
|
|
2481
|
+
| **`fullPrice`** | <code>number</code> | Android one-time products only: full price before discount, in the local currency. | |
|
|
2482
|
+
| **`discountDisplayInfo`** | <code><a href="#onetimepurchaseofferdiscount">OneTimePurchaseOfferDiscount</a></code> | Android one-time products only: discount metadata for discounted offers. | |
|
|
2483
|
+
| **`pricingTerms`** | <code>SubscriptionPricingTerms[]</code> | iOS subscriptions only: StoreKit pricing terms by billing plan. For subscriptions with a monthly billing plan and 12-month commitment, this includes both the standard up-front plan and the monthly commitment plan. Display both `billingDisplayPrice` and `commitmentInfo.priceString` before starting a monthly commitment purchase. | 8.3.8 |
|
|
2484
|
+
| **`subscriptionPeriod`** | <code><a href="#subscriptionperiod">SubscriptionPeriod</a></code> | Recurring billing period for subscription products. | |
|
|
2485
|
+
| **`subscriptionBillingCycles`** | <code>number</code> | Android subscriptions only: committed payment count for installment base plans when Play exposes it on the offer. | |
|
|
2486
|
+
| **`introductoryPrice`** | <code><a href="#skproductdiscount">SKProductDiscount</a> \| null</code> | Introductory price for this product line when the store exposes it. Pair with `priceString` for full subscription offer wording before purchase. It always describes what buying this entry gives. iOS: from StoreKit introductory offers when available. Android base subscription offers (`offerId` null): from the first pricing phase when multiple phases exist (intro then recurring), else null. On Google Play a free trial or intro price is a separate offer on the base plan, so a base plan entry is usually null even when the plan has a trial; that trial is reported on the offer's own entry. Android promotional offer lines (`offerId` set): that offer's own leading phase when it is introductory, else null; buy it with that entry's `offerToken`. Mapping matches `ProductPayloadMapper`. | |
|
|
2487
|
+
| **`introEligibility`** | <code><a href="#intro_eligibility_status">INTRO_ELIGIBILITY_STATUS</a></code> | Whether the current store account is eligible for an introductory offer on this subscription. | 8.8.3 |
|
|
2488
|
+
| **`discounts`** | <code>SKProductDiscount[]</code> | The <a href="#product">Product</a> discounts list. | |
|
|
2489
2489
|
|
|
2490
2490
|
|
|
2491
2491
|
#### OneTimePurchaseOfferDiscount
|
package/android/build.gradle
CHANGED
|
@@ -59,6 +59,8 @@ dependencies {
|
|
|
59
59
|
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
|
60
60
|
testImplementation "junit:junit:$junitVersion"
|
|
61
61
|
testImplementation 'org.mockito:mockito-core:5.14.2'
|
|
62
|
+
// Real org.json for JVM unit tests, so tests can build and read JSObject payloads.
|
|
63
|
+
testImplementation 'org.json:json:20240303'
|
|
62
64
|
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
|
63
65
|
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
|
64
66
|
}
|
|
@@ -103,7 +103,7 @@ public class NativePurchasesPlugin extends Plugin {
|
|
|
103
103
|
return SubscriptionOfferPurchaseResult.ok(selected.getOfferToken(), selected.getBasePlanId());
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
private final String pluginVersion = "8.9.
|
|
106
|
+
private final String pluginVersion = "8.9.12";
|
|
107
107
|
public static final String TAG = "NativePurchases";
|
|
108
108
|
private static final int BILLING_CONNECTION_MAX_ATTEMPTS = 2;
|
|
109
109
|
private static final long BILLING_SETUP_TIMEOUT_SECONDS = 5;
|
|
@@ -120,6 +120,9 @@ final class ProductPayloadMapper {
|
|
|
120
120
|
if (introPhase != null) {
|
|
121
121
|
product.put("introductoryPrice", pricingPhaseToDiscount(introPhase, "", 0, currencyCode, currencySymbol));
|
|
122
122
|
} else {
|
|
123
|
+
// Stays null even when a sibling offer on this base plan has a trial: this entry's
|
|
124
|
+
// offerToken buys the base offer at full price. The trial is reported on the offer's
|
|
125
|
+
// own entry, whose offerToken actually buys it.
|
|
123
126
|
product.put("introductoryPrice", JSONObject.NULL);
|
|
124
127
|
}
|
|
125
128
|
product.put(
|
|
@@ -127,11 +130,36 @@ final class ProductPayloadMapper {
|
|
|
127
130
|
promotionalDiscountsForBasePlan(offerDetails.getBasePlanId(), allOffers, currencyCode, currencySymbol)
|
|
128
131
|
);
|
|
129
132
|
} else {
|
|
130
|
-
|
|
133
|
+
// This entry IS an offer, so its own leading phase is its introductory pricing.
|
|
134
|
+
ProductDetails.PricingPhase introPhase = findLeadingIntroductoryPhase(phases);
|
|
135
|
+
product.put(
|
|
136
|
+
"introductoryPrice",
|
|
137
|
+
introPhase != null
|
|
138
|
+
? pricingPhaseToDiscount(introPhase, offerDetails.getOfferId(), 0, currencyCode, currencySymbol)
|
|
139
|
+
: JSONObject.NULL
|
|
140
|
+
);
|
|
131
141
|
product.put("discounts", new JSONArray());
|
|
132
142
|
}
|
|
133
143
|
}
|
|
134
144
|
|
|
145
|
+
/**
|
|
146
|
+
* An offer's leading phase when it is introductory (a free trial or a reduced first period)
|
|
147
|
+
* rather than the ongoing price.
|
|
148
|
+
*
|
|
149
|
+
* <p>Unlike {@link #findIntroductoryPricingPhase} this does not require a second phase: a
|
|
150
|
+
* trial-only offer is a single non-recurring phase, and it is still introductory pricing.
|
|
151
|
+
*
|
|
152
|
+
* <p>Package-private so {@code ProductPayloadMapperIntroPhaseTest} can cover it without JSON.
|
|
153
|
+
*/
|
|
154
|
+
static ProductDetails.PricingPhase findLeadingIntroductoryPhase(List<ProductDetails.PricingPhase> phases) {
|
|
155
|
+
if (phases == null || phases.isEmpty()) {
|
|
156
|
+
return null;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
ProductDetails.PricingPhase firstPhase = phases.get(0);
|
|
160
|
+
return firstPhase.getRecurrenceMode() == RECURRENCE_MODE_INFINITE_RECURRING ? null : firstPhase;
|
|
161
|
+
}
|
|
162
|
+
|
|
135
163
|
static JSObject subscriptionPeriodFromBillingPeriod(String billingPeriod) {
|
|
136
164
|
JSObject period = parseIso8601Period(billingPeriod);
|
|
137
165
|
if (period == null) {
|
package/dist/docs.json
CHANGED
|
@@ -1801,7 +1801,7 @@
|
|
|
1801
1801
|
{
|
|
1802
1802
|
"name": "introductoryPrice",
|
|
1803
1803
|
"tags": [],
|
|
1804
|
-
"docs": "Introductory price for this product line when the store exposes it. Pair with `priceString`\nfor full subscription offer wording before purchase. iOS: from StoreKit introductory offers
|
|
1804
|
+
"docs": "Introductory price for this product line when the store exposes it. Pair with `priceString`\nfor full subscription offer wording before purchase. It always describes what buying this\nentry gives. iOS: from StoreKit introductory offers when available. Android base subscription\noffers (`offerId` null): from the first pricing phase when multiple phases exist (intro then\nrecurring), else null. On Google Play a free trial or intro price is a separate offer on the\nbase plan, so a base plan entry is usually null even when the plan has a trial; that trial is\nreported on the offer's own entry. Android promotional offer lines (`offerId` set): that\noffer's own leading phase when it is introductory, else null; buy it with that entry's\n`offerToken`. Mapping matches `ProductPayloadMapper`.",
|
|
1805
1805
|
"complexTypes": [
|
|
1806
1806
|
"SKProductDiscount"
|
|
1807
1807
|
],
|
|
@@ -1837,7 +1837,7 @@
|
|
|
1837
1837
|
"name": "platform"
|
|
1838
1838
|
},
|
|
1839
1839
|
{
|
|
1840
|
-
"text": "android On base subscription offers (`offerId` null), lists promotional offers on\nthe same base plan. A promotional offer line itself returns an empty array; its
|
|
1840
|
+
"text": "android On base subscription offers (`offerId` null), lists promotional offers on\nthe same base plan, each quoting its recurring phase (a trial only offer quotes its free\nphase). A promotional offer line itself returns an empty array; its introductory phase is on\n`introductoryPrice`.",
|
|
1841
1841
|
"name": "platform"
|
|
1842
1842
|
}
|
|
1843
1843
|
],
|
|
@@ -996,11 +996,14 @@ export interface Product {
|
|
|
996
996
|
readonly subscriptionBillingCycles?: number;
|
|
997
997
|
/**
|
|
998
998
|
* Introductory price for this product line when the store exposes it. Pair with `priceString`
|
|
999
|
-
* for full subscription offer wording before purchase.
|
|
1000
|
-
*
|
|
1001
|
-
* phase when multiple phases exist (intro then
|
|
1002
|
-
*
|
|
1003
|
-
*
|
|
999
|
+
* for full subscription offer wording before purchase. It always describes what buying this
|
|
1000
|
+
* entry gives. iOS: from StoreKit introductory offers when available. Android base subscription
|
|
1001
|
+
* offers (`offerId` null): from the first pricing phase when multiple phases exist (intro then
|
|
1002
|
+
* recurring), else null. On Google Play a free trial or intro price is a separate offer on the
|
|
1003
|
+
* base plan, so a base plan entry is usually null even when the plan has a trial; that trial is
|
|
1004
|
+
* reported on the offer's own entry. Android promotional offer lines (`offerId` set): that
|
|
1005
|
+
* offer's own leading phase when it is introductory, else null; buy it with that entry's
|
|
1006
|
+
* `offerToken`. Mapping matches `ProductPayloadMapper`.
|
|
1004
1007
|
*/
|
|
1005
1008
|
readonly introductoryPrice: SKProductDiscount | null;
|
|
1006
1009
|
/**
|
|
@@ -1016,8 +1019,9 @@ export interface Product {
|
|
|
1016
1019
|
*
|
|
1017
1020
|
* @platform ios Populated from StoreKit promotional offers when available.
|
|
1018
1021
|
* @platform android On base subscription offers (`offerId` null), lists promotional offers on
|
|
1019
|
-
* the same base plan
|
|
1020
|
-
*
|
|
1022
|
+
* the same base plan, each quoting its recurring phase (a trial only offer quotes its free
|
|
1023
|
+
* phase). A promotional offer line itself returns an empty array; its introductory phase is on
|
|
1024
|
+
* `introductoryPrice`.
|
|
1021
1025
|
*/
|
|
1022
1026
|
readonly discounts: SKProductDiscount[];
|
|
1023
1027
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAEA,MAAM,CAAN,IAAY,mBAOX;AAPD,WAAY,mBAAmB;IAC7B,qFAAoB,CAAA;IACpB,iEAAU,CAAA;IACV,uEAAa,CAAA;IACb,iEAAU,CAAA;IACV,iEAAU,CAAA;IACV,qEAAY,CAAA;AACd,CAAC,EAPW,mBAAmB,KAAnB,mBAAmB,QAO9B;AAED,MAAM,CAAN,IAAY,aAUX;AAVD,WAAY,aAAa;IACvB;;OAEG;IACH,gCAAe,CAAA;IAEf;;OAEG;IACH,8BAAa,CAAA;AACf,CAAC,EAVW,aAAa,KAAb,aAAa,QAUxB;AAED;;;;GAIG;AACH,MAAM,CAAN,IAAY,eAyBX;AAzBD,WAAY,eAAe;IACzB;;OAEG;IACH,uEAAa,CAAA;IAEb;;OAEG;IACH,qFAAoB,CAAA;IAEpB;;OAEG;IACH,iFAAkB,CAAA;IAElB;;OAEG;IACH,mFAAmB,CAAA;IAEnB;;OAEG;IACH,+FAAyB,CAAA;AAC3B,CAAC,EAzBW,eAAe,KAAf,eAAe,QAyB1B;AACD,MAAM,CAAN,IAAY,cA2BX;AA3BD,WAAY,cAAc;IACxB,qIAAiD,CAAA;IAEjD;;;OAGG;IACH,qGAAiC,CAAA;IAEjC;;;;OAIG;IACH,iHAAuC,CAAA;IAEvC;;;OAGG;IACH,iGAA+B,CAAA;IAE/B;;;OAGG;IACH,2DAAY,CAAA;AACd,CAAC,EA3BW,cAAc,KAAd,cAAc,QA2BzB;AAED,MAAM,CAAN,IAAY,YA6CX;AA7CD,WAAY,YAAY;IACtB;;OAEG;IACH,mCAAmB,CAAA;IAEnB;;OAEG;IACH,iCAAiB,CAAA;IAEjB;;OAEG;IACH,qCAAqB,CAAA;IAErB;;OAEG;IACH,iCAAiB,CAAA;IAEjB;;OAEG;IACH,uCAAuB,CAAA;IAEvB;;OAEG;IACH,2CAA2B,CAAA;IAE3B;;OAEG;IACH,uCAAuB,CAAA;IAEvB;;OAEG;IACH,mCAAmB,CAAA;IAEnB;;OAEG;IACH,iCAAiB,CAAA;AACnB,CAAC,EA7CW,YAAY,KAAZ,YAAY,QA6CvB;AAED,MAAM,CAAN,IAAY,wBAaX;AAbD,WAAY,wBAAwB;IAClC;;OAEG;IACH,+HAAoC,CAAA;IACpC;;OAEG;IACH,qIAAuC,CAAA;IACvC;;OAEG;IACH,iIAAqC,CAAA;AACvC,CAAC,EAbW,wBAAwB,KAAxB,wBAAwB,QAanC","sourcesContent":["import type { PluginListenerHandle } from '@capacitor/core';\n\nexport enum ATTRIBUTION_NETWORK {\n APPLE_SEARCH_ADS = 0,\n ADJUST = 1,\n APPSFLYER = 2,\n BRANCH = 3,\n TENJIN = 4,\n FACEBOOK = 5,\n}\n\nexport enum PURCHASE_TYPE {\n /**\n * A type of SKU for in-app products.\n */\n INAPP = 'inapp',\n\n /**\n * A type of SKU for subscriptions.\n */\n SUBS = 'subs',\n}\n\n/**\n * Enum for billing features.\n * Currently, these are only relevant for Google Play Android users:\n * https://developer.android.com/reference/com/android/billingclient/api/BillingClient.FeatureType\n */\nexport enum BILLING_FEATURE {\n /**\n * Purchase/query for subscriptions.\n */\n SUBSCRIPTIONS,\n\n /**\n * Subscriptions update/replace.\n */\n SUBSCRIPTIONS_UPDATE,\n\n /**\n * Purchase/query for in-app items on VR.\n */\n IN_APP_ITEMS_ON_VR,\n\n /**\n * Purchase/query for subscriptions on VR.\n */\n SUBSCRIPTIONS_ON_VR,\n\n /**\n * Launch a price change confirmation flow.\n */\n PRICE_CHANGE_CONFIRMATION,\n}\nexport enum PRORATION_MODE {\n UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY = 0,\n\n /**\n * Replacement takes effect immediately, and the remaining time will be\n * prorated and credited to the user. This is the current default behavior.\n */\n IMMEDIATE_WITH_TIME_PRORATION = 1,\n\n /**\n * Replacement takes effect immediately, and the billing cycle remains the\n * same. The price for the remaining period will be charged. This option is\n * only available for subscription upgrade.\n */\n IMMEDIATE_AND_CHARGE_PRORATED_PRICE = 2,\n\n /**\n * Replacement takes effect immediately, and the new price will be charged on\n * next recurrence time. The billing cycle stays the same.\n */\n IMMEDIATE_WITHOUT_PRORATION = 3,\n\n /**\n * Replacement takes effect when the old plan expires, and the new price will\n * be charged at the same time.\n */\n DEFERRED = 4,\n}\n\nexport enum PACKAGE_TYPE {\n /**\n * A package that was defined with a custom identifier.\n */\n UNKNOWN = 'UNKNOWN',\n\n /**\n * A package that was defined with a custom identifier.\n */\n CUSTOM = 'CUSTOM',\n\n /**\n * A package configured with the predefined lifetime identifier.\n */\n LIFETIME = 'LIFETIME',\n\n /**\n * A package configured with the predefined annual identifier.\n */\n ANNUAL = 'ANNUAL',\n\n /**\n * A package configured with the predefined six month identifier.\n */\n SIX_MONTH = 'SIX_MONTH',\n\n /**\n * A package configured with the predefined three month identifier.\n */\n THREE_MONTH = 'THREE_MONTH',\n\n /**\n * A package configured with the predefined two month identifier.\n */\n TWO_MONTH = 'TWO_MONTH',\n\n /**\n * A package configured with the predefined monthly identifier.\n */\n MONTHLY = 'MONTHLY',\n\n /**\n * A package configured with the predefined weekly identifier.\n */\n WEEKLY = 'WEEKLY',\n}\n\nexport enum INTRO_ELIGIBILITY_STATUS {\n /**\n * doesn't have enough information to determine eligibility.\n */\n INTRO_ELIGIBILITY_STATUS_UNKNOWN = 0,\n /**\n * The user is not eligible for a free trial or intro pricing for this product.\n */\n INTRO_ELIGIBILITY_STATUS_INELIGIBLE = 1,\n /**\n * The user is eligible for a free trial or intro pricing for this product.\n */\n INTRO_ELIGIBILITY_STATUS_ELIGIBLE = 2,\n}\n\nexport interface Transaction {\n /**\n * Unique identifier for the transaction.\n *\n * @since 1.0.0\n * @platform ios Numeric string (e.g., \"2000001043762129\")\n * @platform android The Google Play purchase token (same value as `purchaseToken`), not the `GPA.` order ID in `orderId`\n */\n readonly transactionId: string;\n /**\n * Receipt data for validation (base64 encoded StoreKit receipt).\n *\n * **This is the full verified receipt payload from Apple StoreKit.**\n * Send this to your backend for server-side validation with Apple's receipt verification API.\n * The receipt remains available even after refund - server validation is required to detect refunded transactions.\n *\n * **For backend validation:**\n * - Use Apple's receipt verification API: https://buy.itunes.apple.com/verifyReceipt (production)\n * - Or sandbox: https://sandbox.itunes.apple.com/verifyReceipt\n * - This contains all transaction data needed for validation\n *\n * **Note:** Apple recommends migrating to App Store Server API v2 with `jwsRepresentation` for new implementations.\n * The legacy receipt verification API continues to work but may be deprecated in the future.\n *\n * @since 1.0.0\n * @platform ios Always present\n * @platform android Not available (use purchaseToken instead)\n * @example\n * ```typescript\n * const transaction = await NativePurchases.purchaseProduct({ ... });\n * if (transaction.receipt) {\n * // Send to your backend for validation\n * await fetch('/api/validate-receipt', {\n * method: 'POST',\n * body: JSON.stringify({ receipt: transaction.receipt })\n * });\n * }\n * ```\n */\n readonly receipt?: string;\n /**\n * StoreKit 2 JSON Web Signature (JWS) payload describing the verified transaction.\n *\n * **This is the full verified receipt in JWS format (StoreKit 2).**\n * Send this to your backend when using Apple's App Store Server API v2 instead of raw receipts.\n * Only available when the transaction originated from StoreKit 2 APIs (e.g. Transaction.updates).\n *\n * **For backend validation:**\n * - Use Apple's App Store Server API v2 to decode and verify the JWS\n * - This is the modern alternative to the legacy receipt format\n * - Contains signed transaction information from Apple\n *\n * @since 7.13.2\n * @platform ios Present for StoreKit 2 transactions (iOS 15+)\n * @platform android Not available\n * @example\n * ```typescript\n * const transaction = await NativePurchases.purchaseProduct({ ... });\n * if (transaction.jwsRepresentation) {\n * // Send to your backend for validation with App Store Server API v2\n * await fetch('/api/validate-jws', {\n * method: 'POST',\n * body: JSON.stringify({ jws: transaction.jwsRepresentation })\n * });\n * }\n * ```\n */\n readonly jwsRepresentation?: string;\n /**\n * An optional obfuscated identifier that uniquely associates the transaction with a user account in your app.\n *\n * PURPOSE:\n * - Fraud detection: Helps platforms detect irregular activity (e.g., many devices purchasing on the same account)\n * - User linking: Links purchases to in-game characters, avatars, or in-app profiles\n *\n * PLATFORM DIFFERENCES:\n * - iOS: Must be a valid UUID format (e.g., \"550e8400-e29b-41d4-a716-446655440000\")\n * Apple's StoreKit 2 requires UUID format for the appAccountToken parameter\n * - Android: Can be any obfuscated string (max 64 chars), maps to Google Play's ObfuscatedAccountId\n * Google recommends using encryption or one-way hash\n *\n * SECURITY REQUIREMENTS (especially for Android):\n * - DO NOT store Personally Identifiable Information (PII) like emails in cleartext\n * - Use encryption or a one-way hash to generate an obfuscated identifier\n * - Maximum length: 64 characters (both platforms)\n * - Storing PII in cleartext will result in purchases being blocked by Google Play\n *\n * IMPLEMENTATION EXAMPLE:\n * ```typescript\n * // For iOS: Generate a deterministic UUID from user ID\n * import { v5 as uuidv5 } from 'uuid';\n * const NAMESPACE = '6ba7b810-9dad-11d1-80b4-00c04fd430c8'; // Your app's namespace UUID\n * const appAccountToken = uuidv5(userId, NAMESPACE);\n *\n * // For Android: Can also use UUID or any hashed value\n * // The same UUID approach works for both platforms\n * ```\n */\n readonly appAccountToken?: string | null;\n /**\n * Product identifier associated with the transaction.\n *\n * @since 1.0.0\n * @platform ios Always present\n * @platform android Always present\n */\n readonly productIdentifier: string;\n /**\n * Purchase date of the transaction in ISO 8601 format.\n *\n * @since 1.0.0\n * @example \"2025-10-28T06:03:19Z\"\n * @platform ios Always present\n * @platform android Always present\n */\n readonly purchaseDate: string;\n /**\n * Indicates whether this transaction is the result of a subscription upgrade.\n *\n * Useful for understanding when StoreKit generated the transaction because\n * the customer moved from a lower tier to a higher tier plan.\n *\n * @since 7.13.2\n * @platform ios Present for auto-renewable subscriptions (iOS 15+)\n * @platform android Not available\n */\n readonly isUpgraded?: boolean;\n /**\n * Original purchase date of the transaction in ISO 8601 format.\n *\n * For subscription renewals, this shows the date of the original subscription purchase,\n * while purchaseDate shows the date of the current renewal.\n *\n * @since 1.0.0\n * @platform ios Present for subscriptions only\n * @platform android Not available\n */\n readonly originalPurchaseDate?: string;\n /**\n * Expiration date of the transaction in ISO 8601 format.\n *\n * Check this date to determine if a subscription is still valid.\n * Compare with current date: if expirationDate > now, subscription is active.\n *\n * @since 1.0.0\n * @platform ios Present for subscriptions only\n * @platform android Not available (query Google Play Developer API instead)\n */\n readonly expirationDate?: string;\n /**\n * Whether the subscription is still active/valid.\n *\n * For iOS subscriptions, check if isActive === true to verify an active subscription.\n * For expired or refunded iOS subscriptions, this will be false.\n *\n * @since 1.0.0\n * @platform ios Present for subscriptions only (true if expiration date is in the future)\n * @platform android Not available (check purchaseState === \"1\" instead)\n */\n readonly isActive?: boolean;\n /**\n * Date the transaction was revoked/refunded, in ISO 8601 format.\n *\n * Present when Apple revokes access due to an issue (e.g., refund or developer issue).\n *\n * @since 7.13.2\n * @platform ios Present for revoked transactions (iOS 15+)\n * @platform android Not available\n */\n readonly revocationDate?: string;\n /**\n * Reason why Apple revoked the transaction.\n *\n * Possible values:\n * - `\"developerIssue\"`: Developer-initiated refund or issue\n * - `\"other\"`: Apple-initiated (customer refund, billing problem, etc.)\n * - `\"unknown\"`: StoreKit didn't report a specific reason\n *\n * @since 7.13.2\n * @platform ios Present for revoked transactions (iOS 15+)\n * @platform android Not available\n */\n readonly revocationReason?: 'developerIssue' | 'other' | 'unknown';\n /**\n * Whether the subscription will be cancelled at the end of the billing cycle.\n *\n * - `true`: User has cancelled but subscription remains active until expiration\n * - `false`: Subscription will auto-renew\n * - `null`: Status unknown or not available\n *\n * @since 1.0.0\n * @default null\n * @platform ios Present for subscriptions only (boolean or null)\n * @platform android Always null (use Google Play Developer API for cancellation status)\n */\n readonly willCancel: boolean | null;\n /**\n * Current subscription state reported by StoreKit.\n *\n * Possible values:\n * - `\"subscribed\"`: Auto-renewing and in good standing\n * - `\"expired\"`: Lapsed with no access\n * - `\"revoked\"`: Access removed due to refund or issue\n * - `\"inGracePeriod\"`: Payment issue but still in grace access window\n * - `\"inBillingRetryPeriod\"`: StoreKit retrying failed billing\n * - `\"unknown\"`: StoreKit did not report a state\n *\n * @since 7.13.2\n * @platform ios Present for auto-renewable subscriptions (iOS 15+)\n * @platform android Not available\n */\n readonly subscriptionState?:\n 'subscribed' | 'expired' | 'revoked' | 'inGracePeriod' | 'inBillingRetryPeriod' | 'unknown';\n /**\n * StoreKit billing plan type for auto-renewable subscriptions.\n *\n * - `\"upFront\"`: Standard subscription billing for the full billing period.\n * - `\"monthly\"`: Monthly billing with a 12-month commitment.\n * - `\"unknown\"`: StoreKit returned a future or unsupported value.\n *\n * @since 8.3.8\n * @platform ios Present for StoreKit transactions that include billing plan metadata.\n * @platform android Not available\n */\n readonly billingPlanType?: SubscriptionBillingPlanType;\n /**\n * Commitment metadata for monthly subscriptions with a 12-month commitment.\n *\n * Use `expirationDate` here only to display commitment progress. Continue using\n * the top-level `expirationDate` to decide whether the current billing period\n * grants entitlement access.\n *\n * @since 8.3.8\n * @platform ios Present for monthly commitment subscription transactions.\n * @platform android Not available\n */\n readonly commitmentInfo?: TransactionCommitmentInfo;\n /**\n * StoreKit renewal metadata for auto-renewable subscriptions.\n *\n * `willAutoRenew` here describes the next billing period. For monthly\n * commitment subscriptions, `commitmentInfo.willAutoRenew` describes whether\n * the next 12-month commitment renews after the current commitment ends.\n *\n * @since 8.3.8\n * @platform ios Present for verified subscription renewal info.\n * @platform android Not available\n */\n readonly renewalInfo?: SubscriptionRenewalInfo;\n /**\n * Currency code associated with StoreKit transaction pricing metadata.\n *\n * @since 8.3.8\n * @platform ios Present when StoreKit includes currency in the transaction payload.\n * @platform android Not available\n */\n readonly currencyCode?: string;\n /**\n * Purchase state of the transaction (numeric string value).\n *\n * **Android Values:**\n * - `\"1\"`: Purchase completed and valid (PURCHASED state)\n * - `\"0\"`: Payment pending (PENDING state, e.g., cash payment processing)\n * - Other numeric values: Various other states\n *\n * Always check `purchaseState === \"1\"` on Android to verify a valid purchase.\n * Refunded purchases typically disappear from getPurchases() rather than showing a different state.\n *\n * @since 1.0.0\n * @platform ios Not available (use isActive for subscriptions or receipt validation for IAP)\n * @platform android Always present\n */\n readonly purchaseState?: string;\n /**\n * Order ID associated with the transaction.\n *\n * Use this for server-side verification on Android. This is the Google Play order ID.\n *\n * @since 1.0.0\n * @example \"GPA.1234-5678-9012-34567\"\n * @platform ios Not available\n * @platform android Always present\n */\n readonly orderId?: string;\n /**\n * Purchase token associated with the transaction.\n *\n * **This is the full verified purchase token from Google Play.**\n * Send this to your backend for server-side validation with Google Play Developer API.\n * This is the Android equivalent of iOS's receipt field.\n *\n * **For backend validation:**\n * - Use Google Play Developer API v3 to verify the purchase\n * - API endpoint: androidpublisher.purchases.products.get() or purchases.subscriptions.get()\n * - This token contains all data needed for validation with Google servers\n * - Can also be used for subscription status checks and cancellation detection\n *\n * @since 1.0.0\n * @platform ios Not available (use receipt instead)\n * @platform android Always present\n * @example\n * ```typescript\n * const transaction = await NativePurchases.purchaseProduct({ ... });\n * if (transaction.purchaseToken) {\n * // Send to your backend for validation\n * await fetch('/api/validate-purchase', {\n * method: 'POST',\n * body: JSON.stringify({\n * purchaseToken: transaction.purchaseToken,\n * productId: transaction.productIdentifier\n * })\n * });\n * }\n * ```\n */\n readonly purchaseToken?: string;\n /**\n * Whether the purchase has been acknowledged.\n *\n * Purchases must be acknowledged within 3 days or they will be refunded.\n * By default, this plugin automatically acknowledges purchases unless you set\n * `autoAcknowledgePurchases: false` in purchaseProduct().\n *\n * @since 1.0.0\n * @platform ios Not available\n * @platform android Always present (should be true after successful purchase or manual acknowledgment)\n */\n readonly isAcknowledged?: boolean;\n /**\n * Quantity purchased.\n *\n * @since 1.0.0\n * @default 1\n * @platform ios 1 or higher (as specified in purchaseProduct call)\n * @platform android Always 1 (Google Play doesn't support quantity > 1)\n */\n readonly quantity?: number;\n /**\n * Product type.\n *\n * - `\"inapp\"`: One-time in-app purchase\n * - `\"subs\"`: Subscription\n *\n * @since 1.0.0\n * @platform ios Always present\n * @platform android Always present\n */\n readonly productType?: string;\n /**\n * Indicates how the user obtained access to the product.\n *\n * - `\"purchased\"`: The user purchased the product directly\n * - `\"familyShared\"`: The user has access through Family Sharing (another family member purchased it)\n *\n * This property is useful for:\n * - Detecting family sharing usage for analytics\n * - Implementing different features/limits for family-shared vs. directly purchased products\n * - Understanding your user acquisition channels\n *\n * @since 7.12.8\n * @platform ios Always present (iOS 15.0+, StoreKit 2)\n * @platform android Not available\n */\n readonly ownershipType?: 'purchased' | 'familyShared';\n /**\n * Indicates the server environment where the transaction was processed.\n *\n * - `\"Sandbox\"`: Transaction belongs to testing in the sandbox environment\n * - `\"Production\"`: Transaction belongs to a customer in the production environment\n * - `\"Xcode\"`: Transaction from StoreKit Testing in Xcode\n *\n * This property is useful for:\n * - Debugging and identifying test vs. production purchases\n * - Analytics and reporting (filtering out sandbox transactions)\n * - Server-side validation (knowing which Apple endpoint to use)\n * - Preventing test purchases from affecting production metrics\n *\n * @since 7.12.8\n * @platform ios Present on iOS 16.0+ only (not available on iOS 15)\n * @platform android Not available\n */\n readonly environment?: 'Sandbox' | 'Production' | 'Xcode';\n /**\n * Reason StoreKit generated the transaction.\n *\n * - `\"purchase\"`: Initial purchase that user made manually\n * - `\"renewal\"`: Automatically generated renewal for an auto-renewable subscription\n * - `\"unknown\"`: StoreKit did not return a reason\n *\n * @since 7.13.2\n * @platform ios Present on iOS 17.0+ (StoreKit 2 transactions)\n * @platform android Not available\n */\n readonly transactionReason?: 'purchase' | 'renewal' | 'unknown';\n /**\n * Whether the transaction is in a trial period.\n *\n * - `true`: Currently in free trial period\n * - `false`: Not in trial period\n *\n * @since 1.0.0\n * @platform ios Present for subscriptions with trial offers\n * @platform android Present for subscriptions with trial offers\n */\n readonly isTrialPeriod?: boolean;\n /**\n * Whether the transaction is in an introductory price period.\n *\n * Introductory pricing is a discounted rate, different from a free trial.\n *\n * - `true`: Currently using introductory pricing\n * - `false`: Not in intro period\n *\n * @since 1.0.0\n * @platform ios Present for subscriptions with intro pricing\n * @platform android Present for subscriptions with intro pricing\n */\n readonly isInIntroPricePeriod?: boolean;\n /**\n * Whether the transaction is in a grace period.\n *\n * Grace period allows users to fix payment issues while maintaining access.\n * You typically want to continue providing access during this time.\n *\n * - `true`: Subscription payment failed but user still has access\n * - `false`: Not in grace period\n *\n * @since 1.0.0\n * @platform ios Present for subscriptions in grace period\n * @platform android Present for subscriptions in grace period\n */\n readonly isInGracePeriod?: boolean;\n /**\n * Whether the StoreKit transaction still needs to be finished with `finishTransaction()`.\n *\n * Present when the transaction is returned from `getUnfinishedTransactions()` or from\n * `transactionUpdated` while `autoFinishTransactions` is `false`.\n *\n * @since 8.9.0\n * @platform ios Present when the transaction is unfinished in StoreKit 2\n * @platform android Not available (use `isAcknowledged === false` instead)\n */\n readonly needsFinish?: boolean;\n /**\n * Why StoreKit could not verify this transaction. Treat the transaction as untrusted and do not\n * grant entitlements from it.\n *\n * Present only on unverified entries returned by `getUnfinishedTransactions({ includeUnverified: true })`.\n *\n * @since 8.9.7\n * @platform ios Present when StoreKit reports the transaction as unverified\n * @platform android Not available (Play Billing has no client-side unverified state)\n */\n readonly verificationError?: string;\n}\n\nexport interface TransactionVerificationFailedEvent {\n /**\n * Identifier of the transaction that failed verification.\n *\n * @since 7.13.2\n * @platform ios Present when StoreKit reports an unverified transaction\n * @platform android Not available\n */\n readonly transactionId: string;\n /**\n * Localized error message describing why verification failed.\n *\n * @since 7.13.2\n * @platform ios Always present\n * @platform android Not available\n */\n readonly error: string;\n}\n\n/**\n * Represents the App Transaction information from StoreKit 2.\n * This provides details about when the user originally downloaded or purchased the app,\n * which is useful for determining if users are entitled to features from earlier business models.\n *\n * @see https://developer.apple.com/documentation/storekit/supporting-business-model-changes-by-using-the-app-transaction\n * @since 7.16.0\n */\nexport interface AppTransaction {\n /**\n * The app version that the user originally purchased or downloaded.\n *\n * Use this to determine if users who originally downloaded an earlier version\n * should be entitled to features that were previously free or included.\n *\n * For iOS: This is the `CFBundleShortVersionString` (e.g., \"1.0.0\")\n * For Android: This is the `versionName` from Google Play (e.g., \"1.0.0\")\n *\n * @example \"1.0.0\"\n * @since 7.16.0\n * @platform ios Always present (iOS 16+)\n * @platform android Always present\n */\n readonly originalAppVersion: string;\n\n /**\n * The date when the user originally purchased or downloaded the app.\n * ISO 8601 format.\n *\n * @example \"2023-06-15T10:30:00Z\"\n * @since 7.16.0\n * @platform ios Always present (iOS 16+)\n * @platform android Always present\n */\n readonly originalPurchaseDate: string;\n\n /**\n * The bundle identifier of the app.\n *\n * @example \"com.example.myapp\"\n * @since 7.16.0\n * @platform ios Always present (iOS 16+)\n * @platform android Always present (package name)\n */\n readonly bundleId: string;\n\n /**\n * The current app version installed on the device.\n *\n * @example \"2.0.0\"\n * @since 7.16.0\n * @platform ios Always present\n * @platform android Always present\n */\n readonly appVersion: string;\n\n /**\n * The server environment where the app was originally purchased.\n *\n * @since 7.16.0\n * @platform ios Present (iOS 16+)\n * @platform android Not available (always null)\n */\n readonly environment?: 'Sandbox' | 'Production' | 'Xcode' | null;\n\n /**\n * The JWS (JSON Web Signature) representation of the app transaction.\n * Can be sent to your backend for server-side verification.\n *\n * @since 7.16.0\n * @platform ios Present (iOS 16+)\n * @platform android Not available\n */\n readonly jwsRepresentation?: string;\n}\n\nexport interface SubscriptionPeriod {\n /**\n * The Subscription Period number of unit.\n */\n readonly numberOfUnits: number;\n /**\n * The Subscription Period unit.\n */\n readonly unit: number;\n /**\n * Human-readable subscription period unit.\n *\n * @since 8.3.8\n */\n readonly unitString?: 'day' | 'week' | 'month' | 'year' | 'unknown';\n}\n\nexport type SubscriptionBillingPlanType = 'upFront' | 'monthly' | 'unknown';\n\nexport interface ProductCommitmentInfo {\n /**\n * Total commitment price in the local currency.\n */\n readonly price?: number;\n /**\n * Formatted total commitment price.\n */\n readonly priceString?: string;\n /**\n * Full commitment period.\n */\n readonly period?: SubscriptionPeriod;\n}\n\nexport interface SubscriptionPricingTerms {\n /**\n * Billing plan represented by this pricing entry.\n */\n readonly billingPlanType?: SubscriptionBillingPlanType;\n /**\n * Total commitment details for this billing plan.\n */\n readonly commitmentInfo?: ProductCommitmentInfo;\n /**\n * Formatted price for each billing period.\n */\n readonly billingDisplayPrice?: string;\n /**\n * Numeric price for each billing period.\n */\n readonly billingPrice?: number;\n /**\n * Duration of each billing period.\n */\n readonly billingPeriod?: SubscriptionPeriod;\n /**\n * StoreKit subscription offers that apply to this billing plan.\n */\n readonly subscriptionOffers?: StoreKitSubscriptionOffer[];\n}\n\nexport interface StoreKitSubscriptionOffer {\n /**\n * StoreKit offer identifier.\n */\n readonly identifier?: string;\n /**\n * StoreKit offer type.\n */\n readonly type?: string;\n /**\n * Offer price in the local currency.\n */\n readonly price?: number;\n /**\n * Formatted offer price.\n */\n readonly priceString?: string;\n /**\n * Offer billing period.\n */\n readonly period?: SubscriptionPeriod;\n /**\n * Number of periods the offer applies to.\n */\n readonly periodCount?: number;\n /**\n * StoreKit offer payment mode.\n */\n readonly paymentMode?: string;\n}\n\nexport interface TransactionCommitmentInfo {\n /**\n * Current billing period number within the commitment.\n */\n readonly billingPeriodNumber?: number;\n /**\n * Total number of billing periods in the commitment.\n */\n readonly totalBillingPeriods?: number;\n /**\n * End of the full commitment, in ISO 8601 format.\n */\n readonly expirationDate?: string;\n /**\n * Total commitment price in the local currency.\n */\n readonly price?: number;\n}\n\nexport interface RenewalCommitmentInfo {\n /**\n * Product StoreKit will renew into after the commitment ends.\n */\n readonly autoRenewProductId?: string;\n /**\n * Whether the subscription renews into another commitment after the current commitment ends.\n */\n readonly willAutoRenew?: boolean;\n /**\n * Billing plan StoreKit will use for the next commitment or renewal.\n */\n readonly renewalBillingPlanType?: SubscriptionBillingPlanType;\n /**\n * Renewal date for the next commitment or renewal, in ISO 8601 format.\n */\n readonly renewalDate?: string;\n /**\n * Renewal price in the local currency.\n */\n readonly renewalPrice?: number;\n}\n\nexport interface SubscriptionRenewalInfo {\n /**\n * Whether the next billing period will renew.\n */\n readonly willAutoRenew?: boolean;\n /**\n * Product StoreKit will renew into for the next billing period.\n */\n readonly autoRenewProductId?: string;\n /**\n * Billing plan StoreKit will use for the next billing period.\n */\n readonly renewalBillingPlanType?: SubscriptionBillingPlanType;\n /**\n * Next billing period renewal date, in ISO 8601 format.\n */\n readonly renewalDate?: string;\n /**\n * Next billing period renewal price in the local currency.\n */\n readonly renewalPrice?: number;\n /**\n * Currency code for renewal pricing metadata.\n */\n readonly currencyCode?: string;\n /**\n * Commitment renewal metadata for monthly subscriptions with a 12-month commitment.\n */\n readonly commitmentInfo?: RenewalCommitmentInfo;\n}\n\nexport interface SKProductDiscount {\n /**\n * The Product discount identifier.\n */\n readonly identifier: string;\n /**\n * The Product discount type.\n *\n * iOS values: 0 = introductory, 1 = promotional, 2 = win-back.\n */\n readonly type: number;\n /**\n * The Product discount price.\n */\n readonly price: number;\n /**\n * Formatted price of the item, including its currency sign, such as €3.99.\n */\n readonly priceString: string;\n /**\n * The Product discount currency symbol.\n */\n readonly currencySymbol: string;\n /**\n * The Product discount currency code.\n */\n readonly currencyCode: string;\n /**\n * The Product discount paymentMode.\n */\n readonly paymentMode: number;\n /**\n * The Product discount number Of Periods.\n */\n readonly numberOfPeriods: number;\n /**\n * The Product discount subscription period.\n */\n readonly subscriptionPeriod: SubscriptionPeriod;\n}\n\n/**\n * Android one-time product discount display metadata.\n *\n * @platform android Populated for discounted one-time purchase offers when available.\n * @platform ios Not available\n */\nexport interface OneTimePurchaseOfferDiscount {\n /**\n * Percentage discount off the full price.\n */\n readonly percentageDiscount?: number;\n /**\n * Absolute discount amount in micro-units (1,000,000 micro-units = 1 currency unit).\n */\n readonly discountAmountMicros?: number;\n}\n\nexport interface Product {\n /**\n * Product Id.\n *\n * Android subscriptions note:\n * - `identifier` is the base plan ID (`offerDetails.getBasePlanId()`).\n * - `planIdentifier` is the subscription product ID (`productDetails.getProductId()`).\n *\n * Android one-time products note:\n * - `identifier` is the Google Play product ID (`productDetails.getProductId()`).\n * - When multiple offers exist, `getProducts()` returns one entry per eligible offer.\n *\n * If you group/filter Android subscription results by `identifier`, you are grouping by base plan.\n */\n readonly identifier: string;\n /**\n * Description of the product.\n */\n readonly description: string;\n /**\n * Title of the product.\n */\n readonly title: string;\n /**\n * Price of the product in the local currency.\n */\n readonly price: number;\n /**\n * Formatted price of the item, including its currency sign, such as €3.99.\n *\n * Android subscriptions: set from the standard recurring pricing phase (see\n * `ProductPayloadMapper`). When the offer has an introductory phase, `introductoryPrice`\n * describes that phase, so a pre purchase message should include both or defer confirmation\n * to the store sheet.\n */\n readonly priceString: string;\n /**\n * Currency code for price and original price.\n */\n readonly currencyCode: string;\n /**\n * Currency symbol for price and original price.\n */\n readonly currencySymbol: string;\n /**\n * Boolean indicating if the product is sharable with family\n */\n readonly isFamilyShareable: boolean;\n /**\n * Group identifier for the product.\n */\n readonly subscriptionGroupIdentifier: string;\n /**\n * Android subscriptions only: Google Play product identifier tied to the offer/base plan set.\n */\n readonly planIdentifier?: string;\n /**\n * Android: offer token required when purchasing a specific subscription or one-time offer.\n *\n * Pass it to `purchaseProduct({ offerToken })` to buy this exact offer. It belongs to the\n * query that returned it and goes stale, so read it from the same `getProducts()` /\n * `getProduct()` call you purchase from.\n */\n readonly offerToken?: string;\n /**\n * Android: offer identifier (null/undefined for base offers).\n */\n readonly offerId?: string | null;\n /**\n * Android one-time products only: purchase option identifier (for example `buy-option`).\n *\n * @platform android Present on one-time purchase offers when available.\n * @platform ios Not available\n */\n readonly purchaseOptionId?: string;\n /**\n * Android one-time products only: full price before discount, in the local currency.\n *\n * @platform android Present on discounted one-time purchase offers when available.\n * @platform ios Not available\n */\n readonly fullPrice?: number;\n /**\n * Android one-time products only: discount metadata for discounted offers.\n *\n * @platform android Present on discounted one-time purchase offers when available.\n * @platform ios Not available\n */\n readonly discountDisplayInfo?: OneTimePurchaseOfferDiscount;\n /**\n * iOS subscriptions only: StoreKit pricing terms by billing plan.\n *\n * For subscriptions with a monthly billing plan and 12-month commitment, this\n * includes both the standard up-front plan and the monthly commitment plan.\n * Display both `billingDisplayPrice` and `commitmentInfo.priceString` before\n * starting a monthly commitment purchase.\n *\n * @since 8.3.8\n * @platform ios Present on supported StoreKit subscription products.\n * @platform android Not available\n */\n readonly pricingTerms?: SubscriptionPricingTerms[];\n /**\n * Recurring billing period for subscription products.\n *\n * @platform ios From StoreKit `subscription.subscriptionPeriod`.\n * @platform android From the standard pricing phase billing period when recurrence is\n * infinite recurring, or finite recurring on installment offers (`ProductPayloadMapper.applySubscriptionPricing`).\n * Omitted for prepaid (non-recurring) phases.\n */\n readonly subscriptionPeriod?: SubscriptionPeriod;\n /**\n * Android subscriptions only: committed payment count for installment base plans when Play\n * exposes it on the offer.\n *\n * @platform android From `InstallmentPlanDetails.getInstallmentPlanCommitmentPaymentsCount()`.\n * @platform ios Not available\n */\n readonly subscriptionBillingCycles?: number;\n /**\n * Introductory price for this product line when the store exposes it. Pair with `priceString`\n * for full subscription offer wording before purchase. iOS: from StoreKit introductory offers\n * when available. Android base subscription offers (`offerId` null): from the first pricing\n * phase when multiple phases exist (intro then recurring). Android promotional offer lines\n * (`offerId` set): null; phase pricing is not exposed on `Product`, so defer price confirmation\n * to Play checkout instead of using `priceString` alone. Mapping matches `ProductPayloadMapper`.\n */\n readonly introductoryPrice: SKProductDiscount | null;\n /**\n * Whether the current store account is eligible for an introductory offer on this subscription.\n *\n * @platform ios Set from StoreKit `isEligibleForIntroOffer` when the product has an introductory offer.\n * @platform android Always `INTRO_ELIGIBILITY_STATUS_UNKNOWN` (Google Play filters ineligible offers in billing).\n * @since 8.8.3\n */\n readonly introEligibility?: INTRO_ELIGIBILITY_STATUS;\n /**\n * The Product discounts list.\n *\n * @platform ios Populated from StoreKit promotional offers when available.\n * @platform android On base subscription offers (`offerId` null), lists promotional offers on\n * the same base plan. A promotional offer line itself returns an empty array; its pricing\n * phases are not mapped here or on `introductoryPrice`.\n */\n readonly discounts: SKProductDiscount[];\n}\n\nexport interface NativePurchasesPlugin {\n /**\n * Configure plugin-wide purchase finishing behavior.\n *\n * Call this as early as possible (ideally before other NativePurchases APIs). You can also set\n * `autoFinishTransactions` in `capacitor.config` under `plugins.NativePurchases` so iOS applies\n * the value before the native `transactionUpdated` listener starts.\n *\n * **`autoFinishTransactions` (default `true`)**\n *\n * - **iOS (StoreKit 2)**: When `true`, the plugin finishes transactions automatically for\n * `transactionUpdated`, `restorePurchases`, and `purchaseProduct` (when\n * `autoAcknowledgePurchases` is also true). When `false`, transactions stay unfinished until you call\n * `finishTransaction()` (or `acknowledgePurchase()` with the transaction ID).\n * - **Android**: When `true`, `restorePurchases()` may auto-acknowledge unacknowledged purchases\n * (recovery flow). When `false`, recovery does not acknowledge; use `acknowledgePurchase()`.\n * `purchaseProduct()` auto-acknowledges only when both `autoFinishTransactions` and\n * `autoAcknowledgePurchases` are true.\n *\n * **`autoAcknowledgePurchases`** applies only to the `purchaseProduct()` call and does not change\n * how the iOS `transactionUpdated` listener finishes transactions. Use this method (or config) for that.\n *\n * @param options.autoFinishTransactions When false, manual finishing/acknowledgment is required for the flows above.\n * @since 8.9.0\n *\n * @example\n * ```typescript\n * // capacitor.config.ts\n * export default {\n * plugins: {\n * NativePurchases: {\n * autoFinishTransactions: false,\n * },\n * },\n * };\n *\n * // Optional runtime override (affects subsequent native operations)\n * await NativePurchases.configure({ autoFinishTransactions: false });\n * ```\n */\n configure(options?: { autoFinishTransactions?: boolean }): Promise<void>;\n\n /**\n * Restores a user's previous and links their appUserIDs to any user's also using those .\n */\n restorePurchases(): Promise<void>;\n\n /**\n * Gets the App Transaction information, which provides details about when the user\n * originally downloaded or purchased the app.\n *\n * This is useful for implementing business model changes where you want to\n * grandfather users who originally downloaded an earlier version of the app.\n *\n * **Use Case Example:**\n * If your app was originally free but you're adding a subscription, you can use\n * `originalAppVersion` to check if users downloaded before the subscription was added\n * and give them free access.\n *\n * **Platform Notes:**\n * - **iOS**: Requires iOS 16.0+. Uses StoreKit 2's `AppTransaction.shared`.\n * - **Android**: Uses Google Play's install referrer data when available.\n *\n * @returns {Promise<{ appTransaction: AppTransaction }>} The app transaction info\n * @throws An error if the app transaction cannot be retrieved (iOS 15 or earlier)\n * @since 7.16.0\n *\n * @example\n * ```typescript\n * const { appTransaction } = await NativePurchases.getAppTransaction();\n *\n * // Check if user downloaded before version 2.0.0 (when subscription was added)\n * if (compareVersions(appTransaction.originalAppVersion, '2.0.0') < 0) {\n * // User gets free access - they downloaded before subscriptions\n * grantFreeAccess();\n * }\n * ```\n *\n * @see https://developer.apple.com/documentation/storekit/supporting-business-model-changes-by-using-the-app-transaction\n */\n getAppTransaction(): Promise<{ appTransaction: AppTransaction }>;\n\n /**\n * Compares the original app version from the App Transaction against a target version\n * to determine if the user is entitled to features from an earlier business model.\n *\n * This is a utility method that performs the version comparison natively, which can be\n * more reliable than JavaScript-based comparison for semantic versioning.\n *\n * **Use Case:**\n * Check if the user's original download version is older than a specific version\n * to determine if they should be grandfathered into free features.\n *\n * **Platform Differences:**\n * - iOS: Uses build number (CFBundleVersion) from AppTransaction. Requires iOS 16+.\n * - Android: Uses version name from PackageInfo (current installed version, not original).\n *\n * @param options - The comparison options\n * @param options.targetVersion - The Android version name to compare against (e.g., \"2.0.0\"). Used on Android only.\n * @param options.targetBuildNumber - The iOS build number to compare against (e.g., \"42\"). Used on iOS only.\n * @returns {Promise<{ isOlderVersion: boolean; originalAppVersion: string }>}\n * - `isOlderVersion`: true if the user's original version is older than target\n * - `originalAppVersion`: The user's original app version/build number for reference\n * @throws An error if the app transaction cannot be retrieved\n * @since 7.16.0\n *\n * @example\n * ```typescript\n * // Check if user downloaded before version 2.0.0/build 42 (when subscription was added)\n * const result = await NativePurchases.isEntitledToOldBusinessModel({\n * targetVersion: '2.0.0',\n * targetBuildNumber: '42'\n * });\n *\n * if (result.isOlderVersion) {\n * console.log(`User downloaded v${result.originalAppVersion}, granting free access`);\n * grantFreeAccess();\n * }\n * ```\n */\n isEntitledToOldBusinessModel(options: {\n targetVersion?: string;\n targetBuildNumber?: string;\n }): Promise<{ isOlderVersion: boolean; originalAppVersion: string }>;\n\n /**\n * Started purchase process for the given product.\n *\n * On Android, `offerToken` selects which offer is charged. If the token is\n * missing from the product details returned by the plugin's query, the plugin\n * rejects the purchase instead of selecting another offer. Other failures can\n * also reject the purchase. Google Play may still show a different checkout,\n * for example if the offer stops being eligible after the query, so the final\n * price is not guaranteed.\n * Offer tokens come from a specific product query and go stale, so read\n * one from the same `getProducts()` / `getProduct()` call you purchase\n * from.\n *\n * For a **subscription** (`productType: 'subs'`) the order is: an explicit\n * `offerToken`, then the first offer whose base plan matches\n * `planIdentifier`, then the first offer the store returned.\n * `planIdentifier` is the **base plan id**, which `getProducts()` reports\n * as `Product.identifier`, not `Product.planIdentifier`, which holds the\n * Play product id. It is required unless an `offerToken` is given, since\n * a token already identifies one offer on its own.\n *\n * For a **one-time product** (`productType: 'inapp'`) there is no base\n * plan, so `planIdentifier` plays no part, and an `offerToken` selects one\n * of the product's purchase offers. Without a token no offer token is set\n * at all whenever the product still has a backward-compatible purchase\n * option, which leaves the choice to Play: it charges whichever buy\n * purchase option is marked backward-compatible, which is the first\n * *created* one by default and another only if one was marked\n * `legacyCompatible`. Either way it need not be the first offer\n * `getProducts()` returned. Only for a product with no backward-compatible\n * option does the first offer in the list get used. So pass the token\n * whenever a specific one-time offer matters.\n *\n * @param options - The product to purchase\n * @param options.productIdentifier - The product identifier of the product you want to purchase.\n * @param options.productType - Only Android, the type of product, can be inapp or subs. Will use inapp by default.\n * @param options.planIdentifier - Only Android, the identifier of the base plan you want to purchase from Google Play Console, the value `getProducts()` reports as `Product.identifier` for a subscription, not `Product.planIdentifier`. Required for Android subscriptions unless `offerToken` is given; ignored for one-time products and on iOS.\n * @param options.offerToken - Only Android, the offer token for the selected subscription or one-time product offer. Use the `offerToken` returned by `getProducts()` / `getProduct()`. For a subscription it takes precedence over `planIdentifier`, since it names one specific offer, and makes `planIdentifier` optional. When the token is absent from the plugin query result the purchase is rejected instead of falling back to another offer. Google Play may still change what the user can buy after the query. Offer tokens come from a specific product query and go stale, so read one from the same query you purchase from. Omit it to keep the previous behaviour.\n * @param options.quantity - Only iOS, the number of items you wish to purchase. Will use 1 by default.\n * @param options.billingPlanType - Only iOS, the StoreKit subscription billing plan to purchase. Use `\"monthly\"` for a monthly subscription with a 12-month commitment. Requires iOS 26.4+ and Xcode 26.5 SDK support.\n * @param options.appAccountToken - Optional identifier uniquely associated with the user's account in your app.\n * PLATFORM REQUIREMENTS:\n * - iOS: Must be a valid UUID format (StoreKit 2 requirement)\n * - Android: Can be any obfuscated string (max 64 chars), maps to ObfuscatedAccountId\n * SECURITY: DO NOT use PII like emails in cleartext - use UUID or hashed value.\n * RECOMMENDED: Use UUID v5 with deterministic generation for cross-platform compatibility.\n * @param options.isConsumable - Only Android, when true the purchase token is consumed after granting entitlement (for consumable in-app items). Defaults to false.\n * @param options.autoAcknowledgePurchases - When false, this purchase is not auto-finished/acknowledged when\n * `autoFinishTransactions` is also true. Does not disable auto-finishing on\n * the iOS `transactionUpdated` listener; use `configure({ autoFinishTransactions: false })`\n * for manual finishing across purchase and recovery flows. Defaults to true.\n * - **Android**: Must acknowledge within 3 days or Google Play will refund\n * - **iOS**: Unfinished transactions remain in the queue and may block future purchases\n */\n purchaseProduct(options: {\n productIdentifier: string;\n planIdentifier?: string;\n offerToken?: string;\n productType?: PURCHASE_TYPE;\n quantity?: number;\n billingPlanType?: 'monthly' | 'upFront';\n appAccountToken?: string;\n isConsumable?: boolean;\n autoAcknowledgePurchases?: boolean;\n }): Promise<Transaction>;\n\n /**\n * Gets the product info associated with a list of product identifiers.\n *\n * @param options - The product identifiers you wish to retrieve information for\n * @param options.productIdentifiers - Array of product identifiers\n * @param options.productType - Only Android, the type of product, can be inapp or subs. Will use inapp by default.\n * @returns - The requested product info\n */\n getProducts(options: { productIdentifiers: string[]; productType?: PURCHASE_TYPE }): Promise<{ products: Product[] }>;\n\n /**\n * Gets the product info for a single product identifier.\n *\n * **⚠️ Warning:** Do not call `getProduct` concurrently using `Promise.all`.\n * The underlying native billing client does not support concurrent product\n * queries, and doing so causes a race condition that may result in errors\n * or missing data. To fetch multiple products at once, use `getProducts`\n * instead — it accepts an array of identifiers and is race-condition-free.\n *\n * @example\n * // ❌ Avoid: causes race condition\n * const [a, b] = await Promise.all([\n * NativePurchases.getProduct({ productIdentifier: 'id1' }),\n * NativePurchases.getProduct({ productIdentifier: 'id2' }),\n * ]);\n *\n * // ✅ Correct: use getProducts for multiple identifiers\n * const { products } = await NativePurchases.getProducts({ productIdentifiers: ['id1', 'id2'] });\n *\n * @param options - The product identifier you wish to retrieve information for\n * @param options.productIdentifier - The product identifier\n * @param options.productType - Only Android, the type of product, can be inapp or subs. Will use inapp by default.\n * @returns - The requested product info\n */\n getProduct(options: { productIdentifier: string; productType?: PURCHASE_TYPE }): Promise<{ product: Product }>;\n\n /**\n * Check if billing is supported for the current device.\n *\n *\n */\n isBillingSupported(): Promise<{ isBillingSupported: boolean }>;\n /**\n * Get the native Capacitor plugin version\n *\n * @returns {Promise<{ id: string }>} an Promise with version for this device\n * @throws An error if the something went wrong\n */\n getPluginVersion(): Promise<{ version: string }>;\n\n /**\n * Gets all the user's purchases (both in-app purchases and subscriptions).\n * This method queries the platform's purchase history for the current user.\n *\n * @param options - Optional parameters for filtering purchases\n * @param options.productType - Only Android, filter by product type (inapp or subs). If not specified, returns both types.\n * @param options.appAccountToken - Optional filter to restrict results to purchases that used the provided account token.\n * Must be the same identifier used during purchase (UUID format for iOS, any obfuscated string for Android).\n * iOS: UUID format required. Android: Maps to ObfuscatedAccountId.\n * @param options.onlyCurrentEntitlements - iOS only. When `false` (default), uses `Transaction.all` which returns every\n * transaction ever recorded on the device. When `true`, uses\n * `Transaction.currentEntitlements` which is scoped to the signed-in Apple ID\n * and only includes currently active entitlements. Set to `true` to prevent\n * cross-account purchase leakage on shared or refurbished devices.\n * @returns {Promise<{ purchases: Transaction[] }>} Promise that resolves with array of user's purchases\n * @throws An error if the purchase query fails\n * @since 7.2.0\n */\n getPurchases(options?: {\n productType?: PURCHASE_TYPE;\n appAccountToken?: string;\n onlyCurrentEntitlements?: boolean;\n }): Promise<{ purchases: Transaction[] }>;\n\n /**\n * Opens the platform's native subscription management page.\n * This allows users to view, modify, or cancel their subscriptions.\n *\n * - iOS: Opens the App Store subscription management page for the current app\n * - Android: Opens the Google Play subscription management page\n *\n * @returns {Promise<void>} Promise that resolves when the management page is opened\n * @throws An error if the subscription management page cannot be opened\n * @since 7.10.0\n */\n manageSubscriptions(): Promise<void>;\n\n /**\n * Presents the App Store offer code redemption sheet so users can redeem a subscription offer code in your app.\n *\n * iOS: Uses StoreKit's `AppStore.presentOfferCodeRedeemSheet(in:)` to display the system redemption UI (iOS 16.0+).\n *\n * @returns {Promise<void>} Promise that resolves when the redemption sheet is presented\n * @throws An error if the offer code redemption sheet cannot be presented\n * @since 8.6.0\n * @platform ios\n *\n * @see https://developer.apple.com/documentation/storekit/appstore/presentoffercoderedeemsheet(in:)\n */\n presentOfferCodeRedeemSheet(): Promise<void>;\n\n /**\n * Manually acknowledge/finish a purchase transaction.\n *\n * Call this when automatic finishing or acknowledgment is disabled, for example\n * `purchaseProduct({ autoAcknowledgePurchases: false })`, `configure({ autoFinishTransactions: false })`\n * (Android recovery or iOS updates), or when a returned transaction has `needsFinish: true`.\n *\n * **Platform Behavior:**\n * - **Android**: Acknowledges the purchase with Google Play. Must be called within 3 days or the purchase will be refunded.\n * - **iOS**: Finishes the transaction with StoreKit 2. Unfinished transactions remain in the queue and may block future purchases.\n *\n * **Acknowledgment Options:**\n *\n * **1. Client-side (this method)**: Call from your app after validation\n * ```typescript\n * await NativePurchases.acknowledgePurchase({\n * purchaseToken: transaction.purchaseToken // Android: purchaseToken, iOS: transactionId\n * });\n * ```\n *\n * **2. Server-side (Android only, recommended for security)**: Use Google Play Developer API v3\n * - Endpoint: `POST https://androidpublisher.googleapis.com/androidpublisher/v3/applications/{packageName}/purchases/products/{productId}/tokens/{token}:acknowledge`\n * - Requires OAuth 2.0 authentication with appropriate scopes\n * - See: https://developers.google.com/android-publisher/api-ref/rest/v3/purchases.products/acknowledge\n * - For subscriptions: Use `/purchases/subscriptions/{subscriptionId}/tokens/{token}:acknowledge` instead\n * - Note: iOS has no server-side finish API\n *\n * **When to use manual acknowledgment:**\n * - Server-side validation: Verify the purchase with your backend before acknowledging\n * - Entitlement delivery: Ensure user receives content/features before acknowledging\n * - Multi-step workflows: Complete all steps before final acknowledgment\n * - Security: Prevent client-side manipulation by handling acknowledgment server-side (Android only)\n *\n * @param options - The purchase to acknowledge\n * @param options.purchaseToken - The purchase token (Android) or transaction ID as string (iOS) from the Transaction object\n * @returns {Promise<void>} Promise that resolves when the purchase is acknowledged/finished\n * @throws An error if acknowledgment/finishing fails or transaction not found\n * @platform android Acknowledges the purchase with Google Play\n * @platform ios Finishes the transaction with StoreKit 2\n * @since 7.14.0\n *\n * @example\n * ```typescript\n * // Client-side acknowledgment\n * const transaction = await NativePurchases.purchaseProduct({\n * productIdentifier: 'premium_feature',\n * autoAcknowledgePurchases: false\n * });\n *\n * // Validate with your backend\n * const isValid = await fetch('/api/validate-purchase', {\n * method: 'POST',\n * body: JSON.stringify({ purchaseToken: transaction.purchaseToken })\n * });\n *\n * if (isValid) {\n * // Option 1: Acknowledge from client\n * await NativePurchases.acknowledgePurchase({\n * purchaseToken: transaction.purchaseToken\n * });\n *\n * // Option 2: Or let your backend acknowledge via Google Play API\n * // Your backend calls Google Play Developer API\n * }\n * ```\n */\n acknowledgePurchase(options: { purchaseToken: string }): Promise<void>;\n\n /**\n * Finish a StoreKit 2 transaction on iOS after you validate delivery on your backend.\n *\n * Equivalent to `acknowledgePurchase({ purchaseToken: transactionId })` on iOS. Safe to call more\n * than once; finishing an already finished transaction resolves successfully.\n *\n * A transaction StoreKit could not verify is rejected unless `allowUnverified` is `true`. Finishing\n * one only removes it from the queue so StoreKit stops re-delivering it; never grant entitlements from it.\n *\n * **Android**: Acknowledges the purchase, using `transactionId` as the purchase token. Use\n * `consumePurchase({ purchaseToken })` instead for consumables that must be purchasable again.\n * `allowUnverified` has no effect because Play Billing has no client-side unverified state.\n *\n * @param options.transactionId Transaction ID from the `Transaction` object (numeric string on iOS, purchase token on Android).\n * @param options.allowUnverified Finish the transaction even if StoreKit could not verify it. Defaults to `false`. Since 8.9.7.\n * @since 8.9.0\n * @platform ios Finishes the transaction with StoreKit 2\n * @platform android Acknowledges the purchase with Google Play\n */\n finishTransaction(options: { transactionId: string; allowUnverified?: boolean }): Promise<void>;\n\n /**\n * Returns transactions that still need finishing on iOS, or unacknowledged purchases on Android.\n *\n * Use on app launch when `autoFinishTransactions` is `false` to recover work after a restart.\n *\n * **Android recovery:** After validation, call `consumePurchase({ purchaseToken })` for consumable\n * in-app products (acknowledges and consumes). Call `acknowledgePurchase({ purchaseToken })` for\n * non-consumables and subscriptions. Includes only purchases in the `PURCHASED` state that are not\n * yet acknowledged. Pending purchases are excluded until Google Play marks them purchased.\n *\n * **Unverified transactions:** With `includeUnverified: true`, iOS also returns transactions StoreKit\n * could not verify, each with `verificationError` set. Do not grant entitlements from those; pass them\n * to `finishTransaction({ transactionId, allowUnverified: true })` to clear them. Android has no\n * client-side unverified state, so the option does not change its results.\n *\n * @param options.includeUnverified Also return unfinished transactions StoreKit could not verify. Defaults to `false`. Since 8.9.7.\n * @since 8.9.0\n */\n getUnfinishedTransactions(options?: { includeUnverified?: boolean }): Promise<{ transactions: Transaction[] }>;\n\n /**\n * Consume an in-app purchase on Android.\n *\n * Consuming a purchase does two things:\n * 1. Acknowledges the purchase (so you don't need to call acknowledgePurchase separately)\n * 2. Removes ownership, allowing the user to buy the same product again\n *\n * Use this for consumable products like virtual currency, extra lives, or credits.\n *\n * **Important:** In Google Play Billing Library 8.x, consumed purchases can no longer\n * be queried via getPurchases(). Once consumed, the purchase is gone.\n *\n * Android only — iOS does not have a separate consume concept.\n * On iOS and web, this method rejects with an error.\n *\n * @param options - The purchase to consume\n * @param options.purchaseToken - The purchase token from the Transaction object\n * @returns {Promise<void>} Promise that resolves when the purchase is consumed\n * @throws Error if consumption fails, token is invalid, or called on iOS/web\n * @platform android\n * @since 8.2.0\n *\n * @example\n * ```typescript\n * const transaction = await NativePurchases.purchaseProduct({\n * productIdentifier: 'coins_100',\n * isConsumable: false,\n * autoAcknowledgePurchases: false\n * });\n *\n * // Validate with your backend first\n * const isValid = await validateWithServer(transaction.purchaseToken);\n *\n * if (isValid) {\n * // Grant the coins, then consume to allow re-purchase\n * await NativePurchases.consumePurchase({\n * purchaseToken: transaction.purchaseToken!\n * });\n * }\n * ```\n */\n consumePurchase(options: { purchaseToken: string }): Promise<void>;\n\n /**\n * Get the user's current App Store / Google Play storefront — the country\n * their store account is registered to.\n *\n * iOS: reads StoreKit 2 `Storefront.current`. `countryCode` is ISO 3166-1\n * **alpha-3** (e.g. `\"USA\"`) and `storefrontId` is the Apple-defined\n * storefront identifier.\n * Android: reads Google Play Billing `getBillingConfigAsync()`. `countryCode`\n * is ISO 3166-1 **alpha-2** (e.g. `\"US\"`); `storefrontId` is omitted (Google\n * Play has no storefront-id concept).\n *\n * Contract note (future-major default candidate): `countryCode` is returned in\n * each store's native format and is intentionally NOT normalized across\n * platforms today (iOS alpha-3 vs Android alpha-2), to stay faithful to the\n * platform APIs. Normalizing both to a single scheme (e.g. ISO 3166-1 alpha-2)\n * is a candidate default change for the next Capacitor major, deferred so it\n * can be adopted deliberately rather than as a mid-major breaking change.\n *\n * Resolves a `countryCode` of `\"\"` (it does not reject) when the storefront\n * can't be determined on either platform — e.g. apps distributed via iOS\n * alternative distribution, or Google Play billing being unavailable.\n *\n * Useful for region-dependent logic such as localized offers/pricing and\n * gating external-purchase entitlements, whose eligibility the platforms key\n * to the storefront country. Read it live rather than caching, since the user\n * can change their store region.\n *\n * @returns {Promise<{ countryCode: string; storefrontId?: string }>} the current storefront\n * @since 8.5.0\n *\n * @example\n * ```typescript\n * const { countryCode } = await NativePurchases.getStorefront();\n * if (countryCode === 'USA' || countryCode === 'US') {\n * // show US-specific payment options\n * }\n * ```\n */\n getStorefront(): Promise<{ countryCode: string; storefrontId?: string }>;\n\n /**\n * Listen for StoreKit transaction updates delivered by Apple's Transaction.updates.\n * Fires on app launch if there are unfinished transactions, and for any updates afterward.\n *\n * When `autoFinishTransactions` is `true` (default), the plugin finishes each verified transaction\n * before emitting the event. When `false`, the event includes `needsFinish: true` and you must call\n * `finishTransaction()` after backend validation.\n *\n * iOS only.\n */\n addListener(\n eventName: 'transactionUpdated',\n listenerFunc: (transaction: Transaction) => void,\n ): Promise<PluginListenerHandle>;\n /**\n * Listen for StoreKit transaction verification failures delivered by Apple's Transaction.updates.\n * Fires when the verification result is unverified.\n * iOS only.\n */\n addListener(\n eventName: 'transactionVerificationFailed',\n listenerFunc: (payload: TransactionVerificationFailedEvent) => void,\n ): Promise<PluginListenerHandle>;\n\n /** Remove all registered listeners */\n removeAllListeners(): Promise<void>;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAEA,MAAM,CAAN,IAAY,mBAOX;AAPD,WAAY,mBAAmB;IAC7B,qFAAoB,CAAA;IACpB,iEAAU,CAAA;IACV,uEAAa,CAAA;IACb,iEAAU,CAAA;IACV,iEAAU,CAAA;IACV,qEAAY,CAAA;AACd,CAAC,EAPW,mBAAmB,KAAnB,mBAAmB,QAO9B;AAED,MAAM,CAAN,IAAY,aAUX;AAVD,WAAY,aAAa;IACvB;;OAEG;IACH,gCAAe,CAAA;IAEf;;OAEG;IACH,8BAAa,CAAA;AACf,CAAC,EAVW,aAAa,KAAb,aAAa,QAUxB;AAED;;;;GAIG;AACH,MAAM,CAAN,IAAY,eAyBX;AAzBD,WAAY,eAAe;IACzB;;OAEG;IACH,uEAAa,CAAA;IAEb;;OAEG;IACH,qFAAoB,CAAA;IAEpB;;OAEG;IACH,iFAAkB,CAAA;IAElB;;OAEG;IACH,mFAAmB,CAAA;IAEnB;;OAEG;IACH,+FAAyB,CAAA;AAC3B,CAAC,EAzBW,eAAe,KAAf,eAAe,QAyB1B;AACD,MAAM,CAAN,IAAY,cA2BX;AA3BD,WAAY,cAAc;IACxB,qIAAiD,CAAA;IAEjD;;;OAGG;IACH,qGAAiC,CAAA;IAEjC;;;;OAIG;IACH,iHAAuC,CAAA;IAEvC;;;OAGG;IACH,iGAA+B,CAAA;IAE/B;;;OAGG;IACH,2DAAY,CAAA;AACd,CAAC,EA3BW,cAAc,KAAd,cAAc,QA2BzB;AAED,MAAM,CAAN,IAAY,YA6CX;AA7CD,WAAY,YAAY;IACtB;;OAEG;IACH,mCAAmB,CAAA;IAEnB;;OAEG;IACH,iCAAiB,CAAA;IAEjB;;OAEG;IACH,qCAAqB,CAAA;IAErB;;OAEG;IACH,iCAAiB,CAAA;IAEjB;;OAEG;IACH,uCAAuB,CAAA;IAEvB;;OAEG;IACH,2CAA2B,CAAA;IAE3B;;OAEG;IACH,uCAAuB,CAAA;IAEvB;;OAEG;IACH,mCAAmB,CAAA;IAEnB;;OAEG;IACH,iCAAiB,CAAA;AACnB,CAAC,EA7CW,YAAY,KAAZ,YAAY,QA6CvB;AAED,MAAM,CAAN,IAAY,wBAaX;AAbD,WAAY,wBAAwB;IAClC;;OAEG;IACH,+HAAoC,CAAA;IACpC;;OAEG;IACH,qIAAuC,CAAA;IACvC;;OAEG;IACH,iIAAqC,CAAA;AACvC,CAAC,EAbW,wBAAwB,KAAxB,wBAAwB,QAanC","sourcesContent":["import type { PluginListenerHandle } from '@capacitor/core';\n\nexport enum ATTRIBUTION_NETWORK {\n APPLE_SEARCH_ADS = 0,\n ADJUST = 1,\n APPSFLYER = 2,\n BRANCH = 3,\n TENJIN = 4,\n FACEBOOK = 5,\n}\n\nexport enum PURCHASE_TYPE {\n /**\n * A type of SKU for in-app products.\n */\n INAPP = 'inapp',\n\n /**\n * A type of SKU for subscriptions.\n */\n SUBS = 'subs',\n}\n\n/**\n * Enum for billing features.\n * Currently, these are only relevant for Google Play Android users:\n * https://developer.android.com/reference/com/android/billingclient/api/BillingClient.FeatureType\n */\nexport enum BILLING_FEATURE {\n /**\n * Purchase/query for subscriptions.\n */\n SUBSCRIPTIONS,\n\n /**\n * Subscriptions update/replace.\n */\n SUBSCRIPTIONS_UPDATE,\n\n /**\n * Purchase/query for in-app items on VR.\n */\n IN_APP_ITEMS_ON_VR,\n\n /**\n * Purchase/query for subscriptions on VR.\n */\n SUBSCRIPTIONS_ON_VR,\n\n /**\n * Launch a price change confirmation flow.\n */\n PRICE_CHANGE_CONFIRMATION,\n}\nexport enum PRORATION_MODE {\n UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY = 0,\n\n /**\n * Replacement takes effect immediately, and the remaining time will be\n * prorated and credited to the user. This is the current default behavior.\n */\n IMMEDIATE_WITH_TIME_PRORATION = 1,\n\n /**\n * Replacement takes effect immediately, and the billing cycle remains the\n * same. The price for the remaining period will be charged. This option is\n * only available for subscription upgrade.\n */\n IMMEDIATE_AND_CHARGE_PRORATED_PRICE = 2,\n\n /**\n * Replacement takes effect immediately, and the new price will be charged on\n * next recurrence time. The billing cycle stays the same.\n */\n IMMEDIATE_WITHOUT_PRORATION = 3,\n\n /**\n * Replacement takes effect when the old plan expires, and the new price will\n * be charged at the same time.\n */\n DEFERRED = 4,\n}\n\nexport enum PACKAGE_TYPE {\n /**\n * A package that was defined with a custom identifier.\n */\n UNKNOWN = 'UNKNOWN',\n\n /**\n * A package that was defined with a custom identifier.\n */\n CUSTOM = 'CUSTOM',\n\n /**\n * A package configured with the predefined lifetime identifier.\n */\n LIFETIME = 'LIFETIME',\n\n /**\n * A package configured with the predefined annual identifier.\n */\n ANNUAL = 'ANNUAL',\n\n /**\n * A package configured with the predefined six month identifier.\n */\n SIX_MONTH = 'SIX_MONTH',\n\n /**\n * A package configured with the predefined three month identifier.\n */\n THREE_MONTH = 'THREE_MONTH',\n\n /**\n * A package configured with the predefined two month identifier.\n */\n TWO_MONTH = 'TWO_MONTH',\n\n /**\n * A package configured with the predefined monthly identifier.\n */\n MONTHLY = 'MONTHLY',\n\n /**\n * A package configured with the predefined weekly identifier.\n */\n WEEKLY = 'WEEKLY',\n}\n\nexport enum INTRO_ELIGIBILITY_STATUS {\n /**\n * doesn't have enough information to determine eligibility.\n */\n INTRO_ELIGIBILITY_STATUS_UNKNOWN = 0,\n /**\n * The user is not eligible for a free trial or intro pricing for this product.\n */\n INTRO_ELIGIBILITY_STATUS_INELIGIBLE = 1,\n /**\n * The user is eligible for a free trial or intro pricing for this product.\n */\n INTRO_ELIGIBILITY_STATUS_ELIGIBLE = 2,\n}\n\nexport interface Transaction {\n /**\n * Unique identifier for the transaction.\n *\n * @since 1.0.0\n * @platform ios Numeric string (e.g., \"2000001043762129\")\n * @platform android The Google Play purchase token (same value as `purchaseToken`), not the `GPA.` order ID in `orderId`\n */\n readonly transactionId: string;\n /**\n * Receipt data for validation (base64 encoded StoreKit receipt).\n *\n * **This is the full verified receipt payload from Apple StoreKit.**\n * Send this to your backend for server-side validation with Apple's receipt verification API.\n * The receipt remains available even after refund - server validation is required to detect refunded transactions.\n *\n * **For backend validation:**\n * - Use Apple's receipt verification API: https://buy.itunes.apple.com/verifyReceipt (production)\n * - Or sandbox: https://sandbox.itunes.apple.com/verifyReceipt\n * - This contains all transaction data needed for validation\n *\n * **Note:** Apple recommends migrating to App Store Server API v2 with `jwsRepresentation` for new implementations.\n * The legacy receipt verification API continues to work but may be deprecated in the future.\n *\n * @since 1.0.0\n * @platform ios Always present\n * @platform android Not available (use purchaseToken instead)\n * @example\n * ```typescript\n * const transaction = await NativePurchases.purchaseProduct({ ... });\n * if (transaction.receipt) {\n * // Send to your backend for validation\n * await fetch('/api/validate-receipt', {\n * method: 'POST',\n * body: JSON.stringify({ receipt: transaction.receipt })\n * });\n * }\n * ```\n */\n readonly receipt?: string;\n /**\n * StoreKit 2 JSON Web Signature (JWS) payload describing the verified transaction.\n *\n * **This is the full verified receipt in JWS format (StoreKit 2).**\n * Send this to your backend when using Apple's App Store Server API v2 instead of raw receipts.\n * Only available when the transaction originated from StoreKit 2 APIs (e.g. Transaction.updates).\n *\n * **For backend validation:**\n * - Use Apple's App Store Server API v2 to decode and verify the JWS\n * - This is the modern alternative to the legacy receipt format\n * - Contains signed transaction information from Apple\n *\n * @since 7.13.2\n * @platform ios Present for StoreKit 2 transactions (iOS 15+)\n * @platform android Not available\n * @example\n * ```typescript\n * const transaction = await NativePurchases.purchaseProduct({ ... });\n * if (transaction.jwsRepresentation) {\n * // Send to your backend for validation with App Store Server API v2\n * await fetch('/api/validate-jws', {\n * method: 'POST',\n * body: JSON.stringify({ jws: transaction.jwsRepresentation })\n * });\n * }\n * ```\n */\n readonly jwsRepresentation?: string;\n /**\n * An optional obfuscated identifier that uniquely associates the transaction with a user account in your app.\n *\n * PURPOSE:\n * - Fraud detection: Helps platforms detect irregular activity (e.g., many devices purchasing on the same account)\n * - User linking: Links purchases to in-game characters, avatars, or in-app profiles\n *\n * PLATFORM DIFFERENCES:\n * - iOS: Must be a valid UUID format (e.g., \"550e8400-e29b-41d4-a716-446655440000\")\n * Apple's StoreKit 2 requires UUID format for the appAccountToken parameter\n * - Android: Can be any obfuscated string (max 64 chars), maps to Google Play's ObfuscatedAccountId\n * Google recommends using encryption or one-way hash\n *\n * SECURITY REQUIREMENTS (especially for Android):\n * - DO NOT store Personally Identifiable Information (PII) like emails in cleartext\n * - Use encryption or a one-way hash to generate an obfuscated identifier\n * - Maximum length: 64 characters (both platforms)\n * - Storing PII in cleartext will result in purchases being blocked by Google Play\n *\n * IMPLEMENTATION EXAMPLE:\n * ```typescript\n * // For iOS: Generate a deterministic UUID from user ID\n * import { v5 as uuidv5 } from 'uuid';\n * const NAMESPACE = '6ba7b810-9dad-11d1-80b4-00c04fd430c8'; // Your app's namespace UUID\n * const appAccountToken = uuidv5(userId, NAMESPACE);\n *\n * // For Android: Can also use UUID or any hashed value\n * // The same UUID approach works for both platforms\n * ```\n */\n readonly appAccountToken?: string | null;\n /**\n * Product identifier associated with the transaction.\n *\n * @since 1.0.0\n * @platform ios Always present\n * @platform android Always present\n */\n readonly productIdentifier: string;\n /**\n * Purchase date of the transaction in ISO 8601 format.\n *\n * @since 1.0.0\n * @example \"2025-10-28T06:03:19Z\"\n * @platform ios Always present\n * @platform android Always present\n */\n readonly purchaseDate: string;\n /**\n * Indicates whether this transaction is the result of a subscription upgrade.\n *\n * Useful for understanding when StoreKit generated the transaction because\n * the customer moved from a lower tier to a higher tier plan.\n *\n * @since 7.13.2\n * @platform ios Present for auto-renewable subscriptions (iOS 15+)\n * @platform android Not available\n */\n readonly isUpgraded?: boolean;\n /**\n * Original purchase date of the transaction in ISO 8601 format.\n *\n * For subscription renewals, this shows the date of the original subscription purchase,\n * while purchaseDate shows the date of the current renewal.\n *\n * @since 1.0.0\n * @platform ios Present for subscriptions only\n * @platform android Not available\n */\n readonly originalPurchaseDate?: string;\n /**\n * Expiration date of the transaction in ISO 8601 format.\n *\n * Check this date to determine if a subscription is still valid.\n * Compare with current date: if expirationDate > now, subscription is active.\n *\n * @since 1.0.0\n * @platform ios Present for subscriptions only\n * @platform android Not available (query Google Play Developer API instead)\n */\n readonly expirationDate?: string;\n /**\n * Whether the subscription is still active/valid.\n *\n * For iOS subscriptions, check if isActive === true to verify an active subscription.\n * For expired or refunded iOS subscriptions, this will be false.\n *\n * @since 1.0.0\n * @platform ios Present for subscriptions only (true if expiration date is in the future)\n * @platform android Not available (check purchaseState === \"1\" instead)\n */\n readonly isActive?: boolean;\n /**\n * Date the transaction was revoked/refunded, in ISO 8601 format.\n *\n * Present when Apple revokes access due to an issue (e.g., refund or developer issue).\n *\n * @since 7.13.2\n * @platform ios Present for revoked transactions (iOS 15+)\n * @platform android Not available\n */\n readonly revocationDate?: string;\n /**\n * Reason why Apple revoked the transaction.\n *\n * Possible values:\n * - `\"developerIssue\"`: Developer-initiated refund or issue\n * - `\"other\"`: Apple-initiated (customer refund, billing problem, etc.)\n * - `\"unknown\"`: StoreKit didn't report a specific reason\n *\n * @since 7.13.2\n * @platform ios Present for revoked transactions (iOS 15+)\n * @platform android Not available\n */\n readonly revocationReason?: 'developerIssue' | 'other' | 'unknown';\n /**\n * Whether the subscription will be cancelled at the end of the billing cycle.\n *\n * - `true`: User has cancelled but subscription remains active until expiration\n * - `false`: Subscription will auto-renew\n * - `null`: Status unknown or not available\n *\n * @since 1.0.0\n * @default null\n * @platform ios Present for subscriptions only (boolean or null)\n * @platform android Always null (use Google Play Developer API for cancellation status)\n */\n readonly willCancel: boolean | null;\n /**\n * Current subscription state reported by StoreKit.\n *\n * Possible values:\n * - `\"subscribed\"`: Auto-renewing and in good standing\n * - `\"expired\"`: Lapsed with no access\n * - `\"revoked\"`: Access removed due to refund or issue\n * - `\"inGracePeriod\"`: Payment issue but still in grace access window\n * - `\"inBillingRetryPeriod\"`: StoreKit retrying failed billing\n * - `\"unknown\"`: StoreKit did not report a state\n *\n * @since 7.13.2\n * @platform ios Present for auto-renewable subscriptions (iOS 15+)\n * @platform android Not available\n */\n readonly subscriptionState?:\n 'subscribed' | 'expired' | 'revoked' | 'inGracePeriod' | 'inBillingRetryPeriod' | 'unknown';\n /**\n * StoreKit billing plan type for auto-renewable subscriptions.\n *\n * - `\"upFront\"`: Standard subscription billing for the full billing period.\n * - `\"monthly\"`: Monthly billing with a 12-month commitment.\n * - `\"unknown\"`: StoreKit returned a future or unsupported value.\n *\n * @since 8.3.8\n * @platform ios Present for StoreKit transactions that include billing plan metadata.\n * @platform android Not available\n */\n readonly billingPlanType?: SubscriptionBillingPlanType;\n /**\n * Commitment metadata for monthly subscriptions with a 12-month commitment.\n *\n * Use `expirationDate` here only to display commitment progress. Continue using\n * the top-level `expirationDate` to decide whether the current billing period\n * grants entitlement access.\n *\n * @since 8.3.8\n * @platform ios Present for monthly commitment subscription transactions.\n * @platform android Not available\n */\n readonly commitmentInfo?: TransactionCommitmentInfo;\n /**\n * StoreKit renewal metadata for auto-renewable subscriptions.\n *\n * `willAutoRenew` here describes the next billing period. For monthly\n * commitment subscriptions, `commitmentInfo.willAutoRenew` describes whether\n * the next 12-month commitment renews after the current commitment ends.\n *\n * @since 8.3.8\n * @platform ios Present for verified subscription renewal info.\n * @platform android Not available\n */\n readonly renewalInfo?: SubscriptionRenewalInfo;\n /**\n * Currency code associated with StoreKit transaction pricing metadata.\n *\n * @since 8.3.8\n * @platform ios Present when StoreKit includes currency in the transaction payload.\n * @platform android Not available\n */\n readonly currencyCode?: string;\n /**\n * Purchase state of the transaction (numeric string value).\n *\n * **Android Values:**\n * - `\"1\"`: Purchase completed and valid (PURCHASED state)\n * - `\"0\"`: Payment pending (PENDING state, e.g., cash payment processing)\n * - Other numeric values: Various other states\n *\n * Always check `purchaseState === \"1\"` on Android to verify a valid purchase.\n * Refunded purchases typically disappear from getPurchases() rather than showing a different state.\n *\n * @since 1.0.0\n * @platform ios Not available (use isActive for subscriptions or receipt validation for IAP)\n * @platform android Always present\n */\n readonly purchaseState?: string;\n /**\n * Order ID associated with the transaction.\n *\n * Use this for server-side verification on Android. This is the Google Play order ID.\n *\n * @since 1.0.0\n * @example \"GPA.1234-5678-9012-34567\"\n * @platform ios Not available\n * @platform android Always present\n */\n readonly orderId?: string;\n /**\n * Purchase token associated with the transaction.\n *\n * **This is the full verified purchase token from Google Play.**\n * Send this to your backend for server-side validation with Google Play Developer API.\n * This is the Android equivalent of iOS's receipt field.\n *\n * **For backend validation:**\n * - Use Google Play Developer API v3 to verify the purchase\n * - API endpoint: androidpublisher.purchases.products.get() or purchases.subscriptions.get()\n * - This token contains all data needed for validation with Google servers\n * - Can also be used for subscription status checks and cancellation detection\n *\n * @since 1.0.0\n * @platform ios Not available (use receipt instead)\n * @platform android Always present\n * @example\n * ```typescript\n * const transaction = await NativePurchases.purchaseProduct({ ... });\n * if (transaction.purchaseToken) {\n * // Send to your backend for validation\n * await fetch('/api/validate-purchase', {\n * method: 'POST',\n * body: JSON.stringify({\n * purchaseToken: transaction.purchaseToken,\n * productId: transaction.productIdentifier\n * })\n * });\n * }\n * ```\n */\n readonly purchaseToken?: string;\n /**\n * Whether the purchase has been acknowledged.\n *\n * Purchases must be acknowledged within 3 days or they will be refunded.\n * By default, this plugin automatically acknowledges purchases unless you set\n * `autoAcknowledgePurchases: false` in purchaseProduct().\n *\n * @since 1.0.0\n * @platform ios Not available\n * @platform android Always present (should be true after successful purchase or manual acknowledgment)\n */\n readonly isAcknowledged?: boolean;\n /**\n * Quantity purchased.\n *\n * @since 1.0.0\n * @default 1\n * @platform ios 1 or higher (as specified in purchaseProduct call)\n * @platform android Always 1 (Google Play doesn't support quantity > 1)\n */\n readonly quantity?: number;\n /**\n * Product type.\n *\n * - `\"inapp\"`: One-time in-app purchase\n * - `\"subs\"`: Subscription\n *\n * @since 1.0.0\n * @platform ios Always present\n * @platform android Always present\n */\n readonly productType?: string;\n /**\n * Indicates how the user obtained access to the product.\n *\n * - `\"purchased\"`: The user purchased the product directly\n * - `\"familyShared\"`: The user has access through Family Sharing (another family member purchased it)\n *\n * This property is useful for:\n * - Detecting family sharing usage for analytics\n * - Implementing different features/limits for family-shared vs. directly purchased products\n * - Understanding your user acquisition channels\n *\n * @since 7.12.8\n * @platform ios Always present (iOS 15.0+, StoreKit 2)\n * @platform android Not available\n */\n readonly ownershipType?: 'purchased' | 'familyShared';\n /**\n * Indicates the server environment where the transaction was processed.\n *\n * - `\"Sandbox\"`: Transaction belongs to testing in the sandbox environment\n * - `\"Production\"`: Transaction belongs to a customer in the production environment\n * - `\"Xcode\"`: Transaction from StoreKit Testing in Xcode\n *\n * This property is useful for:\n * - Debugging and identifying test vs. production purchases\n * - Analytics and reporting (filtering out sandbox transactions)\n * - Server-side validation (knowing which Apple endpoint to use)\n * - Preventing test purchases from affecting production metrics\n *\n * @since 7.12.8\n * @platform ios Present on iOS 16.0+ only (not available on iOS 15)\n * @platform android Not available\n */\n readonly environment?: 'Sandbox' | 'Production' | 'Xcode';\n /**\n * Reason StoreKit generated the transaction.\n *\n * - `\"purchase\"`: Initial purchase that user made manually\n * - `\"renewal\"`: Automatically generated renewal for an auto-renewable subscription\n * - `\"unknown\"`: StoreKit did not return a reason\n *\n * @since 7.13.2\n * @platform ios Present on iOS 17.0+ (StoreKit 2 transactions)\n * @platform android Not available\n */\n readonly transactionReason?: 'purchase' | 'renewal' | 'unknown';\n /**\n * Whether the transaction is in a trial period.\n *\n * - `true`: Currently in free trial period\n * - `false`: Not in trial period\n *\n * @since 1.0.0\n * @platform ios Present for subscriptions with trial offers\n * @platform android Present for subscriptions with trial offers\n */\n readonly isTrialPeriod?: boolean;\n /**\n * Whether the transaction is in an introductory price period.\n *\n * Introductory pricing is a discounted rate, different from a free trial.\n *\n * - `true`: Currently using introductory pricing\n * - `false`: Not in intro period\n *\n * @since 1.0.0\n * @platform ios Present for subscriptions with intro pricing\n * @platform android Present for subscriptions with intro pricing\n */\n readonly isInIntroPricePeriod?: boolean;\n /**\n * Whether the transaction is in a grace period.\n *\n * Grace period allows users to fix payment issues while maintaining access.\n * You typically want to continue providing access during this time.\n *\n * - `true`: Subscription payment failed but user still has access\n * - `false`: Not in grace period\n *\n * @since 1.0.0\n * @platform ios Present for subscriptions in grace period\n * @platform android Present for subscriptions in grace period\n */\n readonly isInGracePeriod?: boolean;\n /**\n * Whether the StoreKit transaction still needs to be finished with `finishTransaction()`.\n *\n * Present when the transaction is returned from `getUnfinishedTransactions()` or from\n * `transactionUpdated` while `autoFinishTransactions` is `false`.\n *\n * @since 8.9.0\n * @platform ios Present when the transaction is unfinished in StoreKit 2\n * @platform android Not available (use `isAcknowledged === false` instead)\n */\n readonly needsFinish?: boolean;\n /**\n * Why StoreKit could not verify this transaction. Treat the transaction as untrusted and do not\n * grant entitlements from it.\n *\n * Present only on unverified entries returned by `getUnfinishedTransactions({ includeUnverified: true })`.\n *\n * @since 8.9.7\n * @platform ios Present when StoreKit reports the transaction as unverified\n * @platform android Not available (Play Billing has no client-side unverified state)\n */\n readonly verificationError?: string;\n}\n\nexport interface TransactionVerificationFailedEvent {\n /**\n * Identifier of the transaction that failed verification.\n *\n * @since 7.13.2\n * @platform ios Present when StoreKit reports an unverified transaction\n * @platform android Not available\n */\n readonly transactionId: string;\n /**\n * Localized error message describing why verification failed.\n *\n * @since 7.13.2\n * @platform ios Always present\n * @platform android Not available\n */\n readonly error: string;\n}\n\n/**\n * Represents the App Transaction information from StoreKit 2.\n * This provides details about when the user originally downloaded or purchased the app,\n * which is useful for determining if users are entitled to features from earlier business models.\n *\n * @see https://developer.apple.com/documentation/storekit/supporting-business-model-changes-by-using-the-app-transaction\n * @since 7.16.0\n */\nexport interface AppTransaction {\n /**\n * The app version that the user originally purchased or downloaded.\n *\n * Use this to determine if users who originally downloaded an earlier version\n * should be entitled to features that were previously free or included.\n *\n * For iOS: This is the `CFBundleShortVersionString` (e.g., \"1.0.0\")\n * For Android: This is the `versionName` from Google Play (e.g., \"1.0.0\")\n *\n * @example \"1.0.0\"\n * @since 7.16.0\n * @platform ios Always present (iOS 16+)\n * @platform android Always present\n */\n readonly originalAppVersion: string;\n\n /**\n * The date when the user originally purchased or downloaded the app.\n * ISO 8601 format.\n *\n * @example \"2023-06-15T10:30:00Z\"\n * @since 7.16.0\n * @platform ios Always present (iOS 16+)\n * @platform android Always present\n */\n readonly originalPurchaseDate: string;\n\n /**\n * The bundle identifier of the app.\n *\n * @example \"com.example.myapp\"\n * @since 7.16.0\n * @platform ios Always present (iOS 16+)\n * @platform android Always present (package name)\n */\n readonly bundleId: string;\n\n /**\n * The current app version installed on the device.\n *\n * @example \"2.0.0\"\n * @since 7.16.0\n * @platform ios Always present\n * @platform android Always present\n */\n readonly appVersion: string;\n\n /**\n * The server environment where the app was originally purchased.\n *\n * @since 7.16.0\n * @platform ios Present (iOS 16+)\n * @platform android Not available (always null)\n */\n readonly environment?: 'Sandbox' | 'Production' | 'Xcode' | null;\n\n /**\n * The JWS (JSON Web Signature) representation of the app transaction.\n * Can be sent to your backend for server-side verification.\n *\n * @since 7.16.0\n * @platform ios Present (iOS 16+)\n * @platform android Not available\n */\n readonly jwsRepresentation?: string;\n}\n\nexport interface SubscriptionPeriod {\n /**\n * The Subscription Period number of unit.\n */\n readonly numberOfUnits: number;\n /**\n * The Subscription Period unit.\n */\n readonly unit: number;\n /**\n * Human-readable subscription period unit.\n *\n * @since 8.3.8\n */\n readonly unitString?: 'day' | 'week' | 'month' | 'year' | 'unknown';\n}\n\nexport type SubscriptionBillingPlanType = 'upFront' | 'monthly' | 'unknown';\n\nexport interface ProductCommitmentInfo {\n /**\n * Total commitment price in the local currency.\n */\n readonly price?: number;\n /**\n * Formatted total commitment price.\n */\n readonly priceString?: string;\n /**\n * Full commitment period.\n */\n readonly period?: SubscriptionPeriod;\n}\n\nexport interface SubscriptionPricingTerms {\n /**\n * Billing plan represented by this pricing entry.\n */\n readonly billingPlanType?: SubscriptionBillingPlanType;\n /**\n * Total commitment details for this billing plan.\n */\n readonly commitmentInfo?: ProductCommitmentInfo;\n /**\n * Formatted price for each billing period.\n */\n readonly billingDisplayPrice?: string;\n /**\n * Numeric price for each billing period.\n */\n readonly billingPrice?: number;\n /**\n * Duration of each billing period.\n */\n readonly billingPeriod?: SubscriptionPeriod;\n /**\n * StoreKit subscription offers that apply to this billing plan.\n */\n readonly subscriptionOffers?: StoreKitSubscriptionOffer[];\n}\n\nexport interface StoreKitSubscriptionOffer {\n /**\n * StoreKit offer identifier.\n */\n readonly identifier?: string;\n /**\n * StoreKit offer type.\n */\n readonly type?: string;\n /**\n * Offer price in the local currency.\n */\n readonly price?: number;\n /**\n * Formatted offer price.\n */\n readonly priceString?: string;\n /**\n * Offer billing period.\n */\n readonly period?: SubscriptionPeriod;\n /**\n * Number of periods the offer applies to.\n */\n readonly periodCount?: number;\n /**\n * StoreKit offer payment mode.\n */\n readonly paymentMode?: string;\n}\n\nexport interface TransactionCommitmentInfo {\n /**\n * Current billing period number within the commitment.\n */\n readonly billingPeriodNumber?: number;\n /**\n * Total number of billing periods in the commitment.\n */\n readonly totalBillingPeriods?: number;\n /**\n * End of the full commitment, in ISO 8601 format.\n */\n readonly expirationDate?: string;\n /**\n * Total commitment price in the local currency.\n */\n readonly price?: number;\n}\n\nexport interface RenewalCommitmentInfo {\n /**\n * Product StoreKit will renew into after the commitment ends.\n */\n readonly autoRenewProductId?: string;\n /**\n * Whether the subscription renews into another commitment after the current commitment ends.\n */\n readonly willAutoRenew?: boolean;\n /**\n * Billing plan StoreKit will use for the next commitment or renewal.\n */\n readonly renewalBillingPlanType?: SubscriptionBillingPlanType;\n /**\n * Renewal date for the next commitment or renewal, in ISO 8601 format.\n */\n readonly renewalDate?: string;\n /**\n * Renewal price in the local currency.\n */\n readonly renewalPrice?: number;\n}\n\nexport interface SubscriptionRenewalInfo {\n /**\n * Whether the next billing period will renew.\n */\n readonly willAutoRenew?: boolean;\n /**\n * Product StoreKit will renew into for the next billing period.\n */\n readonly autoRenewProductId?: string;\n /**\n * Billing plan StoreKit will use for the next billing period.\n */\n readonly renewalBillingPlanType?: SubscriptionBillingPlanType;\n /**\n * Next billing period renewal date, in ISO 8601 format.\n */\n readonly renewalDate?: string;\n /**\n * Next billing period renewal price in the local currency.\n */\n readonly renewalPrice?: number;\n /**\n * Currency code for renewal pricing metadata.\n */\n readonly currencyCode?: string;\n /**\n * Commitment renewal metadata for monthly subscriptions with a 12-month commitment.\n */\n readonly commitmentInfo?: RenewalCommitmentInfo;\n}\n\nexport interface SKProductDiscount {\n /**\n * The Product discount identifier.\n */\n readonly identifier: string;\n /**\n * The Product discount type.\n *\n * iOS values: 0 = introductory, 1 = promotional, 2 = win-back.\n */\n readonly type: number;\n /**\n * The Product discount price.\n */\n readonly price: number;\n /**\n * Formatted price of the item, including its currency sign, such as €3.99.\n */\n readonly priceString: string;\n /**\n * The Product discount currency symbol.\n */\n readonly currencySymbol: string;\n /**\n * The Product discount currency code.\n */\n readonly currencyCode: string;\n /**\n * The Product discount paymentMode.\n */\n readonly paymentMode: number;\n /**\n * The Product discount number Of Periods.\n */\n readonly numberOfPeriods: number;\n /**\n * The Product discount subscription period.\n */\n readonly subscriptionPeriod: SubscriptionPeriod;\n}\n\n/**\n * Android one-time product discount display metadata.\n *\n * @platform android Populated for discounted one-time purchase offers when available.\n * @platform ios Not available\n */\nexport interface OneTimePurchaseOfferDiscount {\n /**\n * Percentage discount off the full price.\n */\n readonly percentageDiscount?: number;\n /**\n * Absolute discount amount in micro-units (1,000,000 micro-units = 1 currency unit).\n */\n readonly discountAmountMicros?: number;\n}\n\nexport interface Product {\n /**\n * Product Id.\n *\n * Android subscriptions note:\n * - `identifier` is the base plan ID (`offerDetails.getBasePlanId()`).\n * - `planIdentifier` is the subscription product ID (`productDetails.getProductId()`).\n *\n * Android one-time products note:\n * - `identifier` is the Google Play product ID (`productDetails.getProductId()`).\n * - When multiple offers exist, `getProducts()` returns one entry per eligible offer.\n *\n * If you group/filter Android subscription results by `identifier`, you are grouping by base plan.\n */\n readonly identifier: string;\n /**\n * Description of the product.\n */\n readonly description: string;\n /**\n * Title of the product.\n */\n readonly title: string;\n /**\n * Price of the product in the local currency.\n */\n readonly price: number;\n /**\n * Formatted price of the item, including its currency sign, such as €3.99.\n *\n * Android subscriptions: set from the standard recurring pricing phase (see\n * `ProductPayloadMapper`). When the offer has an introductory phase, `introductoryPrice`\n * describes that phase, so a pre purchase message should include both or defer confirmation\n * to the store sheet.\n */\n readonly priceString: string;\n /**\n * Currency code for price and original price.\n */\n readonly currencyCode: string;\n /**\n * Currency symbol for price and original price.\n */\n readonly currencySymbol: string;\n /**\n * Boolean indicating if the product is sharable with family\n */\n readonly isFamilyShareable: boolean;\n /**\n * Group identifier for the product.\n */\n readonly subscriptionGroupIdentifier: string;\n /**\n * Android subscriptions only: Google Play product identifier tied to the offer/base plan set.\n */\n readonly planIdentifier?: string;\n /**\n * Android: offer token required when purchasing a specific subscription or one-time offer.\n *\n * Pass it to `purchaseProduct({ offerToken })` to buy this exact offer. It belongs to the\n * query that returned it and goes stale, so read it from the same `getProducts()` /\n * `getProduct()` call you purchase from.\n */\n readonly offerToken?: string;\n /**\n * Android: offer identifier (null/undefined for base offers).\n */\n readonly offerId?: string | null;\n /**\n * Android one-time products only: purchase option identifier (for example `buy-option`).\n *\n * @platform android Present on one-time purchase offers when available.\n * @platform ios Not available\n */\n readonly purchaseOptionId?: string;\n /**\n * Android one-time products only: full price before discount, in the local currency.\n *\n * @platform android Present on discounted one-time purchase offers when available.\n * @platform ios Not available\n */\n readonly fullPrice?: number;\n /**\n * Android one-time products only: discount metadata for discounted offers.\n *\n * @platform android Present on discounted one-time purchase offers when available.\n * @platform ios Not available\n */\n readonly discountDisplayInfo?: OneTimePurchaseOfferDiscount;\n /**\n * iOS subscriptions only: StoreKit pricing terms by billing plan.\n *\n * For subscriptions with a monthly billing plan and 12-month commitment, this\n * includes both the standard up-front plan and the monthly commitment plan.\n * Display both `billingDisplayPrice` and `commitmentInfo.priceString` before\n * starting a monthly commitment purchase.\n *\n * @since 8.3.8\n * @platform ios Present on supported StoreKit subscription products.\n * @platform android Not available\n */\n readonly pricingTerms?: SubscriptionPricingTerms[];\n /**\n * Recurring billing period for subscription products.\n *\n * @platform ios From StoreKit `subscription.subscriptionPeriod`.\n * @platform android From the standard pricing phase billing period when recurrence is\n * infinite recurring, or finite recurring on installment offers (`ProductPayloadMapper.applySubscriptionPricing`).\n * Omitted for prepaid (non-recurring) phases.\n */\n readonly subscriptionPeriod?: SubscriptionPeriod;\n /**\n * Android subscriptions only: committed payment count for installment base plans when Play\n * exposes it on the offer.\n *\n * @platform android From `InstallmentPlanDetails.getInstallmentPlanCommitmentPaymentsCount()`.\n * @platform ios Not available\n */\n readonly subscriptionBillingCycles?: number;\n /**\n * Introductory price for this product line when the store exposes it. Pair with `priceString`\n * for full subscription offer wording before purchase. It always describes what buying this\n * entry gives. iOS: from StoreKit introductory offers when available. Android base subscription\n * offers (`offerId` null): from the first pricing phase when multiple phases exist (intro then\n * recurring), else null. On Google Play a free trial or intro price is a separate offer on the\n * base plan, so a base plan entry is usually null even when the plan has a trial; that trial is\n * reported on the offer's own entry. Android promotional offer lines (`offerId` set): that\n * offer's own leading phase when it is introductory, else null; buy it with that entry's\n * `offerToken`. Mapping matches `ProductPayloadMapper`.\n */\n readonly introductoryPrice: SKProductDiscount | null;\n /**\n * Whether the current store account is eligible for an introductory offer on this subscription.\n *\n * @platform ios Set from StoreKit `isEligibleForIntroOffer` when the product has an introductory offer.\n * @platform android Always `INTRO_ELIGIBILITY_STATUS_UNKNOWN` (Google Play filters ineligible offers in billing).\n * @since 8.8.3\n */\n readonly introEligibility?: INTRO_ELIGIBILITY_STATUS;\n /**\n * The Product discounts list.\n *\n * @platform ios Populated from StoreKit promotional offers when available.\n * @platform android On base subscription offers (`offerId` null), lists promotional offers on\n * the same base plan, each quoting its recurring phase (a trial only offer quotes its free\n * phase). A promotional offer line itself returns an empty array; its introductory phase is on\n * `introductoryPrice`.\n */\n readonly discounts: SKProductDiscount[];\n}\n\nexport interface NativePurchasesPlugin {\n /**\n * Configure plugin-wide purchase finishing behavior.\n *\n * Call this as early as possible (ideally before other NativePurchases APIs). You can also set\n * `autoFinishTransactions` in `capacitor.config` under `plugins.NativePurchases` so iOS applies\n * the value before the native `transactionUpdated` listener starts.\n *\n * **`autoFinishTransactions` (default `true`)**\n *\n * - **iOS (StoreKit 2)**: When `true`, the plugin finishes transactions automatically for\n * `transactionUpdated`, `restorePurchases`, and `purchaseProduct` (when\n * `autoAcknowledgePurchases` is also true). When `false`, transactions stay unfinished until you call\n * `finishTransaction()` (or `acknowledgePurchase()` with the transaction ID).\n * - **Android**: When `true`, `restorePurchases()` may auto-acknowledge unacknowledged purchases\n * (recovery flow). When `false`, recovery does not acknowledge; use `acknowledgePurchase()`.\n * `purchaseProduct()` auto-acknowledges only when both `autoFinishTransactions` and\n * `autoAcknowledgePurchases` are true.\n *\n * **`autoAcknowledgePurchases`** applies only to the `purchaseProduct()` call and does not change\n * how the iOS `transactionUpdated` listener finishes transactions. Use this method (or config) for that.\n *\n * @param options.autoFinishTransactions When false, manual finishing/acknowledgment is required for the flows above.\n * @since 8.9.0\n *\n * @example\n * ```typescript\n * // capacitor.config.ts\n * export default {\n * plugins: {\n * NativePurchases: {\n * autoFinishTransactions: false,\n * },\n * },\n * };\n *\n * // Optional runtime override (affects subsequent native operations)\n * await NativePurchases.configure({ autoFinishTransactions: false });\n * ```\n */\n configure(options?: { autoFinishTransactions?: boolean }): Promise<void>;\n\n /**\n * Restores a user's previous and links their appUserIDs to any user's also using those .\n */\n restorePurchases(): Promise<void>;\n\n /**\n * Gets the App Transaction information, which provides details about when the user\n * originally downloaded or purchased the app.\n *\n * This is useful for implementing business model changes where you want to\n * grandfather users who originally downloaded an earlier version of the app.\n *\n * **Use Case Example:**\n * If your app was originally free but you're adding a subscription, you can use\n * `originalAppVersion` to check if users downloaded before the subscription was added\n * and give them free access.\n *\n * **Platform Notes:**\n * - **iOS**: Requires iOS 16.0+. Uses StoreKit 2's `AppTransaction.shared`.\n * - **Android**: Uses Google Play's install referrer data when available.\n *\n * @returns {Promise<{ appTransaction: AppTransaction }>} The app transaction info\n * @throws An error if the app transaction cannot be retrieved (iOS 15 or earlier)\n * @since 7.16.0\n *\n * @example\n * ```typescript\n * const { appTransaction } = await NativePurchases.getAppTransaction();\n *\n * // Check if user downloaded before version 2.0.0 (when subscription was added)\n * if (compareVersions(appTransaction.originalAppVersion, '2.0.0') < 0) {\n * // User gets free access - they downloaded before subscriptions\n * grantFreeAccess();\n * }\n * ```\n *\n * @see https://developer.apple.com/documentation/storekit/supporting-business-model-changes-by-using-the-app-transaction\n */\n getAppTransaction(): Promise<{ appTransaction: AppTransaction }>;\n\n /**\n * Compares the original app version from the App Transaction against a target version\n * to determine if the user is entitled to features from an earlier business model.\n *\n * This is a utility method that performs the version comparison natively, which can be\n * more reliable than JavaScript-based comparison for semantic versioning.\n *\n * **Use Case:**\n * Check if the user's original download version is older than a specific version\n * to determine if they should be grandfathered into free features.\n *\n * **Platform Differences:**\n * - iOS: Uses build number (CFBundleVersion) from AppTransaction. Requires iOS 16+.\n * - Android: Uses version name from PackageInfo (current installed version, not original).\n *\n * @param options - The comparison options\n * @param options.targetVersion - The Android version name to compare against (e.g., \"2.0.0\"). Used on Android only.\n * @param options.targetBuildNumber - The iOS build number to compare against (e.g., \"42\"). Used on iOS only.\n * @returns {Promise<{ isOlderVersion: boolean; originalAppVersion: string }>}\n * - `isOlderVersion`: true if the user's original version is older than target\n * - `originalAppVersion`: The user's original app version/build number for reference\n * @throws An error if the app transaction cannot be retrieved\n * @since 7.16.0\n *\n * @example\n * ```typescript\n * // Check if user downloaded before version 2.0.0/build 42 (when subscription was added)\n * const result = await NativePurchases.isEntitledToOldBusinessModel({\n * targetVersion: '2.0.0',\n * targetBuildNumber: '42'\n * });\n *\n * if (result.isOlderVersion) {\n * console.log(`User downloaded v${result.originalAppVersion}, granting free access`);\n * grantFreeAccess();\n * }\n * ```\n */\n isEntitledToOldBusinessModel(options: {\n targetVersion?: string;\n targetBuildNumber?: string;\n }): Promise<{ isOlderVersion: boolean; originalAppVersion: string }>;\n\n /**\n * Started purchase process for the given product.\n *\n * On Android, `offerToken` selects which offer is charged. If the token is\n * missing from the product details returned by the plugin's query, the plugin\n * rejects the purchase instead of selecting another offer. Other failures can\n * also reject the purchase. Google Play may still show a different checkout,\n * for example if the offer stops being eligible after the query, so the final\n * price is not guaranteed.\n * Offer tokens come from a specific product query and go stale, so read\n * one from the same `getProducts()` / `getProduct()` call you purchase\n * from.\n *\n * For a **subscription** (`productType: 'subs'`) the order is: an explicit\n * `offerToken`, then the first offer whose base plan matches\n * `planIdentifier`, then the first offer the store returned.\n * `planIdentifier` is the **base plan id**, which `getProducts()` reports\n * as `Product.identifier`, not `Product.planIdentifier`, which holds the\n * Play product id. It is required unless an `offerToken` is given, since\n * a token already identifies one offer on its own.\n *\n * For a **one-time product** (`productType: 'inapp'`) there is no base\n * plan, so `planIdentifier` plays no part, and an `offerToken` selects one\n * of the product's purchase offers. Without a token no offer token is set\n * at all whenever the product still has a backward-compatible purchase\n * option, which leaves the choice to Play: it charges whichever buy\n * purchase option is marked backward-compatible, which is the first\n * *created* one by default and another only if one was marked\n * `legacyCompatible`. Either way it need not be the first offer\n * `getProducts()` returned. Only for a product with no backward-compatible\n * option does the first offer in the list get used. So pass the token\n * whenever a specific one-time offer matters.\n *\n * @param options - The product to purchase\n * @param options.productIdentifier - The product identifier of the product you want to purchase.\n * @param options.productType - Only Android, the type of product, can be inapp or subs. Will use inapp by default.\n * @param options.planIdentifier - Only Android, the identifier of the base plan you want to purchase from Google Play Console, the value `getProducts()` reports as `Product.identifier` for a subscription, not `Product.planIdentifier`. Required for Android subscriptions unless `offerToken` is given; ignored for one-time products and on iOS.\n * @param options.offerToken - Only Android, the offer token for the selected subscription or one-time product offer. Use the `offerToken` returned by `getProducts()` / `getProduct()`. For a subscription it takes precedence over `planIdentifier`, since it names one specific offer, and makes `planIdentifier` optional. When the token is absent from the plugin query result the purchase is rejected instead of falling back to another offer. Google Play may still change what the user can buy after the query. Offer tokens come from a specific product query and go stale, so read one from the same query you purchase from. Omit it to keep the previous behaviour.\n * @param options.quantity - Only iOS, the number of items you wish to purchase. Will use 1 by default.\n * @param options.billingPlanType - Only iOS, the StoreKit subscription billing plan to purchase. Use `\"monthly\"` for a monthly subscription with a 12-month commitment. Requires iOS 26.4+ and Xcode 26.5 SDK support.\n * @param options.appAccountToken - Optional identifier uniquely associated with the user's account in your app.\n * PLATFORM REQUIREMENTS:\n * - iOS: Must be a valid UUID format (StoreKit 2 requirement)\n * - Android: Can be any obfuscated string (max 64 chars), maps to ObfuscatedAccountId\n * SECURITY: DO NOT use PII like emails in cleartext - use UUID or hashed value.\n * RECOMMENDED: Use UUID v5 with deterministic generation for cross-platform compatibility.\n * @param options.isConsumable - Only Android, when true the purchase token is consumed after granting entitlement (for consumable in-app items). Defaults to false.\n * @param options.autoAcknowledgePurchases - When false, this purchase is not auto-finished/acknowledged when\n * `autoFinishTransactions` is also true. Does not disable auto-finishing on\n * the iOS `transactionUpdated` listener; use `configure({ autoFinishTransactions: false })`\n * for manual finishing across purchase and recovery flows. Defaults to true.\n * - **Android**: Must acknowledge within 3 days or Google Play will refund\n * - **iOS**: Unfinished transactions remain in the queue and may block future purchases\n */\n purchaseProduct(options: {\n productIdentifier: string;\n planIdentifier?: string;\n offerToken?: string;\n productType?: PURCHASE_TYPE;\n quantity?: number;\n billingPlanType?: 'monthly' | 'upFront';\n appAccountToken?: string;\n isConsumable?: boolean;\n autoAcknowledgePurchases?: boolean;\n }): Promise<Transaction>;\n\n /**\n * Gets the product info associated with a list of product identifiers.\n *\n * @param options - The product identifiers you wish to retrieve information for\n * @param options.productIdentifiers - Array of product identifiers\n * @param options.productType - Only Android, the type of product, can be inapp or subs. Will use inapp by default.\n * @returns - The requested product info\n */\n getProducts(options: { productIdentifiers: string[]; productType?: PURCHASE_TYPE }): Promise<{ products: Product[] }>;\n\n /**\n * Gets the product info for a single product identifier.\n *\n * **⚠️ Warning:** Do not call `getProduct` concurrently using `Promise.all`.\n * The underlying native billing client does not support concurrent product\n * queries, and doing so causes a race condition that may result in errors\n * or missing data. To fetch multiple products at once, use `getProducts`\n * instead — it accepts an array of identifiers and is race-condition-free.\n *\n * @example\n * // ❌ Avoid: causes race condition\n * const [a, b] = await Promise.all([\n * NativePurchases.getProduct({ productIdentifier: 'id1' }),\n * NativePurchases.getProduct({ productIdentifier: 'id2' }),\n * ]);\n *\n * // ✅ Correct: use getProducts for multiple identifiers\n * const { products } = await NativePurchases.getProducts({ productIdentifiers: ['id1', 'id2'] });\n *\n * @param options - The product identifier you wish to retrieve information for\n * @param options.productIdentifier - The product identifier\n * @param options.productType - Only Android, the type of product, can be inapp or subs. Will use inapp by default.\n * @returns - The requested product info\n */\n getProduct(options: { productIdentifier: string; productType?: PURCHASE_TYPE }): Promise<{ product: Product }>;\n\n /**\n * Check if billing is supported for the current device.\n *\n *\n */\n isBillingSupported(): Promise<{ isBillingSupported: boolean }>;\n /**\n * Get the native Capacitor plugin version\n *\n * @returns {Promise<{ id: string }>} an Promise with version for this device\n * @throws An error if the something went wrong\n */\n getPluginVersion(): Promise<{ version: string }>;\n\n /**\n * Gets all the user's purchases (both in-app purchases and subscriptions).\n * This method queries the platform's purchase history for the current user.\n *\n * @param options - Optional parameters for filtering purchases\n * @param options.productType - Only Android, filter by product type (inapp or subs). If not specified, returns both types.\n * @param options.appAccountToken - Optional filter to restrict results to purchases that used the provided account token.\n * Must be the same identifier used during purchase (UUID format for iOS, any obfuscated string for Android).\n * iOS: UUID format required. Android: Maps to ObfuscatedAccountId.\n * @param options.onlyCurrentEntitlements - iOS only. When `false` (default), uses `Transaction.all` which returns every\n * transaction ever recorded on the device. When `true`, uses\n * `Transaction.currentEntitlements` which is scoped to the signed-in Apple ID\n * and only includes currently active entitlements. Set to `true` to prevent\n * cross-account purchase leakage on shared or refurbished devices.\n * @returns {Promise<{ purchases: Transaction[] }>} Promise that resolves with array of user's purchases\n * @throws An error if the purchase query fails\n * @since 7.2.0\n */\n getPurchases(options?: {\n productType?: PURCHASE_TYPE;\n appAccountToken?: string;\n onlyCurrentEntitlements?: boolean;\n }): Promise<{ purchases: Transaction[] }>;\n\n /**\n * Opens the platform's native subscription management page.\n * This allows users to view, modify, or cancel their subscriptions.\n *\n * - iOS: Opens the App Store subscription management page for the current app\n * - Android: Opens the Google Play subscription management page\n *\n * @returns {Promise<void>} Promise that resolves when the management page is opened\n * @throws An error if the subscription management page cannot be opened\n * @since 7.10.0\n */\n manageSubscriptions(): Promise<void>;\n\n /**\n * Presents the App Store offer code redemption sheet so users can redeem a subscription offer code in your app.\n *\n * iOS: Uses StoreKit's `AppStore.presentOfferCodeRedeemSheet(in:)` to display the system redemption UI (iOS 16.0+).\n *\n * @returns {Promise<void>} Promise that resolves when the redemption sheet is presented\n * @throws An error if the offer code redemption sheet cannot be presented\n * @since 8.6.0\n * @platform ios\n *\n * @see https://developer.apple.com/documentation/storekit/appstore/presentoffercoderedeemsheet(in:)\n */\n presentOfferCodeRedeemSheet(): Promise<void>;\n\n /**\n * Manually acknowledge/finish a purchase transaction.\n *\n * Call this when automatic finishing or acknowledgment is disabled, for example\n * `purchaseProduct({ autoAcknowledgePurchases: false })`, `configure({ autoFinishTransactions: false })`\n * (Android recovery or iOS updates), or when a returned transaction has `needsFinish: true`.\n *\n * **Platform Behavior:**\n * - **Android**: Acknowledges the purchase with Google Play. Must be called within 3 days or the purchase will be refunded.\n * - **iOS**: Finishes the transaction with StoreKit 2. Unfinished transactions remain in the queue and may block future purchases.\n *\n * **Acknowledgment Options:**\n *\n * **1. Client-side (this method)**: Call from your app after validation\n * ```typescript\n * await NativePurchases.acknowledgePurchase({\n * purchaseToken: transaction.purchaseToken // Android: purchaseToken, iOS: transactionId\n * });\n * ```\n *\n * **2. Server-side (Android only, recommended for security)**: Use Google Play Developer API v3\n * - Endpoint: `POST https://androidpublisher.googleapis.com/androidpublisher/v3/applications/{packageName}/purchases/products/{productId}/tokens/{token}:acknowledge`\n * - Requires OAuth 2.0 authentication with appropriate scopes\n * - See: https://developers.google.com/android-publisher/api-ref/rest/v3/purchases.products/acknowledge\n * - For subscriptions: Use `/purchases/subscriptions/{subscriptionId}/tokens/{token}:acknowledge` instead\n * - Note: iOS has no server-side finish API\n *\n * **When to use manual acknowledgment:**\n * - Server-side validation: Verify the purchase with your backend before acknowledging\n * - Entitlement delivery: Ensure user receives content/features before acknowledging\n * - Multi-step workflows: Complete all steps before final acknowledgment\n * - Security: Prevent client-side manipulation by handling acknowledgment server-side (Android only)\n *\n * @param options - The purchase to acknowledge\n * @param options.purchaseToken - The purchase token (Android) or transaction ID as string (iOS) from the Transaction object\n * @returns {Promise<void>} Promise that resolves when the purchase is acknowledged/finished\n * @throws An error if acknowledgment/finishing fails or transaction not found\n * @platform android Acknowledges the purchase with Google Play\n * @platform ios Finishes the transaction with StoreKit 2\n * @since 7.14.0\n *\n * @example\n * ```typescript\n * // Client-side acknowledgment\n * const transaction = await NativePurchases.purchaseProduct({\n * productIdentifier: 'premium_feature',\n * autoAcknowledgePurchases: false\n * });\n *\n * // Validate with your backend\n * const isValid = await fetch('/api/validate-purchase', {\n * method: 'POST',\n * body: JSON.stringify({ purchaseToken: transaction.purchaseToken })\n * });\n *\n * if (isValid) {\n * // Option 1: Acknowledge from client\n * await NativePurchases.acknowledgePurchase({\n * purchaseToken: transaction.purchaseToken\n * });\n *\n * // Option 2: Or let your backend acknowledge via Google Play API\n * // Your backend calls Google Play Developer API\n * }\n * ```\n */\n acknowledgePurchase(options: { purchaseToken: string }): Promise<void>;\n\n /**\n * Finish a StoreKit 2 transaction on iOS after you validate delivery on your backend.\n *\n * Equivalent to `acknowledgePurchase({ purchaseToken: transactionId })` on iOS. Safe to call more\n * than once; finishing an already finished transaction resolves successfully.\n *\n * A transaction StoreKit could not verify is rejected unless `allowUnverified` is `true`. Finishing\n * one only removes it from the queue so StoreKit stops re-delivering it; never grant entitlements from it.\n *\n * **Android**: Acknowledges the purchase, using `transactionId` as the purchase token. Use\n * `consumePurchase({ purchaseToken })` instead for consumables that must be purchasable again.\n * `allowUnverified` has no effect because Play Billing has no client-side unverified state.\n *\n * @param options.transactionId Transaction ID from the `Transaction` object (numeric string on iOS, purchase token on Android).\n * @param options.allowUnverified Finish the transaction even if StoreKit could not verify it. Defaults to `false`. Since 8.9.7.\n * @since 8.9.0\n * @platform ios Finishes the transaction with StoreKit 2\n * @platform android Acknowledges the purchase with Google Play\n */\n finishTransaction(options: { transactionId: string; allowUnverified?: boolean }): Promise<void>;\n\n /**\n * Returns transactions that still need finishing on iOS, or unacknowledged purchases on Android.\n *\n * Use on app launch when `autoFinishTransactions` is `false` to recover work after a restart.\n *\n * **Android recovery:** After validation, call `consumePurchase({ purchaseToken })` for consumable\n * in-app products (acknowledges and consumes). Call `acknowledgePurchase({ purchaseToken })` for\n * non-consumables and subscriptions. Includes only purchases in the `PURCHASED` state that are not\n * yet acknowledged. Pending purchases are excluded until Google Play marks them purchased.\n *\n * **Unverified transactions:** With `includeUnverified: true`, iOS also returns transactions StoreKit\n * could not verify, each with `verificationError` set. Do not grant entitlements from those; pass them\n * to `finishTransaction({ transactionId, allowUnverified: true })` to clear them. Android has no\n * client-side unverified state, so the option does not change its results.\n *\n * @param options.includeUnverified Also return unfinished transactions StoreKit could not verify. Defaults to `false`. Since 8.9.7.\n * @since 8.9.0\n */\n getUnfinishedTransactions(options?: { includeUnverified?: boolean }): Promise<{ transactions: Transaction[] }>;\n\n /**\n * Consume an in-app purchase on Android.\n *\n * Consuming a purchase does two things:\n * 1. Acknowledges the purchase (so you don't need to call acknowledgePurchase separately)\n * 2. Removes ownership, allowing the user to buy the same product again\n *\n * Use this for consumable products like virtual currency, extra lives, or credits.\n *\n * **Important:** In Google Play Billing Library 8.x, consumed purchases can no longer\n * be queried via getPurchases(). Once consumed, the purchase is gone.\n *\n * Android only — iOS does not have a separate consume concept.\n * On iOS and web, this method rejects with an error.\n *\n * @param options - The purchase to consume\n * @param options.purchaseToken - The purchase token from the Transaction object\n * @returns {Promise<void>} Promise that resolves when the purchase is consumed\n * @throws Error if consumption fails, token is invalid, or called on iOS/web\n * @platform android\n * @since 8.2.0\n *\n * @example\n * ```typescript\n * const transaction = await NativePurchases.purchaseProduct({\n * productIdentifier: 'coins_100',\n * isConsumable: false,\n * autoAcknowledgePurchases: false\n * });\n *\n * // Validate with your backend first\n * const isValid = await validateWithServer(transaction.purchaseToken);\n *\n * if (isValid) {\n * // Grant the coins, then consume to allow re-purchase\n * await NativePurchases.consumePurchase({\n * purchaseToken: transaction.purchaseToken!\n * });\n * }\n * ```\n */\n consumePurchase(options: { purchaseToken: string }): Promise<void>;\n\n /**\n * Get the user's current App Store / Google Play storefront — the country\n * their store account is registered to.\n *\n * iOS: reads StoreKit 2 `Storefront.current`. `countryCode` is ISO 3166-1\n * **alpha-3** (e.g. `\"USA\"`) and `storefrontId` is the Apple-defined\n * storefront identifier.\n * Android: reads Google Play Billing `getBillingConfigAsync()`. `countryCode`\n * is ISO 3166-1 **alpha-2** (e.g. `\"US\"`); `storefrontId` is omitted (Google\n * Play has no storefront-id concept).\n *\n * Contract note (future-major default candidate): `countryCode` is returned in\n * each store's native format and is intentionally NOT normalized across\n * platforms today (iOS alpha-3 vs Android alpha-2), to stay faithful to the\n * platform APIs. Normalizing both to a single scheme (e.g. ISO 3166-1 alpha-2)\n * is a candidate default change for the next Capacitor major, deferred so it\n * can be adopted deliberately rather than as a mid-major breaking change.\n *\n * Resolves a `countryCode` of `\"\"` (it does not reject) when the storefront\n * can't be determined on either platform — e.g. apps distributed via iOS\n * alternative distribution, or Google Play billing being unavailable.\n *\n * Useful for region-dependent logic such as localized offers/pricing and\n * gating external-purchase entitlements, whose eligibility the platforms key\n * to the storefront country. Read it live rather than caching, since the user\n * can change their store region.\n *\n * @returns {Promise<{ countryCode: string; storefrontId?: string }>} the current storefront\n * @since 8.5.0\n *\n * @example\n * ```typescript\n * const { countryCode } = await NativePurchases.getStorefront();\n * if (countryCode === 'USA' || countryCode === 'US') {\n * // show US-specific payment options\n * }\n * ```\n */\n getStorefront(): Promise<{ countryCode: string; storefrontId?: string }>;\n\n /**\n * Listen for StoreKit transaction updates delivered by Apple's Transaction.updates.\n * Fires on app launch if there are unfinished transactions, and for any updates afterward.\n *\n * When `autoFinishTransactions` is `true` (default), the plugin finishes each verified transaction\n * before emitting the event. When `false`, the event includes `needsFinish: true` and you must call\n * `finishTransaction()` after backend validation.\n *\n * iOS only.\n */\n addListener(\n eventName: 'transactionUpdated',\n listenerFunc: (transaction: Transaction) => void,\n ): Promise<PluginListenerHandle>;\n /**\n * Listen for StoreKit transaction verification failures delivered by Apple's Transaction.updates.\n * Fires when the verification result is unverified.\n * iOS only.\n */\n addListener(\n eventName: 'transactionVerificationFailed',\n listenerFunc: (payload: TransactionVerificationFailedEvent) => void,\n ): Promise<PluginListenerHandle>;\n\n /** Remove all registered listeners */\n removeAllListeners(): Promise<void>;\n}\n"]}
|
|
@@ -26,7 +26,7 @@ public class NativePurchasesPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
26
26
|
CAPPluginMethod(name: "finishTransaction", returnType: CAPPluginReturnPromise)
|
|
27
27
|
]
|
|
28
28
|
|
|
29
|
-
private let pluginVersion: String = "8.9.
|
|
29
|
+
private let pluginVersion: String = "8.9.12"
|
|
30
30
|
var autoFinishTransactions: Bool = true
|
|
31
31
|
private var transactionUpdatesTask: Task<Void, Never>?
|
|
32
32
|
|