@revenuecat/purchases-js 1.43.1 → 1.45.0
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 +125 -18
- package/dist/Purchases.es.js +6139 -6121
- package/dist/Purchases.umd.js +59 -59
- package/package.json +1 -1
package/dist/Purchases.es.d.ts
CHANGED
|
@@ -302,7 +302,17 @@ declare type EventPropertySingleValue = string | number | boolean;
|
|
|
302
302
|
|
|
303
303
|
declare type EventPropertyValue = null | EventPropertySingleValue | Array<EventPropertyValue>;
|
|
304
304
|
|
|
305
|
-
|
|
305
|
+
/**
|
|
306
|
+
* Callback to be called when the express purchase button is ready to be updated.
|
|
307
|
+
* @experimental
|
|
308
|
+
* @public
|
|
309
|
+
*/
|
|
310
|
+
export declare interface ExpressPurchaseButtonUpdater {
|
|
311
|
+
/**
|
|
312
|
+
* Updates the purchase option of the express purchase button.
|
|
313
|
+
*/
|
|
314
|
+
updatePurchase: (pkg: Package, purchaseOption?: PurchaseOption) => void;
|
|
315
|
+
}
|
|
306
316
|
|
|
307
317
|
/**
|
|
308
318
|
* Flags used to enable or disable certain features in the sdk.
|
|
@@ -775,21 +785,7 @@ export declare enum PackageType {
|
|
|
775
785
|
* Listener for paywall purchase lifecycle events.
|
|
776
786
|
* @public
|
|
777
787
|
*/
|
|
778
|
-
export declare
|
|
779
|
-
/**
|
|
780
|
-
* Called when a purchase flow is about to start for the given package.
|
|
781
|
-
*/
|
|
782
|
-
onPurchaseStarted?: (rcPackage: Package) => void;
|
|
783
|
-
/**
|
|
784
|
-
* Callback called when an error that won't close the paywall occurs.
|
|
785
|
-
* For example, a retryable error during the purchase process.
|
|
786
|
-
*/
|
|
787
|
-
onPurchaseError?: (error: Error) => void;
|
|
788
|
-
/**
|
|
789
|
-
* Called when the user cancels the purchase flow.
|
|
790
|
-
*/
|
|
791
|
-
onPurchaseCancelled?: () => void;
|
|
792
|
-
}
|
|
788
|
+
export declare type PaywallListener = PurchaseListener;
|
|
793
789
|
|
|
794
790
|
/**
|
|
795
791
|
* Represents the result of a purchase operation initiated from a paywall.
|
|
@@ -875,7 +871,91 @@ export declare interface PresentedOfferingContext {
|
|
|
875
871
|
readonly placementIdentifier: string | null;
|
|
876
872
|
}
|
|
877
873
|
|
|
878
|
-
|
|
874
|
+
/**
|
|
875
|
+
* Parameters for the {@link Purchases.presentExpressPurchaseButton} method.
|
|
876
|
+
*
|
|
877
|
+
* @example
|
|
878
|
+
* ```ts
|
|
879
|
+
* const offerings = await purchases.getOfferings();
|
|
880
|
+
* const pkg = offerings.current?.availablePackages[0];
|
|
881
|
+
* const htmlTarget = document.getElementById("express-purchase-button");
|
|
882
|
+
* const fallbackButton = document.getElementById("checkout-button");
|
|
883
|
+
*
|
|
884
|
+
* if (pkg && htmlTarget) {
|
|
885
|
+
* let expressButtonUpdater: ExpressPurchaseButtonUpdater | undefined;
|
|
886
|
+
*
|
|
887
|
+
* void purchases.presentExpressPurchaseButton({
|
|
888
|
+
* rcPackage: pkg,
|
|
889
|
+
* htmlTarget,
|
|
890
|
+
* onButtonReady: (updater, walletsAvailable) => {
|
|
891
|
+
* expressButtonUpdater = updater;
|
|
892
|
+
* htmlTarget.hidden = !walletsAvailable;
|
|
893
|
+
*
|
|
894
|
+
* if (fallbackButton) {
|
|
895
|
+
* fallbackButton.hidden = walletsAvailable;
|
|
896
|
+
* }
|
|
897
|
+
* },
|
|
898
|
+
* });
|
|
899
|
+
*
|
|
900
|
+
* // If the customer selects a different package later, update the button
|
|
901
|
+
* // instead of rendering a new one.
|
|
902
|
+
* function onSelectedPackageChanged(nextPackage: Package) {
|
|
903
|
+
* expressButtonUpdater?.updatePurchase(nextPackage);
|
|
904
|
+
* }
|
|
905
|
+
* }
|
|
906
|
+
* ```
|
|
907
|
+
*
|
|
908
|
+
* @experimental
|
|
909
|
+
* @public
|
|
910
|
+
*/
|
|
911
|
+
export declare interface PresentExpressPurchaseButtonParams {
|
|
912
|
+
/**
|
|
913
|
+
* The package you want to purchase. Obtained from {@link Purchases.getOfferings}.
|
|
914
|
+
*/
|
|
915
|
+
rcPackage: Package;
|
|
916
|
+
/**
|
|
917
|
+
* The HTML element where the express purchase button should be rendered.
|
|
918
|
+
*/
|
|
919
|
+
htmlTarget: HTMLElement;
|
|
920
|
+
/**
|
|
921
|
+
* The option to be used for this purchase. If not specified or null the default one will be used.
|
|
922
|
+
*/
|
|
923
|
+
purchaseOption?: PurchaseOption | null;
|
|
924
|
+
/**
|
|
925
|
+
* The email of the user. If undefined, RevenueCat will ask the customer for their email.
|
|
926
|
+
*/
|
|
927
|
+
customerEmail?: string;
|
|
928
|
+
/**
|
|
929
|
+
* The locale to use for the purchase flow. If not specified, English will be used
|
|
930
|
+
*/
|
|
931
|
+
selectedLocale?: string;
|
|
932
|
+
/**
|
|
933
|
+
* The default locale to use if the selectedLocale is not available.
|
|
934
|
+
* Defaults to english.
|
|
935
|
+
*/
|
|
936
|
+
defaultLocale?: string;
|
|
937
|
+
/**
|
|
938
|
+
* The purchase metadata to be passed to the backend.
|
|
939
|
+
* Any information provided here will be propagated to the payment gateway and
|
|
940
|
+
* to the RC transaction as metadata.
|
|
941
|
+
*/
|
|
942
|
+
metadata?: PurchaseMetadata;
|
|
943
|
+
/* Excluded from this release type: labelsOverride */
|
|
944
|
+
/**
|
|
945
|
+
* Callback to be called when the express purchase button is ready to be clicked.
|
|
946
|
+
*/
|
|
947
|
+
onButtonReady?: (updater: ExpressPurchaseButtonUpdater, walletsAvailable: boolean) => void;
|
|
948
|
+
/**
|
|
949
|
+
* Optional listener for purchase lifecycle events.
|
|
950
|
+
*/
|
|
951
|
+
listener?: PurchaseListener;
|
|
952
|
+
/**
|
|
953
|
+
* Theme for the Stripe wallet button appearance.
|
|
954
|
+
* Matches Apple Pay button styles: 'black', 'white', or 'white-outline'
|
|
955
|
+
* Defaults to "black".
|
|
956
|
+
*/
|
|
957
|
+
walletButtonTheme?: WalletButtonTheme;
|
|
958
|
+
}
|
|
879
959
|
|
|
880
960
|
/**
|
|
881
961
|
* Parameters for the {@link Purchases.presentPaywall} method.
|
|
@@ -1193,6 +1273,26 @@ declare enum PurchaseFlowErrorCode {
|
|
|
1193
1273
|
InvalidPaddleAPIKeyError = 9
|
|
1194
1274
|
}
|
|
1195
1275
|
|
|
1276
|
+
/**
|
|
1277
|
+
* Listener for purchase lifecycle events.
|
|
1278
|
+
* @public
|
|
1279
|
+
*/
|
|
1280
|
+
export declare interface PurchaseListener {
|
|
1281
|
+
/**
|
|
1282
|
+
* Called when a purchase flow is about to start for the given package.
|
|
1283
|
+
*/
|
|
1284
|
+
onPurchaseStarted?: (rcPackage: Package) => void;
|
|
1285
|
+
/**
|
|
1286
|
+
* Callback called when an error that won't close the paywall occurs.
|
|
1287
|
+
* For example, a retryable error during the purchase process.
|
|
1288
|
+
*/
|
|
1289
|
+
onPurchaseError?: (error: Error) => void;
|
|
1290
|
+
/**
|
|
1291
|
+
* Called when the user cancels the purchase flow.
|
|
1292
|
+
*/
|
|
1293
|
+
onPurchaseCancelled?: () => void;
|
|
1294
|
+
}
|
|
1295
|
+
|
|
1196
1296
|
/**
|
|
1197
1297
|
* Metadata that can be passed to the backend when making a purchase.
|
|
1198
1298
|
* They will propagate to the payment gateway (i.e. Stripe) and to RevenueCat.
|
|
@@ -1433,7 +1533,14 @@ export declare class Purchases {
|
|
|
1433
1533
|
* @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.
|
|
1434
1534
|
*/
|
|
1435
1535
|
purchasePackage(rcPackage: Package, customerEmail?: string, htmlTarget?: HTMLElement): Promise<PurchaseResult>;
|
|
1436
|
-
|
|
1536
|
+
/**
|
|
1537
|
+
* Renders an Express Purchase button for the supported wallets (Apple Pay/Google Pay).
|
|
1538
|
+
* When clicked it uses the wallet UI to execute the purchase instead of
|
|
1539
|
+
* the checkout flow that would be shown with `.purchase`.
|
|
1540
|
+
* @param params - The parameters object to customise the purchase flow. Check {@link PresentExpressPurchaseButtonParams}
|
|
1541
|
+
* @returns Promise<PurchaseResult>
|
|
1542
|
+
*/
|
|
1543
|
+
presentExpressPurchaseButton(params: PresentExpressPurchaseButtonParams): Promise<PurchaseResult>;
|
|
1437
1544
|
/* Excluded from this release type: getWalletButtonRender */
|
|
1438
1545
|
/**
|
|
1439
1546
|
* Method to perform a purchase for a given package. You can obtain the
|