@revenuecat/purchases-js 0.0.8 → 0.0.10

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
@@ -57,10 +57,11 @@ associated `rcBillingProduct` and price.
57
57
  ```typescript
58
58
  const purchases = new Purchases("your RC_PUBLISHABLE_API_KEY");
59
59
 
60
- purchases.listOfferings().then((offeringsPage) => {
61
- offeringsPage.offerings.forEach((offering) => {
62
- console.log(offering);
63
- });
60
+ purchases.getOfferings().then((offerings) => {
61
+ // Get current offering
62
+ console.log(offerings.current);
63
+ // Or a dictionary of all offerings
64
+ console.log(offerings.all);
64
65
  });
65
66
  ```
66
67
 
@@ -140,7 +141,7 @@ You built your paywall, and your user just clicked on the offer they want to sub
140
141
  ```tsx
141
142
  const purchases = new Purchases("your RC_PUBLISHABLE_API_KEY");
142
143
  // You can retrieve this from the offerings you downloaded, as example:
143
- // offeringsPage.offerings[0].packages[0].rcBillingProduct.identifier
144
+ // offerings.current.packages[0].rcBillingProduct.identifier
144
145
  const rcBillingProductIndentifier =
145
146
  "the Product Identifier the user wants to buy";
146
147
  const appUserId =
@@ -7,13 +7,13 @@ declare interface Offering_2 {
7
7
  packages: Package_2[];
8
8
  }
9
9
 
10
- export declare type OfferingsPage = OfferingsPage_2;
10
+ export declare type Offerings = Offerings_2;
11
11
 
12
- declare interface OfferingsPage_2 {
13
- offerings: Offering_2[];
14
- priceByPackageId: {
15
- [packageId: string]: number;
12
+ declare interface Offerings_2 {
13
+ all: {
14
+ [offeringId: string]: Offering_2;
16
15
  };
16
+ current: Offering_2 | null;
17
17
  }
18
18
 
19
19
  export declare type Package = Package_2;
@@ -21,9 +21,20 @@ export declare type Package = Package_2;
21
21
  declare interface Package_2 {
22
22
  id: string;
23
23
  identifier: string;
24
- rcBillingProduct: Product | null;
24
+ rcBillingProduct: Product;
25
25
  }
26
26
 
27
+ declare type PaymentProvider = "stripe";
28
+
29
+ declare type PaymentProviderConfigModels = {
30
+ stripe?: {
31
+ publishableKey: string;
32
+ accountId: string;
33
+ };
34
+ };
35
+
36
+ declare type PaymentProviderSettings = Record<PaymentProvider, PaymentProviderConfigModels[PaymentProvider]>;
37
+
27
38
  declare interface Price {
28
39
  amount: number;
29
40
  currency: string;
@@ -38,17 +49,20 @@ declare interface Product {
38
49
  }
39
50
 
40
51
  export declare class Purchases {
41
- _API_KEY: string | null;
42
- _APP_USER_ID: string | null;
43
52
  private static readonly _RC_ENDPOINT;
44
53
  private static readonly _BASE_PATH;
45
- constructor(apiKey: string);
46
- private toOfferingsPage;
47
- listOfferings(appUserId: string): Promise<OfferingsPage>;
54
+ constructor(apiKey: string, paymentProviderSettings: PaymentProviderSettings);
55
+ private toOfferings;
56
+ getOfferings(appUserId: string): Promise<Offerings>;
48
57
  isEntitledTo(appUserId: string, entitlementIdentifier: string): Promise<boolean>;
49
58
  waitForEntitlement(appUserId: string, entitlementIdentifier: string, maxAttempts?: number): Promise<boolean>;
50
59
  subscribe(appUserId: string, productId: string, email: string, environment?: "sandbox" | "production"): Promise<SubscribeResponse>;
51
- getPackage(appUserId: string, packageIdentifier: string): Promise<Package | null>;
60
+ purchasePackage(appUserId: string, rcPackage: Package, { environment, customerEmail, htmlTarget, }?: {
61
+ environment?: "sandbox" | "production";
62
+ customerEmail?: string;
63
+ htmlTarget?: HTMLElement;
64
+ }): Promise<void>;
65
+ private logMissingProductIds;
52
66
  }
53
67
 
54
68
  declare interface SubscribeResponse {