@flopay/react 1.0.3 → 1.1.3
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 +19 -6
- package/dist/index.cjs +1400 -550
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +141 -11
- package/dist/index.d.ts +141 -11
- package/dist/index.mjs +1310 -461
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -3
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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, InlineSessionDraft, FloPayError, PaymentResult, DeclineEvent, CheckoutButtonMethod, BeforeButtonClickEvent, InlineSessionPatch, CheckoutMode, CheckoutSession, ElementOptions, ElementChangeEvent, TokenizedBody, AVSFieldConfig, CheckoutItem, CheckoutSubscription, ButtonsLayoutTheme, ButtonsLayoutStyles } from '@flopay/shared';
|
|
4
|
+
import { FloPayAppearance, InlineSessionDraft, FloPayError, PaymentResult, DeclineEvent, CheckoutButtonMethod, BeforeButtonClickEvent, InlineSessionPatch, CheckoutMode, CheckoutSession, ElementOptions, ElementChangeEvent, TokenizedBody, AVSFieldConfig, GatewayEnvironment, CheckoutItem, CheckoutSubscription, ButtonsLayoutTheme, ButtonsLayoutStyles } from '@flopay/shared';
|
|
5
5
|
export { BeforeButtonClickEvent, CheckoutButtonMethod, DeclineEvent, InlineSessionDraft, InlineSessionPatch } from '@flopay/shared';
|
|
6
6
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
7
7
|
|
|
@@ -10,9 +10,9 @@ interface FloPayProviderProps {
|
|
|
10
10
|
/** A `FloPay` instance or a promise that resolves to one (from `loadFloPay()`). */
|
|
11
11
|
flopay: Promise<FloPay> | FloPay;
|
|
12
12
|
/**
|
|
13
|
-
* Optional
|
|
14
|
-
*
|
|
15
|
-
*
|
|
13
|
+
* Optional Stripe `FloPay` instance used to drive the Stripe-rendered PayPal
|
|
14
|
+
* fallback. When omitted or `null`, the Stripe-rendered PayPal button is
|
|
15
|
+
* not rendered. Direct PayPal (`gateways.paypal`) does not use this prop.
|
|
16
16
|
*/
|
|
17
17
|
paypalFlopay?: Promise<FloPay> | FloPay | null;
|
|
18
18
|
/** Optional configuration applied when creating the elements group. */
|
|
@@ -84,6 +84,12 @@ interface FloPayCheckoutProps {
|
|
|
84
84
|
showApplePay?: boolean;
|
|
85
85
|
/** Whether to show Google Pay button (default: true). Only renders on supported devices. */
|
|
86
86
|
showGooglePay?: boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Enables on-screen diagnostic panels (PayPal gate decision, DirectPayPalButton
|
|
89
|
+
* lifecycle). Intended for debugging in-app browsers (Facebook, Instagram, etc.)
|
|
90
|
+
* where remote console access is impractical. Off by default.
|
|
91
|
+
*/
|
|
92
|
+
debug?: boolean;
|
|
87
93
|
/** Layout mode: 'default' (all visible) or 'buttons' (PayPal/wallets + expandable card form). */
|
|
88
94
|
layout?: 'default' | 'buttons';
|
|
89
95
|
/** Theme preset for the buttons layout: 'default', 'minimal', 'rounded', or 'dark'. */
|
|
@@ -148,8 +154,8 @@ interface FloPayCheckoutProps {
|
|
|
148
154
|
onSessionCompleted?: (successUrl: string) => void;
|
|
149
155
|
/**
|
|
150
156
|
* @deprecated No longer used. The Stripe publishable key is sourced exclusively
|
|
151
|
-
* from the checkout session's `
|
|
152
|
-
* backward compatibility with older consumer code — the value is ignored.
|
|
157
|
+
* from the checkout session's `gateways.stripe.publishableKey`. Accepted only
|
|
158
|
+
* for backward compatibility with older consumer code — the value is ignored.
|
|
153
159
|
*/
|
|
154
160
|
fallbackPublishableKey?: string;
|
|
155
161
|
}
|
|
@@ -170,7 +176,7 @@ interface FloPayCheckoutProps {
|
|
|
170
176
|
* />
|
|
171
177
|
* ```
|
|
172
178
|
*/
|
|
173
|
-
declare function FloPayCheckout({ sessionId: sessionIdProp, createSession: createSessionParams, billingApiUrl, appearance, locale, loading: loadingNode, error: errorNode, onComplete, onError, onDecline, onFullNameChange, onCountryChange, onZipChange, showPayPal, showApplePay, showGooglePay, layout, buttonsTheme, buttonsStyles, cardButtonContent, cardBackButtonContent, cardTitleContent, showSecurityFooter, onButtonClick, onBeforeButtonClick, enableAVS, avsLayout, submitLabel, className, initialErrorMessage, children, checkoutMode: checkoutModeProp, confirmLabel, renderConfirmButton, onSessionCompleted, }: FloPayCheckoutProps): React.ReactElement;
|
|
179
|
+
declare function FloPayCheckout({ sessionId: sessionIdProp, createSession: createSessionParams, billingApiUrl, appearance, locale, loading: loadingNode, error: errorNode, onComplete, onError, onDecline, onFullNameChange, onCountryChange, onZipChange, showPayPal, showApplePay, showGooglePay, debug, layout, buttonsTheme, buttonsStyles, cardButtonContent, cardBackButtonContent, cardTitleContent, showSecurityFooter, onButtonClick, onBeforeButtonClick, enableAVS, avsLayout, submitLabel, className, initialErrorMessage, children, checkoutMode: checkoutModeProp, confirmLabel, renderConfirmButton, onSessionCompleted, }: FloPayCheckoutProps): React.ReactElement;
|
|
174
180
|
|
|
175
181
|
/**
|
|
176
182
|
* Returns the current `FloPay` instance, or `null` if the provider
|
|
@@ -180,9 +186,9 @@ declare function FloPayCheckout({ sessionId: sessionIdProp, createSession: creat
|
|
|
180
186
|
*/
|
|
181
187
|
declare function useFloPay(): FloPay | null;
|
|
182
188
|
/**
|
|
183
|
-
* Returns the
|
|
184
|
-
*
|
|
185
|
-
*
|
|
189
|
+
* Returns the Stripe `FloPay` instance dedicated to the Stripe-rendered
|
|
190
|
+
* PayPal fallback, or `null` if PayPal is disabled for this session. Direct
|
|
191
|
+
* PayPal (`gateways.paypal`) does not use this instance.
|
|
186
192
|
*
|
|
187
193
|
* Must be called within a `<FloPayProvider>`.
|
|
188
194
|
*/
|
|
@@ -480,6 +486,26 @@ interface SplitCardFormProps {
|
|
|
480
486
|
currency?: string;
|
|
481
487
|
/** Render the card form expanded on first paint when `layout="buttons"`. */
|
|
482
488
|
initialCardOpen?: boolean;
|
|
489
|
+
/**
|
|
490
|
+
* Direct PayPal gateway configuration. When provided, PayPal renders via
|
|
491
|
+
* the official PayPal JS SDK (in-app browser compliant) instead of via
|
|
492
|
+
* Stripe's ExpressCheckoutElement. Selection is mutually exclusive:
|
|
493
|
+
* setting this disables the Stripe-rendered PayPal path automatically.
|
|
494
|
+
*/
|
|
495
|
+
directPaypal?: {
|
|
496
|
+
clientId: string;
|
|
497
|
+
environment?: GatewayEnvironment;
|
|
498
|
+
};
|
|
499
|
+
/** Whether the active session represents a subscription (drives direct PayPal intent). */
|
|
500
|
+
isSubscription?: boolean;
|
|
501
|
+
/** Backing session — forwarded to direct-PayPal so it can populate accountData. */
|
|
502
|
+
session?: CheckoutSession | null;
|
|
503
|
+
/**
|
|
504
|
+
* Enables on-screen diagnostic panels for the PayPal/wallet gating decision
|
|
505
|
+
* and the `DirectPayPalButton` lifecycle. Intended for debugging in-app
|
|
506
|
+
* browsers where remote console access is impractical. Off by default.
|
|
507
|
+
*/
|
|
508
|
+
debug?: boolean;
|
|
483
509
|
}
|
|
484
510
|
/**
|
|
485
511
|
* Split card checkout form matching `checkout/StripeCardForm`:
|
|
@@ -545,6 +571,110 @@ interface PayPalButtonProps {
|
|
|
545
571
|
*/
|
|
546
572
|
declare function PayPalButton({ sessionId, billingApiUrl, email, userId, firstName, lastName, chv, onTokenizedBody, onComplete, onErrorChange, isProcessing, }: PayPalButtonProps): React.ReactElement;
|
|
547
573
|
|
|
574
|
+
/**
|
|
575
|
+
* Overrides that `SplitCardForm`'s tokenized-body dispatcher uses to apply a
|
|
576
|
+
* `runBeforeButtonClick` patch to the in-flight processPayment call. Kept in
|
|
577
|
+
* sync structurally with `TokenizedBodyOverrides` in `split-card-form.tsx`.
|
|
578
|
+
*/
|
|
579
|
+
interface DirectPayPalTokenizedOverrides {
|
|
580
|
+
accountPatch?: InlineSessionPatch['account'];
|
|
581
|
+
sessionId?: string;
|
|
582
|
+
}
|
|
583
|
+
/**
|
|
584
|
+
* Internal handler signature aligned with `SplitCardForm`'s tokenized-body
|
|
585
|
+
* dispatcher. Direct PayPal completes via the backend's process endpoint and
|
|
586
|
+
* never produces a Stripe PaymentIntent, so we still forward a synthetic
|
|
587
|
+
* `TokenizedBody` describing the captured order, optionally with the
|
|
588
|
+
* session/account patch captured at click-time.
|
|
589
|
+
*/
|
|
590
|
+
type DirectPayPalTokenizedHandler = (body: TokenizedBody, overrides?: DirectPayPalTokenizedOverrides) => void;
|
|
591
|
+
/** Click-time `runBeforeButtonClick` result, structurally compatible with `SplitCardForm`. */
|
|
592
|
+
interface DirectPayPalBeforeButtonClickResult {
|
|
593
|
+
proceed: boolean;
|
|
594
|
+
accountPatch?: InlineSessionPatch['account'];
|
|
595
|
+
sessionId?: string;
|
|
596
|
+
}
|
|
597
|
+
/**
|
|
598
|
+
* Click-time gate. Mirrors `RunBeforeButtonClick` in `SplitCardForm`: lets the
|
|
599
|
+
* consumer patch the session/account before PayPal creates the order, and lets
|
|
600
|
+
* them abort the click entirely by returning `proceed: false`.
|
|
601
|
+
*/
|
|
602
|
+
type DirectPayPalRunBeforeButtonClick = (method: CheckoutButtonMethod) => Promise<DirectPayPalBeforeButtonClickResult>;
|
|
603
|
+
interface DirectPayPalButtonProps {
|
|
604
|
+
/** Checkout session ID. */
|
|
605
|
+
sessionId: string;
|
|
606
|
+
/** Billing API base URL. */
|
|
607
|
+
billingApiUrl: string;
|
|
608
|
+
/** Buyer email. */
|
|
609
|
+
email?: string;
|
|
610
|
+
/** PayPal client identifier (`gateways.paypal.publishableKey`). */
|
|
611
|
+
clientId: string;
|
|
612
|
+
/** Gateway environment, drives the sandbox/live SDK script. */
|
|
613
|
+
environment?: GatewayEnvironment;
|
|
614
|
+
/** ISO 4217 currency code. */
|
|
615
|
+
currency: string;
|
|
616
|
+
/** Whether the session is a subscription (drives intent + flow selection). */
|
|
617
|
+
isSubscription: boolean;
|
|
618
|
+
/**
|
|
619
|
+
* If provided, called with the tokenized body once PayPal capture
|
|
620
|
+
* completes. When omitted, the component processes payment internally.
|
|
621
|
+
*/
|
|
622
|
+
onTokenizedBody?: DirectPayPalTokenizedHandler;
|
|
623
|
+
/** Called when the full self-contained payment flow succeeds. */
|
|
624
|
+
onComplete?: (result: PaymentResult) => void;
|
|
625
|
+
/** Called when an error occurs. */
|
|
626
|
+
onErrorChange?: (error: string | null) => void;
|
|
627
|
+
/** Decline emitter (mirrors SplitCardForm semantics). */
|
|
628
|
+
onDecline?: (decline: DeclineEvent) => void;
|
|
629
|
+
/** External processing state. */
|
|
630
|
+
isProcessing?: boolean;
|
|
631
|
+
/** Notify the parent of the loading state for placeholder swapping. */
|
|
632
|
+
onLoadStateChange?: (ready: boolean) => void;
|
|
633
|
+
/** Tracks button-click for analytics. */
|
|
634
|
+
onButtonClick?: (method: CheckoutButtonMethod) => void;
|
|
635
|
+
/**
|
|
636
|
+
* Click-time gate (runs before PayPal creates the order). When provided, the
|
|
637
|
+
* returned patch is applied to the in-flight create-intent and tokenized
|
|
638
|
+
* dispatch so callers using `onBeforeButtonClick` see the same session/email
|
|
639
|
+
* the Stripe-rendered PayPal flow does.
|
|
640
|
+
*/
|
|
641
|
+
runBeforeButtonClick?: DirectPayPalRunBeforeButtonClick;
|
|
642
|
+
/** Backing session — used for self-contained accountData population. */
|
|
643
|
+
session?: CheckoutSession | null;
|
|
644
|
+
/**
|
|
645
|
+
* Pre-existing PayPal Order id (or Subscription id when `isSubscription` is
|
|
646
|
+
* true) to bind the button to. When set, the button skips its usual
|
|
647
|
+
* `POST /v1/checkouts/payments/intents` round-trip on click and feeds this
|
|
648
|
+
* id straight into PayPal's create-order / create-subscription callback.
|
|
649
|
+
*
|
|
650
|
+
* Used by `SplitCardForm`'s `paypal_direct_required` retry path: backend
|
|
651
|
+
* creates a fresh PayPal order after a stalled process attempt and returns
|
|
652
|
+
* its id; the SDK re-renders this button bound to that id so the buyer can
|
|
653
|
+
* confirm with one more click without the backend re-creating the order on
|
|
654
|
+
* each retry.
|
|
655
|
+
*
|
|
656
|
+
* Changing this value remounts the PayPal SDK so the new createOrder
|
|
657
|
+
* binding takes effect (PayPal's render() options aren't live-updatable).
|
|
658
|
+
*/
|
|
659
|
+
existingOrderId?: string;
|
|
660
|
+
/**
|
|
661
|
+
* When true, renders an on-screen lifecycle tracer panel above the button
|
|
662
|
+
* (mount, loadScript, eligibility, render, errors). Intended for debugging
|
|
663
|
+
* in-app browsers (Facebook IAB, etc.) where remote console access is
|
|
664
|
+
* impractical. Off by default — leave disabled in production.
|
|
665
|
+
*/
|
|
666
|
+
debug?: boolean;
|
|
667
|
+
}
|
|
668
|
+
/**
|
|
669
|
+
* Direct PayPal renderer powered by the official PayPal JS SDK.
|
|
670
|
+
*
|
|
671
|
+
* Renders inside Facebook / Instagram / Meta in-app browsers where Stripe's
|
|
672
|
+
* PayPal ExpressCheckoutElement breaks. Selection between this and the Stripe-
|
|
673
|
+
* rendered PayPal happens at the caller site based on whether the session
|
|
674
|
+
* advertises `gateways.paypal.publishableKey`.
|
|
675
|
+
*/
|
|
676
|
+
declare function DirectPayPalButton({ sessionId, billingApiUrl, email, clientId, environment, currency, isSubscription, onTokenizedBody, onComplete, onErrorChange, onDecline, isProcessing, onLoadStateChange, onButtonClick, runBeforeButtonClick, session, existingOrderId, debug, }: DirectPayPalButtonProps): React.ReactElement | null;
|
|
677
|
+
|
|
548
678
|
interface FloPayAutomaticPaymentSuccessEvent {
|
|
549
679
|
result: PaymentResult;
|
|
550
680
|
session: CheckoutSession | null;
|
|
@@ -576,4 +706,4 @@ interface FloPayAutomaticPaymentButtonProps extends Omit<React.ButtonHTMLAttribu
|
|
|
576
706
|
}
|
|
577
707
|
declare function FloPayAutomaticPaymentButton({ sessionId, createSession, paymentMethodId, checkoutMethod, clientId, items, subscriptions, account, successUrl, cancelUrl, couponCodes, tagsData, utmMetadata, billingApiUrl, locale, buttonsTheme, buttonsStyles: stylesOverride, onSuccess, onError, onDecline, children, disabled, type, style, ...buttonProps }: FloPayAutomaticPaymentButtonProps): react_jsx_runtime.JSX.Element;
|
|
578
708
|
|
|
579
|
-
export { AddressElement, CardCvcElement, CardElement, CardExpiryElement, CardNumberElement, CheckoutForm, type CheckoutFormProps, type CheckoutFormRef, type CheckoutState, type ElementComponentProps, FloPayAutomaticPaymentButton, type FloPayAutomaticPaymentButtonProps, type FloPayAutomaticPaymentSuccessEvent, FloPayCheckout, type FloPayCheckoutProps, FloPayProvider, type FloPayProviderProps, PayPalButton, type PayPalButtonProps, PaymentElement, SplitCardForm, type SplitCardFormProps, type SplitCardFormRef, useCheckout, useElements, useFloPay, usePayPalFloPay };
|
|
709
|
+
export { AddressElement, CardCvcElement, CardElement, CardExpiryElement, CardNumberElement, CheckoutForm, type CheckoutFormProps, type CheckoutFormRef, type CheckoutState, DirectPayPalButton, type DirectPayPalButtonProps, type ElementComponentProps, FloPayAutomaticPaymentButton, type FloPayAutomaticPaymentButtonProps, type FloPayAutomaticPaymentSuccessEvent, FloPayCheckout, type FloPayCheckoutProps, FloPayProvider, type FloPayProviderProps, PayPalButton, type PayPalButtonProps, PaymentElement, SplitCardForm, type SplitCardFormProps, type SplitCardFormRef, useCheckout, useElements, useFloPay, usePayPalFloPay };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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, InlineSessionDraft, FloPayError, PaymentResult, DeclineEvent, CheckoutButtonMethod, BeforeButtonClickEvent, InlineSessionPatch, CheckoutMode, CheckoutSession, ElementOptions, ElementChangeEvent, TokenizedBody, AVSFieldConfig, CheckoutItem, CheckoutSubscription, ButtonsLayoutTheme, ButtonsLayoutStyles } from '@flopay/shared';
|
|
4
|
+
import { FloPayAppearance, InlineSessionDraft, FloPayError, PaymentResult, DeclineEvent, CheckoutButtonMethod, BeforeButtonClickEvent, InlineSessionPatch, CheckoutMode, CheckoutSession, ElementOptions, ElementChangeEvent, TokenizedBody, AVSFieldConfig, GatewayEnvironment, CheckoutItem, CheckoutSubscription, ButtonsLayoutTheme, ButtonsLayoutStyles } from '@flopay/shared';
|
|
5
5
|
export { BeforeButtonClickEvent, CheckoutButtonMethod, DeclineEvent, InlineSessionDraft, InlineSessionPatch } from '@flopay/shared';
|
|
6
6
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
7
7
|
|
|
@@ -10,9 +10,9 @@ interface FloPayProviderProps {
|
|
|
10
10
|
/** A `FloPay` instance or a promise that resolves to one (from `loadFloPay()`). */
|
|
11
11
|
flopay: Promise<FloPay> | FloPay;
|
|
12
12
|
/**
|
|
13
|
-
* Optional
|
|
14
|
-
*
|
|
15
|
-
*
|
|
13
|
+
* Optional Stripe `FloPay` instance used to drive the Stripe-rendered PayPal
|
|
14
|
+
* fallback. When omitted or `null`, the Stripe-rendered PayPal button is
|
|
15
|
+
* not rendered. Direct PayPal (`gateways.paypal`) does not use this prop.
|
|
16
16
|
*/
|
|
17
17
|
paypalFlopay?: Promise<FloPay> | FloPay | null;
|
|
18
18
|
/** Optional configuration applied when creating the elements group. */
|
|
@@ -84,6 +84,12 @@ interface FloPayCheckoutProps {
|
|
|
84
84
|
showApplePay?: boolean;
|
|
85
85
|
/** Whether to show Google Pay button (default: true). Only renders on supported devices. */
|
|
86
86
|
showGooglePay?: boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Enables on-screen diagnostic panels (PayPal gate decision, DirectPayPalButton
|
|
89
|
+
* lifecycle). Intended for debugging in-app browsers (Facebook, Instagram, etc.)
|
|
90
|
+
* where remote console access is impractical. Off by default.
|
|
91
|
+
*/
|
|
92
|
+
debug?: boolean;
|
|
87
93
|
/** Layout mode: 'default' (all visible) or 'buttons' (PayPal/wallets + expandable card form). */
|
|
88
94
|
layout?: 'default' | 'buttons';
|
|
89
95
|
/** Theme preset for the buttons layout: 'default', 'minimal', 'rounded', or 'dark'. */
|
|
@@ -148,8 +154,8 @@ interface FloPayCheckoutProps {
|
|
|
148
154
|
onSessionCompleted?: (successUrl: string) => void;
|
|
149
155
|
/**
|
|
150
156
|
* @deprecated No longer used. The Stripe publishable key is sourced exclusively
|
|
151
|
-
* from the checkout session's `
|
|
152
|
-
* backward compatibility with older consumer code — the value is ignored.
|
|
157
|
+
* from the checkout session's `gateways.stripe.publishableKey`. Accepted only
|
|
158
|
+
* for backward compatibility with older consumer code — the value is ignored.
|
|
153
159
|
*/
|
|
154
160
|
fallbackPublishableKey?: string;
|
|
155
161
|
}
|
|
@@ -170,7 +176,7 @@ interface FloPayCheckoutProps {
|
|
|
170
176
|
* />
|
|
171
177
|
* ```
|
|
172
178
|
*/
|
|
173
|
-
declare function FloPayCheckout({ sessionId: sessionIdProp, createSession: createSessionParams, billingApiUrl, appearance, locale, loading: loadingNode, error: errorNode, onComplete, onError, onDecline, onFullNameChange, onCountryChange, onZipChange, showPayPal, showApplePay, showGooglePay, layout, buttonsTheme, buttonsStyles, cardButtonContent, cardBackButtonContent, cardTitleContent, showSecurityFooter, onButtonClick, onBeforeButtonClick, enableAVS, avsLayout, submitLabel, className, initialErrorMessage, children, checkoutMode: checkoutModeProp, confirmLabel, renderConfirmButton, onSessionCompleted, }: FloPayCheckoutProps): React.ReactElement;
|
|
179
|
+
declare function FloPayCheckout({ sessionId: sessionIdProp, createSession: createSessionParams, billingApiUrl, appearance, locale, loading: loadingNode, error: errorNode, onComplete, onError, onDecline, onFullNameChange, onCountryChange, onZipChange, showPayPal, showApplePay, showGooglePay, debug, layout, buttonsTheme, buttonsStyles, cardButtonContent, cardBackButtonContent, cardTitleContent, showSecurityFooter, onButtonClick, onBeforeButtonClick, enableAVS, avsLayout, submitLabel, className, initialErrorMessage, children, checkoutMode: checkoutModeProp, confirmLabel, renderConfirmButton, onSessionCompleted, }: FloPayCheckoutProps): React.ReactElement;
|
|
174
180
|
|
|
175
181
|
/**
|
|
176
182
|
* Returns the current `FloPay` instance, or `null` if the provider
|
|
@@ -180,9 +186,9 @@ declare function FloPayCheckout({ sessionId: sessionIdProp, createSession: creat
|
|
|
180
186
|
*/
|
|
181
187
|
declare function useFloPay(): FloPay | null;
|
|
182
188
|
/**
|
|
183
|
-
* Returns the
|
|
184
|
-
*
|
|
185
|
-
*
|
|
189
|
+
* Returns the Stripe `FloPay` instance dedicated to the Stripe-rendered
|
|
190
|
+
* PayPal fallback, or `null` if PayPal is disabled for this session. Direct
|
|
191
|
+
* PayPal (`gateways.paypal`) does not use this instance.
|
|
186
192
|
*
|
|
187
193
|
* Must be called within a `<FloPayProvider>`.
|
|
188
194
|
*/
|
|
@@ -480,6 +486,26 @@ interface SplitCardFormProps {
|
|
|
480
486
|
currency?: string;
|
|
481
487
|
/** Render the card form expanded on first paint when `layout="buttons"`. */
|
|
482
488
|
initialCardOpen?: boolean;
|
|
489
|
+
/**
|
|
490
|
+
* Direct PayPal gateway configuration. When provided, PayPal renders via
|
|
491
|
+
* the official PayPal JS SDK (in-app browser compliant) instead of via
|
|
492
|
+
* Stripe's ExpressCheckoutElement. Selection is mutually exclusive:
|
|
493
|
+
* setting this disables the Stripe-rendered PayPal path automatically.
|
|
494
|
+
*/
|
|
495
|
+
directPaypal?: {
|
|
496
|
+
clientId: string;
|
|
497
|
+
environment?: GatewayEnvironment;
|
|
498
|
+
};
|
|
499
|
+
/** Whether the active session represents a subscription (drives direct PayPal intent). */
|
|
500
|
+
isSubscription?: boolean;
|
|
501
|
+
/** Backing session — forwarded to direct-PayPal so it can populate accountData. */
|
|
502
|
+
session?: CheckoutSession | null;
|
|
503
|
+
/**
|
|
504
|
+
* Enables on-screen diagnostic panels for the PayPal/wallet gating decision
|
|
505
|
+
* and the `DirectPayPalButton` lifecycle. Intended for debugging in-app
|
|
506
|
+
* browsers where remote console access is impractical. Off by default.
|
|
507
|
+
*/
|
|
508
|
+
debug?: boolean;
|
|
483
509
|
}
|
|
484
510
|
/**
|
|
485
511
|
* Split card checkout form matching `checkout/StripeCardForm`:
|
|
@@ -545,6 +571,110 @@ interface PayPalButtonProps {
|
|
|
545
571
|
*/
|
|
546
572
|
declare function PayPalButton({ sessionId, billingApiUrl, email, userId, firstName, lastName, chv, onTokenizedBody, onComplete, onErrorChange, isProcessing, }: PayPalButtonProps): React.ReactElement;
|
|
547
573
|
|
|
574
|
+
/**
|
|
575
|
+
* Overrides that `SplitCardForm`'s tokenized-body dispatcher uses to apply a
|
|
576
|
+
* `runBeforeButtonClick` patch to the in-flight processPayment call. Kept in
|
|
577
|
+
* sync structurally with `TokenizedBodyOverrides` in `split-card-form.tsx`.
|
|
578
|
+
*/
|
|
579
|
+
interface DirectPayPalTokenizedOverrides {
|
|
580
|
+
accountPatch?: InlineSessionPatch['account'];
|
|
581
|
+
sessionId?: string;
|
|
582
|
+
}
|
|
583
|
+
/**
|
|
584
|
+
* Internal handler signature aligned with `SplitCardForm`'s tokenized-body
|
|
585
|
+
* dispatcher. Direct PayPal completes via the backend's process endpoint and
|
|
586
|
+
* never produces a Stripe PaymentIntent, so we still forward a synthetic
|
|
587
|
+
* `TokenizedBody` describing the captured order, optionally with the
|
|
588
|
+
* session/account patch captured at click-time.
|
|
589
|
+
*/
|
|
590
|
+
type DirectPayPalTokenizedHandler = (body: TokenizedBody, overrides?: DirectPayPalTokenizedOverrides) => void;
|
|
591
|
+
/** Click-time `runBeforeButtonClick` result, structurally compatible with `SplitCardForm`. */
|
|
592
|
+
interface DirectPayPalBeforeButtonClickResult {
|
|
593
|
+
proceed: boolean;
|
|
594
|
+
accountPatch?: InlineSessionPatch['account'];
|
|
595
|
+
sessionId?: string;
|
|
596
|
+
}
|
|
597
|
+
/**
|
|
598
|
+
* Click-time gate. Mirrors `RunBeforeButtonClick` in `SplitCardForm`: lets the
|
|
599
|
+
* consumer patch the session/account before PayPal creates the order, and lets
|
|
600
|
+
* them abort the click entirely by returning `proceed: false`.
|
|
601
|
+
*/
|
|
602
|
+
type DirectPayPalRunBeforeButtonClick = (method: CheckoutButtonMethod) => Promise<DirectPayPalBeforeButtonClickResult>;
|
|
603
|
+
interface DirectPayPalButtonProps {
|
|
604
|
+
/** Checkout session ID. */
|
|
605
|
+
sessionId: string;
|
|
606
|
+
/** Billing API base URL. */
|
|
607
|
+
billingApiUrl: string;
|
|
608
|
+
/** Buyer email. */
|
|
609
|
+
email?: string;
|
|
610
|
+
/** PayPal client identifier (`gateways.paypal.publishableKey`). */
|
|
611
|
+
clientId: string;
|
|
612
|
+
/** Gateway environment, drives the sandbox/live SDK script. */
|
|
613
|
+
environment?: GatewayEnvironment;
|
|
614
|
+
/** ISO 4217 currency code. */
|
|
615
|
+
currency: string;
|
|
616
|
+
/** Whether the session is a subscription (drives intent + flow selection). */
|
|
617
|
+
isSubscription: boolean;
|
|
618
|
+
/**
|
|
619
|
+
* If provided, called with the tokenized body once PayPal capture
|
|
620
|
+
* completes. When omitted, the component processes payment internally.
|
|
621
|
+
*/
|
|
622
|
+
onTokenizedBody?: DirectPayPalTokenizedHandler;
|
|
623
|
+
/** Called when the full self-contained payment flow succeeds. */
|
|
624
|
+
onComplete?: (result: PaymentResult) => void;
|
|
625
|
+
/** Called when an error occurs. */
|
|
626
|
+
onErrorChange?: (error: string | null) => void;
|
|
627
|
+
/** Decline emitter (mirrors SplitCardForm semantics). */
|
|
628
|
+
onDecline?: (decline: DeclineEvent) => void;
|
|
629
|
+
/** External processing state. */
|
|
630
|
+
isProcessing?: boolean;
|
|
631
|
+
/** Notify the parent of the loading state for placeholder swapping. */
|
|
632
|
+
onLoadStateChange?: (ready: boolean) => void;
|
|
633
|
+
/** Tracks button-click for analytics. */
|
|
634
|
+
onButtonClick?: (method: CheckoutButtonMethod) => void;
|
|
635
|
+
/**
|
|
636
|
+
* Click-time gate (runs before PayPal creates the order). When provided, the
|
|
637
|
+
* returned patch is applied to the in-flight create-intent and tokenized
|
|
638
|
+
* dispatch so callers using `onBeforeButtonClick` see the same session/email
|
|
639
|
+
* the Stripe-rendered PayPal flow does.
|
|
640
|
+
*/
|
|
641
|
+
runBeforeButtonClick?: DirectPayPalRunBeforeButtonClick;
|
|
642
|
+
/** Backing session — used for self-contained accountData population. */
|
|
643
|
+
session?: CheckoutSession | null;
|
|
644
|
+
/**
|
|
645
|
+
* Pre-existing PayPal Order id (or Subscription id when `isSubscription` is
|
|
646
|
+
* true) to bind the button to. When set, the button skips its usual
|
|
647
|
+
* `POST /v1/checkouts/payments/intents` round-trip on click and feeds this
|
|
648
|
+
* id straight into PayPal's create-order / create-subscription callback.
|
|
649
|
+
*
|
|
650
|
+
* Used by `SplitCardForm`'s `paypal_direct_required` retry path: backend
|
|
651
|
+
* creates a fresh PayPal order after a stalled process attempt and returns
|
|
652
|
+
* its id; the SDK re-renders this button bound to that id so the buyer can
|
|
653
|
+
* confirm with one more click without the backend re-creating the order on
|
|
654
|
+
* each retry.
|
|
655
|
+
*
|
|
656
|
+
* Changing this value remounts the PayPal SDK so the new createOrder
|
|
657
|
+
* binding takes effect (PayPal's render() options aren't live-updatable).
|
|
658
|
+
*/
|
|
659
|
+
existingOrderId?: string;
|
|
660
|
+
/**
|
|
661
|
+
* When true, renders an on-screen lifecycle tracer panel above the button
|
|
662
|
+
* (mount, loadScript, eligibility, render, errors). Intended for debugging
|
|
663
|
+
* in-app browsers (Facebook IAB, etc.) where remote console access is
|
|
664
|
+
* impractical. Off by default — leave disabled in production.
|
|
665
|
+
*/
|
|
666
|
+
debug?: boolean;
|
|
667
|
+
}
|
|
668
|
+
/**
|
|
669
|
+
* Direct PayPal renderer powered by the official PayPal JS SDK.
|
|
670
|
+
*
|
|
671
|
+
* Renders inside Facebook / Instagram / Meta in-app browsers where Stripe's
|
|
672
|
+
* PayPal ExpressCheckoutElement breaks. Selection between this and the Stripe-
|
|
673
|
+
* rendered PayPal happens at the caller site based on whether the session
|
|
674
|
+
* advertises `gateways.paypal.publishableKey`.
|
|
675
|
+
*/
|
|
676
|
+
declare function DirectPayPalButton({ sessionId, billingApiUrl, email, clientId, environment, currency, isSubscription, onTokenizedBody, onComplete, onErrorChange, onDecline, isProcessing, onLoadStateChange, onButtonClick, runBeforeButtonClick, session, existingOrderId, debug, }: DirectPayPalButtonProps): React.ReactElement | null;
|
|
677
|
+
|
|
548
678
|
interface FloPayAutomaticPaymentSuccessEvent {
|
|
549
679
|
result: PaymentResult;
|
|
550
680
|
session: CheckoutSession | null;
|
|
@@ -576,4 +706,4 @@ interface FloPayAutomaticPaymentButtonProps extends Omit<React.ButtonHTMLAttribu
|
|
|
576
706
|
}
|
|
577
707
|
declare function FloPayAutomaticPaymentButton({ sessionId, createSession, paymentMethodId, checkoutMethod, clientId, items, subscriptions, account, successUrl, cancelUrl, couponCodes, tagsData, utmMetadata, billingApiUrl, locale, buttonsTheme, buttonsStyles: stylesOverride, onSuccess, onError, onDecline, children, disabled, type, style, ...buttonProps }: FloPayAutomaticPaymentButtonProps): react_jsx_runtime.JSX.Element;
|
|
578
708
|
|
|
579
|
-
export { AddressElement, CardCvcElement, CardElement, CardExpiryElement, CardNumberElement, CheckoutForm, type CheckoutFormProps, type CheckoutFormRef, type CheckoutState, type ElementComponentProps, FloPayAutomaticPaymentButton, type FloPayAutomaticPaymentButtonProps, type FloPayAutomaticPaymentSuccessEvent, FloPayCheckout, type FloPayCheckoutProps, FloPayProvider, type FloPayProviderProps, PayPalButton, type PayPalButtonProps, PaymentElement, SplitCardForm, type SplitCardFormProps, type SplitCardFormRef, useCheckout, useElements, useFloPay, usePayPalFloPay };
|
|
709
|
+
export { AddressElement, CardCvcElement, CardElement, CardExpiryElement, CardNumberElement, CheckoutForm, type CheckoutFormProps, type CheckoutFormRef, type CheckoutState, DirectPayPalButton, type DirectPayPalButtonProps, type ElementComponentProps, FloPayAutomaticPaymentButton, type FloPayAutomaticPaymentButtonProps, type FloPayAutomaticPaymentSuccessEvent, FloPayCheckout, type FloPayCheckoutProps, FloPayProvider, type FloPayProviderProps, PayPalButton, type PayPalButtonProps, PaymentElement, SplitCardForm, type SplitCardFormProps, type SplitCardFormRef, useCheckout, useElements, useFloPay, usePayPalFloPay };
|