@superwall/runtime 2.2.0 → 2.2.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.
@@ -21,13 +21,25 @@ export type SuperwallCheckoutMode = "external" | "sheet" | "applePay";
21
21
  * - `managedPayments` overrides the account's Stripe managed-payments
22
22
  * setting for this paywall: `true` forces it on, `false` forces it off.
23
23
  * Omitted, the account setting applies.
24
+ * - `prepaidCards` decides whether Stripe Checkout accepts prepaid cards.
25
+ * Default: `"allow"`. See `SuperwallPrepaidCards`.
24
26
  */
25
27
  export type SuperwallCheckoutConfig<TReference extends string = string> = SuperwallCheckoutMode | {
26
28
  mode: SuperwallCheckoutMode;
27
29
  prefetch?: TReference | false;
28
30
  managedPayments?: boolean;
31
+ prepaidCards?: SuperwallPrepaidCards;
29
32
  };
33
+ /**
34
+ * Whether a web checkout accepts prepaid cards: `"allow"` (the default) or
35
+ * `"block"`, which makes Stripe refuse them, a defence against free-trial
36
+ * abuse. It applies to the sheet and the hosted checkout page; an Apple Pay
37
+ * payment can't be filtered by card type, so in `applePay` mode only the
38
+ * sheet fallback refuses them. Store purchases ignore it.
39
+ */
40
+ export type SuperwallPrepaidCards = "allow" | "block";
30
41
  export type SuperwallManagedPaymentsOverride = "USE_MANAGED_PAYMENTS" | "USE_DEFAULT_PAYMENTS";
31
42
  export declare const checkoutModeOf: (checkout: SuperwallCheckoutConfig | undefined) => SuperwallCheckoutMode | undefined;
32
43
  export declare const checkoutPrefetchOf: (checkout: SuperwallCheckoutConfig | undefined) => string | false | undefined;
33
44
  export declare const checkoutManagedPaymentsOf: (checkout: SuperwallCheckoutConfig | undefined) => SuperwallManagedPaymentsOverride | undefined;
45
+ export declare const checkoutPrepaidCardsOf: (checkout: SuperwallCheckoutConfig | undefined) => SuperwallPrepaidCards;
@@ -6,3 +6,4 @@ export const checkoutManagedPaymentsOf = (checkout) => {
6
6
  return undefined;
7
7
  return override ? "USE_MANAGED_PAYMENTS" : "USE_DEFAULT_PAYMENTS";
8
8
  };
9
+ export const checkoutPrepaidCardsOf = (checkout) => (typeof checkout === "object" ? checkout.prepaidCards : undefined) ?? "allow";
@@ -92,7 +92,7 @@ export type SuperwallConfig<TLocale extends string = string, TStripeReference ex
92
92
  };
93
93
  export { allowedHostsOf, LOOPBACK_HOST, MAX_ALLOWED_HOSTS, type ResolvedAllowedHosts, type SuperwallAllowedHostsConfig, } from "./allowedHosts";
94
94
  export { backgroundOf, type ResolvedBackground, type SuperwallBackgroundConfig, } from "./background";
95
- export { checkoutManagedPaymentsOf, checkoutModeOf, checkoutPrefetchOf, type SuperwallCheckoutConfig, type SuperwallCheckoutMode, type SuperwallManagedPaymentsOverride, } from "./checkout";
95
+ export { checkoutManagedPaymentsOf, checkoutModeOf, checkoutPrefetchOf, checkoutPrepaidCardsOf, type SuperwallCheckoutConfig, type SuperwallCheckoutMode, type SuperwallManagedPaymentsOverride, type SuperwallPrepaidCards, } from "./checkout";
96
96
  export { INSET_EDGES, insetsOf, type InsetEdge, type ResolvedInsets, type SuperwallInsetSide, type SuperwallInsetsConfig, } from "./insets";
97
97
  export type { SuperwallLocalizationConfig, SuperwallMessages } from "./localization";
98
98
  export type { SuperwallNotificationsConfig, SuperwallTrialReminderConfig, SuperwallTrialReminderContext, SuperwallTrialReminderNotification, SuperwallTrialReminderStaticConfig, } from "./notifications";
@@ -1,6 +1,6 @@
1
1
  export { allowedHostsOf, LOOPBACK_HOST, MAX_ALLOWED_HOSTS, } from "./allowedHosts";
2
2
  export { backgroundOf, } from "./background";
3
- export { checkoutManagedPaymentsOf, checkoutModeOf, checkoutPrefetchOf, } from "./checkout";
3
+ export { checkoutManagedPaymentsOf, checkoutModeOf, checkoutPrefetchOf, checkoutPrepaidCardsOf, } from "./checkout";
4
4
  export { INSET_EDGES, insetsOf, } from "./insets";
5
5
  export { normalizePlatform, SUPERWALL_PLATFORMS } from "./platforms";
6
6
  export { dismissesOnPurchase } from "./postPurchase";
@@ -1,5 +1,5 @@
1
1
  import type { ITransport, TEventTrackingBehavior, TIncomingMessage, TIncomingMessageCallbackResult, TIncomingMessageTransactionAbandon, TIncomingMessageTransactionComplete, TOutgoingMessage, TPermissionStatus, TPermissionTypeMessage, TransportKind } from "@superwall/protocol";
2
- import type { SuperwallCheckoutMode, SuperwallConfig, SuperwallPostPurchase } from "../config";
2
+ import type { SuperwallCheckoutMode, SuperwallConfig, SuperwallPostPurchase, SuperwallPrepaidCards } from "../config";
3
3
  import type { SuperwallTranslateValues } from "../localization";
4
4
  import type { SuperwallProduct, SuperwallProductInput, SuperwallProductVariables } from "../products";
5
5
  import type { Outgoing, PageViewInput } from "./outgoing";
@@ -104,6 +104,13 @@ export type SuperwallPurchaseOptions = {
104
104
  * Default: the config's `checkout` mode.
105
105
  */
106
106
  checkout?: SuperwallCheckoutMode;
107
+ /**
108
+ * Whether this purchase's web checkout accepts prepaid cards, overriding
109
+ * the config's `checkout.prepaidCards` for this call. See
110
+ * `SuperwallPrepaidCards`. Ignored by store purchases.
111
+ * Default: the config's `checkout.prepaidCards`, else `"allow"`.
112
+ */
113
+ prepaidCards?: SuperwallPrepaidCards;
107
114
  };
108
115
  export type SuperwallCallbackOptions = {
109
116
  behavior?: CallbackBehavior;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superwall/runtime",
3
- "version": "2.2.0",
3
+ "version": "2.2.1",
4
4
  "description": "Framework-agnostic runtime for headless Superwall paywalls: bridge, session, products, localization, mock host.",
5
5
  "keywords": [
6
6
  "paywall",
@@ -39,7 +39,7 @@
39
39
  "clean": "rm -rf dist coverage"
40
40
  },
41
41
  "dependencies": {
42
- "@superwall/protocol": "2.2.0"
42
+ "@superwall/protocol": "2.2.1"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@superwall/host": "workspace:*",
@@ -22,10 +22,26 @@ export type SuperwallCheckoutMode = "external" | "sheet" | "applePay";
22
22
  * - `managedPayments` overrides the account's Stripe managed-payments
23
23
  * setting for this paywall: `true` forces it on, `false` forces it off.
24
24
  * Omitted, the account setting applies.
25
+ * - `prepaidCards` decides whether Stripe Checkout accepts prepaid cards.
26
+ * Default: `"allow"`. See `SuperwallPrepaidCards`.
25
27
  */
26
28
  export type SuperwallCheckoutConfig<TReference extends string = string> =
27
29
  | SuperwallCheckoutMode
28
- | { mode: SuperwallCheckoutMode; prefetch?: TReference | false; managedPayments?: boolean };
30
+ | {
31
+ mode: SuperwallCheckoutMode;
32
+ prefetch?: TReference | false;
33
+ managedPayments?: boolean;
34
+ prepaidCards?: SuperwallPrepaidCards;
35
+ };
36
+
37
+ /**
38
+ * Whether a web checkout accepts prepaid cards: `"allow"` (the default) or
39
+ * `"block"`, which makes Stripe refuse them, a defence against free-trial
40
+ * abuse. It applies to the sheet and the hosted checkout page; an Apple Pay
41
+ * payment can't be filtered by card type, so in `applePay` mode only the
42
+ * sheet fallback refuses them. Store purchases ignore it.
43
+ */
44
+ export type SuperwallPrepaidCards = "allow" | "block";
29
45
 
30
46
  export type SuperwallManagedPaymentsOverride = "USE_MANAGED_PAYMENTS" | "USE_DEFAULT_PAYMENTS";
31
47
 
@@ -44,3 +60,8 @@ export const checkoutManagedPaymentsOf = (
44
60
  if (override === undefined) return undefined;
45
61
  return override ? "USE_MANAGED_PAYMENTS" : "USE_DEFAULT_PAYMENTS";
46
62
  };
63
+
64
+ export const checkoutPrepaidCardsOf = (
65
+ checkout: SuperwallCheckoutConfig | undefined,
66
+ ): SuperwallPrepaidCards =>
67
+ (typeof checkout === "object" ? checkout.prepaidCards : undefined) ?? "allow";
@@ -126,9 +126,11 @@ export {
126
126
  checkoutManagedPaymentsOf,
127
127
  checkoutModeOf,
128
128
  checkoutPrefetchOf,
129
+ checkoutPrepaidCardsOf,
129
130
  type SuperwallCheckoutConfig,
130
131
  type SuperwallCheckoutMode,
131
132
  type SuperwallManagedPaymentsOverride,
133
+ type SuperwallPrepaidCards,
132
134
  } from "./checkout";
133
135
  export {
134
136
  INSET_EDGES,
@@ -10,7 +10,12 @@ import type {
10
10
  TPermissionTypeMessage,
11
11
  TransportKind,
12
12
  } from "@superwall/protocol";
13
- import type { SuperwallCheckoutMode, SuperwallConfig, SuperwallPostPurchase } from "../config";
13
+ import type {
14
+ SuperwallCheckoutMode,
15
+ SuperwallConfig,
16
+ SuperwallPostPurchase,
17
+ SuperwallPrepaidCards,
18
+ } from "../config";
14
19
  import type { SuperwallTranslateValues } from "../localization";
15
20
  import type {
16
21
  SuperwallProduct,
@@ -143,6 +148,13 @@ export type SuperwallPurchaseOptions = {
143
148
  * Default: the config's `checkout` mode.
144
149
  */
145
150
  checkout?: SuperwallCheckoutMode;
151
+ /**
152
+ * Whether this purchase's web checkout accepts prepaid cards, overriding
153
+ * the config's `checkout.prepaidCards` for this call. See
154
+ * `SuperwallPrepaidCards`. Ignored by store purchases.
155
+ * Default: the config's `checkout.prepaidCards`, else `"allow"`.
156
+ */
157
+ prepaidCards?: SuperwallPrepaidCards;
146
158
  };
147
159
 
148
160
  export type SuperwallCallbackOptions = {