@flopay/react 0.3.5 → 0.3.12

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,8 @@
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, FloPayError, PaymentResult, CheckoutMode, CheckoutSession, ElementOptions, ElementChangeEvent, TokenizedBody } from '@flopay/shared';
4
+ import { FloPayAppearance, InlineSessionDraft, FloPayError, PaymentResult, DeclineEvent, CheckoutButtonMethod, BeforeButtonClickEvent, InlineSessionPatch, CheckoutMode, CheckoutSession, ElementOptions, ElementChangeEvent, TokenizedBody } from '@flopay/shared';
5
+ export { BeforeButtonClickEvent, CheckoutButtonMethod, DeclineEvent, InlineSessionDraft, InlineSessionPatch } from '@flopay/shared';
5
6
 
6
7
  /** Props for the `FloPayProvider` component. */
7
8
  interface FloPayProviderProps {
@@ -45,7 +46,7 @@ interface FloPayCheckoutProps {
45
46
  * The component POSTs to the billing API, gets the full session back, and renders the form.
46
47
  * Alternative to `sessionId` (provide one or the other).
47
48
  */
48
- createSession?: _flopay_shared.InlineSessionParams;
49
+ createSession?: InlineSessionDraft;
49
50
  /** Billing API base URL. Defaults to the shared `BILLING_API_URL` constant. */
50
51
  billingApiUrl?: string;
51
52
  /** Visual appearance for payment elements. */
@@ -69,6 +70,8 @@ interface FloPayCheckoutProps {
69
70
  onComplete?: (result: PaymentResult) => void;
70
71
  /** Called when a payment error occurs. */
71
72
  onError?: (error: FloPayError) => void;
73
+ /** Called when a payment is declined or the authentication step fails. */
74
+ onDecline?: (decline: DeclineEvent) => void;
72
75
  /** Whether to show the PayPal button (default: true). */
73
76
  showPayPal?: boolean;
74
77
  /** Whether to show Apple Pay button (default: true). Only renders on supported devices. */
@@ -83,11 +86,22 @@ interface FloPayCheckoutProps {
83
86
  buttonsStyles?: _flopay_shared.ButtonsLayoutStyles;
84
87
  /** Custom React content rendered inside the card button when `layout="buttons"`. */
85
88
  cardButtonContent?: React.ReactNode;
89
+ /** Custom React content rendered for the buttons-layout card back button label. */
90
+ cardBackButtonContent?: React.ReactNode;
91
+ /** Custom React content rendered for the card-form title. */
92
+ cardTitleContent?: React.ReactNode;
86
93
  /**
87
94
  * Called when a payment method button is clicked.
88
95
  * `method`: `'card'` | `'paypal'` | `'apple_pay'` | `'google_pay'`
89
96
  */
90
- onButtonClick?: (method: string) => void;
97
+ onButtonClick?: (method: CheckoutButtonMethod) => void;
98
+ /**
99
+ * Called before the credit/debit card button continues.
100
+ * Card only: this does not run for PayPal or wallet buttons.
101
+ * In `layout="buttons"` with `createSession`, the returned patch is merged
102
+ * into the inline session params before the real card session is created.
103
+ */
104
+ onBeforeButtonClick?: (event: BeforeButtonClickEvent) => void | false | Promise<void | false | InlineSessionPatch> | InlineSessionPatch;
91
105
  /**
92
106
  * Enable AVS (Address Verification). Shows country dropdown + ZIP/postcode input
93
107
  * in the card form. When enabled, billing_details are passed to Stripe for AVS checks.
@@ -138,7 +152,7 @@ interface FloPayCheckoutProps {
138
152
  * />
139
153
  * ```
140
154
  */
141
- declare function FloPayCheckout({ sessionId: sessionIdProp, createSession: createSessionParams, billingApiUrl, appearance, locale, fallbackPublishableKey, loading: loadingNode, error: errorNode, onComplete, onError, showPayPal, showApplePay, showGooglePay, layout, buttonsTheme, buttonsStyles, cardButtonContent, onButtonClick, enableAVS, avsLayout, submitLabel, className, children, checkoutMode: checkoutModeProp, confirmLabel, renderConfirmButton, onSessionCompleted, }: FloPayCheckoutProps): React.ReactElement;
155
+ declare function FloPayCheckout({ sessionId: sessionIdProp, createSession: createSessionParams, billingApiUrl, appearance, locale, fallbackPublishableKey, loading: loadingNode, error: errorNode, onComplete, onError, onDecline, showPayPal, showApplePay, showGooglePay, layout, buttonsTheme, buttonsStyles, cardButtonContent, cardBackButtonContent, cardTitleContent, onButtonClick, onBeforeButtonClick, enableAVS, avsLayout, submitLabel, className, children, checkoutMode: checkoutModeProp, confirmLabel, renderConfirmButton, onSessionCompleted, }: FloPayCheckoutProps): React.ReactElement;
142
156
 
143
157
  /**
144
158
  * Returns the current `FloPay` instance, or `null` if the provider
@@ -247,6 +261,8 @@ interface CheckoutFormProps {
247
261
  onComplete?: (result: PaymentResult) => void;
248
262
  /** Called when a payment error occurs. */
249
263
  onError?: (error: FloPayError) => void;
264
+ /** Called when a payment is declined or the authentication step fails. */
265
+ onDecline?: (decline: DeclineEvent) => void;
250
266
  /**
251
267
  * **Override**: If provided, the form tokenizes the card and confirms
252
268
  * the payment, but delegates backend submission to the caller.
@@ -306,6 +322,7 @@ interface CheckoutFormProps {
306
322
  */
307
323
  declare const CheckoutForm: React.ForwardRefExoticComponent<CheckoutFormProps & React.RefAttributes<CheckoutFormRef>>;
308
324
 
325
+ type MaybePromise<T> = T | Promise<T>;
309
326
  /** Methods exposed via ref for external 3DS handling. */
310
327
  interface SplitCardFormRef {
311
328
  handleNextAction: (clientSecret: string) => Promise<void>;
@@ -324,6 +341,8 @@ interface SplitCardFormProps {
324
341
  onComplete?: (result: PaymentResult) => void;
325
342
  /** Called when a payment error occurs. */
326
343
  onError?: (error: FloPayError) => void;
344
+ /** Called when a payment is declined or the authentication step fails. */
345
+ onDecline?: (decline: DeclineEvent) => void;
327
346
  /**
328
347
  * **Override**: If provided, delegates backend submission to the caller.
329
348
  * When omitted, processes internally (calls processPayment + handles 3DS).
@@ -380,11 +399,20 @@ interface SplitCardFormProps {
380
399
  buttonsStyles?: _flopay_shared.ButtonsLayoutStyles;
381
400
  /** Custom React content rendered inside the card button when `layout="buttons"`. */
382
401
  cardButtonContent?: React.ReactNode;
402
+ /** Custom React content rendered for the buttons-layout card back button label. */
403
+ cardBackButtonContent?: React.ReactNode;
404
+ /** Custom React content rendered for the card-form title. */
405
+ cardTitleContent?: React.ReactNode;
383
406
  /**
384
407
  * Called when a payment method button is clicked.
385
408
  * `method`: `'card'` | `'paypal'` | `'apple_pay'` | `'google_pay'`
386
409
  */
387
- onButtonClick?: (method: string) => void;
410
+ onButtonClick?: (method: CheckoutButtonMethod) => void;
411
+ /**
412
+ * Called before the credit/debit card button continues.
413
+ * Card only: this does not run for PayPal or wallet buttons.
414
+ */
415
+ onBeforeButtonClick?: (event: BeforeButtonClickEvent) => MaybePromise<void | false | InlineSessionPatch>;
388
416
  /**
389
417
  * Enable AVS (Address Verification). Shows country dropdown + ZIP/postcode input.
390
418
  * When enabled, billing_details are passed to Stripe's createPaymentMethod for AVS checks.
@@ -404,6 +432,8 @@ interface SplitCardFormProps {
404
432
  totalAmount?: number;
405
433
  /** Currency code (used for PayPal Elements config). */
406
434
  currency?: string;
435
+ /** Render the card form expanded on first paint when `layout="buttons"`. */
436
+ initialCardOpen?: boolean;
407
437
  }
408
438
  /**
409
439
  * Split card checkout form matching `checkout/StripeCardForm`:
package/dist/index.d.ts CHANGED
@@ -1,7 +1,8 @@
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, FloPayError, PaymentResult, CheckoutMode, CheckoutSession, ElementOptions, ElementChangeEvent, TokenizedBody } from '@flopay/shared';
4
+ import { FloPayAppearance, InlineSessionDraft, FloPayError, PaymentResult, DeclineEvent, CheckoutButtonMethod, BeforeButtonClickEvent, InlineSessionPatch, CheckoutMode, CheckoutSession, ElementOptions, ElementChangeEvent, TokenizedBody } from '@flopay/shared';
5
+ export { BeforeButtonClickEvent, CheckoutButtonMethod, DeclineEvent, InlineSessionDraft, InlineSessionPatch } from '@flopay/shared';
5
6
 
6
7
  /** Props for the `FloPayProvider` component. */
7
8
  interface FloPayProviderProps {
@@ -45,7 +46,7 @@ interface FloPayCheckoutProps {
45
46
  * The component POSTs to the billing API, gets the full session back, and renders the form.
46
47
  * Alternative to `sessionId` (provide one or the other).
47
48
  */
48
- createSession?: _flopay_shared.InlineSessionParams;
49
+ createSession?: InlineSessionDraft;
49
50
  /** Billing API base URL. Defaults to the shared `BILLING_API_URL` constant. */
50
51
  billingApiUrl?: string;
51
52
  /** Visual appearance for payment elements. */
@@ -69,6 +70,8 @@ interface FloPayCheckoutProps {
69
70
  onComplete?: (result: PaymentResult) => void;
70
71
  /** Called when a payment error occurs. */
71
72
  onError?: (error: FloPayError) => void;
73
+ /** Called when a payment is declined or the authentication step fails. */
74
+ onDecline?: (decline: DeclineEvent) => void;
72
75
  /** Whether to show the PayPal button (default: true). */
73
76
  showPayPal?: boolean;
74
77
  /** Whether to show Apple Pay button (default: true). Only renders on supported devices. */
@@ -83,11 +86,22 @@ interface FloPayCheckoutProps {
83
86
  buttonsStyles?: _flopay_shared.ButtonsLayoutStyles;
84
87
  /** Custom React content rendered inside the card button when `layout="buttons"`. */
85
88
  cardButtonContent?: React.ReactNode;
89
+ /** Custom React content rendered for the buttons-layout card back button label. */
90
+ cardBackButtonContent?: React.ReactNode;
91
+ /** Custom React content rendered for the card-form title. */
92
+ cardTitleContent?: React.ReactNode;
86
93
  /**
87
94
  * Called when a payment method button is clicked.
88
95
  * `method`: `'card'` | `'paypal'` | `'apple_pay'` | `'google_pay'`
89
96
  */
90
- onButtonClick?: (method: string) => void;
97
+ onButtonClick?: (method: CheckoutButtonMethod) => void;
98
+ /**
99
+ * Called before the credit/debit card button continues.
100
+ * Card only: this does not run for PayPal or wallet buttons.
101
+ * In `layout="buttons"` with `createSession`, the returned patch is merged
102
+ * into the inline session params before the real card session is created.
103
+ */
104
+ onBeforeButtonClick?: (event: BeforeButtonClickEvent) => void | false | Promise<void | false | InlineSessionPatch> | InlineSessionPatch;
91
105
  /**
92
106
  * Enable AVS (Address Verification). Shows country dropdown + ZIP/postcode input
93
107
  * in the card form. When enabled, billing_details are passed to Stripe for AVS checks.
@@ -138,7 +152,7 @@ interface FloPayCheckoutProps {
138
152
  * />
139
153
  * ```
140
154
  */
141
- declare function FloPayCheckout({ sessionId: sessionIdProp, createSession: createSessionParams, billingApiUrl, appearance, locale, fallbackPublishableKey, loading: loadingNode, error: errorNode, onComplete, onError, showPayPal, showApplePay, showGooglePay, layout, buttonsTheme, buttonsStyles, cardButtonContent, onButtonClick, enableAVS, avsLayout, submitLabel, className, children, checkoutMode: checkoutModeProp, confirmLabel, renderConfirmButton, onSessionCompleted, }: FloPayCheckoutProps): React.ReactElement;
155
+ declare function FloPayCheckout({ sessionId: sessionIdProp, createSession: createSessionParams, billingApiUrl, appearance, locale, fallbackPublishableKey, loading: loadingNode, error: errorNode, onComplete, onError, onDecline, showPayPal, showApplePay, showGooglePay, layout, buttonsTheme, buttonsStyles, cardButtonContent, cardBackButtonContent, cardTitleContent, onButtonClick, onBeforeButtonClick, enableAVS, avsLayout, submitLabel, className, children, checkoutMode: checkoutModeProp, confirmLabel, renderConfirmButton, onSessionCompleted, }: FloPayCheckoutProps): React.ReactElement;
142
156
 
143
157
  /**
144
158
  * Returns the current `FloPay` instance, or `null` if the provider
@@ -247,6 +261,8 @@ interface CheckoutFormProps {
247
261
  onComplete?: (result: PaymentResult) => void;
248
262
  /** Called when a payment error occurs. */
249
263
  onError?: (error: FloPayError) => void;
264
+ /** Called when a payment is declined or the authentication step fails. */
265
+ onDecline?: (decline: DeclineEvent) => void;
250
266
  /**
251
267
  * **Override**: If provided, the form tokenizes the card and confirms
252
268
  * the payment, but delegates backend submission to the caller.
@@ -306,6 +322,7 @@ interface CheckoutFormProps {
306
322
  */
307
323
  declare const CheckoutForm: React.ForwardRefExoticComponent<CheckoutFormProps & React.RefAttributes<CheckoutFormRef>>;
308
324
 
325
+ type MaybePromise<T> = T | Promise<T>;
309
326
  /** Methods exposed via ref for external 3DS handling. */
310
327
  interface SplitCardFormRef {
311
328
  handleNextAction: (clientSecret: string) => Promise<void>;
@@ -324,6 +341,8 @@ interface SplitCardFormProps {
324
341
  onComplete?: (result: PaymentResult) => void;
325
342
  /** Called when a payment error occurs. */
326
343
  onError?: (error: FloPayError) => void;
344
+ /** Called when a payment is declined or the authentication step fails. */
345
+ onDecline?: (decline: DeclineEvent) => void;
327
346
  /**
328
347
  * **Override**: If provided, delegates backend submission to the caller.
329
348
  * When omitted, processes internally (calls processPayment + handles 3DS).
@@ -380,11 +399,20 @@ interface SplitCardFormProps {
380
399
  buttonsStyles?: _flopay_shared.ButtonsLayoutStyles;
381
400
  /** Custom React content rendered inside the card button when `layout="buttons"`. */
382
401
  cardButtonContent?: React.ReactNode;
402
+ /** Custom React content rendered for the buttons-layout card back button label. */
403
+ cardBackButtonContent?: React.ReactNode;
404
+ /** Custom React content rendered for the card-form title. */
405
+ cardTitleContent?: React.ReactNode;
383
406
  /**
384
407
  * Called when a payment method button is clicked.
385
408
  * `method`: `'card'` | `'paypal'` | `'apple_pay'` | `'google_pay'`
386
409
  */
387
- onButtonClick?: (method: string) => void;
410
+ onButtonClick?: (method: CheckoutButtonMethod) => void;
411
+ /**
412
+ * Called before the credit/debit card button continues.
413
+ * Card only: this does not run for PayPal or wallet buttons.
414
+ */
415
+ onBeforeButtonClick?: (event: BeforeButtonClickEvent) => MaybePromise<void | false | InlineSessionPatch>;
388
416
  /**
389
417
  * Enable AVS (Address Verification). Shows country dropdown + ZIP/postcode input.
390
418
  * When enabled, billing_details are passed to Stripe's createPaymentMethod for AVS checks.
@@ -404,6 +432,8 @@ interface SplitCardFormProps {
404
432
  totalAmount?: number;
405
433
  /** Currency code (used for PayPal Elements config). */
406
434
  currency?: string;
435
+ /** Render the card form expanded on first paint when `layout="buttons"`. */
436
+ initialCardOpen?: boolean;
407
437
  }
408
438
  /**
409
439
  * Split card checkout form matching `checkout/StripeCardForm`: