@flopay/react 1.16.3 → 1.16.4

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
@@ -283,6 +283,31 @@ Sentry.init({ beforeSend: dropThirdPartyOnlyError });
283
283
 
284
284
  It drops only complete exception stacks with no app or `@flopay/*` frame and at least one recognized browser-extension or Stripe controller frame; every other error passes through unchanged.
285
285
 
286
+ #### Card-field lifecycle
287
+
288
+ `onCardFieldsReady` is called once per hosted card form, when the card fields are on screen and the buyer can type in them (not when the form's markup is inserted), with `{ type: 'card_fields_ready', elapsedMs }`: the milliseconds since that card form mounted. `onCardFieldsFailed` is called when the card fields fail to load, or are not ready within `cardFieldsTimeoutMs` (default 15 000 ms, the same on every device; a value that is not a positive number keeps the default), with `{ type: 'card_fields_failed', reason, elapsedMs }`. `reason` is always one of:
289
+
290
+ | Reason | When |
291
+ |--------|------|
292
+ | `load_error` | The card form failed to load, for example its network request failed |
293
+ | `timeout` | The card fields were not interactive within `cardFieldsTimeoutMs` |
294
+ | `blocked` | A content-security policy blocked the card form's own script or frame |
295
+ | `other` | Any other failure, such as the card form not mounting at all |
296
+
297
+ A card-field failure is not a declined or failed payment: it never calls `onDecline`, and on `onInstrument` it is `card_fields_failed`, never `checkout_error`. If the fields become ready after a `timeout`, `onCardFieldsReady` still follows, with no second failure. Both events also reach `onInstrument` as `{ schemaVersion: 1, name: 'card_fields_ready', elapsedMs }` and `{ schemaVersion: 1, name: 'card_fields_failed', reason, elapsedMs }`, and Flo's SDK telemetry with the checkout session id. They never carry card data, a throwing callback does not affect the checkout, and nothing changes if you use neither.
298
+
299
+ `onError` is unchanged: it is still called, as before, when the hosted form itself reports that it failed to load. A timeout, a blocked form or any other failure the SDK detects reaches only `onCardFieldsFailed`. With an older hosted form that does not report when its fields become interactive, `onCardFieldsReady` is called when that form reports its own ready instead.
300
+
301
+ ```tsx
302
+ <FloPayCheckout
303
+ sessionId={sessionId}
304
+ nonce={nonce}
305
+ cardFieldsTimeoutMs={20_000}
306
+ onCardFieldsReady={({ elapsedMs }) => track('card_fields_ready', { elapsedMs })}
307
+ onCardFieldsFailed={({ reason, elapsedMs }) => track('card_fields_failed', { reason, elapsedMs })}
308
+ />
309
+ ```
310
+
286
311
  ### FloPayCardSetup
287
312
 
288
313
  `FloPayCardSetup` lets a customer add or verify a card without a purchase or charge. Your trusted server first calls the merchant-authenticated card-setup endpoint and passes only its opaque `sessionId` and bound `nonce` to the browser; never send API credentials or a customer identifier to this component. See the [payment methods reference](https://flopay.com/docs/technical-reference/rest/payment-methods) for listing, setup, and deletion.
@@ -661,6 +686,9 @@ export function ComposedCheckout({ session, nonce }: { session: CheckoutSession;
661
686
  | `avsLayout` | `'row' \| 'column'` | AVS field layout |
662
687
  | `cardFieldOrder` | `VaultCardFieldKey[]?` | Order of the hosted card rows |
663
688
  | `cardAutoFocus` | `boolean?` | Set `false` to stop the checkout focusing the card form (or the identity/AVS field above it) when it opens; omitted or `true` keeps the default |
689
+ | `cardFieldsTimeoutMs` | `number?` | Milliseconds the card fields may take to become interactive before `onCardFieldsFailed` reports `timeout` (default 15 000) |
690
+ | `onCardFieldsReady` | `(event: CardFieldsReadyEvent) => void` | The hosted card fields are interactive; once per card form, with `elapsedMs` since it mounted |
691
+ | `onCardFieldsFailed` | `(event: CardFieldsFailedEvent) => void` | The card fields failed to load or were not ready in time; not a decline or payment error |
664
692
  | `cardPreFormSlot` | `ReactNode?` | Content rendered above the hosted card form |
665
693
  | `cardButtonContent` | `ReactNode?` | Card tile content in `layout="buttons"` |
666
694
  | `cardBackButtonContent` | `ReactNode?` | Back-button label in `layout="buttons"` |
@@ -770,6 +798,8 @@ Also accepts every standard `button` attribute, such as `onClick`, `disabled`, a
770
798
  | `enableAVS` | `boolean \| AVSFieldConfig` | Collect and validate the billing address |
771
799
  | `cardFieldOrder` | `VaultCardFieldKey[]?` | Order of the hosted card rows |
772
800
  | `cardAutoFocus` | `boolean?` | Set `false` to stop the form focusing the hosted card (or the identity/AVS field above it) when it opens; omitted or `true` keeps the default |
801
+ | `cardFieldsTimeoutMs` | `number?` | Milliseconds the card fields may take to become interactive before `onCardFieldsFailed` reports `timeout` (default 15 000) |
802
+ | `onCardFieldsReady` / `onCardFieldsFailed` | callbacks | Card-field lifecycle; see **Card-field lifecycle** above |
773
803
  | `onBuyerIdentityReady` | `(identity) => MaybePromise<void>` | Attach a buyer identity collected by the form; `FloPayCheckout` wires its late-buyer claim here |
774
804
  | `onTokenizedBody` | `(body: TokenizedBody) => void` | Take over non-card backend submission yourself |
775
805
  | `onComplete` / `onDecline` / `onError` | callbacks | Checkout outcomes |
@@ -824,6 +854,10 @@ Also accepts every standard `button` attribute, such as `onClick`, `disabled`, a
824
854
  | `PaymentMethodLayoutRules` | `{ order?: PaymentMethodGroup[]; moreOptions?: PaymentMethodGroup[]; countryRules?: PaymentMethodCountryRule[] }`, the merchant's layout rules |
825
855
  | `PaymentMethodCountryRule` | `{ countries: string[]; order?: PaymentMethodGroup[]; moreOptions?: PaymentMethodGroup[] }`, a rule for buyers in the listed ISO 3166-1 alpha-2 countries |
826
856
  | `FloInstrumentEvent` | Versioned merchant instrument union |
857
+ | `CardFieldsReadyEvent` | `{ type: 'card_fields_ready', elapsedMs }`, the payload of the onCardFieldsReady callback |
858
+ | `CardFieldsFailedEvent` | `{ type: 'card_fields_failed', reason, elapsedMs }`, the payload of the onCardFieldsFailed callback |
859
+ | `CardFieldsFailureReason` | `'load_error'`, `'timeout'`, `'blocked'` or `'other'` |
860
+ | `CardFieldsEvent` | `CardFieldsReadyEvent \| CardFieldsFailedEvent` |
827
861
 
828
862
  ## Errors
829
863
 
@@ -1,4 +1,4 @@
1
- import type { BeforeButtonClickEvent, CheckoutButtonMethod, CheckoutMode, DeclineEvent, FloInstrumentEvent, FloPayAppearance, FloPayPaymentCancelEvent, InlineSessionDraft, InlineSessionPatch, PaymentMethodLayoutRules, PaymentResult, WalletPresentation } from '@flopay/shared';
1
+ import type { BeforeButtonClickEvent, CardFieldsFailedEvent, CardFieldsReadyEvent, 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. */
@@ -40,6 +40,12 @@ export interface FloPayCheckoutProps {
40
40
  onInstrument?: (event: FloInstrumentEvent) => void;
41
41
  /** Called when a payment is declined or the authentication step fails. */
42
42
  onDecline?: (decline: DeclineEvent) => void;
43
+ /** Called once per card form when the hosted card fields are interactive. */
44
+ onCardFieldsReady?: (event: CardFieldsReadyEvent) => void;
45
+ /** Called when the hosted card fields fail to load or are not ready within the timeout. */
46
+ onCardFieldsFailed?: (event: CardFieldsFailedEvent) => void;
47
+ /** Milliseconds the card fields may take to become ready before a `timeout` failure. */
48
+ cardFieldsTimeoutMs?: number;
43
49
  /**
44
50
  * Called once when the buyer closes or leaves the direct PayPal button's
45
51
  * PayPal window without approving. Never called for an approval, a decline
@@ -259,4 +265,4 @@ export interface FloPayCheckoutProps {
259
265
  * />
260
266
  * ```
261
267
  */
262
- 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, moreOptionsLabel, 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;
268
+ 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, moreOptionsLabel, theme, buttonsTheme, buttonsStyles, cardButtonContent, cardBackButtonContent, cardTitleContent, showSecurityFooter: _showSecurityFooter, onButtonClick, onBeforeButtonClick, enableAVS, cardFieldOrder, cardAutoFocus, onCardFieldsReady, onCardFieldsFailed, cardFieldsTimeoutMs, cardPreFormSlot, avsLayout, submitLabel, className, initialErrorMessage, initialPayPalOrderId, children, checkoutMode: checkoutModeProp, confirmLabel, renderConfirmButton, onSessionCompleted, }: FloPayCheckoutProps): React.ReactElement;