@flopay/react 1.14.14 → 1.15.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/README.md CHANGED
@@ -218,6 +218,29 @@ One value styles non-card Stripe Elements, the SDK-rendered wrapper and AVS fiel
218
218
 
219
219
  `layout="buttons"` stacks the payment methods as buttons with an expandable card form, and can change at runtime without recreating the session. In that layout, `onButtonClick` reports every method click, `onDecline` reports declines and cancellations, and `onBeforeButtonClick` runs before a method continues: return an `InlineSessionPatch` to update the inline draft, or `false` to stop. Keep it well under 900 ms for PayPal, Apple Pay, and Google Pay, because it runs during the provider's button handshake (see **Stalled wallet clicks** above).
220
220
 
221
+ `paymentMethodLayout` sets the order of the payment method groups: `'card'`, `'paypal'`, `'wallets'` (Apple Pay and Google Pay) and `'apms'` (alternative payment methods such as Klarna, iDEAL or SEPA), with optional rules for buyers in particular countries. Without it, the order is PayPal, wallets, APMs, then card, and nothing extra is requested.
222
+
223
+ - `order` is the default order. Groups you leave out follow the ones you list, in the default order, so `order: ['card']` puts card first and keeps the rest as they were.
224
+ - `countryRules` gives buyers in some countries their own `order`. Each rule lists ISO 3166-1 alpha-2 `countries`; the first rule naming the buyer's country applies, and a rule without `order` uses the default `order`.
225
+ - The FloPay billing API applies the rules to each buyer and the checkout shows the order it resolves. The buyer's country is the checkout session's country when it has one, otherwise the buyer's IP country. The IP country is used only to pick the rule and never reaches your page. Unknown or repeated values are ignored, and the API's warnings about them are logged to the console.
226
+ - Until the order is known the payment methods show placeholders, so nothing moves once it is on screen. If the API is slow or unavailable, the default `order` applies without country rules.
227
+ - In `layout="buttons"` every group follows the order, and Card is the **Credit / Debit Card** button. In the default layout PayPal, wallets and APMs follow the order among the buttons; Card first puts the card form above them, with an "or pay another way" divider, and anywhere else the card form stays below "or pay with card".
228
+ - A group that is hidden (`showPayPal={false}`) or unavailable (no wallet on the device, no APM for the currency) is skipped and leaves no gap. Hiding a group is still the job of the show/hide props.
229
+ - The rules can change after mount. The checkout asks the API again and keeps the current order until the new one is known. A group whose place changes is mounted again rather than moved, so its provider frame never breaks; set the rules before the buyer starts paying, because a moved card form reloads its fields.
230
+ - `FloPayCheckout` passes the rules to its built-in form and injects them into custom-layout children that do not set their own.
231
+
232
+ ```tsx
233
+ <FloPayCheckout
234
+ sessionId={sessionId}
235
+ nonce={nonce}
236
+ layout="buttons"
237
+ paymentMethodLayout={{
238
+ order: ['card', 'wallets', 'apms', 'paypal'],
239
+ countryRules: [{ countries: ['US', 'GB', 'CA', 'AU', 'NZ', 'IE'], order: ['paypal'] }],
240
+ }}
241
+ />
242
+ ```
243
+
221
244
  #### Merchant instrument feed
222
245
 
223
246
  `onInstrument` on `FloPayCheckout` or `FloPayProvider` forwards a stable, privacy-safe checkout funnel to your own analytics as `FloInstrumentEvent` values. `schemaVersion` is always `1`, and `gateway` (`stripe` or `paypal`) is included only when an event is attributable to that provider.
@@ -605,6 +628,7 @@ export function ComposedCheckout({ session, nonce }: { session: CheckoutSession;
605
628
  | `checkoutMode` | `CheckoutMode?` | Overrides the session's checkout mode |
606
629
  | `billingApiUrl` | `string?` | Billing API base URL; defaults to the configured environment |
607
630
  | `layout` | `'default' \| 'buttons'` | Payment form layout |
631
+ | `paymentMethodLayout` | `PaymentMethodLayoutRules?` | Order of `'card'`, `'paypal'`, `'wallets'` and `'apms'`, with per-country rules, resolved for each buyer by the billing API; without it, PayPal, wallets, APMs, card |
608
632
  | `theme` | `ThemeId?` | Theme bundle for the whole checkout |
609
633
  | `appearance` | `FloPayAppearance?` | Stripe-side appearance overrides |
610
634
  | `buttonsStyles` | `ButtonsLayoutStyles?` | Wrapper style overrides layered on the theme |
@@ -719,6 +743,7 @@ Also accepts every standard `button` attribute, such as `onClick`, `disabled`, a
719
743
  | `totalAmount` | `number?` | Amount in the smallest currency unit, for wallet and PayPal configuration |
720
744
  | `currency` | `string?` | Currency code for wallet and PayPal configuration |
721
745
  | `layout` | `'default' \| 'buttons'` | Payment form layout |
746
+ | `paymentMethodLayout` | `PaymentMethodLayoutRules?` | Order of `'card'`, `'paypal'`, `'wallets'` and `'apms'`, with per-country rules, resolved for each buyer by the billing API; without it, PayPal, wallets, APMs, card |
722
747
  | `theme` | `ThemeId?` | Theme bundle |
723
748
  | `submitLabel` | `(string \| null)?` | Live wording for the hosted card submit button; omitted, `null`, or blank shows the hosted default `CONFIRM PAYMENT` |
724
749
  | `showStripe` / `showPayPal` | `boolean?` | Toggle Stripe methods and PayPal |
@@ -777,6 +802,9 @@ Also accepts every standard `button` attribute, such as `onClick`, `disabled`, a
777
802
  | `InlineSessionDraft` | Draft accepted by `FloPayCheckoutProps.createSession` |
778
803
  | `InlineSessionPatch` | Partial draft returned from `FloPayCheckoutProps.onBeforeButtonClick` |
779
804
  | `WalletPresentation` | Closed wallet presentation preference: `auto`, `popup`, or `prefer_redirect` |
805
+ | `PaymentMethodGroup` | A group `paymentMethodLayout` can place: `'card'`, `'paypal'`, `'wallets'` or `'apms'` |
806
+ | `PaymentMethodLayoutRules` | `{ order?: PaymentMethodGroup[]; countryRules?: PaymentMethodCountryRule[] }`, the merchant's layout rules |
807
+ | `PaymentMethodCountryRule` | `{ countries: string[]; order?: PaymentMethodGroup[] }`, a rule for buyers in the listed ISO 3166-1 alpha-2 countries |
780
808
  | `FloInstrumentEvent` | Versioned merchant instrument union |
781
809
 
782
810
  ## Errors
@@ -1,4 +1,4 @@
1
- import type { BeforeButtonClickEvent, CheckoutButtonMethod, CheckoutMode, DeclineEvent, FloInstrumentEvent, FloPayAppearance, FloPayPaymentCancelEvent, InlineSessionDraft, InlineSessionPatch, PaymentResult, WalletPresentation } from '@flopay/shared';
1
+ import type { BeforeButtonClickEvent, CheckoutButtonMethod, CheckoutMode, DeclineEvent, FloInstrumentEvent, FloPayAppearance, FloPayPaymentCancelEvent, InlineSessionDraft, InlineSessionPatch, PaymentMethodLayoutRules, PaymentResult, WalletPresentation } from '@flopay/shared';
2
2
  import { FloPayError } from '@flopay/shared';
3
3
  import React from 'react';
4
4
  /** Props for the all-in-one `FloPayCheckout` wrapper. */
@@ -104,6 +104,16 @@ export interface FloPayCheckoutProps {
104
104
  debug?: boolean;
105
105
  /** Layout mode: 'default' (all visible) or 'buttons' (PayPal/wallets + expandable card form). */
106
106
  layout?: 'default' | 'buttons';
107
+ /**
108
+ * The merchant's rules for the order of `'card'`, `'paypal'`, `'wallets'`
109
+ * and `'apms'`, with optional per-country rules. The billing API applies
110
+ * them to each buyer and the checkout shows the order it resolves. Without
111
+ * the prop the order is PayPal, wallets, APMs, then card. Can change after
112
+ * mount; a group whose place changes is mounted again. Injected into
113
+ * custom-layout children that set none. See
114
+ * `SplitCardFormProps.paymentMethodLayout`.
115
+ */
116
+ paymentMethodLayout?: PaymentMethodLayoutRules;
107
117
  /**
108
118
  * High-level theme bundle that styles non-card Stripe Elements, the FloPay
109
119
  * wrapper / AVS inputs, and the hosted vault widget. One of: `'classic'`
@@ -242,4 +252,4 @@ export interface FloPayCheckoutProps {
242
252
  * />
243
253
  * ```
244
254
  */
245
- export declare function FloPayCheckout({ sessionId: sessionIdProp, nonce: nonceProp, createSession: createSessionParams, billingApiUrl, telemetry, appearance: appearanceOverride, locale, loading: loadingNode, error: errorNode, onComplete, onError, onInstrument, onDecline, onCancel, onCountryChange, onZipChange, showPayPal, showStripe, walletPresentation, enabledPaymentMethods: enabledPaymentMethodsProp, showApplePay, showGooglePay, debug, layout, theme, buttonsTheme, buttonsStyles, cardButtonContent, cardBackButtonContent, cardTitleContent, showSecurityFooter: _showSecurityFooter, onButtonClick, onBeforeButtonClick, enableAVS, cardFieldOrder, cardAutoFocus, cardPreFormSlot, avsLayout, submitLabel, className, initialErrorMessage, initialPayPalOrderId, children, checkoutMode: checkoutModeProp, confirmLabel, renderConfirmButton, onSessionCompleted, }: FloPayCheckoutProps): React.ReactElement;
255
+ export declare function FloPayCheckout({ sessionId: sessionIdProp, nonce: nonceProp, createSession: createSessionParams, billingApiUrl, telemetry, appearance: appearanceOverride, locale, loading: loadingNode, error: errorNode, onComplete, onError, onInstrument, onDecline, onCancel, onCountryChange, onZipChange, showPayPal, showStripe, walletPresentation, enabledPaymentMethods: enabledPaymentMethodsProp, showApplePay, showGooglePay, debug, layout, paymentMethodLayout, theme, buttonsTheme, buttonsStyles, cardButtonContent, cardBackButtonContent, cardTitleContent, showSecurityFooter: _showSecurityFooter, onButtonClick, onBeforeButtonClick, enableAVS, cardFieldOrder, cardAutoFocus, cardPreFormSlot, avsLayout, submitLabel, className, initialErrorMessage, initialPayPalOrderId, children, checkoutMode: checkoutModeProp, confirmLabel, renderConfirmButton, onSessionCompleted, }: FloPayCheckoutProps): React.ReactElement;