@capgo/native-purchases 0.0.29 → 0.0.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -72,14 +72,14 @@ Started purchase process for the given product.
72
72
  ### getProducts(...)
73
73
 
74
74
  ```typescript
75
- getProducts(options: { productIdentifiers: string[]; productType?: PURCHASE_TYPE; }) => any
75
+ getProducts(options: { productIdentifiers: string[]; planIdentifier?: string; productType?: PURCHASE_TYPE; }) => any
76
76
  ```
77
77
 
78
78
  Gets the product info associated with a list of product identifiers.
79
79
 
80
- | Param | Type | Description |
81
- | ------------- | -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------- |
82
- | **`options`** | <code>{ productIdentifiers: {}; productType?: <a href="#purchase_type">PURCHASE_TYPE</a>; }</code> | - The product identifiers you wish to retrieve information for |
80
+ | Param | Type | Description |
81
+ | ------------- | --------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------- |
82
+ | **`options`** | <code>{ productIdentifiers: {}; planIdentifier?: string; productType?: <a href="#purchase_type">PURCHASE_TYPE</a>; }</code> | - The product identifiers you wish to retrieve information for |
83
83
 
84
84
  **Returns:** <code>any</code>
85
85
 
@@ -209,61 +209,67 @@ public class NativePurchasesPlugin extends Plugin {
209
209
  .setProductList(productList)
210
210
  .build();
211
211
  this.initBillingClient(call);
212
- billingClient.queryProductDetailsAsync(
213
- params,
214
- new ProductDetailsResponseListener() {
215
- public void onProductDetailsResponse(
216
- BillingResult billingResult,
217
- List<ProductDetails> productDetailsList
218
- ) {
219
- if (productDetailsList.size() == 0) {
220
- billingClient.endConnection();
221
- billingClient = null;
222
- call.reject("Product not found");
223
- return;
224
- }
225
- // Process the result
226
- List<BillingFlowParams.ProductDetailsParams> productDetailsParamsList = new ArrayList<>();
227
- for (ProductDetails productDetailsItem : productDetailsList) {
228
- BillingFlowParams.ProductDetailsParams.Builder productDetailsParams = BillingFlowParams.ProductDetailsParams
229
- .newBuilder()
230
- .setProductDetails(productDetailsItem);
231
- if (productType.equals("subs")) {
232
- // list the SubscriptionOfferDetails and find the one who match the planIdentifier if not found get the first one
233
- ProductDetails.SubscriptionOfferDetails selectedOfferDetails =
234
- null;
235
- for (ProductDetails.SubscriptionOfferDetails offerDetails : productDetailsItem.getSubscriptionOfferDetails()) {
236
- if (offerDetails.getOfferId().equals(planIdentifier)) {
237
- selectedOfferDetails = offerDetails;
238
- break;
212
+ try {
213
+ billingClient.queryProductDetailsAsync(
214
+ params,
215
+ new ProductDetailsResponseListener() {
216
+ public void onProductDetailsResponse(
217
+ BillingResult billingResult,
218
+ List<ProductDetails> productDetailsList
219
+ ) {
220
+ if (productDetailsList.size() == 0) {
221
+ billingClient.endConnection();
222
+ billingClient = null;
223
+ call.reject("Product not found");
224
+ return;
225
+ }
226
+ // Process the result
227
+ List<BillingFlowParams.ProductDetailsParams> productDetailsParamsList = new ArrayList<>();
228
+ for (ProductDetails productDetailsItem : productDetailsList) {
229
+ BillingFlowParams.ProductDetailsParams.Builder productDetailsParams = BillingFlowParams.ProductDetailsParams
230
+ .newBuilder()
231
+ .setProductDetails(productDetailsItem);
232
+ if (productType.equals("subs")) {
233
+ // list the SubscriptionOfferDetails and find the one who match the planIdentifier if not found get the first one
234
+ ProductDetails.SubscriptionOfferDetails selectedOfferDetails =
235
+ null;
236
+ for (ProductDetails.SubscriptionOfferDetails offerDetails : productDetailsItem.getSubscriptionOfferDetails()) {
237
+ if (offerDetails.getOfferId().equals(planIdentifier)) {
238
+ selectedOfferDetails = offerDetails;
239
+ break;
240
+ }
239
241
  }
242
+ if (selectedOfferDetails == null) {
243
+ selectedOfferDetails =
244
+ productDetailsItem.getSubscriptionOfferDetails().get(0);
245
+ }
246
+ productDetailsParams.setOfferToken(
247
+ selectedOfferDetails.getOfferToken()
248
+ );
240
249
  }
241
- if (selectedOfferDetails == null) {
242
- selectedOfferDetails =
243
- productDetailsItem.getSubscriptionOfferDetails().get(0);
244
- }
245
- productDetailsParams.setOfferToken(
246
- selectedOfferDetails.getOfferToken()
247
- );
250
+ productDetailsParamsList.add(productDetailsParams.build());
248
251
  }
249
- productDetailsParamsList.add(productDetailsParams.build());
252
+ BillingFlowParams billingFlowParams = BillingFlowParams
253
+ .newBuilder()
254
+ .setProductDetailsParamsList(productDetailsParamsList)
255
+ .build();
256
+ // Launch the billing flow
257
+ BillingResult billingResult2 = billingClient.launchBillingFlow(
258
+ getActivity(),
259
+ billingFlowParams
260
+ );
261
+ Log.i(
262
+ "NativePurchases",
263
+ "onProductDetailsResponse2" + billingResult2
264
+ );
250
265
  }
251
- BillingFlowParams billingFlowParams = BillingFlowParams
252
- .newBuilder()
253
- .setProductDetailsParamsList(productDetailsParamsList)
254
- .build();
255
- // Launch the billing flow
256
- BillingResult billingResult2 = billingClient.launchBillingFlow(
257
- getActivity(),
258
- billingFlowParams
259
- );
260
- Log.i(
261
- "NativePurchases",
262
- "onProductDetailsResponse2" + billingResult2
263
- );
264
266
  }
265
- }
266
- );
267
+ );
268
+ } catch (Exception e) {
269
+ billingClient.endConnection();
270
+ billingClient = null;
271
+ call.reject(e.getMessage());
272
+ }
267
273
  }
268
274
 
269
275
  @PluginMethod
@@ -283,7 +289,9 @@ public class NativePurchasesPlugin extends Plugin {
283
289
  call.reject("planIdentifier cannot be empty if productType is subs");
284
290
  return;
285
291
  }
286
- if (productIdentifiersArray == null || productIdentifiersArray.length() == 0) {
292
+ if (
293
+ productIdentifiersArray == null || productIdentifiersArray.length() == 0
294
+ ) {
287
295
  call.reject("productIdentifiers array missing");
288
296
  return;
289
297
  }
@@ -319,109 +327,117 @@ public class NativePurchasesPlugin extends Plugin {
319
327
  .setProductList(productList)
320
328
  .build();
321
329
  this.initBillingClient(call);
322
- billingClient.queryProductDetailsAsync(
323
- params,
324
- new ProductDetailsResponseListener() {
325
- public void onProductDetailsResponse(
326
- BillingResult billingResult,
327
- List<ProductDetails> productDetailsList
328
- ) {
329
- if (productDetailsList.size() == 0) {
330
- billingClient.endConnection();
331
- billingClient = null;
332
- call.reject("Product not found");
333
- return;
334
- }
335
- Log.i(
336
- "NativePurchases",
337
- "onProductDetailsResponse" + billingResult + productDetailsList
338
- );
339
- // Process the result
340
- JSObject ret = new JSObject();
341
- JSONArray products = new JSONArray();
342
- Number productIdIndex = 0;
343
- for (ProductDetails productDetails : productDetailsList) {
344
- JSObject product = new JSObject();
345
- product.put("identifier", productDetails.getProductId());
346
- product.put("title", productDetails.getTitle());
347
- product.put("description", productDetails.getDescription());
348
- if (productType.equals("inapp")) {
349
- product.put(
350
- "price",
351
- productDetails
352
- .getOneTimePurchaseOfferDetails()
353
- .getPriceAmountMicros() /
354
- 1000000.0
355
- );
356
- product.put(
357
- "priceString",
358
- productDetails
359
- .getOneTimePurchaseOfferDetails()
360
- .getFormattedPrice()
361
- );
362
- product.put(
363
- "currencyCode",
364
- productDetails
365
- .getOneTimePurchaseOfferDetails()
366
- .getPriceCurrencyCode()
367
- );
368
- } else {
369
- // productIdIndex is used to get the correct SubscriptionOfferDetails by productIdentifiersArray index and increment it
370
- String subscriptionOfferIdentifier = productIdentifiers.get(
371
- productIdIndex.intValue()
372
- );
373
- productIdIndex = productIdIndex.intValue() + 1;
374
- // get the SubscriptionOfferDetails who match the subscriptionOfferIdentifier
375
- ProductDetails.SubscriptionOfferDetails selectedOfferDetails =
376
- null;
377
- for (ProductDetails.SubscriptionOfferDetails offerDetails : productDetails.getSubscriptionOfferDetails()) {
378
- if (
379
- offerDetails.getOfferId().equals(subscriptionOfferIdentifier)
380
- ) {
381
- selectedOfferDetails = offerDetails;
382
- break;
330
+ try {
331
+ billingClient.queryProductDetailsAsync(
332
+ params,
333
+ new ProductDetailsResponseListener() {
334
+ public void onProductDetailsResponse(
335
+ BillingResult billingResult,
336
+ List<ProductDetails> productDetailsList
337
+ ) {
338
+ if (productDetailsList.size() == 0) {
339
+ billingClient.endConnection();
340
+ billingClient = null;
341
+ call.reject("Product not found");
342
+ return;
343
+ }
344
+ Log.i(
345
+ "NativePurchases",
346
+ "onProductDetailsResponse" + billingResult + productDetailsList
347
+ );
348
+ // Process the result
349
+ JSObject ret = new JSObject();
350
+ JSONArray products = new JSONArray();
351
+ Number productIdIndex = 0;
352
+ for (ProductDetails productDetails : productDetailsList) {
353
+ JSObject product = new JSObject();
354
+ product.put("identifier", productDetails.getProductId());
355
+ product.put("title", productDetails.getTitle());
356
+ product.put("description", productDetails.getDescription());
357
+ if (productType.equals("inapp")) {
358
+ product.put(
359
+ "price",
360
+ productDetails
361
+ .getOneTimePurchaseOfferDetails()
362
+ .getPriceAmountMicros() /
363
+ 1000000.0
364
+ );
365
+ product.put(
366
+ "priceString",
367
+ productDetails
368
+ .getOneTimePurchaseOfferDetails()
369
+ .getFormattedPrice()
370
+ );
371
+ product.put(
372
+ "currencyCode",
373
+ productDetails
374
+ .getOneTimePurchaseOfferDetails()
375
+ .getPriceCurrencyCode()
376
+ );
377
+ } else {
378
+ // productIdIndex is used to get the correct SubscriptionOfferDetails by productIdentifiersArray index and increment it
379
+ String subscriptionOfferIdentifier = productIdentifiers.get(
380
+ productIdIndex.intValue()
381
+ );
382
+ productIdIndex = productIdIndex.intValue() + 1;
383
+ // get the SubscriptionOfferDetails who match the subscriptionOfferIdentifier
384
+ ProductDetails.SubscriptionOfferDetails selectedOfferDetails =
385
+ null;
386
+ for (ProductDetails.SubscriptionOfferDetails offerDetails : productDetails.getSubscriptionOfferDetails()) {
387
+ if (
388
+ offerDetails
389
+ .getOfferId()
390
+ .equals(subscriptionOfferIdentifier)
391
+ ) {
392
+ selectedOfferDetails = offerDetails;
393
+ break;
394
+ }
383
395
  }
396
+ if (selectedOfferDetails == null) {
397
+ selectedOfferDetails =
398
+ productDetails.getSubscriptionOfferDetails().get(0);
399
+ }
400
+ product.put(
401
+ "price",
402
+ selectedOfferDetails
403
+ .getPricingPhases()
404
+ .getPricingPhaseList()
405
+ .get(0)
406
+ .getPriceAmountMicros() /
407
+ 1000000.0
408
+ );
409
+ product.put(
410
+ "priceString",
411
+ selectedOfferDetails
412
+ .getPricingPhases()
413
+ .getPricingPhaseList()
414
+ .get(0)
415
+ .getFormattedPrice()
416
+ );
417
+ product.put(
418
+ "currencyCode",
419
+ selectedOfferDetails
420
+ .getPricingPhases()
421
+ .getPricingPhaseList()
422
+ .get(0)
423
+ .getPriceCurrencyCode()
424
+ );
384
425
  }
385
- if (selectedOfferDetails == null) {
386
- selectedOfferDetails =
387
- productDetails.getSubscriptionOfferDetails().get(0);
388
- }
389
- product.put(
390
- "price",
391
- selectedOfferDetails
392
- .getPricingPhases()
393
- .getPricingPhaseList()
394
- .get(0)
395
- .getPriceAmountMicros() /
396
- 1000000.0
397
- );
398
- product.put(
399
- "priceString",
400
- selectedOfferDetails
401
- .getPricingPhases()
402
- .getPricingPhaseList()
403
- .get(0)
404
- .getFormattedPrice()
405
- );
406
- product.put(
407
- "currencyCode",
408
- selectedOfferDetails
409
- .getPricingPhases()
410
- .getPricingPhaseList()
411
- .get(0)
412
- .getPriceCurrencyCode()
413
- );
414
- }
415
426
 
416
- product.put("isFamilyShareable", false);
417
- products.put(product);
427
+ product.put("isFamilyShareable", false);
428
+ products.put(product);
429
+ }
430
+ ret.put("products", products);
431
+ billingClient.endConnection();
432
+ billingClient = null;
433
+ call.resolve(ret);
418
434
  }
419
- ret.put("products", products);
420
- billingClient.endConnection();
421
- billingClient = null;
422
- call.resolve(ret);
423
435
  }
424
- }
425
- );
436
+ );
437
+ } catch (Exception e) {
438
+ billingClient.endConnection();
439
+ billingClient = null;
440
+ call.reject(e.getMessage());
441
+ }
426
442
  }
427
443
  }
package/dist/docs.json CHANGED
@@ -43,7 +43,7 @@
43
43
  },
44
44
  {
45
45
  "name": "param",
46
- "text": "options.planIdentifier - Only Android, the identifier of the plan you want to purchase."
46
+ "text": "options.planIdentifier - Only Android, the identifier of the plan you want to purchase, require for for subs."
47
47
  },
48
48
  {
49
49
  "name": "param",
@@ -59,12 +59,12 @@
59
59
  },
60
60
  {
61
61
  "name": "getProducts",
62
- "signature": "(options: { productIdentifiers: string[]; productType?: PURCHASE_TYPE; }) => any",
62
+ "signature": "(options: { productIdentifiers: string[]; planIdentifier?: string; productType?: PURCHASE_TYPE; }) => any",
63
63
  "parameters": [
64
64
  {
65
65
  "name": "options",
66
66
  "docs": "- The product identifiers you wish to retrieve information for",
67
- "type": "{ productIdentifiers: {}; productType?: PURCHASE_TYPE | undefined; }"
67
+ "type": "{ productIdentifiers: {}; planIdentifier?: string | undefined; productType?: PURCHASE_TYPE | undefined; }"
68
68
  }
69
69
  ],
70
70
  "returns": "any",
@@ -77,6 +77,10 @@
77
77
  "name": "param",
78
78
  "text": "options.productIdentifiers - Array of product identifiers"
79
79
  },
80
+ {
81
+ "name": "param",
82
+ "text": "options.planIdentifier - Only Android, the identifier of the plan you want to purchase, require for for subs."
83
+ },
80
84
  {
81
85
  "name": "param",
82
86
  "text": "options.productType - Only Android, the type of product, can be inapp or subs. Will use inapp by default."
@@ -289,7 +289,7 @@ export interface NativePurchasesPlugin {
289
289
  * @param options - The product to purchase
290
290
  * @param options.productIdentifier - The product identifier of the product you want to purchase.
291
291
  * @param options.productType - Only Android, the type of product, can be inapp or subs. Will use inapp by default.
292
- * @param options.planIdentifier - Only Android, the identifier of the plan you want to purchase.
292
+ * @param options.planIdentifier - Only Android, the identifier of the plan you want to purchase, require for for subs.
293
293
  * @param options.quantity - Only iOS, the number of items you wish to purchase. Will use 1 by default.
294
294
  */
295
295
  purchaseProduct(options: {
@@ -303,11 +303,13 @@ export interface NativePurchasesPlugin {
303
303
  *
304
304
  * @param options - The product identifiers you wish to retrieve information for
305
305
  * @param options.productIdentifiers - Array of product identifiers
306
+ * @param options.planIdentifier - Only Android, the identifier of the plan you want to purchase, require for for subs.
306
307
  * @param options.productType - Only Android, the type of product, can be inapp or subs. Will use inapp by default.
307
308
  * @returns - The requested product info
308
309
  */
309
310
  getProducts(options: {
310
311
  productIdentifiers: string[];
312
+ planIdentifier?: string;
311
313
  productType?: PURCHASE_TYPE;
312
314
  }): Promise<{
313
315
  products: Product[];
@@ -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 * 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 CustomerInfo {\n /**\n * Set of active subscription skus\n */\n readonly activeSubscriptions: [string];\n /**\n * Set of purchased skus, active and inactive\n */\n readonly allPurchasedProductIdentifiers: [string];\n /**\n * Returns all the non-subscription a user has made.\n * The are ordered by purchase date in ascending order.\n */\n readonly nonSubscriptionTransactions: Transaction[];\n /**\n * The latest expiration date of all purchased skus\n */\n readonly latestExpirationDate: string | null;\n /**\n * The date this user was first seen in RevenueCat.\n */\n readonly firstSeen: string;\n /**\n * The original App User Id recorded for this user.\n */\n readonly originalAppUserId: string;\n /**\n * Date when this info was requested\n */\n readonly requestDate: string;\n /**\n * Returns the version number for the version of the application when the\n * user bought the app. Use this for grandfathering users when migrating\n * to subscriptions.\n *\n * This corresponds to the value of CFBundleVersion (in iOS) in the\n * Info.plist file when the purchase was originally made. This is always null\n * in Android\n */\n readonly originalApplicationVersion: string | null;\n /**\n * Returns the purchase date for the version of the application when the user bought the app.\n * Use this for grandfathering users when migrating to subscriptions.\n */\n readonly originalPurchaseDate: string | null;\n /**\n * URL to manage the active subscription of the user. If this user has an active iOS\n * subscription, this will point to the App Store, if the user has an active Play Store subscription\n * it will point there. If there are no active subscriptions it will be null.\n * If there are multiple for different platforms, it will point to the device store.\n */\n readonly managementURL: string | null;\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<{ customerInfo: CustomerInfo }>;\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.\n * @param options.quantity - Only iOS, the number of items you wish to purchase. Will use 1 by default.\n */\n purchaseProduct(options: {\n productIdentifier: string;\n planIdentifier?: string;\n productType?: PURCHASE_TYPE;\n quantity?: number;\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 * 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"]}
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 * 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 CustomerInfo {\n /**\n * Set of active subscription skus\n */\n readonly activeSubscriptions: [string];\n /**\n * Set of purchased skus, active and inactive\n */\n readonly allPurchasedProductIdentifiers: [string];\n /**\n * Returns all the non-subscription a user has made.\n * The are ordered by purchase date in ascending order.\n */\n readonly nonSubscriptionTransactions: Transaction[];\n /**\n * The latest expiration date of all purchased skus\n */\n readonly latestExpirationDate: string | null;\n /**\n * The date this user was first seen in RevenueCat.\n */\n readonly firstSeen: string;\n /**\n * The original App User Id recorded for this user.\n */\n readonly originalAppUserId: string;\n /**\n * Date when this info was requested\n */\n readonly requestDate: string;\n /**\n * Returns the version number for the version of the application when the\n * user bought the app. Use this for grandfathering users when migrating\n * to subscriptions.\n *\n * This corresponds to the value of CFBundleVersion (in iOS) in the\n * Info.plist file when the purchase was originally made. This is always null\n * in Android\n */\n readonly originalApplicationVersion: string | null;\n /**\n * Returns the purchase date for the version of the application when the user bought the app.\n * Use this for grandfathering users when migrating to subscriptions.\n */\n readonly originalPurchaseDate: string | null;\n /**\n * URL to manage the active subscription of the user. If this user has an active iOS\n * subscription, this will point to the App Store, if the user has an active Play Store subscription\n * it will point there. If there are no active subscriptions it will be null.\n * If there are multiple for different platforms, it will point to the device store.\n */\n readonly managementURL: string | null;\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<{ customerInfo: CustomerInfo }>;\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 */\n purchaseProduct(options: {\n productIdentifier: string;\n planIdentifier?: string;\n productType?: PURCHASE_TYPE;\n quantity?: number;\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.planIdentifier - Only Android, the identifier of the plan you want to purchase, require for for subs.\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 planIdentifier?: string;\n productType?: PURCHASE_TYPE;\n }): Promise<{ products: 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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/native-purchases",
3
- "version": "0.0.29",
3
+ "version": "0.0.31",
4
4
  "description": "In-app Subscriptions Made Easy",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",