@capgo/native-purchases 7.4.0 → 7.5.3

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.
@@ -10,7 +10,8 @@ Pod::Spec.new do |s|
10
10
  s.homepage = package['repository']['url']
11
11
  s.author = package['author']
12
12
  s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
13
- s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
13
+ s.source_files = 'ios/Sources/**/*.{swift,h,m,c,cc,mm,cpp}'
14
+ s.exclude_files = '**/node_modules/**/*', '**/examples/**/*'
14
15
  s.ios.deployment_target = '14.0'
15
16
  s.dependency 'Capacitor'
16
17
  s.swift_version = '5.1'
package/Package.swift ADDED
@@ -0,0 +1,28 @@
1
+ // swift-tools-version: 5.9
2
+ import PackageDescription
3
+
4
+ let package = Package(
5
+ name: "CapgoNativePurchases",
6
+ platforms: [.iOS(.v14)],
7
+ products: [
8
+ .library(
9
+ name: "CapgoNativePurchases",
10
+ targets: ["NativePurchasesPlugin"])
11
+ ],
12
+ dependencies: [
13
+ .package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "7.4.2")
14
+ ],
15
+ targets: [
16
+ .target(
17
+ name: "NativePurchasesPlugin",
18
+ dependencies: [
19
+ .product(name: "Capacitor", package: "capacitor-swift-pm"),
20
+ .product(name: "Cordova", package: "capacitor-swift-pm")
21
+ ],
22
+ path: "ios/Sources/NativePurchasesPlugin"),
23
+ .testTarget(
24
+ name: "NativePurchasesPluginTests",
25
+ dependencies: ["NativePurchasesPlugin"],
26
+ path: "ios/Tests/NativePurchasesPluginTests")
27
+ ]
28
+ )
package/README.md CHANGED
@@ -848,27 +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
- | **`purchaseState`** | <code>string</code> | Purchase state of the transaction. |
861
- | **`orderId`** | <code>string</code> | Order ID associated with the transaction (Android). |
862
- | **`purchaseToken`** | <code>string</code> | Purchase token associated with the transaction (Android). |
863
- | **`isAcknowledged`** | <code>boolean</code> | Whether the purchase has been acknowledged (Android). |
864
- | **`quantity`** | <code>number</code> | Quantity purchased. |
865
- | **`productType`** | <code>string</code> | <a href="#product">Product</a> type (inapp or subs). |
866
- | **`isTrialPeriod`** | <code>boolean</code> | Whether the transaction is a trial period. |
867
- | **`isInIntroPricePeriod`** | <code>boolean</code> | Whether the transaction is in intro price period. |
868
- | **`isInGracePeriod`** | <code>boolean</code> | Whether the transaction is in grace period. |
869
- | **`isRevoked`** | <code>boolean</code> | Whether the transaction is revoked. |
870
- | **`revocationDate`** | <code>string</code> | Revocation date if the transaction was revoked. |
871
- | **`revocationReason`** | <code>string</code> | Revocation reason if the transaction was revoked. |
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. |
872
870
 
873
871
 
874
872
  #### Product
@@ -165,6 +165,11 @@ public class NativePurchasesPlugin extends Plugin {
165
165
  ret.put("isAcknowledged", purchase.isAcknowledged());
166
166
  ret.put("purchaseState", String.valueOf(purchase.getPurchaseState()));
167
167
 
168
+ // Add cancellation information
169
+ // Note: Android doesn't provide direct cancellation information in the Purchase object
170
+ // This would require additional Google Play API calls to get detailed subscription status
171
+ ret.put("willCancel", null); // Default to null, would need API call to determine actual cancellation date
172
+
168
173
  // For subscriptions, try to get additional information
169
174
  if (
170
175
  purchase.getPurchaseState() == Purchase.PurchaseState.PURCHASED &&
@@ -951,6 +956,9 @@ public class NativePurchasesPlugin extends Plugin {
951
956
  "purchaseState",
952
957
  String.valueOf(purchase.getPurchaseState())
953
958
  );
959
+ // Add cancellation information
960
+ // Note: Android doesn't provide direct cancellation information in the Purchase object
961
+ purchaseData.put("willCancel", null); // Default to null, would need API call to determine actual cancellation date
954
962
  allPurchases.put(purchaseData);
955
963
  }
956
964
  }
@@ -1013,6 +1021,9 @@ public class NativePurchasesPlugin extends Plugin {
1013
1021
  "purchaseState",
1014
1022
  String.valueOf(purchase.getPurchaseState())
1015
1023
  );
1024
+ // Add cancellation information
1025
+ // Note: Android doesn't provide direct cancellation information in the Purchase object
1026
+ purchaseData.put("willCancel", null); // Default to null, would need API call to determine actual cancellation date
1016
1027
  allPurchases.put(purchaseData);
1017
1028
  }
1018
1029
  }
@@ -1088,6 +1099,9 @@ public class NativePurchasesPlugin extends Plugin {
1088
1099
  "purchaseState",
1089
1100
  String.valueOf(purchase.getPurchaseState())
1090
1101
  );
1102
+ // Add cancellation information
1103
+ // Note: Android doesn't provide direct cancellation information in the Purchase object
1104
+ purchaseData.put("willCancel", null); // Default to null, would need API call to determine actual cancellation date
1091
1105
  allPurchases.put(purchaseData);
1092
1106
  }
1093
1107
  }
package/dist/docs.json CHANGED
@@ -260,6 +260,13 @@
260
260
  "complexTypes": [],
261
261
  "type": "boolean | undefined"
262
262
  },
263
+ {
264
+ "name": "willCancel",
265
+ "tags": [],
266
+ "docs": "Date when the subscription was cancelled/revoked, or null if not cancelled. Only available on iOS.",
267
+ "complexTypes": [],
268
+ "type": "string | null | undefined"
269
+ },
263
270
  {
264
271
  "name": "purchaseState",
265
272
  "tags": [],
@@ -322,27 +329,6 @@
322
329
  "docs": "Whether the transaction is in grace period.",
323
330
  "complexTypes": [],
324
331
  "type": "boolean | undefined"
325
- },
326
- {
327
- "name": "isRevoked",
328
- "tags": [],
329
- "docs": "Whether the transaction is revoked.",
330
- "complexTypes": [],
331
- "type": "boolean | undefined"
332
- },
333
- {
334
- "name": "revocationDate",
335
- "tags": [],
336
- "docs": "Revocation date if the transaction was revoked.",
337
- "complexTypes": [],
338
- "type": "string | undefined"
339
- },
340
- {
341
- "name": "revocationReason",
342
- "tags": [],
343
- "docs": "Revocation reason if the transaction was revoked.",
344
- "complexTypes": [],
345
- "type": "string | undefined"
346
332
  }
347
333
  ]
348
334
  },
@@ -148,6 +148,10 @@ export interface Transaction {
148
148
  * Whether the transaction is still active/valid.
149
149
  */
150
150
  readonly isActive?: boolean;
151
+ /**
152
+ * Date when the subscription was cancelled/revoked, or null if not cancelled. Only available on iOS.
153
+ */
154
+ readonly willCancel?: string | null;
151
155
  /**
152
156
  * Purchase state of the transaction.
153
157
  */
@@ -184,18 +188,6 @@ export interface Transaction {
184
188
  * Whether the transaction is in grace period.
185
189
  */
186
190
  readonly isInGracePeriod?: boolean;
187
- /**
188
- * Whether the transaction is revoked.
189
- */
190
- readonly isRevoked?: boolean;
191
- /**
192
- * Revocation date if the transaction was revoked.
193
- */
194
- readonly revocationDate?: string;
195
- /**
196
- * Revocation reason if the transaction was revoked.
197
- */
198
- readonly revocationReason?: string;
199
191
  }
200
192
  export interface SubscriptionPeriod {
201
193
  /**
@@ -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 * 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 * Whether the transaction is revoked.\n */\n readonly isRevoked?: boolean;\n /**\n * Revocation date if the transaction was revoked.\n */\n readonly revocationDate?: string;\n /**\n * Revocation reason if the transaction was revoked.\n */\n readonly revocationReason?: 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}\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 * 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"]}
@@ -92,17 +92,16 @@ public class NativePurchasesPlugin: CAPPlugin, CAPBridgedPlugin {
92
92
  response["originalPurchaseDate"] = ISO8601DateFormatter().string(from: transaction.originalPurchaseDate)
93
93
  if let expirationDate = transaction.expirationDate {
94
94
  response["expirationDate"] = ISO8601DateFormatter().string(from: expirationDate)
95
- response["isActive"] = expirationDate > Date()
95
+ let isActive = expirationDate > Date()
96
+ response["isActive"] = isActive
96
97
  }
97
98
  }
98
99
 
99
- // Add revocation information if applicable
100
- if transaction.revocationDate != nil {
101
- response["isRevoked"] = true
102
- response["revocationDate"] = ISO8601DateFormatter().string(from: transaction.revocationDate!)
103
- response["revocationReason"] = transaction.revocationReason?.rawValue
100
+ // Add cancellation information
101
+ if let revocationDate = transaction.revocationDate {
102
+ response["willCancel"] = ISO8601DateFormatter().string(from: revocationDate)
104
103
  } else {
105
- response["isRevoked"] = false
104
+ response["willCancel"] = nil
106
105
  }
107
106
 
108
107
  await transaction.finish()
@@ -243,17 +242,16 @@ public class NativePurchasesPlugin: CAPPlugin, CAPBridgedPlugin {
243
242
  purchaseData["originalPurchaseDate"] = ISO8601DateFormatter().string(from: transaction.originalPurchaseDate)
244
243
  if let expirationDate = transaction.expirationDate {
245
244
  purchaseData["expirationDate"] = ISO8601DateFormatter().string(from: expirationDate)
246
- purchaseData["isActive"] = expirationDate > Date()
245
+ let isActive = expirationDate > Date()
246
+ purchaseData["isActive"] = isActive
247
247
  }
248
248
  }
249
249
 
250
- // Add revocation information if applicable
251
- if transaction.revocationDate != nil {
252
- purchaseData["isRevoked"] = true
253
- purchaseData["revocationDate"] = ISO8601DateFormatter().string(from: transaction.revocationDate!)
254
- purchaseData["revocationReason"] = transaction.revocationReason?.rawValue
250
+ // Add cancellation information
251
+ if let revocationDate = transaction.revocationDate {
252
+ purchaseData["willCancel"] = ISO8601DateFormatter().string(from: revocationDate)
255
253
  } else {
256
- purchaseData["isRevoked"] = false
254
+ purchaseData["willCancel"] = nil
257
255
  }
258
256
 
259
257
  allPurchases.append(purchaseData)
@@ -294,17 +292,16 @@ public class NativePurchasesPlugin: CAPPlugin, CAPBridgedPlugin {
294
292
  purchaseData["originalPurchaseDate"] = ISO8601DateFormatter().string(from: transaction.originalPurchaseDate)
295
293
  if let expirationDate = transaction.expirationDate {
296
294
  purchaseData["expirationDate"] = ISO8601DateFormatter().string(from: expirationDate)
297
- purchaseData["isActive"] = expirationDate > Date()
295
+ let isActive = expirationDate > Date()
296
+ purchaseData["isActive"] = isActive
298
297
  }
299
298
  }
300
299
 
301
- // Add revocation information if applicable
302
- if transaction.revocationDate != nil {
303
- purchaseData["isRevoked"] = true
304
- purchaseData["revocationDate"] = ISO8601DateFormatter().string(from: transaction.revocationDate!)
305
- purchaseData["revocationReason"] = transaction.revocationReason?.rawValue
300
+ // Add cancellation information
301
+ if let revocationDate = transaction.revocationDate {
302
+ purchaseData["willCancel"] = ISO8601DateFormatter().string(from: revocationDate)
306
303
  } else {
307
- purchaseData["isRevoked"] = false
304
+ purchaseData["willCancel"] = nil
308
305
  }
309
306
 
310
307
  allPurchases.append(purchaseData)
@@ -0,0 +1,15 @@
1
+ import XCTest
2
+ @testable import NativePurchasesPlugin
3
+
4
+ class SocialLoginTests: XCTestCase {
5
+ func testEcho() {
6
+ // This is an example of a functional test case for a plugin.
7
+ // Use XCTAssert and related functions to verify your tests produce the correct results.
8
+
9
+ let implementation = NativePurchasesPlugin()
10
+ let value = "Hello, World!"
11
+ let result = implementation.echo(value)
12
+
13
+ XCTAssertEqual(value, result)
14
+ }
15
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/native-purchases",
3
- "version": "7.4.0",
3
+ "version": "7.5.3",
4
4
  "description": "In-app Subscriptions Made Easy",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",
@@ -10,7 +10,9 @@
10
10
  "android/src/main/",
11
11
  "android/build.gradle",
12
12
  "dist/",
13
- "ios/Plugin/",
13
+ "ios/Sources",
14
+ "ios/Tests",
15
+ "Package.swift",
14
16
  "CapgoNativePurchases.podspec"
15
17
  ],
16
18
  "author": "Martin Donadieu <martin@capgo.app>",
@@ -33,7 +35,7 @@
33
35
  ],
34
36
  "scripts": {
35
37
  "verify": "npm run verify:ios && npm run verify:android && npm run verify:web",
36
- "verify:ios": "cd ios && pod install && xcodebuild -workspace Plugin.xcworkspace -scheme Plugin -destination generic/platform=iOS && cd ..",
38
+ "verify:ios": "xcodebuild -scheme CapgoNativePurchases -destination generic/platform=iOS",
37
39
  "verify:android": "cd android && ./gradlew clean build test && cd ..",
38
40
  "verify:web": "npm run build",
39
41
  "lint": "npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint",
@@ -1,24 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
- <plist version="1.0">
4
- <dict>
5
- <key>CFBundleDevelopmentRegion</key>
6
- <string>$(DEVELOPMENT_LANGUAGE)</string>
7
- <key>CFBundleExecutable</key>
8
- <string>$(EXECUTABLE_NAME)</string>
9
- <key>CFBundleIdentifier</key>
10
- <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
11
- <key>CFBundleInfoDictionaryVersion</key>
12
- <string>6.0</string>
13
- <key>CFBundleName</key>
14
- <string>$(PRODUCT_NAME)</string>
15
- <key>CFBundlePackageType</key>
16
- <string>FMWK</string>
17
- <key>CFBundleShortVersionString</key>
18
- <string>1.0</string>
19
- <key>CFBundleVersion</key>
20
- <string>$(CURRENT_PROJECT_VERSION)</string>
21
- <key>NSPrincipalClass</key>
22
- <string></string>
23
- </dict>
24
- </plist>