@appfunnel-dev/sdk 2.0.1 → 2.1.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/CHANGELOG.md CHANGED
@@ -1,5 +1,33 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.1.0
4
+
5
+ ### `methods` is now `options`, and it styles the wallet button
6
+
7
+ `<Checkout>` and `<CheckoutButton>` take `options` where they took `methods`. Everything `methods`
8
+ did works the same under the new name, and `methods` keeps working.
9
+
10
+ New in `options`: `express`, the wallet button. It takes Stripe's own Express Checkout Element
11
+ options — which wallets show (`paymentMethods`), how many buttons per row and how many rows
12
+ (`layout`), and the buttons' height, colour and label (`buttonHeight`, `buttonTheme`, `buttonType`).
13
+
14
+ ```tsx
15
+ <Checkout
16
+ offering="plan"
17
+ options={{ express: { paymentMethods: { link: 'auto' }, layout: { maxColumns: 1 }, buttonHeight: 48 } }}
18
+ />
19
+ ```
20
+
21
+ ### The wallet button offers Apple Pay and Google Pay only
22
+
23
+ The wallet button used to offer every wallet the Stripe account had turned on, Link, PayPal, Amazon
24
+ Pay and Klarna included. It now offers Apple Pay and Google Pay, both `'always'`; the others are off
25
+ unless a funnel names them in `options.express.paymentMethods`. Anything you name is merged over
26
+ that default, one wallet at a time.
27
+
28
+ `'always'` shows Apple Pay and Google Pay wherever the browser supports them, even before the
29
+ visitor has added a card. Set `'auto'` to show them only where a card is ready to pay.
30
+
3
31
  ## 2.0.1
4
32
 
5
33
  A checkout that names no offering is now caught, in both places it can be caught.
@@ -1,5 +1,5 @@
1
1
  import { ReactNode, ComponentType, ReactElement } from 'react';
2
- import { Appearance } from '@stripe/stripe-js';
2
+ import { Appearance, StripeExpressCheckoutElementOptions } from '@stripe/stripe-js';
3
3
  import { CheckoutSettings } from '@paddle/paddle-js';
4
4
  import { c as CheckoutProvider, b as CheckoutIntent, d as CheckoutSurface, U as UpsellKind, C as CheckoutError, a as CheckoutErrorCategory, h as PaymentMode, H as HostedPaymentMode, e as OpensIn, i as PaymentRendering } from './capabilities-BtnJi2JD.js';
5
5
 
@@ -99,10 +99,11 @@ interface CheckoutRequest {
99
99
  */
100
100
  appearance?: CheckoutAppearance;
101
101
  /**
102
- * How the provider LISTS the payment methods see {@link CheckoutMethods}. Display-only, same
103
- * as `appearance`: it never leaves the browser.
102
+ * How the provider LISTS the payment methods and draws the wallet button — the author's
103
+ * `options` (see {@link CheckoutOptions}). Display-only, same as `appearance`: it never leaves
104
+ * the browser.
104
105
  */
105
- methods?: CheckoutMethods;
106
+ methods?: CheckoutOptions;
106
107
  /**
107
108
  * Classes for the buttons the SDK renders itself — see {@link CheckoutClassNames}. Display-only.
108
109
  */
@@ -162,22 +163,22 @@ interface CheckoutAppearance {
162
163
  paddle?: Pick<CheckoutSettings, 'theme' | 'frameStyle' | 'frameInitialHeight'>;
163
164
  }
164
165
  /**
165
- * How the list of payment methods is PRESENTED, in the surfaces the SDK mounts itself.
166
+ * How the payment methods are PRESENTED the method list and the wallet button — in the surfaces
167
+ * the SDK mounts itself.
166
168
  *
167
169
  * Normalized, unlike {@link CheckoutAppearance} — and the difference is real rather than an
168
170
  * inconsistency. Appearance is a token bag whose true cross-provider intersection is roughly empty,
169
171
  * so a shared shape there would be a lie. "Stack the methods and start them collapsed" is one idea
170
172
  * with one meaning, so it gets one spelling.
171
173
  *
172
- * The DEFAULT is `{ layout: 'accordion', collapsed: true }`: the buyer sees the methods they can pay
173
- * with wallets included and picks one before any field appears, instead of landing on an open
174
- * card form with the wallet they'd have preferred hidden below it.
174
+ * The DEFAULT is `{ layout: 'accordion', collapsed: false }` the first method open and a wallet
175
+ * button offering Apple Pay and Google Pay (see {@link CheckoutOptions.express}).
175
176
  *
176
177
  * ```tsx
177
178
  * <Checkout offering="plan" /> // accordion, collapsed
178
- * <Checkout offering="plan" methods={{ collapsed: false }} /> // first method open
179
- * <Checkout offering="plan" methods={{ layout: 'tabs' }} /> // methods across the top
180
- * <Checkout offering="plan" methods={{ order: ['apple_pay', 'card'] }} /> // lead with Apple Pay
179
+ * <Checkout offering="plan" options={{ collapsed: false }} /> // first method open
180
+ * <Checkout offering="plan" options={{ layout: 'tabs' }} /> // methods across the top
181
+ * <Checkout offering="plan" options={{ order: ['apple_pay', 'card'] }} /> // lead with Apple Pay
181
182
  * ```
182
183
  *
183
184
  * **Only applies where the SDK mounts the method list** — `payment="card"`, and the `payment="auto"`
@@ -186,7 +187,7 @@ interface CheckoutAppearance {
186
187
  * setting. Wallets also have to be able to appear at all before ordering them means anything — that
187
188
  * needs the domain registered with Stripe as a payment method domain.
188
189
  */
189
- interface CheckoutMethods {
190
+ interface CheckoutOptions {
190
191
  /** `'accordion'` (default) stacks the methods as rows; `'tabs'` runs them across the top. */
191
192
  layout?: 'accordion' | 'tabs';
192
193
  /** Start with every method closed, so the buyer chooses before any fields render. Default `true`. */
@@ -208,7 +209,32 @@ interface CheckoutMethods {
208
209
  * nowhere else to go on this screen. Leave it on unless the funnel is deliberately wallet-only.
209
210
  */
210
211
  payAnotherWay?: boolean;
212
+ /**
213
+ * The wallet BUTTON — Stripe's Express Checkout Element options, passed through as-is: which
214
+ * wallets it offers (`paymentMethods`), how many buttons per row and how many rows (`layout`),
215
+ * and the buttons' height, colour and label (`buttonHeight`, `buttonTheme`, `buttonType`).
216
+ *
217
+ * ```tsx
218
+ * <Checkout offering="plan" options={{ express: { paymentMethods: { link: 'auto' } } }} />
219
+ * <Checkout offering="plan" options={{ express: { layout: { maxColumns: 1 }, buttonHeight: 48 } }} />
220
+ * ```
221
+ *
222
+ * `paymentMethods` defaults to Apple Pay and Google Pay (`'always'`) with Link, PayPal, Amazon Pay
223
+ * and Klarna off (`'never'`), merged per wallet over that default — `{ link: 'auto' }` adds Link
224
+ * and leaves the rest as they were. `'always'` shows Apple Pay / Google Pay wherever the browser
225
+ * supports them, even before the buyer has added a card; `'auto'` only where one is ready to pay.
226
+ * Everything else unset is Stripe's default. Stripe only.
227
+ */
228
+ express?: CheckoutExpressOptions;
211
229
  }
230
+ /**
231
+ * The part of Stripe's `StripeExpressCheckoutElementOptions` that decides what the wallet button
232
+ * offers and how it LOOKS. The rest (line items, shipping, email and phone collection) belongs to the
233
+ * charge, which the SDK sets, so it isn't offered here.
234
+ */
235
+ type CheckoutExpressOptions = Pick<StripeExpressCheckoutElementOptions, 'paymentMethods' | 'paymentMethodOrder' | 'layout' | 'buttonHeight' | 'buttonTheme' | 'buttonType'>;
236
+ /** @deprecated Renamed to {@link CheckoutOptions}. */
237
+ type CheckoutMethods = CheckoutOptions;
212
238
  interface CheckoutResult {
213
239
  ok: boolean;
214
240
  error?: CheckoutError;
@@ -508,9 +534,11 @@ interface CheckoutCommonProps extends Omit<UseCheckoutOptions, 'managed'> {
508
534
  * fields render in a cross-origin iframe the funnel's CSS can't reach.
509
535
  */
510
536
  appearance?: CheckoutAppearance;
511
- /** How the provider lists the payment methods ({@link CheckoutMethods}) — accordion + collapsed
512
- * by default. Ignored on surfaces where the provider owns the whole UI. */
513
- methods?: CheckoutMethods;
537
+ /** How the payment methods are listed and how the wallet button looks ({@link CheckoutOptions}).
538
+ * Ignored on surfaces where the provider owns the whole UI. */
539
+ options?: CheckoutOptions;
540
+ /** @deprecated Renamed to `options`. */
541
+ methods?: CheckoutOptions;
514
542
  }
515
543
  /**
516
544
  * The `managed` × `payment` constraint, as a type rather than a runtime rejection.
@@ -747,4 +775,4 @@ declare function UpsellButton(props: UpsellButtonProps): ReactNode;
747
775
  */
748
776
  declare function CheckoutResume(options?: UseCheckoutOptions): ReactNode;
749
777
 
750
- export { useCheckout as A, type CheckoutDriverContext as C, type FailureModalProps as F, type MockDriverOptions as M, type OnFailedMap as O, type PaymentAxis as P, type TriggerAxis as T, UpsellButton as U, type CheckoutDriver as a, Checkout as b, type CheckoutAppearance as c, CheckoutButton as d, type CheckoutButtonProps as e, type CheckoutCallbacks as f, type CheckoutClassNames as g, type CheckoutCommonProps as h, type CheckoutHandle as i, type CheckoutInlineProps as j, type CheckoutMethods as k, type CheckoutProps as l, type CheckoutRequest as m, type CheckoutResult as n, CheckoutResume as o, CheckoutSpinner as p, type CheckoutStatus as q, type FailureRoute as r, type OpensAxis as s, type TriggerState as t, type UpsellButtonProps as u, type UpsellCommonProps as v, type UpsellRecovery as w, type UseCheckoutOptions as x, createMockDriver as y, driverWithEmail as z };
778
+ export { createMockDriver as A, driverWithEmail as B, type CheckoutDriverContext as C, useCheckout as D, type FailureModalProps as F, type MockDriverOptions as M, type OnFailedMap as O, type PaymentAxis as P, type TriggerAxis as T, UpsellButton as U, type CheckoutDriver as a, Checkout as b, type CheckoutAppearance as c, CheckoutButton as d, type CheckoutButtonProps as e, type CheckoutCallbacks as f, type CheckoutClassNames as g, type CheckoutCommonProps as h, type CheckoutExpressOptions as i, type CheckoutHandle as j, type CheckoutInlineProps as k, type CheckoutMethods as l, type CheckoutOptions as m, type CheckoutProps as n, type CheckoutRequest as o, type CheckoutResult as p, CheckoutResume as q, CheckoutSpinner as r, type CheckoutStatus as s, type FailureRoute as t, type OpensAxis as u, type TriggerState as v, type UpsellButtonProps as w, type UpsellCommonProps as x, type UpsellRecovery as y, type UseCheckoutOptions as z };
@@ -1,5 +1,5 @@
1
1
  import { ReactNode, ComponentType, ReactElement } from 'react';
2
- import { Appearance } from '@stripe/stripe-js';
2
+ import { Appearance, StripeExpressCheckoutElementOptions } from '@stripe/stripe-js';
3
3
  import { CheckoutSettings } from '@paddle/paddle-js';
4
4
  import { c as CheckoutProvider, b as CheckoutIntent, d as CheckoutSurface, U as UpsellKind, C as CheckoutError, a as CheckoutErrorCategory, h as PaymentMode, H as HostedPaymentMode, e as OpensIn, i as PaymentRendering } from './capabilities-BtnJi2JD.cjs';
5
5
 
@@ -99,10 +99,11 @@ interface CheckoutRequest {
99
99
  */
100
100
  appearance?: CheckoutAppearance;
101
101
  /**
102
- * How the provider LISTS the payment methods see {@link CheckoutMethods}. Display-only, same
103
- * as `appearance`: it never leaves the browser.
102
+ * How the provider LISTS the payment methods and draws the wallet button — the author's
103
+ * `options` (see {@link CheckoutOptions}). Display-only, same as `appearance`: it never leaves
104
+ * the browser.
104
105
  */
105
- methods?: CheckoutMethods;
106
+ methods?: CheckoutOptions;
106
107
  /**
107
108
  * Classes for the buttons the SDK renders itself — see {@link CheckoutClassNames}. Display-only.
108
109
  */
@@ -162,22 +163,22 @@ interface CheckoutAppearance {
162
163
  paddle?: Pick<CheckoutSettings, 'theme' | 'frameStyle' | 'frameInitialHeight'>;
163
164
  }
164
165
  /**
165
- * How the list of payment methods is PRESENTED, in the surfaces the SDK mounts itself.
166
+ * How the payment methods are PRESENTED the method list and the wallet button — in the surfaces
167
+ * the SDK mounts itself.
166
168
  *
167
169
  * Normalized, unlike {@link CheckoutAppearance} — and the difference is real rather than an
168
170
  * inconsistency. Appearance is a token bag whose true cross-provider intersection is roughly empty,
169
171
  * so a shared shape there would be a lie. "Stack the methods and start them collapsed" is one idea
170
172
  * with one meaning, so it gets one spelling.
171
173
  *
172
- * The DEFAULT is `{ layout: 'accordion', collapsed: true }`: the buyer sees the methods they can pay
173
- * with wallets included and picks one before any field appears, instead of landing on an open
174
- * card form with the wallet they'd have preferred hidden below it.
174
+ * The DEFAULT is `{ layout: 'accordion', collapsed: false }` the first method open and a wallet
175
+ * button offering Apple Pay and Google Pay (see {@link CheckoutOptions.express}).
175
176
  *
176
177
  * ```tsx
177
178
  * <Checkout offering="plan" /> // accordion, collapsed
178
- * <Checkout offering="plan" methods={{ collapsed: false }} /> // first method open
179
- * <Checkout offering="plan" methods={{ layout: 'tabs' }} /> // methods across the top
180
- * <Checkout offering="plan" methods={{ order: ['apple_pay', 'card'] }} /> // lead with Apple Pay
179
+ * <Checkout offering="plan" options={{ collapsed: false }} /> // first method open
180
+ * <Checkout offering="plan" options={{ layout: 'tabs' }} /> // methods across the top
181
+ * <Checkout offering="plan" options={{ order: ['apple_pay', 'card'] }} /> // lead with Apple Pay
181
182
  * ```
182
183
  *
183
184
  * **Only applies where the SDK mounts the method list** — `payment="card"`, and the `payment="auto"`
@@ -186,7 +187,7 @@ interface CheckoutAppearance {
186
187
  * setting. Wallets also have to be able to appear at all before ordering them means anything — that
187
188
  * needs the domain registered with Stripe as a payment method domain.
188
189
  */
189
- interface CheckoutMethods {
190
+ interface CheckoutOptions {
190
191
  /** `'accordion'` (default) stacks the methods as rows; `'tabs'` runs them across the top. */
191
192
  layout?: 'accordion' | 'tabs';
192
193
  /** Start with every method closed, so the buyer chooses before any fields render. Default `true`. */
@@ -208,7 +209,32 @@ interface CheckoutMethods {
208
209
  * nowhere else to go on this screen. Leave it on unless the funnel is deliberately wallet-only.
209
210
  */
210
211
  payAnotherWay?: boolean;
212
+ /**
213
+ * The wallet BUTTON — Stripe's Express Checkout Element options, passed through as-is: which
214
+ * wallets it offers (`paymentMethods`), how many buttons per row and how many rows (`layout`),
215
+ * and the buttons' height, colour and label (`buttonHeight`, `buttonTheme`, `buttonType`).
216
+ *
217
+ * ```tsx
218
+ * <Checkout offering="plan" options={{ express: { paymentMethods: { link: 'auto' } } }} />
219
+ * <Checkout offering="plan" options={{ express: { layout: { maxColumns: 1 }, buttonHeight: 48 } }} />
220
+ * ```
221
+ *
222
+ * `paymentMethods` defaults to Apple Pay and Google Pay (`'always'`) with Link, PayPal, Amazon Pay
223
+ * and Klarna off (`'never'`), merged per wallet over that default — `{ link: 'auto' }` adds Link
224
+ * and leaves the rest as they were. `'always'` shows Apple Pay / Google Pay wherever the browser
225
+ * supports them, even before the buyer has added a card; `'auto'` only where one is ready to pay.
226
+ * Everything else unset is Stripe's default. Stripe only.
227
+ */
228
+ express?: CheckoutExpressOptions;
211
229
  }
230
+ /**
231
+ * The part of Stripe's `StripeExpressCheckoutElementOptions` that decides what the wallet button
232
+ * offers and how it LOOKS. The rest (line items, shipping, email and phone collection) belongs to the
233
+ * charge, which the SDK sets, so it isn't offered here.
234
+ */
235
+ type CheckoutExpressOptions = Pick<StripeExpressCheckoutElementOptions, 'paymentMethods' | 'paymentMethodOrder' | 'layout' | 'buttonHeight' | 'buttonTheme' | 'buttonType'>;
236
+ /** @deprecated Renamed to {@link CheckoutOptions}. */
237
+ type CheckoutMethods = CheckoutOptions;
212
238
  interface CheckoutResult {
213
239
  ok: boolean;
214
240
  error?: CheckoutError;
@@ -508,9 +534,11 @@ interface CheckoutCommonProps extends Omit<UseCheckoutOptions, 'managed'> {
508
534
  * fields render in a cross-origin iframe the funnel's CSS can't reach.
509
535
  */
510
536
  appearance?: CheckoutAppearance;
511
- /** How the provider lists the payment methods ({@link CheckoutMethods}) — accordion + collapsed
512
- * by default. Ignored on surfaces where the provider owns the whole UI. */
513
- methods?: CheckoutMethods;
537
+ /** How the payment methods are listed and how the wallet button looks ({@link CheckoutOptions}).
538
+ * Ignored on surfaces where the provider owns the whole UI. */
539
+ options?: CheckoutOptions;
540
+ /** @deprecated Renamed to `options`. */
541
+ methods?: CheckoutOptions;
514
542
  }
515
543
  /**
516
544
  * The `managed` × `payment` constraint, as a type rather than a runtime rejection.
@@ -747,4 +775,4 @@ declare function UpsellButton(props: UpsellButtonProps): ReactNode;
747
775
  */
748
776
  declare function CheckoutResume(options?: UseCheckoutOptions): ReactNode;
749
777
 
750
- export { useCheckout as A, type CheckoutDriverContext as C, type FailureModalProps as F, type MockDriverOptions as M, type OnFailedMap as O, type PaymentAxis as P, type TriggerAxis as T, UpsellButton as U, type CheckoutDriver as a, Checkout as b, type CheckoutAppearance as c, CheckoutButton as d, type CheckoutButtonProps as e, type CheckoutCallbacks as f, type CheckoutClassNames as g, type CheckoutCommonProps as h, type CheckoutHandle as i, type CheckoutInlineProps as j, type CheckoutMethods as k, type CheckoutProps as l, type CheckoutRequest as m, type CheckoutResult as n, CheckoutResume as o, CheckoutSpinner as p, type CheckoutStatus as q, type FailureRoute as r, type OpensAxis as s, type TriggerState as t, type UpsellButtonProps as u, type UpsellCommonProps as v, type UpsellRecovery as w, type UseCheckoutOptions as x, createMockDriver as y, driverWithEmail as z };
778
+ export { createMockDriver as A, driverWithEmail as B, type CheckoutDriverContext as C, useCheckout as D, type FailureModalProps as F, type MockDriverOptions as M, type OnFailedMap as O, type PaymentAxis as P, type TriggerAxis as T, UpsellButton as U, type CheckoutDriver as a, Checkout as b, type CheckoutAppearance as c, CheckoutButton as d, type CheckoutButtonProps as e, type CheckoutCallbacks as f, type CheckoutClassNames as g, type CheckoutCommonProps as h, type CheckoutExpressOptions as i, type CheckoutHandle as j, type CheckoutInlineProps as k, type CheckoutMethods as l, type CheckoutOptions as m, type CheckoutProps as n, type CheckoutRequest as o, type CheckoutResult as p, CheckoutResume as q, CheckoutSpinner as r, type CheckoutStatus as s, type FailureRoute as t, type OpensAxis as u, type TriggerState as v, type UpsellButtonProps as w, type UpsellCommonProps as x, type UpsellRecovery as y, type UseCheckoutOptions as z };
@@ -7640,6 +7640,7 @@ function Checkout(props) {
7640
7640
  payment,
7641
7641
  className,
7642
7642
  appearance,
7643
+ options: displayOptions,
7643
7644
  methods,
7644
7645
  classNames,
7645
7646
  ...options
@@ -7650,7 +7651,8 @@ function Checkout(props) {
7650
7651
  offering,
7651
7652
  className,
7652
7653
  appearance,
7653
- methods,
7654
+ // `options` is the prop; `methods` is its old name, still accepted.
7655
+ methods: displayOptions ?? methods,
7654
7656
  classNames,
7655
7657
  as: "Checkout",
7656
7658
  // The axes resolve, and the result is always an INLINE rendering: `<Checkout>` is the payment
@@ -7668,6 +7670,7 @@ function CheckoutButton(props) {
7668
7670
  children,
7669
7671
  className,
7670
7672
  appearance,
7673
+ options: displayOptions,
7671
7674
  methods,
7672
7675
  classNames,
7673
7676
  ...options
@@ -7678,7 +7681,7 @@ function CheckoutButton(props) {
7678
7681
  offering,
7679
7682
  className,
7680
7683
  appearance,
7681
- methods,
7684
+ methods: displayOptions ?? methods,
7682
7685
  classNames,
7683
7686
  asChild,
7684
7687
  children,
@@ -9532,5 +9535,5 @@ function useGroupProgress() {
9532
9535
  }
9533
9536
 
9534
9537
  export { Checkout, CheckoutButton, CheckoutResume, CheckoutSpinner, EmbedBridge, FunnelProvider, FunnelToaster, FunnelView, Modal, Sheet, UpsellButton, VariableStore, attachBus, buildAcquisition, buildContext, createBus, createConsoleTracker, createFunnelStore, createMockDriver, defineModal, dismissAllModals, driverWithEmail, ensureCheckoutButtonStyles, exposurePayload, hideModal, isValidEmail, newEventId, registerModal, removeModal, showModal, toast, unregisterModal, useActiveLocale, useCheckout, useClickIds, useContextValue, useData, useDevice, useExperiment, useField, useFunnel, useGroupProgress, useLocale, useMarketingConsent, useModal, useNavigation, useOffering, useOfferings, usePage, useResponse, useSystem, useTracker, useTranslation, useUserAttribute, useUtm, withBus };
9535
- //# sourceMappingURL=chunk-WCBVSZHJ.js.map
9536
- //# sourceMappingURL=chunk-WCBVSZHJ.js.map
9538
+ //# sourceMappingURL=chunk-AW2YURFE.js.map
9539
+ //# sourceMappingURL=chunk-AW2YURFE.js.map