@flopay/react 1.1.6 → 1.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.
package/dist/index.d.cts CHANGED
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { FloPay, FloPayElements } from '@flopay/js';
3
3
  import * as _flopay_shared from '@flopay/shared';
4
- import { FloPayAppearance, InlineSessionDraft, FloPayError, PaymentResult, DeclineEvent, CheckoutButtonMethod, BeforeButtonClickEvent, InlineSessionPatch, CheckoutMode, CheckoutSession, ElementOptions, ElementChangeEvent, TokenizedBody, AVSFieldConfig, GatewayEnvironment, CheckoutItem, CheckoutSubscription, ThemeId, ButtonsLayoutTheme, ButtonsLayoutStyles } from '@flopay/shared';
4
+ import { FloPayAppearance, InlineSessionDraft, FloPayError, PaymentResult, DeclineEvent, CheckoutButtonMethod, BeforeButtonClickEvent, InlineSessionPatch, CheckoutMode, CheckoutSession, ElementOptions, ElementChangeEvent, TokenizedBody, AVSFieldConfig, GatewayEnvironment, CheckoutProduct, CheckoutItem, CheckoutSubscription, ThemeId, ButtonsLayoutTheme, ButtonsLayoutStyles } from '@flopay/shared';
5
5
  export { BeforeButtonClickEvent, CheckoutButtonMethod, DeclineEvent, InlineSessionDraft, InlineSessionPatch } from '@flopay/shared';
6
6
  import * as react_jsx_runtime from 'react/jsx-runtime';
7
7
 
@@ -50,6 +50,15 @@ declare function FloPayProvider({ flopay: floPayProp, paypalFlopay: paypalFloPay
50
50
  interface FloPayCheckoutProps {
51
51
  /** The checkout session ID (UUID from billing API). Required unless `createSession` is provided. */
52
52
  sessionId?: string;
53
+ /**
54
+ * Session-bound checkout token (the `nonce` returned when the session was
55
+ * created). Sent as the `x-checkout-session-token` header when fetching a
56
+ * session by `sessionId`. Required by post-#640 backends, which no longer
57
+ * let the UUID alone authorize a session read; harmless on older backends.
58
+ * Only consulted in the `sessionId` flow — inline `createSession` sessions
59
+ * carry their own freshly-minted nonce server-side.
60
+ */
61
+ nonce?: string;
53
62
  /**
54
63
  * Create a checkout session inline — no separate API route needed.
55
64
  * The component POSTs to the billing API, gets the full session back, and renders the form.
@@ -78,11 +87,30 @@ interface FloPayCheckoutProps {
78
87
  onCountryChange?: (country: string) => void;
79
88
  /** Called when the AVS ZIP/postcode input changes. */
80
89
  onZipChange?: (zip: string) => void;
81
- /** Whether to show the PayPal button (default: true). */
90
+ /**
91
+ * Show the PayPal payment surface (default: `true`). Renderer is chosen
92
+ * from `gateways.paypal` on the session — DirectPayPalButton when present,
93
+ * Stripe-rendered PayPal otherwise.
94
+ */
82
95
  showPayPal?: boolean;
83
- /** Whether to show Apple Pay button (default: true). Only renders on supported devices. */
96
+ /**
97
+ * Show the Stripe-rendered checkout — card fields, ExpressCheckoutElement,
98
+ * and the PaymentElement accordion (default: `true`). When `false`, only
99
+ * `DirectPayPalButton` can render. Both `showStripe=false` and
100
+ * `showPayPal=false` (with no PayPal gateway configured) triggers a
101
+ * bootstrap-time validation error.
102
+ */
103
+ showStripe?: boolean;
104
+ /**
105
+ * @deprecated Apple Pay availability is now driven by
106
+ * `gateways.stripe.enabledPaymentMethods` on the per-session response from
107
+ * the billing API. Setting this prop emits a one-time deprecation warning
108
+ * and is otherwise ignored once the backend ships the list.
109
+ */
84
110
  showApplePay?: boolean;
85
- /** Whether to show Google Pay button (default: true). Only renders on supported devices. */
111
+ /**
112
+ * @deprecated See {@link FloPayCheckoutProps.showApplePay}.
113
+ */
86
114
  showGooglePay?: boolean;
87
115
  /**
88
116
  * Enables on-screen diagnostic panels (PayPal gate decision, DirectPayPalButton
@@ -193,7 +221,7 @@ interface FloPayCheckoutProps {
193
221
  * />
194
222
  * ```
195
223
  */
196
- declare function FloPayCheckout({ sessionId: sessionIdProp, createSession: createSessionParams, billingApiUrl, appearance: appearanceOverride, locale, loading: loadingNode, error: errorNode, onComplete, onError, onDecline, onFullNameChange, onCountryChange, onZipChange, showPayPal, showApplePay, showGooglePay, debug, layout, theme, buttonsTheme, buttonsStyles, cardButtonContent, cardBackButtonContent, cardTitleContent, showSecurityFooter: _showSecurityFooter, onButtonClick, onBeforeButtonClick, enableAVS, avsLayout, submitLabel, className, initialErrorMessage, children, checkoutMode: checkoutModeProp, confirmLabel, renderConfirmButton, onSessionCompleted, }: FloPayCheckoutProps): React.ReactElement;
224
+ declare function FloPayCheckout({ sessionId: sessionIdProp, nonce: nonceProp, createSession: createSessionParams, billingApiUrl, appearance: appearanceOverride, locale, loading: loadingNode, error: errorNode, onComplete, onError, onDecline, onFullNameChange, onCountryChange, onZipChange, showPayPal, showStripe, showApplePay, showGooglePay, debug, layout, theme, buttonsTheme, buttonsStyles, cardButtonContent, cardBackButtonContent, cardTitleContent, showSecurityFooter: _showSecurityFooter, onButtonClick, onBeforeButtonClick, enableAVS, avsLayout, submitLabel, className, initialErrorMessage, children, checkoutMode: checkoutModeProp, confirmLabel, renderConfirmButton, onSessionCompleted, }: FloPayCheckoutProps): React.ReactElement;
197
225
 
198
226
  /**
199
227
  * Returns the current `FloPay` instance, or `null` if the provider
@@ -422,14 +450,44 @@ interface SplitCardFormProps {
422
450
  /** Callback when last name changes (from the name input). */
423
451
  onLastNameChange?: (value: string) => void;
424
452
  /**
425
- * Show PayPal button above card fields. Defaults to `true`.
426
- * Uses Stripe's ExpressCheckoutElement in a separate Elements instance,
427
- * matching checkout/StripeCardForm architecture.
453
+ * Show the PayPal payment surface above card fields. Defaults to `true`.
454
+ * The renderer is chosen from `session.gateways.paypal`: when that gateway
455
+ * is configured, `DirectPayPalButton` (PayPal JS SDK) takes over and Stripe
456
+ * drops `paypal` from its express row to avoid double-rendering; otherwise
457
+ * PayPal renders inside `ExpressCheckoutElement` (using either a dedicated
458
+ * `gateways.stripe.paypalPublishableKey` sub-account or the main Stripe
459
+ * account when the enabled-methods list includes `paypal`).
428
460
  */
429
461
  showPayPal?: boolean;
430
- /** Show Apple Pay button. Defaults to `true`. Only renders on supported devices. */
462
+ /**
463
+ * Show the Stripe-rendered checkout (card fields + ExpressCheckoutElement +
464
+ * PaymentElement). Defaults to `true`. When `false`, every Stripe surface
465
+ * is hidden — only `DirectPayPalButton` can render. Setting both
466
+ * `showStripe={false}` and `showPayPal={false}` (with no PayPal gateway
467
+ * configured) throws a bootstrap-time validation error.
468
+ */
469
+ showStripe?: boolean;
470
+ /**
471
+ * Per-session list of Stripe payment method type identifiers (as returned
472
+ * by the billing API on `gateways.stripe.enabledPaymentMethods`). When
473
+ * supplied, drives the contents of the `ExpressCheckoutElement` row and the
474
+ * accordion `PaymentElement` instead of the historic hardcoded
475
+ * Apple/Google/PayPal set. When omitted, the SDK falls back to the legacy
476
+ * `showApplePay`/`showGooglePay`/`showPayPal` toggles.
477
+ */
478
+ enabledPaymentMethods?: string[];
479
+ /**
480
+ * @deprecated The Apple Pay / Google Pay surface is now driven by the
481
+ * `gateways.stripe.enabledPaymentMethods` list returned per-session by the
482
+ * billing API. Pass {@link SplitCardFormProps.enabledPaymentMethods} (or
483
+ * upgrade the backend so `FloPayCheckout` threads it through automatically).
484
+ * Setting this prop emits a one-time deprecation warning and is otherwise
485
+ * ignored when `enabledPaymentMethods` is supplied.
486
+ */
431
487
  showApplePay?: boolean;
432
- /** Show Google Pay button. Defaults to `true`. Only renders on supported devices. */
488
+ /**
489
+ * @deprecated See {@link SplitCardFormProps.showApplePay}.
490
+ */
433
491
  showGooglePay?: boolean;
434
492
  /**
435
493
  * Layout mode for the payment form.
@@ -736,6 +794,12 @@ interface FloPayAutomaticPaymentButtonProps extends Omit<React.ButtonHTMLAttribu
736
794
  */
737
795
  checkoutMethod?: CheckoutButtonMethod;
738
796
  clientId?: string;
797
+ /**
798
+ * Unified products array (TeamFloPay/backend#760). When supplied,
799
+ * `items`/`subscriptions` are ignored. The SDK folds the legacy fields
800
+ * into this shape internally.
801
+ */
802
+ products?: CheckoutProduct[];
739
803
  items?: CheckoutItem[];
740
804
  subscriptions?: CheckoutSubscription[];
741
805
  account?: InlineSessionDraft['account'];
@@ -766,6 +830,6 @@ interface FloPayAutomaticPaymentButtonProps extends Omit<React.ButtonHTMLAttribu
766
830
  onDecline?: (decline: DeclineEvent) => void;
767
831
  children?: React.ReactNode;
768
832
  }
769
- declare function FloPayAutomaticPaymentButton({ sessionId, createSession, paymentMethodId: _deprecatedPaymentMethodId, checkoutMethod: _deprecatedCheckoutMethod, clientId, items, subscriptions, account, successUrl, cancelUrl, couponCodes, tagsData, utmMetadata, billingApiUrl, locale, theme, buttonsTheme, buttonsStyles: stylesOverride, onSuccess, onError, onDecline, children, disabled, type, style, ...buttonProps }: FloPayAutomaticPaymentButtonProps): react_jsx_runtime.JSX.Element;
833
+ declare function FloPayAutomaticPaymentButton({ sessionId, createSession, paymentMethodId: _deprecatedPaymentMethodId, checkoutMethod: _deprecatedCheckoutMethod, clientId, products, items, subscriptions, account, successUrl, cancelUrl, couponCodes, tagsData, utmMetadata, billingApiUrl, locale, theme, buttonsTheme, buttonsStyles: stylesOverride, onSuccess, onError, onDecline, children, disabled, type, style, ...buttonProps }: FloPayAutomaticPaymentButtonProps): react_jsx_runtime.JSX.Element;
770
834
 
771
835
  export { AddressElement, CardCvcElement, CardElement, CardExpiryElement, CardNumberElement, CheckoutForm, type CheckoutFormProps, type CheckoutFormRef, type CheckoutState, DirectPayPalButton, type DirectPayPalButtonProps, type ElementComponentProps, FloPayAutomaticPaymentButton, type FloPayAutomaticPaymentButtonProps, type FloPayAutomaticPaymentSuccessEvent, FloPayCheckout, type FloPayCheckoutProps, FloPayProvider, type FloPayProviderProps, PayPalButton, type PayPalButtonProps, PaymentElement, SplitCardForm, type SplitCardFormProps, type SplitCardFormRef, useCheckout, useElements, useFloPay, usePayPalFloPay };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { FloPay, FloPayElements } from '@flopay/js';
3
3
  import * as _flopay_shared from '@flopay/shared';
4
- import { FloPayAppearance, InlineSessionDraft, FloPayError, PaymentResult, DeclineEvent, CheckoutButtonMethod, BeforeButtonClickEvent, InlineSessionPatch, CheckoutMode, CheckoutSession, ElementOptions, ElementChangeEvent, TokenizedBody, AVSFieldConfig, GatewayEnvironment, CheckoutItem, CheckoutSubscription, ThemeId, ButtonsLayoutTheme, ButtonsLayoutStyles } from '@flopay/shared';
4
+ import { FloPayAppearance, InlineSessionDraft, FloPayError, PaymentResult, DeclineEvent, CheckoutButtonMethod, BeforeButtonClickEvent, InlineSessionPatch, CheckoutMode, CheckoutSession, ElementOptions, ElementChangeEvent, TokenizedBody, AVSFieldConfig, GatewayEnvironment, CheckoutProduct, CheckoutItem, CheckoutSubscription, ThemeId, ButtonsLayoutTheme, ButtonsLayoutStyles } from '@flopay/shared';
5
5
  export { BeforeButtonClickEvent, CheckoutButtonMethod, DeclineEvent, InlineSessionDraft, InlineSessionPatch } from '@flopay/shared';
6
6
  import * as react_jsx_runtime from 'react/jsx-runtime';
7
7
 
@@ -50,6 +50,15 @@ declare function FloPayProvider({ flopay: floPayProp, paypalFlopay: paypalFloPay
50
50
  interface FloPayCheckoutProps {
51
51
  /** The checkout session ID (UUID from billing API). Required unless `createSession` is provided. */
52
52
  sessionId?: string;
53
+ /**
54
+ * Session-bound checkout token (the `nonce` returned when the session was
55
+ * created). Sent as the `x-checkout-session-token` header when fetching a
56
+ * session by `sessionId`. Required by post-#640 backends, which no longer
57
+ * let the UUID alone authorize a session read; harmless on older backends.
58
+ * Only consulted in the `sessionId` flow — inline `createSession` sessions
59
+ * carry their own freshly-minted nonce server-side.
60
+ */
61
+ nonce?: string;
53
62
  /**
54
63
  * Create a checkout session inline — no separate API route needed.
55
64
  * The component POSTs to the billing API, gets the full session back, and renders the form.
@@ -78,11 +87,30 @@ interface FloPayCheckoutProps {
78
87
  onCountryChange?: (country: string) => void;
79
88
  /** Called when the AVS ZIP/postcode input changes. */
80
89
  onZipChange?: (zip: string) => void;
81
- /** Whether to show the PayPal button (default: true). */
90
+ /**
91
+ * Show the PayPal payment surface (default: `true`). Renderer is chosen
92
+ * from `gateways.paypal` on the session — DirectPayPalButton when present,
93
+ * Stripe-rendered PayPal otherwise.
94
+ */
82
95
  showPayPal?: boolean;
83
- /** Whether to show Apple Pay button (default: true). Only renders on supported devices. */
96
+ /**
97
+ * Show the Stripe-rendered checkout — card fields, ExpressCheckoutElement,
98
+ * and the PaymentElement accordion (default: `true`). When `false`, only
99
+ * `DirectPayPalButton` can render. Both `showStripe=false` and
100
+ * `showPayPal=false` (with no PayPal gateway configured) triggers a
101
+ * bootstrap-time validation error.
102
+ */
103
+ showStripe?: boolean;
104
+ /**
105
+ * @deprecated Apple Pay availability is now driven by
106
+ * `gateways.stripe.enabledPaymentMethods` on the per-session response from
107
+ * the billing API. Setting this prop emits a one-time deprecation warning
108
+ * and is otherwise ignored once the backend ships the list.
109
+ */
84
110
  showApplePay?: boolean;
85
- /** Whether to show Google Pay button (default: true). Only renders on supported devices. */
111
+ /**
112
+ * @deprecated See {@link FloPayCheckoutProps.showApplePay}.
113
+ */
86
114
  showGooglePay?: boolean;
87
115
  /**
88
116
  * Enables on-screen diagnostic panels (PayPal gate decision, DirectPayPalButton
@@ -193,7 +221,7 @@ interface FloPayCheckoutProps {
193
221
  * />
194
222
  * ```
195
223
  */
196
- declare function FloPayCheckout({ sessionId: sessionIdProp, createSession: createSessionParams, billingApiUrl, appearance: appearanceOverride, locale, loading: loadingNode, error: errorNode, onComplete, onError, onDecline, onFullNameChange, onCountryChange, onZipChange, showPayPal, showApplePay, showGooglePay, debug, layout, theme, buttonsTheme, buttonsStyles, cardButtonContent, cardBackButtonContent, cardTitleContent, showSecurityFooter: _showSecurityFooter, onButtonClick, onBeforeButtonClick, enableAVS, avsLayout, submitLabel, className, initialErrorMessage, children, checkoutMode: checkoutModeProp, confirmLabel, renderConfirmButton, onSessionCompleted, }: FloPayCheckoutProps): React.ReactElement;
224
+ declare function FloPayCheckout({ sessionId: sessionIdProp, nonce: nonceProp, createSession: createSessionParams, billingApiUrl, appearance: appearanceOverride, locale, loading: loadingNode, error: errorNode, onComplete, onError, onDecline, onFullNameChange, onCountryChange, onZipChange, showPayPal, showStripe, showApplePay, showGooglePay, debug, layout, theme, buttonsTheme, buttonsStyles, cardButtonContent, cardBackButtonContent, cardTitleContent, showSecurityFooter: _showSecurityFooter, onButtonClick, onBeforeButtonClick, enableAVS, avsLayout, submitLabel, className, initialErrorMessage, children, checkoutMode: checkoutModeProp, confirmLabel, renderConfirmButton, onSessionCompleted, }: FloPayCheckoutProps): React.ReactElement;
197
225
 
198
226
  /**
199
227
  * Returns the current `FloPay` instance, or `null` if the provider
@@ -422,14 +450,44 @@ interface SplitCardFormProps {
422
450
  /** Callback when last name changes (from the name input). */
423
451
  onLastNameChange?: (value: string) => void;
424
452
  /**
425
- * Show PayPal button above card fields. Defaults to `true`.
426
- * Uses Stripe's ExpressCheckoutElement in a separate Elements instance,
427
- * matching checkout/StripeCardForm architecture.
453
+ * Show the PayPal payment surface above card fields. Defaults to `true`.
454
+ * The renderer is chosen from `session.gateways.paypal`: when that gateway
455
+ * is configured, `DirectPayPalButton` (PayPal JS SDK) takes over and Stripe
456
+ * drops `paypal` from its express row to avoid double-rendering; otherwise
457
+ * PayPal renders inside `ExpressCheckoutElement` (using either a dedicated
458
+ * `gateways.stripe.paypalPublishableKey` sub-account or the main Stripe
459
+ * account when the enabled-methods list includes `paypal`).
428
460
  */
429
461
  showPayPal?: boolean;
430
- /** Show Apple Pay button. Defaults to `true`. Only renders on supported devices. */
462
+ /**
463
+ * Show the Stripe-rendered checkout (card fields + ExpressCheckoutElement +
464
+ * PaymentElement). Defaults to `true`. When `false`, every Stripe surface
465
+ * is hidden — only `DirectPayPalButton` can render. Setting both
466
+ * `showStripe={false}` and `showPayPal={false}` (with no PayPal gateway
467
+ * configured) throws a bootstrap-time validation error.
468
+ */
469
+ showStripe?: boolean;
470
+ /**
471
+ * Per-session list of Stripe payment method type identifiers (as returned
472
+ * by the billing API on `gateways.stripe.enabledPaymentMethods`). When
473
+ * supplied, drives the contents of the `ExpressCheckoutElement` row and the
474
+ * accordion `PaymentElement` instead of the historic hardcoded
475
+ * Apple/Google/PayPal set. When omitted, the SDK falls back to the legacy
476
+ * `showApplePay`/`showGooglePay`/`showPayPal` toggles.
477
+ */
478
+ enabledPaymentMethods?: string[];
479
+ /**
480
+ * @deprecated The Apple Pay / Google Pay surface is now driven by the
481
+ * `gateways.stripe.enabledPaymentMethods` list returned per-session by the
482
+ * billing API. Pass {@link SplitCardFormProps.enabledPaymentMethods} (or
483
+ * upgrade the backend so `FloPayCheckout` threads it through automatically).
484
+ * Setting this prop emits a one-time deprecation warning and is otherwise
485
+ * ignored when `enabledPaymentMethods` is supplied.
486
+ */
431
487
  showApplePay?: boolean;
432
- /** Show Google Pay button. Defaults to `true`. Only renders on supported devices. */
488
+ /**
489
+ * @deprecated See {@link SplitCardFormProps.showApplePay}.
490
+ */
433
491
  showGooglePay?: boolean;
434
492
  /**
435
493
  * Layout mode for the payment form.
@@ -736,6 +794,12 @@ interface FloPayAutomaticPaymentButtonProps extends Omit<React.ButtonHTMLAttribu
736
794
  */
737
795
  checkoutMethod?: CheckoutButtonMethod;
738
796
  clientId?: string;
797
+ /**
798
+ * Unified products array (TeamFloPay/backend#760). When supplied,
799
+ * `items`/`subscriptions` are ignored. The SDK folds the legacy fields
800
+ * into this shape internally.
801
+ */
802
+ products?: CheckoutProduct[];
739
803
  items?: CheckoutItem[];
740
804
  subscriptions?: CheckoutSubscription[];
741
805
  account?: InlineSessionDraft['account'];
@@ -766,6 +830,6 @@ interface FloPayAutomaticPaymentButtonProps extends Omit<React.ButtonHTMLAttribu
766
830
  onDecline?: (decline: DeclineEvent) => void;
767
831
  children?: React.ReactNode;
768
832
  }
769
- declare function FloPayAutomaticPaymentButton({ sessionId, createSession, paymentMethodId: _deprecatedPaymentMethodId, checkoutMethod: _deprecatedCheckoutMethod, clientId, items, subscriptions, account, successUrl, cancelUrl, couponCodes, tagsData, utmMetadata, billingApiUrl, locale, theme, buttonsTheme, buttonsStyles: stylesOverride, onSuccess, onError, onDecline, children, disabled, type, style, ...buttonProps }: FloPayAutomaticPaymentButtonProps): react_jsx_runtime.JSX.Element;
833
+ declare function FloPayAutomaticPaymentButton({ sessionId, createSession, paymentMethodId: _deprecatedPaymentMethodId, checkoutMethod: _deprecatedCheckoutMethod, clientId, products, items, subscriptions, account, successUrl, cancelUrl, couponCodes, tagsData, utmMetadata, billingApiUrl, locale, theme, buttonsTheme, buttonsStyles: stylesOverride, onSuccess, onError, onDecline, children, disabled, type, style, ...buttonProps }: FloPayAutomaticPaymentButtonProps): react_jsx_runtime.JSX.Element;
770
834
 
771
835
  export { AddressElement, CardCvcElement, CardElement, CardExpiryElement, CardNumberElement, CheckoutForm, type CheckoutFormProps, type CheckoutFormRef, type CheckoutState, DirectPayPalButton, type DirectPayPalButtonProps, type ElementComponentProps, FloPayAutomaticPaymentButton, type FloPayAutomaticPaymentButtonProps, type FloPayAutomaticPaymentSuccessEvent, FloPayCheckout, type FloPayCheckoutProps, FloPayProvider, type FloPayProviderProps, PayPalButton, type PayPalButtonProps, PaymentElement, SplitCardForm, type SplitCardFormProps, type SplitCardFormRef, useCheckout, useElements, useFloPay, usePayPalFloPay };