@capgo/native-purchases 7.5.5 → 7.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Package.swift CHANGED
@@ -10,7 +10,7 @@ let package = Package(
10
10
  targets: ["NativePurchasesPlugin"])
11
11
  ],
12
12
  dependencies: [
13
- .package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "7.4.2")
13
+ .package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "7.4.3")
14
14
  ],
15
15
  targets: [
16
16
  .target(
package/README.md CHANGED
@@ -848,25 +848,25 @@ This method queries the platform's purchase history for the current user.
848
848
 
849
849
  #### Transaction
850
850
 
851
- | Prop | Type | Description |
852
- | -------------------------- | --------------------------- | -------------------------------------------------------------------------------------------------- |
853
- | **`transactionId`** | <code>string</code> | RevenueCat Id associated to the transaction. |
854
- | **`receipt`** | <code>string</code> | Receipt data for validation (iOS only - base64 encoded receipt) |
855
- | **`productIdentifier`** | <code>string</code> | <a href="#product">Product</a> Id associated with the transaction. |
856
- | **`purchaseDate`** | <code>string</code> | Purchase date of the transaction in ISO 8601 format. |
857
- | **`originalPurchaseDate`** | <code>string</code> | Original purchase date of the transaction in ISO 8601 format (for subscriptions). |
858
- | **`expirationDate`** | <code>string</code> | Expiration date of the transaction in ISO 8601 format (for subscriptions). |
859
- | **`isActive`** | <code>boolean</code> | Whether the transaction is still active/valid. |
860
- | **`willCancel`** | <code>string \| null</code> | Date when the subscription was cancelled/revoked, or null if not cancelled. Only available on iOS. |
861
- | **`purchaseState`** | <code>string</code> | Purchase state of the transaction. |
862
- | **`orderId`** | <code>string</code> | Order ID associated with the transaction (Android). |
863
- | **`purchaseToken`** | <code>string</code> | Purchase token associated with the transaction (Android). |
864
- | **`isAcknowledged`** | <code>boolean</code> | Whether the purchase has been acknowledged (Android). |
865
- | **`quantity`** | <code>number</code> | Quantity purchased. |
866
- | **`productType`** | <code>string</code> | <a href="#product">Product</a> type (inapp or subs). |
867
- | **`isTrialPeriod`** | <code>boolean</code> | Whether the transaction is a trial period. |
868
- | **`isInIntroPricePeriod`** | <code>boolean</code> | Whether the transaction is in intro price period. |
869
- | **`isInGracePeriod`** | <code>boolean</code> | Whether the transaction is in grace period. |
851
+ | Prop | Type | Description |
852
+ | -------------------------- | ---------------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
853
+ | **`transactionId`** | <code>string</code> | RevenueCat Id associated to the transaction. |
854
+ | **`receipt`** | <code>string</code> | Receipt data for validation (iOS only - base64 encoded receipt) |
855
+ | **`productIdentifier`** | <code>string</code> | <a href="#product">Product</a> Id associated with the transaction. |
856
+ | **`purchaseDate`** | <code>string</code> | Purchase date of the transaction in ISO 8601 format. |
857
+ | **`originalPurchaseDate`** | <code>string</code> | Original purchase date of the transaction in ISO 8601 format (for subscriptions). |
858
+ | **`expirationDate`** | <code>string</code> | Expiration date of the transaction in ISO 8601 format (for subscriptions). |
859
+ | **`isActive`** | <code>boolean</code> | Whether the transaction is still active/valid. |
860
+ | **`willCancel`** | <code>boolean \| null</code> | Whether the subscription will be cancelled at the end of the billing cycle, or null if not cancelled. Only available on iOS. |
861
+ | **`purchaseState`** | <code>string</code> | Purchase state of the transaction. |
862
+ | **`orderId`** | <code>string</code> | Order ID associated with the transaction (Android). |
863
+ | **`purchaseToken`** | <code>string</code> | Purchase token associated with the transaction (Android). |
864
+ | **`isAcknowledged`** | <code>boolean</code> | Whether the purchase has been acknowledged (Android). |
865
+ | **`quantity`** | <code>number</code> | Quantity purchased. |
866
+ | **`productType`** | <code>string</code> | <a href="#product">Product</a> type (inapp or subs). |
867
+ | **`isTrialPeriod`** | <code>boolean</code> | Whether the transaction is a trial period. |
868
+ | **`isInIntroPricePeriod`** | <code>boolean</code> | Whether the transaction is in intro price period. |
869
+ | **`isInGracePeriod`** | <code>boolean</code> | Whether the transaction is in grace period. |
870
870
 
871
871
 
872
872
  #### Product
package/dist/docs.json CHANGED
@@ -263,9 +263,9 @@
263
263
  {
264
264
  "name": "willCancel",
265
265
  "tags": [],
266
- "docs": "Date when the subscription was cancelled/revoked, or null if not cancelled. Only available on iOS.",
266
+ "docs": "Whether the subscription will be cancelled at the end of the billing cycle, or null if not cancelled. Only available on iOS.",
267
267
  "complexTypes": [],
268
- "type": "string | null"
268
+ "type": "boolean | null"
269
269
  },
270
270
  {
271
271
  "name": "purchaseState",
@@ -149,9 +149,9 @@ export interface Transaction {
149
149
  */
150
150
  readonly isActive?: boolean;
151
151
  /**
152
- * Date when the subscription was cancelled/revoked, or null if not cancelled. Only available on iOS.
152
+ * Whether the subscription will be cancelled at the end of the billing cycle, or null if not cancelled. Only available on iOS.
153
153
  */
154
- readonly willCancel: string | null;
154
+ readonly willCancel: boolean | null;
155
155
  /**
156
156
  * Purchase state of the transaction.
157
157
  */
@@ -1 +1 @@
1
- {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAAA,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,qIAAmC,CAAA;IACnC;;OAEG;IACH,iIAAiC,CAAA;AACnC,CAAC,EAbW,wBAAwB,KAAxB,wBAAwB,QAanC","sourcesContent":["export 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 * RevenueCat 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,\n /**\n * The user is eligible for a free trial or intro pricing for this product.\n */\n INTRO_ELIGIBILITY_STATUS_ELIGIBLE,\n}\n\nexport interface Transaction {\n /**\n * RevenueCat Id associated to the transaction.\n */\n readonly transactionId: string;\n /**\n * Receipt data for validation (iOS only - base64 encoded receipt)\n */\n readonly receipt?: string;\n /**\n * Product Id associated with the transaction.\n */\n readonly productIdentifier: string;\n /**\n * Purchase date of the transaction in ISO 8601 format.\n */\n readonly purchaseDate: string;\n /**\n * Original purchase date of the transaction in ISO 8601 format (for subscriptions).\n */\n readonly originalPurchaseDate?: string;\n /**\n * Expiration date of the transaction in ISO 8601 format (for subscriptions).\n */\n readonly expirationDate?: string;\n /**\n * Whether the transaction is still active/valid.\n */\n readonly isActive?: boolean;\n /**\n * Date when the subscription was cancelled/revoked, or null if not cancelled. Only available on iOS.\n */\n readonly willCancel: string | null;\n /**\n * Purchase state of the transaction.\n */\n readonly purchaseState?: string;\n /**\n * Order ID associated with the transaction (Android).\n */\n readonly orderId?: string;\n /**\n * Purchase token associated with the transaction (Android).\n */\n readonly purchaseToken?: string;\n /**\n * Whether the purchase has been acknowledged (Android).\n */\n readonly isAcknowledged?: boolean;\n /**\n * Quantity purchased.\n */\n readonly quantity?: number;\n /**\n * Product type (inapp or subs).\n */\n readonly productType?: string;\n /**\n * Whether the transaction is a trial period.\n */\n readonly isTrialPeriod?: boolean;\n /**\n * Whether the transaction is in intro price period.\n */\n readonly isInIntroPricePeriod?: boolean;\n /**\n * Whether the transaction is in grace period.\n */\n readonly isInGracePeriod?: boolean;\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}\nexport interface SKProductDiscount {\n /**\n * The Product discount identifier.\n */\n readonly identifier: string;\n /**\n * The Product discount type.\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}\nexport interface Product {\n /**\n * Product Id.\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 * The Product subcription group identifier.\n */\n readonly subscriptionPeriod: SubscriptionPeriod;\n /**\n * The Product introductory Price.\n */\n readonly introductoryPrice: SKProductDiscount | null;\n /**\n * The Product discounts list.\n */\n readonly discounts: SKProductDiscount[];\n}\n\nexport interface NativePurchasesPlugin {\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 * 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 plan you want to purchase, require for for subs.\n * @param options.quantity - Only iOS, the number of items you wish to purchase. Will use 1 by default.\n * @param options.appAccountToken - Only iOS, UUID for the user's account. Used to link purchases to the user account for App Store Server Notifications.\n */\n purchaseProduct(options: {\n productIdentifier: string;\n planIdentifier?: string;\n productType?: PURCHASE_TYPE;\n quantity?: number;\n appAccountToken?: string;\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: {\n productIdentifiers: string[];\n productType?: PURCHASE_TYPE;\n }): Promise<{ products: Product[] }>;\n\n /**\n * Gets the product info for a single product identifier.\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: {\n productIdentifier: string;\n productType?: PURCHASE_TYPE;\n }): 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 * @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 }): Promise<{ purchases: Transaction[] }>;\n}\n"]}
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAAA,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,qIAAmC,CAAA;IACnC;;OAEG;IACH,iIAAiC,CAAA;AACnC,CAAC,EAbW,wBAAwB,KAAxB,wBAAwB,QAanC","sourcesContent":["export 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 * RevenueCat 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,\n /**\n * The user is eligible for a free trial or intro pricing for this product.\n */\n INTRO_ELIGIBILITY_STATUS_ELIGIBLE,\n}\n\nexport interface Transaction {\n /**\n * RevenueCat Id associated to the transaction.\n */\n readonly transactionId: string;\n /**\n * Receipt data for validation (iOS only - base64 encoded receipt)\n */\n readonly receipt?: string;\n /**\n * Product Id associated with the transaction.\n */\n readonly productIdentifier: string;\n /**\n * Purchase date of the transaction in ISO 8601 format.\n */\n readonly purchaseDate: string;\n /**\n * Original purchase date of the transaction in ISO 8601 format (for subscriptions).\n */\n readonly originalPurchaseDate?: string;\n /**\n * Expiration date of the transaction in ISO 8601 format (for subscriptions).\n */\n readonly expirationDate?: string;\n /**\n * Whether the transaction is still active/valid.\n */\n readonly isActive?: boolean;\n /**\n * Whether the subscription will be cancelled at the end of the billing cycle, or null if not cancelled. Only available on iOS.\n */\n readonly willCancel: boolean | null;\n /**\n * Purchase state of the transaction.\n */\n readonly purchaseState?: string;\n /**\n * Order ID associated with the transaction (Android).\n */\n readonly orderId?: string;\n /**\n * Purchase token associated with the transaction (Android).\n */\n readonly purchaseToken?: string;\n /**\n * Whether the purchase has been acknowledged (Android).\n */\n readonly isAcknowledged?: boolean;\n /**\n * Quantity purchased.\n */\n readonly quantity?: number;\n /**\n * Product type (inapp or subs).\n */\n readonly productType?: string;\n /**\n * Whether the transaction is a trial period.\n */\n readonly isTrialPeriod?: boolean;\n /**\n * Whether the transaction is in intro price period.\n */\n readonly isInIntroPricePeriod?: boolean;\n /**\n * Whether the transaction is in grace period.\n */\n readonly isInGracePeriod?: boolean;\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}\nexport interface SKProductDiscount {\n /**\n * The Product discount identifier.\n */\n readonly identifier: string;\n /**\n * The Product discount type.\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}\nexport interface Product {\n /**\n * Product Id.\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 * The Product subcription group identifier.\n */\n readonly subscriptionPeriod: SubscriptionPeriod;\n /**\n * The Product introductory Price.\n */\n readonly introductoryPrice: SKProductDiscount | null;\n /**\n * The Product discounts list.\n */\n readonly discounts: SKProductDiscount[];\n}\n\nexport interface NativePurchasesPlugin {\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 * 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 plan you want to purchase, require for for subs.\n * @param options.quantity - Only iOS, the number of items you wish to purchase. Will use 1 by default.\n * @param options.appAccountToken - Only iOS, UUID for the user's account. Used to link purchases to the user account for App Store Server Notifications.\n */\n purchaseProduct(options: {\n productIdentifier: string;\n planIdentifier?: string;\n productType?: PURCHASE_TYPE;\n quantity?: number;\n appAccountToken?: string;\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: {\n productIdentifiers: string[];\n productType?: PURCHASE_TYPE;\n }): Promise<{ products: Product[] }>;\n\n /**\n * Gets the product info for a single product identifier.\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: {\n productIdentifier: string;\n productType?: PURCHASE_TYPE;\n }): 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 * @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 }): Promise<{ purchases: Transaction[] }>;\n}\n"]}
@@ -97,11 +97,30 @@ public class NativePurchasesPlugin: CAPPlugin, CAPBridgedPlugin {
97
97
  }
98
98
  }
99
99
 
100
- // Add cancellation information - ALWAYS set willCancel
101
- if let revocationDate = transaction.revocationDate {
102
- response["willCancel"] = ISO8601DateFormatter().string(from: revocationDate)
103
- } else {
104
- response["willCancel"] = NSNull()
100
+ let subscriptionStatus = await transaction.subscriptionStatus
101
+ if let subscriptionStatus = subscriptionStatus {
102
+ // You can use 'state' here if needed
103
+ let state = subscriptionStatus.state
104
+ if state == .subscribed {
105
+ // Use Objective-C reflection to access advancedCommerceInfo
106
+ let renewalInfo = subscriptionStatus.renewalInfo
107
+
108
+ switch (renewalInfo) {
109
+ case .verified(let value):
110
+ // if #available(iOS 18.4, *) {
111
+ // // This should work but may need runtime access
112
+ // let advancedInfo = value.advancedCommerceInfo
113
+ // print("Advanced commerce info: \(advancedInfo)")
114
+ // }
115
+ // print("[InAppPurchase] Subscription renewalInfo verified.")
116
+ response["willCancel"] = !value.willAutoRenew
117
+ break;
118
+ case .unverified(_, _):
119
+ print("[InAppPurchase] Subscription renewalInfo not verified.")
120
+ response["willCancel"] = NSNull()
121
+ break;
122
+ }
123
+ }
105
124
  }
106
125
 
107
126
  await transaction.finish()
@@ -247,11 +266,30 @@ public class NativePurchasesPlugin: CAPPlugin, CAPBridgedPlugin {
247
266
  }
248
267
  }
249
268
 
250
- // Add cancellation information - ALWAYS set willCancel
251
- if let revocationDate = transaction.revocationDate {
252
- purchaseData["willCancel"] = ISO8601DateFormatter().string(from: revocationDate)
253
- } else {
254
- purchaseData["willCancel"] = NSNull()
269
+ let subscriptionStatus = await transaction.subscriptionStatus
270
+ if let subscriptionStatus = subscriptionStatus {
271
+ // You can use 'state' here if needed
272
+ let state = subscriptionStatus.state
273
+ if state == .subscribed {
274
+ // Use Objective-C reflection to access advancedCommerceInfo
275
+ let renewalInfo = subscriptionStatus.renewalInfo
276
+
277
+ switch (renewalInfo) {
278
+ case .verified(let value):
279
+ // if #available(iOS 18.4, *) {
280
+ // // This should work but may need runtime access
281
+ // let advancedInfo = value.advancedCommerceInfo
282
+ // print("Advanced commerce info: \(advancedInfo)")
283
+ // }
284
+ // print("[InAppPurchase] Subscription renewalInfo verified.")
285
+ purchaseData["willCancel"] = !value.willAutoRenew
286
+ break;
287
+ case .unverified(_, _):
288
+ print("[InAppPurchase] Subscription renewalInfo not verified.")
289
+ purchaseData["willCancel"] = NSNull()
290
+ break;
291
+ }
292
+ }
255
293
  }
256
294
 
257
295
  allPurchases.append(purchaseData)
@@ -297,11 +335,30 @@ public class NativePurchasesPlugin: CAPPlugin, CAPBridgedPlugin {
297
335
  }
298
336
  }
299
337
 
300
- // Add cancellation information - ALWAYS set willCancel
301
- if let revocationDate = transaction.revocationDate {
302
- purchaseData["willCancel"] = ISO8601DateFormatter().string(from: revocationDate)
303
- } else {
304
- purchaseData["willCancel"] = NSNull()
338
+ let subscriptionStatus = await transaction.subscriptionStatus
339
+ if let subscriptionStatus = subscriptionStatus {
340
+ // You can use 'state' here if needed
341
+ let state = subscriptionStatus.state
342
+ if state == .subscribed {
343
+ // Use Objective-C reflection to access advancedCommerceInfo
344
+ let renewalInfo = subscriptionStatus.renewalInfo
345
+
346
+ switch (renewalInfo) {
347
+ case .verified(let value):
348
+ // if #available(iOS 18.4, *) {
349
+ // // This should work but may need runtime access
350
+ // let advancedInfo = value.advancedCommerceInfo
351
+ // print("Advanced commerce info: \(advancedInfo)")
352
+ // }
353
+ // print("[InAppPurchase] Subscription renewalInfo verified.")
354
+ purchaseData["willCancel"] = !value.willAutoRenew
355
+ break;
356
+ case .unverified(_, _):
357
+ print("[InAppPurchase] Subscription renewalInfo not verified.")
358
+ purchaseData["willCancel"] = NSNull()
359
+ break;
360
+ }
361
+ }
305
362
  }
306
363
 
307
364
  allPurchases.append(purchaseData)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/native-purchases",
3
- "version": "7.5.5",
3
+ "version": "7.6.1",
4
4
  "description": "In-app Subscriptions Made Easy",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",