@flopay/react 0.3.11 → 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. */
@@ -91,7 +94,14 @@ interface FloPayCheckoutProps {
91
94
  * Called when a payment method button is clicked.
92
95
  * `method`: `'card'` | `'paypal'` | `'apple_pay'` | `'google_pay'`
93
96
  */
94
- 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;
95
105
  /**
96
106
  * Enable AVS (Address Verification). Shows country dropdown + ZIP/postcode input
97
107
  * in the card form. When enabled, billing_details are passed to Stripe for AVS checks.
@@ -142,7 +152,7 @@ interface FloPayCheckoutProps {
142
152
  * />
143
153
  * ```
144
154
  */
145
- declare function FloPayCheckout({ sessionId: sessionIdProp, createSession: createSessionParams, billingApiUrl, appearance, locale, fallbackPublishableKey, loading: loadingNode, error: errorNode, onComplete, onError, showPayPal, showApplePay, showGooglePay, layout, buttonsTheme, buttonsStyles, cardButtonContent, cardBackButtonContent, cardTitleContent, 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;
146
156
 
147
157
  /**
148
158
  * Returns the current `FloPay` instance, or `null` if the provider
@@ -251,6 +261,8 @@ interface CheckoutFormProps {
251
261
  onComplete?: (result: PaymentResult) => void;
252
262
  /** Called when a payment error occurs. */
253
263
  onError?: (error: FloPayError) => void;
264
+ /** Called when a payment is declined or the authentication step fails. */
265
+ onDecline?: (decline: DeclineEvent) => void;
254
266
  /**
255
267
  * **Override**: If provided, the form tokenizes the card and confirms
256
268
  * the payment, but delegates backend submission to the caller.
@@ -310,6 +322,7 @@ interface CheckoutFormProps {
310
322
  */
311
323
  declare const CheckoutForm: React.ForwardRefExoticComponent<CheckoutFormProps & React.RefAttributes<CheckoutFormRef>>;
312
324
 
325
+ type MaybePromise<T> = T | Promise<T>;
313
326
  /** Methods exposed via ref for external 3DS handling. */
314
327
  interface SplitCardFormRef {
315
328
  handleNextAction: (clientSecret: string) => Promise<void>;
@@ -328,6 +341,8 @@ interface SplitCardFormProps {
328
341
  onComplete?: (result: PaymentResult) => void;
329
342
  /** Called when a payment error occurs. */
330
343
  onError?: (error: FloPayError) => void;
344
+ /** Called when a payment is declined or the authentication step fails. */
345
+ onDecline?: (decline: DeclineEvent) => void;
331
346
  /**
332
347
  * **Override**: If provided, delegates backend submission to the caller.
333
348
  * When omitted, processes internally (calls processPayment + handles 3DS).
@@ -392,7 +407,12 @@ interface SplitCardFormProps {
392
407
  * Called when a payment method button is clicked.
393
408
  * `method`: `'card'` | `'paypal'` | `'apple_pay'` | `'google_pay'`
394
409
  */
395
- 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>;
396
416
  /**
397
417
  * Enable AVS (Address Verification). Shows country dropdown + ZIP/postcode input.
398
418
  * When enabled, billing_details are passed to Stripe's createPaymentMethod for AVS checks.
@@ -412,6 +432,8 @@ interface SplitCardFormProps {
412
432
  totalAmount?: number;
413
433
  /** Currency code (used for PayPal Elements config). */
414
434
  currency?: string;
435
+ /** Render the card form expanded on first paint when `layout="buttons"`. */
436
+ initialCardOpen?: boolean;
415
437
  }
416
438
  /**
417
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. */
@@ -91,7 +94,14 @@ interface FloPayCheckoutProps {
91
94
  * Called when a payment method button is clicked.
92
95
  * `method`: `'card'` | `'paypal'` | `'apple_pay'` | `'google_pay'`
93
96
  */
94
- 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;
95
105
  /**
96
106
  * Enable AVS (Address Verification). Shows country dropdown + ZIP/postcode input
97
107
  * in the card form. When enabled, billing_details are passed to Stripe for AVS checks.
@@ -142,7 +152,7 @@ interface FloPayCheckoutProps {
142
152
  * />
143
153
  * ```
144
154
  */
145
- declare function FloPayCheckout({ sessionId: sessionIdProp, createSession: createSessionParams, billingApiUrl, appearance, locale, fallbackPublishableKey, loading: loadingNode, error: errorNode, onComplete, onError, showPayPal, showApplePay, showGooglePay, layout, buttonsTheme, buttonsStyles, cardButtonContent, cardBackButtonContent, cardTitleContent, 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;
146
156
 
147
157
  /**
148
158
  * Returns the current `FloPay` instance, or `null` if the provider
@@ -251,6 +261,8 @@ interface CheckoutFormProps {
251
261
  onComplete?: (result: PaymentResult) => void;
252
262
  /** Called when a payment error occurs. */
253
263
  onError?: (error: FloPayError) => void;
264
+ /** Called when a payment is declined or the authentication step fails. */
265
+ onDecline?: (decline: DeclineEvent) => void;
254
266
  /**
255
267
  * **Override**: If provided, the form tokenizes the card and confirms
256
268
  * the payment, but delegates backend submission to the caller.
@@ -310,6 +322,7 @@ interface CheckoutFormProps {
310
322
  */
311
323
  declare const CheckoutForm: React.ForwardRefExoticComponent<CheckoutFormProps & React.RefAttributes<CheckoutFormRef>>;
312
324
 
325
+ type MaybePromise<T> = T | Promise<T>;
313
326
  /** Methods exposed via ref for external 3DS handling. */
314
327
  interface SplitCardFormRef {
315
328
  handleNextAction: (clientSecret: string) => Promise<void>;
@@ -328,6 +341,8 @@ interface SplitCardFormProps {
328
341
  onComplete?: (result: PaymentResult) => void;
329
342
  /** Called when a payment error occurs. */
330
343
  onError?: (error: FloPayError) => void;
344
+ /** Called when a payment is declined or the authentication step fails. */
345
+ onDecline?: (decline: DeclineEvent) => void;
331
346
  /**
332
347
  * **Override**: If provided, delegates backend submission to the caller.
333
348
  * When omitted, processes internally (calls processPayment + handles 3DS).
@@ -392,7 +407,12 @@ interface SplitCardFormProps {
392
407
  * Called when a payment method button is clicked.
393
408
  * `method`: `'card'` | `'paypal'` | `'apple_pay'` | `'google_pay'`
394
409
  */
395
- 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>;
396
416
  /**
397
417
  * Enable AVS (Address Verification). Shows country dropdown + ZIP/postcode input.
398
418
  * When enabled, billing_details are passed to Stripe's createPaymentMethod for AVS checks.
@@ -412,6 +432,8 @@ interface SplitCardFormProps {
412
432
  totalAmount?: number;
413
433
  /** Currency code (used for PayPal Elements config). */
414
434
  currency?: string;
435
+ /** Render the card form expanded on first paint when `layout="buttons"`. */
436
+ initialCardOpen?: boolean;
415
437
  }
416
438
  /**
417
439
  * Split card checkout form matching `checkout/StripeCardForm`: