@capgo/native-purchases 8.9.6 → 8.9.8

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.
@@ -562,6 +562,17 @@ export interface Transaction {
562
562
  * @platform android Not available (use `isAcknowledged === false` instead)
563
563
  */
564
564
  readonly needsFinish?: boolean;
565
+ /**
566
+ * Why StoreKit could not verify this transaction. Treat the transaction as untrusted and do not
567
+ * grant entitlements from it.
568
+ *
569
+ * Present only on unverified entries returned by `getUnfinishedTransactions({ includeUnverified: true })`.
570
+ *
571
+ * @since 8.10.0
572
+ * @platform ios Present when StoreKit reports the transaction as unverified
573
+ * @platform android Not available (Play Billing has no client-side unverified state)
574
+ */
575
+ readonly verificationError?: string;
565
576
  }
566
577
  export interface TransactionVerificationFailedEvent {
567
578
  /**
@@ -893,6 +904,11 @@ export interface Product {
893
904
  readonly price: number;
894
905
  /**
895
906
  * Formatted price of the item, including its currency sign, such as €3.99.
907
+ *
908
+ * Android subscriptions: set from the standard recurring pricing phase (see
909
+ * `ProductPayloadMapper`). When the offer has an introductory phase, `introductoryPrice`
910
+ * describes that phase, so a pre purchase message should include both or defer confirmation
911
+ * to the store sheet.
896
912
  */
897
913
  readonly priceString: string;
898
914
  /**
@@ -917,6 +933,10 @@ export interface Product {
917
933
  readonly planIdentifier?: string;
918
934
  /**
919
935
  * Android: offer token required when purchasing a specific subscription or one-time offer.
936
+ *
937
+ * Pass it to `purchaseProduct({ offerToken })` to buy this exact offer. It belongs to the
938
+ * query that returned it and goes stale, so read it from the same `getProducts()` /
939
+ * `getProduct()` call you purchase from.
920
940
  */
921
941
  readonly offerToken?: string;
922
942
  /**
@@ -958,14 +978,29 @@ export interface Product {
958
978
  */
959
979
  readonly pricingTerms?: SubscriptionPricingTerms[];
960
980
  /**
961
- * The Product subscription group identifier.
981
+ * Recurring billing period for subscription products.
982
+ *
983
+ * @platform ios From StoreKit `subscription.subscriptionPeriod`.
984
+ * @platform android From the standard pricing phase billing period when recurrence is
985
+ * infinite recurring, or finite recurring on installment offers (`ProductPayloadMapper.applySubscriptionPricing`).
986
+ * Omitted for prepaid (non-recurring) phases.
962
987
  */
963
- readonly subscriptionPeriod: SubscriptionPeriod;
988
+ readonly subscriptionPeriod?: SubscriptionPeriod;
964
989
  /**
965
- * The Product introductory Price.
990
+ * Android subscriptions only: committed payment count for installment base plans when Play
991
+ * exposes it on the offer.
966
992
  *
967
- * @platform ios Populated from StoreKit introductory offers when available.
968
- * @platform android Populated from the first pricing phase on base subscription offers when multiple phases are present.
993
+ * @platform android From `InstallmentPlanDetails.getInstallmentPlanCommitmentPaymentsCount()`.
994
+ * @platform ios Not available
995
+ */
996
+ readonly subscriptionBillingCycles?: number;
997
+ /**
998
+ * Introductory price for this product line when the store exposes it. Pair with `priceString`
999
+ * for full subscription offer wording before purchase. iOS: from StoreKit introductory offers
1000
+ * when available. Android base subscription offers (`offerId` null): from the first pricing
1001
+ * phase when multiple phases exist (intro then recurring). Android promotional offer lines
1002
+ * (`offerId` set): null; phase pricing is not exposed on `Product`, so defer price confirmation
1003
+ * to Play checkout instead of using `priceString` alone. Mapping matches `ProductPayloadMapper`.
969
1004
  */
970
1005
  readonly introductoryPrice: SKProductDiscount | null;
971
1006
  /**
@@ -980,7 +1015,9 @@ export interface Product {
980
1015
  * The Product discounts list.
981
1016
  *
982
1017
  * @platform ios Populated from StoreKit promotional offers when available.
983
- * @platform android Populated from promotional subscription offers that share the same base plan.
1018
+ * @platform android On base subscription offers (`offerId` null), lists promotional offers on
1019
+ * the same base plan. A promotional offer line itself returns an empty array; its pricing
1020
+ * phases are not mapped here or on `introductoryPrice`.
984
1021
  */
985
1022
  readonly discounts: SKProductDiscount[];
986
1023
  }
@@ -1115,11 +1152,41 @@ export interface NativePurchasesPlugin {
1115
1152
  /**
1116
1153
  * Started purchase process for the given product.
1117
1154
  *
1155
+ * On Android, `offerToken` selects which offer is charged. If the token is
1156
+ * missing from the product details returned by the plugin's query, the plugin
1157
+ * rejects the purchase instead of selecting another offer. Other failures can
1158
+ * also reject the purchase. Google Play may still show a different checkout,
1159
+ * for example if the offer stops being eligible after the query, so the final
1160
+ * price is not guaranteed.
1161
+ * Offer tokens come from a specific product query and go stale, so read
1162
+ * one from the same `getProducts()` / `getProduct()` call you purchase
1163
+ * from.
1164
+ *
1165
+ * For a **subscription** (`productType: 'subs'`) the order is: an explicit
1166
+ * `offerToken`, then the first offer whose base plan matches
1167
+ * `planIdentifier`, then the first offer the store returned.
1168
+ * `planIdentifier` is the **base plan id**, which `getProducts()` reports
1169
+ * as `Product.identifier`, not `Product.planIdentifier`, which holds the
1170
+ * Play product id. It is required unless an `offerToken` is given, since
1171
+ * a token already identifies one offer on its own.
1172
+ *
1173
+ * For a **one-time product** (`productType: 'inapp'`) there is no base
1174
+ * plan, so `planIdentifier` plays no part, and an `offerToken` selects one
1175
+ * of the product's purchase offers. Without a token no offer token is set
1176
+ * at all whenever the product still has a backward-compatible purchase
1177
+ * option, which leaves the choice to Play: it charges whichever buy
1178
+ * purchase option is marked backward-compatible, which is the first
1179
+ * *created* one by default and another only if one was marked
1180
+ * `legacyCompatible`. Either way it need not be the first offer
1181
+ * `getProducts()` returned. Only for a product with no backward-compatible
1182
+ * option does the first offer in the list get used. So pass the token
1183
+ * whenever a specific one-time offer matters.
1184
+ *
1118
1185
  * @param options - The product to purchase
1119
1186
  * @param options.productIdentifier - The product identifier of the product you want to purchase.
1120
1187
  * @param options.productType - Only Android, the type of product, can be inapp or subs. Will use inapp by default.
1121
- * @param options.planIdentifier - Only Android, the identifier of the base plan you want to purchase from Google Play Console. REQUIRED for Android subscriptions, ignored on iOS.
1122
- * @param options.offerToken - Only Android, the offer token for the selected subscription or one-time product offer. Use the `offerToken` returned by `getProducts()` / `getProduct()`.
1188
+ * @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.
1189
+ * @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.
1123
1190
  * @param options.quantity - Only iOS, the number of items you wish to purchase. Will use 1 by default.
1124
1191
  * @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.
1125
1192
  * @param options.appAccountToken - Optional identifier uniquely associated with the user's account in your app.
@@ -1333,16 +1400,22 @@ export interface NativePurchasesPlugin {
1333
1400
  * Equivalent to `acknowledgePurchase({ purchaseToken: transactionId })` on iOS. Safe to call more
1334
1401
  * than once; finishing an already finished transaction resolves successfully.
1335
1402
  *
1336
- * **Android**: Google Play uses purchase acknowledgment, not StoreKit finishing. Call
1337
- * `acknowledgePurchase({ purchaseToken })` instead. This method rejects on Android.
1403
+ * A transaction StoreKit could not verify is rejected unless `allowUnverified` is `true`. Finishing
1404
+ * one only removes it from the queue so StoreKit stops re-delivering it; never grant entitlements from it.
1338
1405
  *
1339
- * @param options.transactionId StoreKit transaction ID from the `Transaction` object (numeric string).
1406
+ * **Android**: Acknowledges the purchase, using `transactionId` as the purchase token. Use
1407
+ * `consumePurchase({ purchaseToken })` instead for consumables that must be purchasable again.
1408
+ * `allowUnverified` has no effect because Play Billing has no client-side unverified state.
1409
+ *
1410
+ * @param options.transactionId Transaction ID from the `Transaction` object (numeric string on iOS, purchase token on Android).
1411
+ * @param options.allowUnverified Finish the transaction even if StoreKit could not verify it. Defaults to `false`.
1340
1412
  * @since 8.9.0
1341
1413
  * @platform ios Finishes the transaction with StoreKit 2
1342
- * @platform android Rejects; use `acknowledgePurchase()`
1414
+ * @platform android Acknowledges the purchase with Google Play
1343
1415
  */
1344
1416
  finishTransaction(options: {
1345
1417
  transactionId: string;
1418
+ allowUnverified?: boolean;
1346
1419
  }): Promise<void>;
1347
1420
  /**
1348
1421
  * Returns transactions that still need finishing on iOS, or unacknowledged purchases on Android.
@@ -1354,9 +1427,17 @@ export interface NativePurchasesPlugin {
1354
1427
  * non-consumables and subscriptions. Includes only purchases in the `PURCHASED` state that are not
1355
1428
  * yet acknowledged. Pending purchases are excluded until Google Play marks them purchased.
1356
1429
  *
1430
+ * **Unverified transactions:** With `includeUnverified: true`, iOS also returns transactions StoreKit
1431
+ * could not verify, each with `verificationError` set. Do not grant entitlements from those; pass them
1432
+ * to `finishTransaction({ transactionId, allowUnverified: true })` to clear them. Android has no
1433
+ * client-side unverified state, so the option does not change its results.
1434
+ *
1435
+ * @param options.includeUnverified Also return unfinished transactions StoreKit could not verify. Defaults to `false`.
1357
1436
  * @since 8.9.0
1358
1437
  */
1359
- getUnfinishedTransactions(): Promise<{
1438
+ getUnfinishedTransactions(options?: {
1439
+ includeUnverified?: boolean;
1440
+ }): Promise<{
1360
1441
  transactions: Transaction[];
1361
1442
  }>;
1362
1443
  /**
@@ -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 Alphanumeric string (e.g., \"GPA.1234-5678-9012-34567\")\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'\n | 'expired'\n | 'revoked'\n | 'inGracePeriod'\n | 'inBillingRetryPeriod'\n | '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\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 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 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 * The Product subscription group identifier.\n */\n readonly subscriptionPeriod: SubscriptionPeriod;\n /**\n * The Product introductory Price.\n *\n * @platform ios Populated from StoreKit introductory offers when available.\n * @platform android Populated from the first pricing phase on base subscription offers when multiple phases are present.\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 Populated from promotional subscription offers that share the same base plan.\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 * @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. REQUIRED for Android subscriptions, ignored 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()`.\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 * **Android**: Google Play uses purchase acknowledgment, not StoreKit finishing. Call\n * `acknowledgePurchase({ purchaseToken })` instead. This method rejects on Android.\n *\n * @param options.transactionId StoreKit transaction ID from the `Transaction` object (numeric string).\n * @since 8.9.0\n * @platform ios Finishes the transaction with StoreKit 2\n * @platform android Rejects; use `acknowledgePurchase()`\n */\n finishTransaction(options: { transactionId: string }): 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 * @since 8.9.0\n */\n getUnfinishedTransactions(): 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 Alphanumeric string (e.g., \"GPA.1234-5678-9012-34567\")\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'\n | 'expired'\n | 'revoked'\n | 'inGracePeriod'\n | 'inBillingRetryPeriod'\n | '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.10.0\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`.\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`.\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"]}
package/dist/esm/web.d.ts CHANGED
@@ -4,11 +4,14 @@ export declare class NativePurchasesWeb extends WebPlugin implements NativePurch
4
4
  configure(options?: {
5
5
  autoFinishTransactions?: boolean;
6
6
  }): Promise<void>;
7
- getUnfinishedTransactions(): Promise<{
7
+ getUnfinishedTransactions(options?: {
8
+ includeUnverified?: boolean;
9
+ }): Promise<{
8
10
  transactions: Transaction[];
9
11
  }>;
10
12
  finishTransaction(options: {
11
13
  transactionId: string;
14
+ allowUnverified?: boolean;
12
15
  }): Promise<void>;
13
16
  restorePurchases(): Promise<void>;
14
17
  getProducts(options: {
package/dist/esm/web.js CHANGED
@@ -3,7 +3,8 @@ export class NativePurchasesWeb extends WebPlugin {
3
3
  async configure(options) {
4
4
  void options;
5
5
  }
6
- async getUnfinishedTransactions() {
6
+ async getUnfinishedTransactions(options) {
7
+ void options;
7
8
  console.error('getUnfinishedTransactions only mocked in web');
8
9
  return { transactions: [] };
9
10
  }
@@ -1 +1 @@
1
- {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,OAAO,kBAAmB,SAAQ,SAAS;IAC/C,KAAK,CAAC,SAAS,CAAC,OAA8C;QAC5D,KAAK,OAAO,CAAC;IACf,CAAC;IAED,KAAK,CAAC,yBAAyB;QAC7B,OAAO,CAAC,KAAK,CAAC,8CAA8C,CAAC,CAAC;QAC9D,OAAO,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC;IAC9B,CAAC;IAED,KAAK,CAAC,iBAAiB,CAAC,OAAkC;QACxD,KAAK,OAAO,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,sCAAsC,CAAC,CAAC;IACxD,CAAC;IAED,KAAK,CAAC,gBAAgB;QACpB,OAAO,CAAC,KAAK,CAAC,qCAAqC,CAAC,CAAC;IACvD,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,OAGjB;QACC,OAAO,CAAC,KAAK,CAAC,iCAAiC,GAAG,OAAO,CAAC,CAAC;QAC3D,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;IAC1B,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,OAAmE;QAClF,OAAO,CAAC,KAAK,CAAC,gCAAgC,GAAG,OAAO,CAAC,CAAC;QAC1D,OAAO,EAAE,OAAO,EAAE,EAAS,EAAE,CAAC;IAChC,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,OAUrB;QACC,OAAO,CAAC,KAAK,CAAC,oCAAoC,GAAG,OAAO,CAAC,CAAC;QAC9D,OAAO,EAAE,aAAa,EAAE,eAAe,EAAS,CAAC;IACnD,CAAC;IAED,KAAK,CAAC,kBAAkB;QACtB,OAAO,CAAC,KAAK,CAAC,uCAAuC,CAAC,CAAC;QACvD,OAAO,EAAE,kBAAkB,EAAE,KAAK,EAAE,CAAC;IACvC,CAAC;IACD,KAAK,CAAC,gBAAgB;QACpB,OAAO,CAAC,IAAI,CAAC,kCAAkC,CAAC,CAAC;QACjD,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;IAChC,CAAC;IACD,KAAK,CAAC,YAAY,CAAC,OAIlB;QACC,OAAO,CAAC,KAAK,CAAC,kCAAkC,GAAG,OAAO,CAAC,CAAC;QAC5D,OAAO,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC;IAC3B,CAAC;IACD,KAAK,CAAC,mBAAmB;QACvB,OAAO,CAAC,KAAK,CAAC,wCAAwC,CAAC,CAAC;IAC1D,CAAC;IAED,KAAK,CAAC,2BAA2B;QAC/B,OAAO,CAAC,KAAK,CAAC,gDAAgD,CAAC,CAAC;IAClE,CAAC;IAED,KAAK,CAAC,mBAAmB,CAAC,OAAkC;QAC1D,KAAK,OAAO,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,wCAAwC,CAAC,CAAC;IAC1D,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,OAAkC;QACtD,KAAK,OAAO,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;IAClE,CAAC;IAED,KAAK,CAAC,aAAa;QACjB,OAAO,CAAC,KAAK,CAAC,kCAAkC,CAAC,CAAC;QAClD,OAAO,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC;IAC7B,CAAC;IAED,KAAK,CAAC,iBAAiB;QACrB,OAAO,CAAC,KAAK,CAAC,sCAAsC,CAAC,CAAC;QACtD,OAAO;YACL,cAAc,EAAE;gBACd,kBAAkB,EAAE,OAAO;gBAC3B,oBAAoB,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;gBAC9C,QAAQ,EAAE,iBAAiB;gBAC3B,UAAU,EAAE,OAAO;gBACnB,WAAW,EAAE,IAAI;aAClB;SACF,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,4BAA4B,CAAC,OAGlC;QACC,KAAK,OAAO,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,iDAAiD,CAAC,CAAC;QACjE,OAAO;YACL,cAAc,EAAE,KAAK;YACrB,kBAAkB,EAAE,OAAO;SAC5B,CAAC;IACJ,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type { AppTransaction, NativePurchasesPlugin, Product, PURCHASE_TYPE, Transaction } from './definitions';\n\nexport class NativePurchasesWeb extends WebPlugin implements NativePurchasesPlugin {\n async configure(options?: { autoFinishTransactions?: boolean }): Promise<void> {\n void options;\n }\n\n async getUnfinishedTransactions(): Promise<{ transactions: Transaction[] }> {\n console.error('getUnfinishedTransactions only mocked in web');\n return { transactions: [] };\n }\n\n async finishTransaction(options: { transactionId: string }): Promise<void> {\n void options;\n console.error('finishTransaction only mocked in web');\n }\n\n async restorePurchases(): Promise<void> {\n console.error('restorePurchases only mocked in web');\n }\n\n async getProducts(options: {\n productIdentifiers: string[];\n productType?: PURCHASE_TYPE;\n }): Promise<{ products: Product[] }> {\n console.error('getProducts only mocked in web ' + options);\n return { products: [] };\n }\n\n async getProduct(options: { productIdentifier: string; productType?: PURCHASE_TYPE }): Promise<{ product: Product }> {\n console.error('getProduct only mocked in web ' + options);\n return { product: {} as any };\n }\n\n async 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 console.error('purchaseProduct only mocked in web' + options);\n return { transactionId: 'transactionId' } as any;\n }\n\n async isBillingSupported(): Promise<{ isBillingSupported: boolean }> {\n console.error('isBillingSupported only mocked in web');\n return { isBillingSupported: false };\n }\n async getPluginVersion(): Promise<{ version: string }> {\n console.warn('Cannot get plugin version in web');\n return { version: 'default' };\n }\n async getPurchases(options?: {\n productType?: PURCHASE_TYPE;\n appAccountToken?: string;\n onlyCurrentEntitlements?: boolean;\n }): Promise<{ purchases: Transaction[] }> {\n console.error('getPurchases only mocked in web ' + options);\n return { purchases: [] };\n }\n async manageSubscriptions(): Promise<void> {\n console.error('manageSubscriptions only mocked in web');\n }\n\n async presentOfferCodeRedeemSheet(): Promise<void> {\n console.error('presentOfferCodeRedeemSheet only mocked in web');\n }\n\n async acknowledgePurchase(options: { purchaseToken: string }): Promise<void> {\n void options;\n console.error('acknowledgePurchase only mocked in web');\n }\n\n async consumePurchase(options: { purchaseToken: string }): Promise<void> {\n void options;\n throw new Error('consumePurchase is only available on Android');\n }\n\n async getStorefront(): Promise<{ countryCode: string; storefrontId?: string }> {\n console.error('getStorefront only mocked in web');\n return { countryCode: '' };\n }\n\n async getAppTransaction(): Promise<{ appTransaction: AppTransaction }> {\n console.error('getAppTransaction only mocked in web');\n return {\n appTransaction: {\n originalAppVersion: '1.0.0',\n originalPurchaseDate: new Date().toISOString(),\n bundleId: 'com.example.app',\n appVersion: '1.0.0',\n environment: null,\n },\n };\n }\n\n async isEntitledToOldBusinessModel(options: {\n targetVersion?: string;\n targetBuildNumber?: string;\n }): Promise<{ isOlderVersion: boolean; originalAppVersion: string }> {\n void options;\n console.error('isEntitledToOldBusinessModel only mocked in web');\n return {\n isOlderVersion: false,\n originalAppVersion: '1.0.0',\n };\n }\n}\n"]}
1
+ {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,OAAO,kBAAmB,SAAQ,SAAS;IAC/C,KAAK,CAAC,SAAS,CAAC,OAA8C;QAC5D,KAAK,OAAO,CAAC;IACf,CAAC;IAED,KAAK,CAAC,yBAAyB,CAAC,OAAyC;QACvE,KAAK,OAAO,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,8CAA8C,CAAC,CAAC;QAC9D,OAAO,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC;IAC9B,CAAC;IAED,KAAK,CAAC,iBAAiB,CAAC,OAA6D;QACnF,KAAK,OAAO,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,sCAAsC,CAAC,CAAC;IACxD,CAAC;IAED,KAAK,CAAC,gBAAgB;QACpB,OAAO,CAAC,KAAK,CAAC,qCAAqC,CAAC,CAAC;IACvD,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,OAGjB;QACC,OAAO,CAAC,KAAK,CAAC,iCAAiC,GAAG,OAAO,CAAC,CAAC;QAC3D,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;IAC1B,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,OAAmE;QAClF,OAAO,CAAC,KAAK,CAAC,gCAAgC,GAAG,OAAO,CAAC,CAAC;QAC1D,OAAO,EAAE,OAAO,EAAE,EAAS,EAAE,CAAC;IAChC,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,OAUrB;QACC,OAAO,CAAC,KAAK,CAAC,oCAAoC,GAAG,OAAO,CAAC,CAAC;QAC9D,OAAO,EAAE,aAAa,EAAE,eAAe,EAAS,CAAC;IACnD,CAAC;IAED,KAAK,CAAC,kBAAkB;QACtB,OAAO,CAAC,KAAK,CAAC,uCAAuC,CAAC,CAAC;QACvD,OAAO,EAAE,kBAAkB,EAAE,KAAK,EAAE,CAAC;IACvC,CAAC;IACD,KAAK,CAAC,gBAAgB;QACpB,OAAO,CAAC,IAAI,CAAC,kCAAkC,CAAC,CAAC;QACjD,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;IAChC,CAAC;IACD,KAAK,CAAC,YAAY,CAAC,OAIlB;QACC,OAAO,CAAC,KAAK,CAAC,kCAAkC,GAAG,OAAO,CAAC,CAAC;QAC5D,OAAO,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC;IAC3B,CAAC;IACD,KAAK,CAAC,mBAAmB;QACvB,OAAO,CAAC,KAAK,CAAC,wCAAwC,CAAC,CAAC;IAC1D,CAAC;IAED,KAAK,CAAC,2BAA2B;QAC/B,OAAO,CAAC,KAAK,CAAC,gDAAgD,CAAC,CAAC;IAClE,CAAC;IAED,KAAK,CAAC,mBAAmB,CAAC,OAAkC;QAC1D,KAAK,OAAO,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,wCAAwC,CAAC,CAAC;IAC1D,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,OAAkC;QACtD,KAAK,OAAO,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;IAClE,CAAC;IAED,KAAK,CAAC,aAAa;QACjB,OAAO,CAAC,KAAK,CAAC,kCAAkC,CAAC,CAAC;QAClD,OAAO,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC;IAC7B,CAAC;IAED,KAAK,CAAC,iBAAiB;QACrB,OAAO,CAAC,KAAK,CAAC,sCAAsC,CAAC,CAAC;QACtD,OAAO;YACL,cAAc,EAAE;gBACd,kBAAkB,EAAE,OAAO;gBAC3B,oBAAoB,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;gBAC9C,QAAQ,EAAE,iBAAiB;gBAC3B,UAAU,EAAE,OAAO;gBACnB,WAAW,EAAE,IAAI;aAClB;SACF,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,4BAA4B,CAAC,OAGlC;QACC,KAAK,OAAO,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,iDAAiD,CAAC,CAAC;QACjE,OAAO;YACL,cAAc,EAAE,KAAK;YACrB,kBAAkB,EAAE,OAAO;SAC5B,CAAC;IACJ,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type { AppTransaction, NativePurchasesPlugin, Product, PURCHASE_TYPE, Transaction } from './definitions';\n\nexport class NativePurchasesWeb extends WebPlugin implements NativePurchasesPlugin {\n async configure(options?: { autoFinishTransactions?: boolean }): Promise<void> {\n void options;\n }\n\n async getUnfinishedTransactions(options?: { includeUnverified?: boolean }): Promise<{ transactions: Transaction[] }> {\n void options;\n console.error('getUnfinishedTransactions only mocked in web');\n return { transactions: [] };\n }\n\n async finishTransaction(options: { transactionId: string; allowUnverified?: boolean }): Promise<void> {\n void options;\n console.error('finishTransaction only mocked in web');\n }\n\n async restorePurchases(): Promise<void> {\n console.error('restorePurchases only mocked in web');\n }\n\n async getProducts(options: {\n productIdentifiers: string[];\n productType?: PURCHASE_TYPE;\n }): Promise<{ products: Product[] }> {\n console.error('getProducts only mocked in web ' + options);\n return { products: [] };\n }\n\n async getProduct(options: { productIdentifier: string; productType?: PURCHASE_TYPE }): Promise<{ product: Product }> {\n console.error('getProduct only mocked in web ' + options);\n return { product: {} as any };\n }\n\n async 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 console.error('purchaseProduct only mocked in web' + options);\n return { transactionId: 'transactionId' } as any;\n }\n\n async isBillingSupported(): Promise<{ isBillingSupported: boolean }> {\n console.error('isBillingSupported only mocked in web');\n return { isBillingSupported: false };\n }\n async getPluginVersion(): Promise<{ version: string }> {\n console.warn('Cannot get plugin version in web');\n return { version: 'default' };\n }\n async getPurchases(options?: {\n productType?: PURCHASE_TYPE;\n appAccountToken?: string;\n onlyCurrentEntitlements?: boolean;\n }): Promise<{ purchases: Transaction[] }> {\n console.error('getPurchases only mocked in web ' + options);\n return { purchases: [] };\n }\n async manageSubscriptions(): Promise<void> {\n console.error('manageSubscriptions only mocked in web');\n }\n\n async presentOfferCodeRedeemSheet(): Promise<void> {\n console.error('presentOfferCodeRedeemSheet only mocked in web');\n }\n\n async acknowledgePurchase(options: { purchaseToken: string }): Promise<void> {\n void options;\n console.error('acknowledgePurchase only mocked in web');\n }\n\n async consumePurchase(options: { purchaseToken: string }): Promise<void> {\n void options;\n throw new Error('consumePurchase is only available on Android');\n }\n\n async getStorefront(): Promise<{ countryCode: string; storefrontId?: string }> {\n console.error('getStorefront only mocked in web');\n return { countryCode: '' };\n }\n\n async getAppTransaction(): Promise<{ appTransaction: AppTransaction }> {\n console.error('getAppTransaction only mocked in web');\n return {\n appTransaction: {\n originalAppVersion: '1.0.0',\n originalPurchaseDate: new Date().toISOString(),\n bundleId: 'com.example.app',\n appVersion: '1.0.0',\n environment: null,\n },\n };\n }\n\n async isEntitledToOldBusinessModel(options: {\n targetVersion?: string;\n targetBuildNumber?: string;\n }): Promise<{ isOlderVersion: boolean; originalAppVersion: string }> {\n void options;\n console.error('isEntitledToOldBusinessModel only mocked in web');\n return {\n isOlderVersion: false,\n originalAppVersion: '1.0.0',\n };\n }\n}\n"]}
@@ -137,7 +137,7 @@ const NativePurchases = core.registerPlugin('NativePurchases', {
137
137
  class NativePurchasesWeb extends core.WebPlugin {
138
138
  async configure(options) {
139
139
  }
140
- async getUnfinishedTransactions() {
140
+ async getUnfinishedTransactions(options) {
141
141
  console.error('getUnfinishedTransactions only mocked in web');
142
142
  return { transactions: [] };
143
143
  }