@flopay/react 1.7.0 → 1.8.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,9 +1,9 @@
1
1
  import * as _flopay_shared from '@flopay/shared';
2
- import { InlineSessionDraft, CheckoutButtonMethod, CheckoutProduct, CheckoutItem, CheckoutSubscription, ThemeId, FloPayAppearance, ButtonsLayoutTheme, ButtonsLayoutStyles, PaymentResult, CheckoutSession, FloPayError, DeclineEvent, GatewayEnvironment, PayPalProviderObjectType, TokenizedBody, InlineSessionPatch, ElementOptions, ElementChangeEvent, FloInstrumentEvent, BeforeButtonClickEvent, CheckoutMode, AVSFieldConfig, CardCaptureAdapter, VaultCardThemeColors } from '@flopay/shared';
2
+ import { InlineSessionDraft, CheckoutButtonMethod, CheckoutProduct, CheckoutItem, CheckoutSubscription, ThemeId, FloPayAppearance, ButtonsLayoutTheme, ButtonsLayoutStyles, PaymentResult, CheckoutSession, FloPayError, DeclineEvent, GatewayEnvironment, PayPalProviderObjectType, TokenizedBody, InlineSessionPatch, FloInstrumentEvent, BeforeButtonClickEvent, CheckoutMode, AVSFieldConfig, CardCaptureAdapter, VaultCardThemeColors } from '@flopay/shared';
3
3
  export { BeforeButtonClickEvent, CheckoutButtonMethod, DeclineEvent, FloInstrumentEvent, InlineSessionDraft, InlineSessionPatch, SentryEventLike, SentryStackFrameLike, dropThirdPartyOnlyError } from '@flopay/shared';
4
4
  import React from 'react';
5
5
  export { FloPayCardSetup, FloPayCardSetupCancelEvent, FloPayCardSetupCompleteEvent, FloPayCardSetupDeclineEvent, FloPayCardSetupError, FloPayCardSetupProps } from './card-setup-entry.cjs';
6
- import { FloPayElements, FloPay } from '@flopay/js';
6
+ import { FloPay } from '@flopay/js';
7
7
 
8
8
  interface FloPayAutomaticPaymentSuccessEvent {
9
9
  result: PaymentResult;
@@ -211,48 +211,6 @@ interface DirectPayPalButtonProps {
211
211
  /** Public direct-PayPal surface: telemetry accepts only the boolean opt-out. */
212
212
  declare function DirectPayPalButton(props: DirectPayPalButtonProps): React.ReactElement | null;
213
213
 
214
- /** Common props shared by all element components. */
215
- interface ElementComponentProps {
216
- /** Additional CSS class for the wrapper div. */
217
- className?: string;
218
- /** Element id attribute for the wrapper div. */
219
- id?: string;
220
- /** Inline styles for the wrapper div. */
221
- style?: React.CSSProperties;
222
- /** Options forwarded to the underlying element. */
223
- options?: Partial<ElementOptions>;
224
- /** Fired when the element's value changes. */
225
- onChange?: (event: ElementChangeEvent) => void;
226
- /** Fired when the element is fully rendered and ready. */
227
- onReady?: () => void;
228
- /** Fired when the element gains focus. */
229
- onFocus?: () => void;
230
- /** Fired when the element loses focus. */
231
- onBlur?: () => void;
232
- /** Fired when the Escape key is pressed inside the element. */
233
- onEscape?: () => void;
234
- }
235
- /** Props for the standalone non-card Payment Element. */
236
- interface PaymentElementProps extends Omit<ElementComponentProps, 'options'> {
237
- /**
238
- * Element options with an explicit wallet/APM allowlist. `card` is removed
239
- * at runtime; an empty result is rejected before the provider is called.
240
- */
241
- options: Omit<Partial<ElementOptions>, 'paymentMethodTypes'> & {
242
- paymentMethodTypes: readonly string[];
243
- };
244
- }
245
- /**
246
- * Renders a provider Payment Element restricted to the declared non-card
247
- * wallet/APM methods. Card collection is available only through the hosted
248
- * vault checkout surfaces.
249
- */
250
- declare const PaymentElement: React.FC<PaymentElementProps>;
251
- /**
252
- * Renders an address input element.
253
- */
254
- declare const AddressElement: React.FC<ElementComponentProps>;
255
-
256
214
  /** Props for the all-in-one `FloPayCheckout` wrapper. */
257
215
  interface FloPayCheckoutProps {
258
216
  /** The checkout session ID (UUID from billing API). Required unless `createSession` is provided. */
@@ -474,13 +432,6 @@ declare function useFloPay(): FloPay | null;
474
432
  * Must be called within a `<FloPayProvider>`.
475
433
  */
476
434
  declare function usePayPalFloPay(): FloPay | null;
477
- /**
478
- * Returns the current `FloPayElements` instance, or `null` if the
479
- * provider is still loading.
480
- *
481
- * Must be called within a `<FloPayProvider>`.
482
- */
483
- declare function useElements(): FloPayElements | null;
484
435
  /** Checkout state exposed by `useCheckout()`. */
485
436
  interface CheckoutState {
486
437
  session: CheckoutSession | null;
@@ -496,66 +447,6 @@ interface CheckoutState {
496
447
  */
497
448
  declare function useCheckout(): CheckoutState;
498
449
 
499
- /**
500
- * Props for the `PayPalButton` component.
501
- *
502
- * Must be rendered inside its own `FloPayProvider` with `paymentMethodCreation: undefined`
503
- * (not 'manual') because this PayPal flow needs automatic payment-method creation.
504
- */
505
- interface PayPalButtonProps {
506
- /** The checkout session ID (UUID from billing API). */
507
- sessionId: string;
508
- /**
509
- * Session-bound checkout token returned by session creation. Forwarded as
510
- * `x-checkout-session-token` on continuation requests — required by
511
- * post-#640 backends.
512
- */
513
- nonce?: string;
514
- /** Billing API base URL. Optional — defaults to the value from FloPayProvider or the shared constant. */
515
- billingApiUrl?: string;
516
- /** User's email. */
517
- email?: string;
518
- /** User ID for processing payments. */
519
- userId?: string;
520
- /** First name for billing. */
521
- firstName?: string;
522
- /** Last name for billing. */
523
- lastName?: string;
524
- /** Checkout version for tracking. */
525
- chv?: string;
526
- /**
527
- * Called with tokenized data after PayPal authorization.
528
- * If omitted, the component calls processPayment internally.
529
- */
530
- onTokenizedBody?: (body: TokenizedBody) => void;
531
- /** Called on successful payment (self-contained mode). */
532
- onComplete?: () => void;
533
- /** Called when an error occurs. */
534
- onErrorChange?: (error: string | null) => void;
535
- /** External processing state. */
536
- isProcessing?: boolean;
537
- }
538
- /**
539
- * PayPal button that handles the full PayPal payment flow.
540
- *
541
- * **Important**: PayPal requires its own `FloPayProvider` with automatic
542
- * payment-method creation. Keep it separate from manually created wallet/APM
543
- * Elements groups.
544
- *
545
- * ```tsx
546
- * {/* Main checkout provider *\/}
547
- * <FloPayProvider flopay={flopay} options={{ amount, currency }}>
548
- * <SplitCardForm ... />
549
- * </FloPayProvider>
550
- *
551
- * {/* PayPal provider (no paymentMethodCreation) *\/}
552
- * <FloPayProvider flopay={flopay} options={{ amount, currency, paymentMethodCreation: 'auto' }}>
553
- * <PayPalButton ... />
554
- * </FloPayProvider>
555
- * ```
556
- */
557
- declare function PayPalButton({ sessionId, nonce, billingApiUrl, email, userId, firstName, lastName, chv, onTokenizedBody, onComplete, onErrorChange, isProcessing, }: PayPalButtonProps): React.ReactElement;
558
-
559
450
  /** Props for the `FloPayProvider` component. */
560
451
  interface FloPayProviderProps {
561
452
  /** A `FloPay` instance or a promise that resolves to one (from `loadFloPay()`). */
@@ -566,25 +457,8 @@ interface FloPayProviderProps {
566
457
  * not rendered. Direct PayPal (`gateways.paypal`) does not use this prop.
567
458
  */
568
459
  paypalFlopay?: Promise<FloPay> | FloPay | null;
569
- /** Optional configuration applied when creating the elements group. */
460
+ /** Optional provider configuration. */
570
461
  options?: {
571
- locale?: string;
572
- appearance?: FloPayAppearance;
573
- /**
574
- * Client secret for an existing non-card PaymentIntent or SetupIntent.
575
- * The SDK verifies the provider intent against the `PaymentElement`'s
576
- * explicit `paymentMethodTypes` allowlist before mounting and rejects card
577
- * or undeclared methods. Card checkout uses the hosted vault.
578
- */
579
- clientSecret?: string;
580
- /** Total amount in cents for deferred non-card Elements without a client secret. */
581
- amount?: number;
582
- /** ISO 4217 currency code for deferred non-card Elements without a client secret. */
583
- currency?: string;
584
- /** How non-card payment methods are created: `'manual'` or `'auto'` (needed for PayPal). */
585
- paymentMethodCreation?: 'manual' | 'auto';
586
- /** Requests reusable payment credentials for future payments. */
587
- setupFutureUsage?: 'off_session' | 'on_session';
588
462
  /** Billing API base URL. Set once here so child components don't need to repeat it. */
589
463
  billingApiUrl?: string;
590
464
  };
@@ -595,16 +469,15 @@ interface FloPayProviderProps {
595
469
  /**
596
470
  * Provides FloPay SDK context to the component tree.
597
471
  *
598
- * Wrap provider-context elements with this provider:
472
+ * Wrap components that consume FloPay context with this provider:
599
473
  *
600
474
  * ```tsx
601
475
  * <FloPayProvider flopay={loadFloPay('pk_test_...')}>
602
- * <PaymentElement options={{ paymentMethodTypes: ['cashapp', 'ideal'] }} />
476
+ * <YourCheckout />
603
477
  * </FloPayProvider>
604
478
  * ```
605
479
  *
606
- * `FloPayCheckout` is a standalone integration that owns its provider and
607
- * session-specific Elements setup:
480
+ * `FloPayCheckout` is a standalone integration that owns its provider:
608
481
  *
609
482
  * ```tsx
610
483
  * <FloPayCheckout sessionId="sess_..." />
@@ -912,4 +785,4 @@ interface VaultCardFieldsProps {
912
785
  */
913
786
  declare function VaultCardFields({ capture, html, messageToken, expectedOrigin, theme, containerStyle, onReady, onError, onValidation, }: VaultCardFieldsProps): React.ReactElement;
914
787
 
915
- export { AddressElement, type CheckoutState, DirectPayPalButton, type DirectPayPalButtonProps, type DirectPayPalInitializationState, type ElementComponentProps, FloPayAutomaticPaymentButton, type FloPayAutomaticPaymentButtonProps, type FloPayAutomaticPaymentSuccessEvent, FloPayCheckout, type FloPayCheckoutProps, FloPayProvider, type FloPayProviderProps, PayPalButton, type PayPalButtonProps, PaymentElement, type PaymentElementProps, SplitCardForm, type SplitCardFormProps, VaultCardFields, type VaultCardFieldsProps, useCheckout, useElements, useFloPay, usePayPalFloPay };
788
+ export { type CheckoutState, DirectPayPalButton, type DirectPayPalButtonProps, type DirectPayPalInitializationState, FloPayAutomaticPaymentButton, type FloPayAutomaticPaymentButtonProps, type FloPayAutomaticPaymentSuccessEvent, FloPayCheckout, type FloPayCheckoutProps, FloPayProvider, type FloPayProviderProps, SplitCardForm, type SplitCardFormProps, VaultCardFields, type VaultCardFieldsProps, useCheckout, useFloPay, usePayPalFloPay };
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import * as _flopay_shared from '@flopay/shared';
2
- import { InlineSessionDraft, CheckoutButtonMethod, CheckoutProduct, CheckoutItem, CheckoutSubscription, ThemeId, FloPayAppearance, ButtonsLayoutTheme, ButtonsLayoutStyles, PaymentResult, CheckoutSession, FloPayError, DeclineEvent, GatewayEnvironment, PayPalProviderObjectType, TokenizedBody, InlineSessionPatch, ElementOptions, ElementChangeEvent, FloInstrumentEvent, BeforeButtonClickEvent, CheckoutMode, AVSFieldConfig, CardCaptureAdapter, VaultCardThemeColors } from '@flopay/shared';
2
+ import { InlineSessionDraft, CheckoutButtonMethod, CheckoutProduct, CheckoutItem, CheckoutSubscription, ThemeId, FloPayAppearance, ButtonsLayoutTheme, ButtonsLayoutStyles, PaymentResult, CheckoutSession, FloPayError, DeclineEvent, GatewayEnvironment, PayPalProviderObjectType, TokenizedBody, InlineSessionPatch, FloInstrumentEvent, BeforeButtonClickEvent, CheckoutMode, AVSFieldConfig, CardCaptureAdapter, VaultCardThemeColors } from '@flopay/shared';
3
3
  export { BeforeButtonClickEvent, CheckoutButtonMethod, DeclineEvent, FloInstrumentEvent, InlineSessionDraft, InlineSessionPatch, SentryEventLike, SentryStackFrameLike, dropThirdPartyOnlyError } from '@flopay/shared';
4
4
  import React from 'react';
5
5
  export { FloPayCardSetup, FloPayCardSetupCancelEvent, FloPayCardSetupCompleteEvent, FloPayCardSetupDeclineEvent, FloPayCardSetupError, FloPayCardSetupProps } from './card-setup-entry.js';
6
- import { FloPayElements, FloPay } from '@flopay/js';
6
+ import { FloPay } from '@flopay/js';
7
7
 
8
8
  interface FloPayAutomaticPaymentSuccessEvent {
9
9
  result: PaymentResult;
@@ -211,48 +211,6 @@ interface DirectPayPalButtonProps {
211
211
  /** Public direct-PayPal surface: telemetry accepts only the boolean opt-out. */
212
212
  declare function DirectPayPalButton(props: DirectPayPalButtonProps): React.ReactElement | null;
213
213
 
214
- /** Common props shared by all element components. */
215
- interface ElementComponentProps {
216
- /** Additional CSS class for the wrapper div. */
217
- className?: string;
218
- /** Element id attribute for the wrapper div. */
219
- id?: string;
220
- /** Inline styles for the wrapper div. */
221
- style?: React.CSSProperties;
222
- /** Options forwarded to the underlying element. */
223
- options?: Partial<ElementOptions>;
224
- /** Fired when the element's value changes. */
225
- onChange?: (event: ElementChangeEvent) => void;
226
- /** Fired when the element is fully rendered and ready. */
227
- onReady?: () => void;
228
- /** Fired when the element gains focus. */
229
- onFocus?: () => void;
230
- /** Fired when the element loses focus. */
231
- onBlur?: () => void;
232
- /** Fired when the Escape key is pressed inside the element. */
233
- onEscape?: () => void;
234
- }
235
- /** Props for the standalone non-card Payment Element. */
236
- interface PaymentElementProps extends Omit<ElementComponentProps, 'options'> {
237
- /**
238
- * Element options with an explicit wallet/APM allowlist. `card` is removed
239
- * at runtime; an empty result is rejected before the provider is called.
240
- */
241
- options: Omit<Partial<ElementOptions>, 'paymentMethodTypes'> & {
242
- paymentMethodTypes: readonly string[];
243
- };
244
- }
245
- /**
246
- * Renders a provider Payment Element restricted to the declared non-card
247
- * wallet/APM methods. Card collection is available only through the hosted
248
- * vault checkout surfaces.
249
- */
250
- declare const PaymentElement: React.FC<PaymentElementProps>;
251
- /**
252
- * Renders an address input element.
253
- */
254
- declare const AddressElement: React.FC<ElementComponentProps>;
255
-
256
214
  /** Props for the all-in-one `FloPayCheckout` wrapper. */
257
215
  interface FloPayCheckoutProps {
258
216
  /** The checkout session ID (UUID from billing API). Required unless `createSession` is provided. */
@@ -474,13 +432,6 @@ declare function useFloPay(): FloPay | null;
474
432
  * Must be called within a `<FloPayProvider>`.
475
433
  */
476
434
  declare function usePayPalFloPay(): FloPay | null;
477
- /**
478
- * Returns the current `FloPayElements` instance, or `null` if the
479
- * provider is still loading.
480
- *
481
- * Must be called within a `<FloPayProvider>`.
482
- */
483
- declare function useElements(): FloPayElements | null;
484
435
  /** Checkout state exposed by `useCheckout()`. */
485
436
  interface CheckoutState {
486
437
  session: CheckoutSession | null;
@@ -496,66 +447,6 @@ interface CheckoutState {
496
447
  */
497
448
  declare function useCheckout(): CheckoutState;
498
449
 
499
- /**
500
- * Props for the `PayPalButton` component.
501
- *
502
- * Must be rendered inside its own `FloPayProvider` with `paymentMethodCreation: undefined`
503
- * (not 'manual') because this PayPal flow needs automatic payment-method creation.
504
- */
505
- interface PayPalButtonProps {
506
- /** The checkout session ID (UUID from billing API). */
507
- sessionId: string;
508
- /**
509
- * Session-bound checkout token returned by session creation. Forwarded as
510
- * `x-checkout-session-token` on continuation requests — required by
511
- * post-#640 backends.
512
- */
513
- nonce?: string;
514
- /** Billing API base URL. Optional — defaults to the value from FloPayProvider or the shared constant. */
515
- billingApiUrl?: string;
516
- /** User's email. */
517
- email?: string;
518
- /** User ID for processing payments. */
519
- userId?: string;
520
- /** First name for billing. */
521
- firstName?: string;
522
- /** Last name for billing. */
523
- lastName?: string;
524
- /** Checkout version for tracking. */
525
- chv?: string;
526
- /**
527
- * Called with tokenized data after PayPal authorization.
528
- * If omitted, the component calls processPayment internally.
529
- */
530
- onTokenizedBody?: (body: TokenizedBody) => void;
531
- /** Called on successful payment (self-contained mode). */
532
- onComplete?: () => void;
533
- /** Called when an error occurs. */
534
- onErrorChange?: (error: string | null) => void;
535
- /** External processing state. */
536
- isProcessing?: boolean;
537
- }
538
- /**
539
- * PayPal button that handles the full PayPal payment flow.
540
- *
541
- * **Important**: PayPal requires its own `FloPayProvider` with automatic
542
- * payment-method creation. Keep it separate from manually created wallet/APM
543
- * Elements groups.
544
- *
545
- * ```tsx
546
- * {/* Main checkout provider *\/}
547
- * <FloPayProvider flopay={flopay} options={{ amount, currency }}>
548
- * <SplitCardForm ... />
549
- * </FloPayProvider>
550
- *
551
- * {/* PayPal provider (no paymentMethodCreation) *\/}
552
- * <FloPayProvider flopay={flopay} options={{ amount, currency, paymentMethodCreation: 'auto' }}>
553
- * <PayPalButton ... />
554
- * </FloPayProvider>
555
- * ```
556
- */
557
- declare function PayPalButton({ sessionId, nonce, billingApiUrl, email, userId, firstName, lastName, chv, onTokenizedBody, onComplete, onErrorChange, isProcessing, }: PayPalButtonProps): React.ReactElement;
558
-
559
450
  /** Props for the `FloPayProvider` component. */
560
451
  interface FloPayProviderProps {
561
452
  /** A `FloPay` instance or a promise that resolves to one (from `loadFloPay()`). */
@@ -566,25 +457,8 @@ interface FloPayProviderProps {
566
457
  * not rendered. Direct PayPal (`gateways.paypal`) does not use this prop.
567
458
  */
568
459
  paypalFlopay?: Promise<FloPay> | FloPay | null;
569
- /** Optional configuration applied when creating the elements group. */
460
+ /** Optional provider configuration. */
570
461
  options?: {
571
- locale?: string;
572
- appearance?: FloPayAppearance;
573
- /**
574
- * Client secret for an existing non-card PaymentIntent or SetupIntent.
575
- * The SDK verifies the provider intent against the `PaymentElement`'s
576
- * explicit `paymentMethodTypes` allowlist before mounting and rejects card
577
- * or undeclared methods. Card checkout uses the hosted vault.
578
- */
579
- clientSecret?: string;
580
- /** Total amount in cents for deferred non-card Elements without a client secret. */
581
- amount?: number;
582
- /** ISO 4217 currency code for deferred non-card Elements without a client secret. */
583
- currency?: string;
584
- /** How non-card payment methods are created: `'manual'` or `'auto'` (needed for PayPal). */
585
- paymentMethodCreation?: 'manual' | 'auto';
586
- /** Requests reusable payment credentials for future payments. */
587
- setupFutureUsage?: 'off_session' | 'on_session';
588
462
  /** Billing API base URL. Set once here so child components don't need to repeat it. */
589
463
  billingApiUrl?: string;
590
464
  };
@@ -595,16 +469,15 @@ interface FloPayProviderProps {
595
469
  /**
596
470
  * Provides FloPay SDK context to the component tree.
597
471
  *
598
- * Wrap provider-context elements with this provider:
472
+ * Wrap components that consume FloPay context with this provider:
599
473
  *
600
474
  * ```tsx
601
475
  * <FloPayProvider flopay={loadFloPay('pk_test_...')}>
602
- * <PaymentElement options={{ paymentMethodTypes: ['cashapp', 'ideal'] }} />
476
+ * <YourCheckout />
603
477
  * </FloPayProvider>
604
478
  * ```
605
479
  *
606
- * `FloPayCheckout` is a standalone integration that owns its provider and
607
- * session-specific Elements setup:
480
+ * `FloPayCheckout` is a standalone integration that owns its provider:
608
481
  *
609
482
  * ```tsx
610
483
  * <FloPayCheckout sessionId="sess_..." />
@@ -912,4 +785,4 @@ interface VaultCardFieldsProps {
912
785
  */
913
786
  declare function VaultCardFields({ capture, html, messageToken, expectedOrigin, theme, containerStyle, onReady, onError, onValidation, }: VaultCardFieldsProps): React.ReactElement;
914
787
 
915
- export { AddressElement, type CheckoutState, DirectPayPalButton, type DirectPayPalButtonProps, type DirectPayPalInitializationState, type ElementComponentProps, FloPayAutomaticPaymentButton, type FloPayAutomaticPaymentButtonProps, type FloPayAutomaticPaymentSuccessEvent, FloPayCheckout, type FloPayCheckoutProps, FloPayProvider, type FloPayProviderProps, PayPalButton, type PayPalButtonProps, PaymentElement, type PaymentElementProps, SplitCardForm, type SplitCardFormProps, VaultCardFields, type VaultCardFieldsProps, useCheckout, useElements, useFloPay, usePayPalFloPay };
788
+ export { type CheckoutState, DirectPayPalButton, type DirectPayPalButtonProps, type DirectPayPalInitializationState, FloPayAutomaticPaymentButton, type FloPayAutomaticPaymentButtonProps, type FloPayAutomaticPaymentSuccessEvent, FloPayCheckout, type FloPayCheckoutProps, FloPayProvider, type FloPayProviderProps, SplitCardForm, type SplitCardFormProps, VaultCardFields, type VaultCardFieldsProps, useCheckout, useFloPay, usePayPalFloPay };