@capgo/native-purchases 7.3.2 → 7.5.2

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,8 +10,13 @@ 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'
17
+ s.dependency 'FBSDKCoreKit', '18.0.0'
18
+ s.dependency 'FBSDKLoginKit', '18.0.0'
19
+ s.dependency 'GoogleSignIn', '~> 9.0.0'
20
+ s.dependency 'Alamofire', '~> 5.10.2'
16
21
  s.swift_version = '5.1'
17
22
  end
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,10 +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) |
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. |
855
870
 
856
871
 
857
872
  #### Product
@@ -145,6 +145,43 @@ public class NativePurchasesPlugin extends Plugin {
145
145
 
146
146
  JSObject ret = new JSObject();
147
147
  ret.put("transactionId", purchase.getPurchaseToken());
148
+ ret.put("productIdentifier", purchase.getProducts().get(0));
149
+ ret.put(
150
+ "purchaseDate",
151
+ new java.text.SimpleDateFormat(
152
+ "yyyy-MM-dd'T'HH:mm:ss'Z'",
153
+ java.util.Locale.US
154
+ ).format(new java.util.Date(purchase.getPurchaseTime()))
155
+ );
156
+ ret.put("quantity", purchase.getQuantity());
157
+ ret.put(
158
+ "productType",
159
+ purchase.getPurchaseState() == Purchase.PurchaseState.PURCHASED
160
+ ? "inapp"
161
+ : "subs"
162
+ );
163
+ ret.put("orderId", purchase.getOrderId());
164
+ ret.put("purchaseToken", purchase.getPurchaseToken());
165
+ ret.put("isAcknowledged", purchase.isAcknowledged());
166
+ ret.put("purchaseState", String.valueOf(purchase.getPurchaseState()));
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
+
173
+ // For subscriptions, try to get additional information
174
+ if (
175
+ purchase.getPurchaseState() == Purchase.PurchaseState.PURCHASED &&
176
+ purchase.getProducts().get(0).contains("sub")
177
+ ) {
178
+ // Note: Android doesn't provide direct expiration date in Purchase object
179
+ // This would need to be calculated based on subscription period or fetched from Google Play API
180
+ ret.put("productType", "subs");
181
+ // For subscriptions, we can't get expiration date directly from Purchase object
182
+ // This would require additional Google Play API calls to get subscription details
183
+ }
184
+
148
185
  Log.d(
149
186
  TAG,
150
187
  "Resolving purchase call with transactionId: " +
@@ -899,6 +936,29 @@ public class NativePurchasesPlugin extends Plugin {
899
936
  );
900
937
  JSObject purchaseData = new JSObject();
901
938
  purchaseData.put("transactionId", purchase.getPurchaseToken());
939
+ purchaseData.put(
940
+ "productIdentifier",
941
+ purchase.getProducts().get(0)
942
+ );
943
+ purchaseData.put(
944
+ "purchaseDate",
945
+ new java.text.SimpleDateFormat(
946
+ "yyyy-MM-dd'T'HH:mm:ss'Z'",
947
+ java.util.Locale.US
948
+ ).format(new java.util.Date(purchase.getPurchaseTime()))
949
+ );
950
+ purchaseData.put("quantity", purchase.getQuantity());
951
+ purchaseData.put("productType", "inapp");
952
+ purchaseData.put("orderId", purchase.getOrderId());
953
+ purchaseData.put("purchaseToken", purchase.getPurchaseToken());
954
+ purchaseData.put("isAcknowledged", purchase.isAcknowledged());
955
+ purchaseData.put(
956
+ "purchaseState",
957
+ String.valueOf(purchase.getPurchaseState())
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
902
962
  allPurchases.put(purchaseData);
903
963
  }
904
964
  }
@@ -935,6 +995,35 @@ public class NativePurchasesPlugin extends Plugin {
935
995
  "transactionId",
936
996
  purchase.getPurchaseToken()
937
997
  );
998
+ purchaseData.put(
999
+ "productIdentifier",
1000
+ purchase.getProducts().get(0)
1001
+ );
1002
+ purchaseData.put(
1003
+ "purchaseDate",
1004
+ new java.text.SimpleDateFormat(
1005
+ "yyyy-MM-dd'T'HH:mm:ss'Z'",
1006
+ java.util.Locale.US
1007
+ ).format(new java.util.Date(purchase.getPurchaseTime()))
1008
+ );
1009
+ purchaseData.put("quantity", purchase.getQuantity());
1010
+ purchaseData.put("productType", "subs");
1011
+ purchaseData.put("orderId", purchase.getOrderId());
1012
+ purchaseData.put(
1013
+ "purchaseToken",
1014
+ purchase.getPurchaseToken()
1015
+ );
1016
+ purchaseData.put(
1017
+ "isAcknowledged",
1018
+ purchase.isAcknowledged()
1019
+ );
1020
+ purchaseData.put(
1021
+ "purchaseState",
1022
+ String.valueOf(purchase.getPurchaseState())
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
938
1027
  allPurchases.put(purchaseData);
939
1028
  }
940
1029
  }
@@ -990,6 +1079,29 @@ public class NativePurchasesPlugin extends Plugin {
990
1079
  );
991
1080
  JSObject purchaseData = new JSObject();
992
1081
  purchaseData.put("transactionId", purchase.getPurchaseToken());
1082
+ purchaseData.put(
1083
+ "productIdentifier",
1084
+ purchase.getProducts().get(0)
1085
+ );
1086
+ purchaseData.put(
1087
+ "purchaseDate",
1088
+ new java.text.SimpleDateFormat(
1089
+ "yyyy-MM-dd'T'HH:mm:ss'Z'",
1090
+ java.util.Locale.US
1091
+ ).format(new java.util.Date(purchase.getPurchaseTime()))
1092
+ );
1093
+ purchaseData.put("quantity", purchase.getQuantity());
1094
+ purchaseData.put("productType", "subs");
1095
+ purchaseData.put("orderId", purchase.getOrderId());
1096
+ purchaseData.put("purchaseToken", purchase.getPurchaseToken());
1097
+ purchaseData.put("isAcknowledged", purchase.isAcknowledged());
1098
+ purchaseData.put(
1099
+ "purchaseState",
1100
+ String.valueOf(purchase.getPurchaseState())
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
993
1105
  allPurchases.put(purchaseData);
994
1106
  }
995
1107
  }
package/dist/docs.json CHANGED
@@ -224,6 +224,111 @@
224
224
  "docs": "Receipt data for validation (iOS only - base64 encoded receipt)",
225
225
  "complexTypes": [],
226
226
  "type": "string | undefined"
227
+ },
228
+ {
229
+ "name": "productIdentifier",
230
+ "tags": [],
231
+ "docs": "Product Id associated with the transaction.",
232
+ "complexTypes": [],
233
+ "type": "string"
234
+ },
235
+ {
236
+ "name": "purchaseDate",
237
+ "tags": [],
238
+ "docs": "Purchase date of the transaction in ISO 8601 format.",
239
+ "complexTypes": [],
240
+ "type": "string"
241
+ },
242
+ {
243
+ "name": "originalPurchaseDate",
244
+ "tags": [],
245
+ "docs": "Original purchase date of the transaction in ISO 8601 format (for subscriptions).",
246
+ "complexTypes": [],
247
+ "type": "string | undefined"
248
+ },
249
+ {
250
+ "name": "expirationDate",
251
+ "tags": [],
252
+ "docs": "Expiration date of the transaction in ISO 8601 format (for subscriptions).",
253
+ "complexTypes": [],
254
+ "type": "string | undefined"
255
+ },
256
+ {
257
+ "name": "isActive",
258
+ "tags": [],
259
+ "docs": "Whether the transaction is still active/valid.",
260
+ "complexTypes": [],
261
+ "type": "boolean | undefined"
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
+ },
270
+ {
271
+ "name": "purchaseState",
272
+ "tags": [],
273
+ "docs": "Purchase state of the transaction.",
274
+ "complexTypes": [],
275
+ "type": "string | undefined"
276
+ },
277
+ {
278
+ "name": "orderId",
279
+ "tags": [],
280
+ "docs": "Order ID associated with the transaction (Android).",
281
+ "complexTypes": [],
282
+ "type": "string | undefined"
283
+ },
284
+ {
285
+ "name": "purchaseToken",
286
+ "tags": [],
287
+ "docs": "Purchase token associated with the transaction (Android).",
288
+ "complexTypes": [],
289
+ "type": "string | undefined"
290
+ },
291
+ {
292
+ "name": "isAcknowledged",
293
+ "tags": [],
294
+ "docs": "Whether the purchase has been acknowledged (Android).",
295
+ "complexTypes": [],
296
+ "type": "boolean | undefined"
297
+ },
298
+ {
299
+ "name": "quantity",
300
+ "tags": [],
301
+ "docs": "Quantity purchased.",
302
+ "complexTypes": [],
303
+ "type": "number | undefined"
304
+ },
305
+ {
306
+ "name": "productType",
307
+ "tags": [],
308
+ "docs": "Product type (inapp or subs).",
309
+ "complexTypes": [],
310
+ "type": "string | undefined"
311
+ },
312
+ {
313
+ "name": "isTrialPeriod",
314
+ "tags": [],
315
+ "docs": "Whether the transaction is a trial period.",
316
+ "complexTypes": [],
317
+ "type": "boolean | undefined"
318
+ },
319
+ {
320
+ "name": "isInIntroPricePeriod",
321
+ "tags": [],
322
+ "docs": "Whether the transaction is in intro price period.",
323
+ "complexTypes": [],
324
+ "type": "boolean | undefined"
325
+ },
326
+ {
327
+ "name": "isInGracePeriod",
328
+ "tags": [],
329
+ "docs": "Whether the transaction is in grace period.",
330
+ "complexTypes": [],
331
+ "type": "boolean | undefined"
227
332
  }
228
333
  ]
229
334
  },
@@ -128,6 +128,66 @@ export interface Transaction {
128
128
  * Receipt data for validation (iOS only - base64 encoded receipt)
129
129
  */
130
130
  readonly receipt?: string;
131
+ /**
132
+ * Product Id associated with the transaction.
133
+ */
134
+ readonly productIdentifier: string;
135
+ /**
136
+ * Purchase date of the transaction in ISO 8601 format.
137
+ */
138
+ readonly purchaseDate: string;
139
+ /**
140
+ * Original purchase date of the transaction in ISO 8601 format (for subscriptions).
141
+ */
142
+ readonly originalPurchaseDate?: string;
143
+ /**
144
+ * Expiration date of the transaction in ISO 8601 format (for subscriptions).
145
+ */
146
+ readonly expirationDate?: string;
147
+ /**
148
+ * Whether the transaction is still active/valid.
149
+ */
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;
155
+ /**
156
+ * Purchase state of the transaction.
157
+ */
158
+ readonly purchaseState?: string;
159
+ /**
160
+ * Order ID associated with the transaction (Android).
161
+ */
162
+ readonly orderId?: string;
163
+ /**
164
+ * Purchase token associated with the transaction (Android).
165
+ */
166
+ readonly purchaseToken?: string;
167
+ /**
168
+ * Whether the purchase has been acknowledged (Android).
169
+ */
170
+ readonly isAcknowledged?: boolean;
171
+ /**
172
+ * Quantity purchased.
173
+ */
174
+ readonly quantity?: number;
175
+ /**
176
+ * Product type (inapp or subs).
177
+ */
178
+ readonly productType?: string;
179
+ /**
180
+ * Whether the transaction is a trial period.
181
+ */
182
+ readonly isTrialPeriod?: boolean;
183
+ /**
184
+ * Whether the transaction is in intro price period.
185
+ */
186
+ readonly isInIntroPricePeriod?: boolean;
187
+ /**
188
+ * Whether the transaction is in grace period.
189
+ */
190
+ readonly isInGracePeriod?: boolean;
131
191
  }
132
192
  export interface SubscriptionPeriod {
133
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\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"]}
package/dist/esm/web.d.ts CHANGED
@@ -16,9 +16,7 @@ export declare class NativePurchasesWeb extends WebPlugin implements NativePurch
16
16
  productIdentifier: string;
17
17
  planIdentifier: string;
18
18
  quantity: number;
19
- }): Promise<{
20
- transactionId: string;
21
- }>;
19
+ }): Promise<Transaction>;
22
20
  isBillingSupported(): Promise<{
23
21
  isBillingSupported: boolean;
24
22
  }>;
@@ -1 +1 @@
1
- {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAS5C,MAAM,OAAO,kBACX,SAAQ,SAAS;IAGjB,KAAK,CAAC,gBAAgB;QACpB,OAAO,CAAC,KAAK,CAAC,qCAAqC,CAAC,CAAC;IACvD,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,OAEjB;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,OAEhB;QACC,OAAO,CAAC,KAAK,CAAC,gCAAgC,GAAG,OAAO,CAAC,CAAC;QAC1D,OAAO,EAAE,OAAO,EAAE,EAAS,EAAE,CAAC;IAChC,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,OAIrB;QACC,OAAO,CAAC,KAAK,CAAC,oCAAoC,GAAG,OAAO,CAAC,CAAC;QAC9D,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,CAAC;IAC5C,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,OAElB;QACC,OAAO,CAAC,KAAK,CAAC,kCAAkC,GAAG,OAAO,CAAC,CAAC;QAC5D,OAAO,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC;IAC3B,CAAC;CACF","sourcesContent":["import { WebPlugin } from \"@capacitor/core\";\n\nimport type {\n NativePurchasesPlugin,\n Product,\n PURCHASE_TYPE,\n Transaction,\n} from \"./definitions\";\n\nexport class NativePurchasesWeb\n extends WebPlugin\n implements NativePurchasesPlugin\n{\n async restorePurchases(): Promise<void> {\n console.error(\"restorePurchases only mocked in web\");\n }\n\n async getProducts(options: {\n productIdentifiers: string[];\n }): Promise<{ products: Product[] }> {\n console.error(\"getProducts only mocked in web \" + options);\n return { products: [] };\n }\n\n async getProduct(options: {\n productIdentifier: string;\n }): 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 quantity: number;\n }): Promise<{ transactionId: string }> {\n console.error(\"purchaseProduct only mocked in web\" + options);\n return { transactionId: \"transactionId\" };\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 }): Promise<{ purchases: Transaction[] }> {\n console.error(\"getPurchases only mocked in web \" + options);\n return { purchases: [] };\n }\n}\n"]}
1
+ {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAS5C,MAAM,OAAO,kBACX,SAAQ,SAAS;IAGjB,KAAK,CAAC,gBAAgB;QACpB,OAAO,CAAC,KAAK,CAAC,qCAAqC,CAAC,CAAC;IACvD,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,OAEjB;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,OAEhB;QACC,OAAO,CAAC,KAAK,CAAC,gCAAgC,GAAG,OAAO,CAAC,CAAC;QAC1D,OAAO,EAAE,OAAO,EAAE,EAAS,EAAE,CAAC;IAChC,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,OAIrB;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,OAElB;QACC,OAAO,CAAC,KAAK,CAAC,kCAAkC,GAAG,OAAO,CAAC,CAAC;QAC5D,OAAO,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC;IAC3B,CAAC;CACF","sourcesContent":["import { WebPlugin } from \"@capacitor/core\";\n\nimport type {\n NativePurchasesPlugin,\n Product,\n PURCHASE_TYPE,\n Transaction,\n} from \"./definitions\";\n\nexport class NativePurchasesWeb\n extends WebPlugin\n implements NativePurchasesPlugin\n{\n async restorePurchases(): Promise<void> {\n console.error(\"restorePurchases only mocked in web\");\n }\n\n async getProducts(options: {\n productIdentifiers: string[];\n }): Promise<{ products: Product[] }> {\n console.error(\"getProducts only mocked in web \" + options);\n return { products: [] };\n }\n\n async getProduct(options: {\n productIdentifier: string;\n }): 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 quantity: number;\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 }): Promise<{ purchases: Transaction[] }> {\n console.error(\"getPurchases only mocked in web \" + options);\n return { purchases: [] };\n }\n}\n"]}
@@ -82,6 +82,28 @@ public class NativePurchasesPlugin: CAPPlugin, CAPBridgedPlugin {
82
82
  response["receipt"] = receiptBase64
83
83
  }
84
84
 
85
+ // Add detailed transaction information
86
+ response["productIdentifier"] = transaction.productID
87
+ response["purchaseDate"] = ISO8601DateFormatter().string(from: transaction.purchaseDate)
88
+ response["productType"] = transaction.productType == .autoRenewable ? "subs" : "inapp"
89
+
90
+ // Add subscription-specific information
91
+ if transaction.productType == .autoRenewable {
92
+ response["originalPurchaseDate"] = ISO8601DateFormatter().string(from: transaction.originalPurchaseDate)
93
+ if let expirationDate = transaction.expirationDate {
94
+ response["expirationDate"] = ISO8601DateFormatter().string(from: expirationDate)
95
+ let isActive = expirationDate > Date()
96
+ response["isActive"] = isActive
97
+ }
98
+ }
99
+
100
+ // Add cancellation information
101
+ if let revocationDate = transaction.revocationDate {
102
+ response["willCancel"] = ISO8601DateFormatter().string(from: revocationDate)
103
+ } else {
104
+ response["willCancel"] = nil
105
+ }
106
+
85
107
  await transaction.finish()
86
108
  call.resolve(response)
87
109
  case let .success(.unverified(_, error)):
@@ -210,6 +232,28 @@ public class NativePurchasesPlugin: CAPPlugin, CAPBridgedPlugin {
210
232
  purchaseData["receipt"] = receiptBase64
211
233
  }
212
234
 
235
+ // Add detailed transaction information
236
+ purchaseData["productIdentifier"] = transaction.productID
237
+ purchaseData["purchaseDate"] = ISO8601DateFormatter().string(from: transaction.purchaseDate)
238
+ purchaseData["productType"] = transaction.productType == .autoRenewable ? "subs" : "inapp"
239
+
240
+ // Add subscription-specific information
241
+ if transaction.productType == .autoRenewable {
242
+ purchaseData["originalPurchaseDate"] = ISO8601DateFormatter().string(from: transaction.originalPurchaseDate)
243
+ if let expirationDate = transaction.expirationDate {
244
+ purchaseData["expirationDate"] = ISO8601DateFormatter().string(from: expirationDate)
245
+ let isActive = expirationDate > Date()
246
+ purchaseData["isActive"] = isActive
247
+ }
248
+ }
249
+
250
+ // Add cancellation information
251
+ if let revocationDate = transaction.revocationDate {
252
+ purchaseData["willCancel"] = ISO8601DateFormatter().string(from: revocationDate)
253
+ } else {
254
+ purchaseData["willCancel"] = nil
255
+ }
256
+
213
257
  allPurchases.append(purchaseData)
214
258
  }
215
259
  }
@@ -238,6 +282,28 @@ public class NativePurchasesPlugin: CAPPlugin, CAPBridgedPlugin {
238
282
  purchaseData["receipt"] = receiptBase64
239
283
  }
240
284
 
285
+ // Add detailed transaction information
286
+ purchaseData["productIdentifier"] = transaction.productID
287
+ purchaseData["purchaseDate"] = ISO8601DateFormatter().string(from: transaction.purchaseDate)
288
+ purchaseData["productType"] = transaction.productType == .autoRenewable ? "subs" : "inapp"
289
+
290
+ // Add subscription-specific information
291
+ if transaction.productType == .autoRenewable {
292
+ purchaseData["originalPurchaseDate"] = ISO8601DateFormatter().string(from: transaction.originalPurchaseDate)
293
+ if let expirationDate = transaction.expirationDate {
294
+ purchaseData["expirationDate"] = ISO8601DateFormatter().string(from: expirationDate)
295
+ let isActive = expirationDate > Date()
296
+ purchaseData["isActive"] = isActive
297
+ }
298
+ }
299
+
300
+ // Add cancellation information
301
+ if let revocationDate = transaction.revocationDate {
302
+ purchaseData["willCancel"] = ISO8601DateFormatter().string(from: revocationDate)
303
+ } else {
304
+ purchaseData["willCancel"] = nil
305
+ }
306
+
241
307
  allPurchases.append(purchaseData)
242
308
  }
243
309
  }
@@ -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.3.2",
3
+ "version": "7.5.2",
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>