@revenuecat/purchases-js 0.2.2 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Purchases.es.d.ts +210 -69
- package/dist/Purchases.es.js +1546 -1362
- package/dist/Purchases.umd.js +4 -4
- package/dist/style.css +1 -1
- package/package.json +2 -2
package/dist/Purchases.es.d.ts
CHANGED
|
@@ -341,6 +341,21 @@ export declare enum PackageType {
|
|
|
341
341
|
Weekly = "$rc_weekly"
|
|
342
342
|
}
|
|
343
343
|
|
|
344
|
+
/**
|
|
345
|
+
* Represents a period of time.
|
|
346
|
+
* @public
|
|
347
|
+
*/
|
|
348
|
+
export declare interface Period {
|
|
349
|
+
/**
|
|
350
|
+
* The number of units in the period.
|
|
351
|
+
*/
|
|
352
|
+
number: number;
|
|
353
|
+
/**
|
|
354
|
+
* The unit of time.
|
|
355
|
+
*/
|
|
356
|
+
unit: PeriodUnit;
|
|
357
|
+
}
|
|
358
|
+
|
|
344
359
|
/**
|
|
345
360
|
* Supported period types for an entitlement.
|
|
346
361
|
* - "normal" If the entitlement is not under an introductory or trial period.
|
|
@@ -350,6 +365,17 @@ export declare enum PackageType {
|
|
|
350
365
|
*/
|
|
351
366
|
export declare type PeriodType = "normal" | "intro" | "trial";
|
|
352
367
|
|
|
368
|
+
/**
|
|
369
|
+
* Represents a unit of time.
|
|
370
|
+
* @public
|
|
371
|
+
*/
|
|
372
|
+
export declare enum PeriodUnit {
|
|
373
|
+
Year = "year",
|
|
374
|
+
Month = "month",
|
|
375
|
+
Week = "week",
|
|
376
|
+
Day = "day"
|
|
377
|
+
}
|
|
378
|
+
|
|
353
379
|
/**
|
|
354
380
|
* Price information for a product.
|
|
355
381
|
* @public
|
|
@@ -372,6 +398,31 @@ export declare interface Price {
|
|
|
372
398
|
readonly formattedPrice: string;
|
|
373
399
|
}
|
|
374
400
|
|
|
401
|
+
/**
|
|
402
|
+
* Represents the price and duration information for a phase of the purchase option.
|
|
403
|
+
* @public
|
|
404
|
+
*/
|
|
405
|
+
export declare interface PricingPhase {
|
|
406
|
+
/**
|
|
407
|
+
* The duration of the phase in ISO 8601 format.
|
|
408
|
+
*/
|
|
409
|
+
readonly periodDuration: string | null;
|
|
410
|
+
/**
|
|
411
|
+
* The duration of the phase as a {@link Period}.
|
|
412
|
+
*/
|
|
413
|
+
readonly period: Period | null;
|
|
414
|
+
/**
|
|
415
|
+
* The price for the purchase option.
|
|
416
|
+
* Null in case of trials.
|
|
417
|
+
*/
|
|
418
|
+
readonly price: Price | null;
|
|
419
|
+
/**
|
|
420
|
+
* The number of cycles this option's price repeats.
|
|
421
|
+
* I.e. 2 subscription cycles, 0 if not applicable.
|
|
422
|
+
*/
|
|
423
|
+
readonly cycleCount: number;
|
|
424
|
+
}
|
|
425
|
+
|
|
375
426
|
/**
|
|
376
427
|
* Represents product's listing details.
|
|
377
428
|
* @public
|
|
@@ -383,20 +434,80 @@ export declare interface Product {
|
|
|
383
434
|
readonly identifier: string;
|
|
384
435
|
/**
|
|
385
436
|
* Name of the product.
|
|
437
|
+
* @deprecated - Use {@link Product.title} instead.
|
|
386
438
|
*/
|
|
387
439
|
readonly displayName: string;
|
|
388
440
|
/**
|
|
389
|
-
*
|
|
441
|
+
* The title of the product as configured in the RevenueCat dashboard.
|
|
442
|
+
*/
|
|
443
|
+
readonly title: string;
|
|
444
|
+
/**
|
|
445
|
+
* The description of the product as configured in the RevenueCat dashboard.
|
|
446
|
+
*/
|
|
447
|
+
readonly description: string | null;
|
|
448
|
+
/**
|
|
449
|
+
* Price of the product. In the case of subscriptions, this will match the
|
|
450
|
+
* default option's base phase price.
|
|
390
451
|
*/
|
|
391
452
|
readonly currentPrice: Price;
|
|
392
453
|
/**
|
|
393
|
-
* The period duration for a subscription product.
|
|
454
|
+
* The period duration for a subscription product. This will match the default
|
|
455
|
+
* option's base phase period duration.
|
|
394
456
|
*/
|
|
395
457
|
readonly normalPeriodDuration: string | null;
|
|
396
458
|
/**
|
|
397
459
|
* The offering ID used to obtain this product.
|
|
398
460
|
*/
|
|
399
461
|
readonly presentedOfferingIdentifier: string;
|
|
462
|
+
/**
|
|
463
|
+
* The default subscription option for this product. Null if no subscription
|
|
464
|
+
* options are available like in the case of consumables and non-consumables.
|
|
465
|
+
*/
|
|
466
|
+
readonly defaultSubscriptionOption: SubscriptionOption | null;
|
|
467
|
+
/**
|
|
468
|
+
* A dictionary with all the possible subscription options available for this
|
|
469
|
+
* product. Each key contains the key to be used when executing a purchase.
|
|
470
|
+
*
|
|
471
|
+
* If retrieved through getOfferings the offers are only the ones the customer is
|
|
472
|
+
* entitled to.
|
|
473
|
+
*/
|
|
474
|
+
readonly subscriptionOptions: {
|
|
475
|
+
[optionId: string]: SubscriptionOption;
|
|
476
|
+
};
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
/**
|
|
480
|
+
* Represents a possible option to purchase a product.
|
|
481
|
+
* @public
|
|
482
|
+
*/
|
|
483
|
+
export declare interface PurchaseOption {
|
|
484
|
+
/**
|
|
485
|
+
* The unique id for a purchase option
|
|
486
|
+
*/
|
|
487
|
+
readonly id: string;
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
/**
|
|
491
|
+
* Parameters used to customise the purchase flow when invoking the `.purchase` method.
|
|
492
|
+
* @public
|
|
493
|
+
*/
|
|
494
|
+
export declare interface PurchaseParams {
|
|
495
|
+
/**
|
|
496
|
+
* The package you want to purchase. Obtained from {@link Purchases.getOfferings}.
|
|
497
|
+
*/
|
|
498
|
+
rcPackage: Package;
|
|
499
|
+
/**
|
|
500
|
+
* The option to be used for this purchase. If not specified or null the default one will be used.
|
|
501
|
+
*/
|
|
502
|
+
purchaseOption?: PurchaseOption | null;
|
|
503
|
+
/**
|
|
504
|
+
* The HTML element where the billing view should be added. If undefined, a new div will be created at the root of the page and appended to the body.
|
|
505
|
+
*/
|
|
506
|
+
htmlTarget?: HTMLElement;
|
|
507
|
+
/**
|
|
508
|
+
* The email of the user. If undefined, RevenueCat will ask the customer for their email.
|
|
509
|
+
*/
|
|
510
|
+
customerEmail?: string;
|
|
400
511
|
}
|
|
401
512
|
|
|
402
513
|
/**
|
|
@@ -451,87 +562,117 @@ export declare class Purchases {
|
|
|
451
562
|
* package from {@link Purchases.getOfferings}. This method will present the purchase
|
|
452
563
|
* form on your site, using the given HTML element as the mount point, if
|
|
453
564
|
* provided, or as a modal if not.
|
|
565
|
+
* @deprecated - please use .purchase
|
|
454
566
|
* @param rcPackage - The package you want to purchase. Obtained from {@link Purchases.getOfferings}.
|
|
455
|
-
* @param customerEmail - The email of the user. If
|
|
456
|
-
* @param htmlTarget - The HTML element where the billing view should be added. If
|
|
457
|
-
* @returns
|
|
567
|
+
* @param customerEmail - The email of the user. If undefined, RevenueCat will ask the customer for their email.
|
|
568
|
+
* @param htmlTarget - The HTML element where the billing view should be added. If undefined, a new div will be created at the root of the page and appended to the body.
|
|
569
|
+
* @returns a Promise for the customer info after the purchase is completed successfully.
|
|
458
570
|
* @throws {@link PurchasesError} if there is an error while performing the purchase. If the {@link PurchasesError.errorCode} is {@link ErrorCode.UserCancelledError}, the user cancelled the purchase.
|
|
459
571
|
*/
|
|
460
572
|
purchasePackage(rcPackage: Package, customerEmail?: string, htmlTarget?: HTMLElement): Promise<{
|
|
461
573
|
customerInfo: CustomerInfo;
|
|
462
574
|
}>;
|
|
463
575
|
/**
|
|
464
|
-
*
|
|
465
|
-
*
|
|
466
|
-
*
|
|
576
|
+
* Method to perform a purchase for a given package. You can obtain the
|
|
577
|
+
* package from {@link Purchases.getOfferings}. This method will present the purchase
|
|
578
|
+
* form on your site, using the given HTML element as the mount point, if
|
|
579
|
+
* provided, or as a modal if not.
|
|
580
|
+
* @param params - The parameters object to customise the purchase flow. Check {@link PurchaseParams}
|
|
581
|
+
* @returns a Promise for the customer info after the purchase is completed successfully.
|
|
582
|
+
* @throws {@link PurchasesError} if there is an error while performing the purchase. If the {@link PurchasesError.errorCode} is {@link ErrorCode.UserCancelledError}, the user cancelled the purchase.
|
|
467
583
|
*/
|
|
468
|
-
|
|
584
|
+
purchase(params: PurchaseParams): Promise<{
|
|
585
|
+
customerInfo: CustomerInfo;
|
|
586
|
+
}>;
|
|
469
587
|
/**
|
|
470
|
-
* Gets
|
|
471
|
-
|
|
472
|
-
|
|
588
|
+
* Gets latest available {@link CustomerInfo}.
|
|
589
|
+
* @returns The latest {@link CustomerInfo}.
|
|
590
|
+
* @throws {@link PurchasesError} if there is an error while fetching the customer info.
|
|
591
|
+
*/
|
|
592
|
+
getCustomerInfo(): Promise<CustomerInfo>;
|
|
593
|
+
/**
|
|
594
|
+
* Gets the current app user id.
|
|
595
|
+
*/
|
|
596
|
+
getAppUserId(): string;
|
|
597
|
+
/**
|
|
598
|
+
* Change the current app user id. Returns the customer info for the new
|
|
599
|
+
* user id.
|
|
600
|
+
* @param newAppUserId - The user id to change to.
|
|
601
|
+
*/
|
|
602
|
+
changeUser(newAppUserId: string): Promise<CustomerInfo>;
|
|
603
|
+
/**
|
|
604
|
+
* @returns Whether the SDK is using a sandbox API Key.
|
|
605
|
+
*/
|
|
606
|
+
isSandbox(): boolean;
|
|
607
|
+
/**
|
|
608
|
+
* Closes the Purchases instance. You should never have to do this normally.
|
|
609
|
+
*/
|
|
610
|
+
close(): void;
|
|
611
|
+
}
|
|
612
|
+
|
|
473
613
|
/**
|
|
474
|
-
*
|
|
475
|
-
*
|
|
476
|
-
* @
|
|
614
|
+
* Error class for Purchases SDK. You should handle these errors and react
|
|
615
|
+
* accordingly in your app.
|
|
616
|
+
* @public
|
|
477
617
|
*/
|
|
478
|
-
|
|
618
|
+
export declare class PurchasesError extends Error {
|
|
619
|
+
/**
|
|
620
|
+
* Error code for the error. This is useful to appropriately react to
|
|
621
|
+
* different error situations.
|
|
622
|
+
*/
|
|
623
|
+
readonly errorCode: ErrorCode;
|
|
624
|
+
/**
|
|
625
|
+
* Underlying error message. This provides more details on the error and
|
|
626
|
+
* can be useful for debugging and logging.
|
|
627
|
+
*/
|
|
628
|
+
readonly underlyingErrorMessage?: string | null | undefined;
|
|
629
|
+
constructor(
|
|
630
|
+
/**
|
|
631
|
+
* Error code for the error. This is useful to appropriately react to
|
|
632
|
+
* different error situations.
|
|
633
|
+
*/
|
|
634
|
+
errorCode: ErrorCode,
|
|
635
|
+
/**
|
|
636
|
+
* Message for the error. This is useful for debugging and logging.
|
|
637
|
+
*/
|
|
638
|
+
message?: string,
|
|
639
|
+
/**
|
|
640
|
+
* Underlying error message. This provides more details on the error and
|
|
641
|
+
* can be useful for debugging and logging.
|
|
642
|
+
*/
|
|
643
|
+
underlyingErrorMessage?: string | null | undefined);
|
|
644
|
+
toString: () => string;
|
|
645
|
+
}
|
|
646
|
+
|
|
479
647
|
/**
|
|
480
|
-
*
|
|
648
|
+
* The store where the user originally subscribed.
|
|
649
|
+
* @public
|
|
481
650
|
*/
|
|
482
|
-
|
|
651
|
+
export declare type Store = "app_store" | "mac_app_store" | "play_store" | "amazon" | "stripe" | "rc_billing" | "promotional" | "unknown";
|
|
652
|
+
|
|
483
653
|
/**
|
|
484
|
-
*
|
|
654
|
+
* Represents a possible option to purchase a subscription product.
|
|
655
|
+
* @public
|
|
485
656
|
*/
|
|
486
|
-
|
|
487
|
-
|
|
657
|
+
export declare interface SubscriptionOption extends PurchaseOption {
|
|
658
|
+
/**
|
|
659
|
+
* The base phase for a SubscriptionOption, represents
|
|
660
|
+
* the price that the customer will be charged after all the discounts have
|
|
661
|
+
* been consumed and the period at which it will renew.
|
|
662
|
+
*/
|
|
663
|
+
readonly base: PricingPhase;
|
|
664
|
+
/**
|
|
665
|
+
* The trial information for this subscription option if available.
|
|
666
|
+
*/
|
|
667
|
+
readonly trial: PricingPhase | null;
|
|
668
|
+
}
|
|
488
669
|
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
* Error code for the error. This is useful to appropriately react to
|
|
497
|
-
* different error situations.
|
|
498
|
-
*/
|
|
499
|
-
readonly errorCode: ErrorCode;
|
|
500
|
-
/**
|
|
501
|
-
* Underlying error message. This provides more details on the error and
|
|
502
|
-
* can be useful for debugging and logging.
|
|
503
|
-
*/
|
|
504
|
-
readonly underlyingErrorMessage?: string | null | undefined;
|
|
505
|
-
constructor(
|
|
506
|
-
/**
|
|
507
|
-
* Error code for the error. This is useful to appropriately react to
|
|
508
|
-
* different error situations.
|
|
509
|
-
*/
|
|
510
|
-
errorCode: ErrorCode,
|
|
511
|
-
/**
|
|
512
|
-
* Message for the error. This is useful for debugging and logging.
|
|
513
|
-
*/
|
|
514
|
-
message?: string,
|
|
515
|
-
/**
|
|
516
|
-
* Underlying error message. This provides more details on the error and
|
|
517
|
-
* can be useful for debugging and logging.
|
|
518
|
-
*/
|
|
519
|
-
underlyingErrorMessage?: string | null | undefined);
|
|
520
|
-
toString: () => string;
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
/**
|
|
524
|
-
* The store where the user originally subscribed.
|
|
525
|
-
* @public
|
|
526
|
-
*/
|
|
527
|
-
export declare type Store = "app_store" | "mac_app_store" | "play_store" | "amazon" | "stripe" | "rc_billing" | "promotional" | "unknown";
|
|
528
|
-
|
|
529
|
-
/**
|
|
530
|
-
* Error indicating that the SDK was accessed before it was initialized.
|
|
531
|
-
* @public
|
|
532
|
-
*/
|
|
533
|
-
export declare class UninitializedPurchasesError extends Error {
|
|
534
|
-
constructor();
|
|
535
|
-
}
|
|
670
|
+
/**
|
|
671
|
+
* Error indicating that the SDK was accessed before it was initialized.
|
|
672
|
+
* @public
|
|
673
|
+
*/
|
|
674
|
+
export declare class UninitializedPurchasesError extends Error {
|
|
675
|
+
constructor();
|
|
676
|
+
}
|
|
536
677
|
|
|
537
|
-
|
|
678
|
+
export { }
|