@fanfare-io/fanfare-sdk-react 0.13.0 → 0.14.0

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.
@@ -1,8 +1,8 @@
1
1
  import { CheckoutProcessingSlotProps } from '../widgets/experience-widget';
2
2
  import * as React from "react";
3
3
  /**
4
- * Default processing panel shown for the gap between a submitted reservation checkout and the
5
- * server's confirmation.
4
+ * Default processing panel shown for the gap between a submitted checkout and the server's
5
+ * confirmation.
6
6
  *
7
7
  * The consumer must not navigate away while the payment settles, so the wait is announced rather
8
8
  * than shown only as motion.
@@ -1,4 +1,3 @@
1
1
  export { CheckoutProcessingPanel } from './checkout-processing-panel';
2
2
  export { PaymentCollectionPanel } from './payment-collection-panel';
3
3
  export { ReceiptPanel } from './receipt-panel';
4
- export { ReservationCheckoutPanel } from './reservation-checkout-panel';
@@ -1,8 +1,7 @@
1
1
  import { PaymentCollectionSlotProps } from '../widgets/experience-widget';
2
2
  import * as React from "react";
3
3
  /**
4
- * Default payment-collection panel for pre-auth distributions, rendered both when the consumer is
5
- * about to enter and when a failed authorization leaves a retry open.
4
+ * Default payment-collection panel for pre-auth entry/re-entry and grant-keyed at-end checkout.
6
5
  *
7
6
  * The hold amount is rendered from the view's own figure — the client never derives one.
8
7
  *
@@ -15,4 +14,4 @@ import * as React from "react";
15
14
  * minted across the whole flow. An ended view carries no pending action, so the retry mount reaches
16
15
  * none of this.
17
16
  */
18
- export declare function PaymentCollectionPanel({ preAuthAmount, preAuthCurrencyCode, savedPaymentMethods, paymentProvider, onEnter, isEntering, intent, pendingAction, onRetryPaymentConfig, ...slotProps }: PaymentCollectionSlotProps): React.ReactElement;
17
+ export declare function PaymentCollectionPanel(props: PaymentCollectionSlotProps): React.ReactElement;
@@ -1,7 +1,7 @@
1
1
  import { StripeClientConfig } from './stripe-client';
2
2
  /**
3
3
  * The SDK's card-entry field: a Stripe Card Element and the controller that turns it into a
4
- * payment-method id. It knows nothing about reservations, pre-auth, or amounts.
4
+ * payment-method id. It knows nothing about settlement, pre-auth, or amounts.
5
5
  *
6
6
  * `@stripe/stripe-js` is a type-only dependency across the SDK, so no vendor bytes ship in any
7
7
  * chunk. This module is the one lazy split: it is reached only through a dynamic `import()` from
@@ -1,11 +1,18 @@
1
- import { ReservationPaymentAffordance } from '@fanfare-io/fanfare-sdk-core/experiences';
1
+ import { SequenceView } from '@fanfare-io/fanfare-sdk-core/experiences';
2
2
  import { Stripe, StripeConstructor, StripeElementStyle } from '@stripe/stripe-js';
3
+ /** How a granted win settles, as the granted views carry it. */
4
+ type GrantedSettlement = Extract<SequenceView, {
5
+ phase: "granted";
6
+ }>["settlement"];
3
7
  /**
4
8
  * The wire block a checkout-capable view carries, reached through the adapter's declared
5
9
  * dependency on `fanfare-sdk-core` rather than the contracts package: core re-exports the contract
6
- * types so adapter modules never resolve `@fanfare-io/fanfare-sdk-contracts` directly.
10
+ * types so adapter modules never resolve `@fanfare-io/fanfare-sdk-contracts` directly. Core names
11
+ * the shape only within the arms that carry it, so it is read back off one of them.
7
12
  */
8
- type PaymentProviderConfig = NonNullable<ReservationPaymentAffordance["paymentProvider"]>;
13
+ type PaymentProviderConfig = NonNullable<Extract<GrantedSettlement, {
14
+ mode: "at_end";
15
+ }>["paymentProvider"]>;
9
16
  declare global {
10
17
  interface Window {
11
18
  Stripe?: StripeConstructor;
@@ -62,8 +69,8 @@ export declare function deriveStripeCardStyle(root: HTMLElement): StripeElementS
62
69
  *
63
70
  * `null` means no usable Stripe client configuration reached this view. On a checkout-capable arm
64
71
  * that has exactly one cause — the configuration read failed — because the processor discriminator
65
- * is the `processor` field (reserved) or `checkoutMode` (enterable), never the presence of this
66
- * block. The condition is transient and retryable.
72
+ * is the settlement's `processor`/`mode` pair (granted) or `checkoutMode` (enterable), never the
73
+ * presence of this block. The condition is transient and retryable.
67
74
  */
68
75
  export declare function resolveStripeClientConfig(source: PaymentProviderConfig | undefined): StripeClientConfig | null;
69
76
  /** Test-only seam over every memo this module holds. Never exported from an adapter's public entry. */
@@ -3,9 +3,14 @@
3
3
  *
4
4
  * Shared granted composition for distribution modules. Renders the
5
5
  * winning-state panel: status badge, expiry countdown (or fallback message
6
- * when no expiry is known), and a checkout CTA. Used by queue / draw /
7
- * auction / timed-release modules the JSX is structurally identical
8
- * across all four; only the i18n strings differ.
6
+ * when no expiry is known), and only when the caller supplies a
7
+ * destination a checkout CTA. Used by queue / draw / auction /
8
+ * timed-release modules the JSX is structurally identical across all
9
+ * four; only the i18n strings differ.
10
+ *
11
+ * A granted frame with no `onCtaClick` renders no button: the grant is
12
+ * already settled where the consumer stands, so an inert affordance would
13
+ * promise a hand-off that does not exist.
9
14
  *
10
15
  * <GrantedPanel
11
16
  * label="Congratulations!"
@@ -24,9 +29,9 @@ import * as React from "react";
24
29
  export interface GrantedPanelProps {
25
30
  label: React.ReactNode;
26
31
  fallbackMessage: React.ReactNode;
27
- ctaLabel: React.ReactNode;
32
+ ctaLabel?: React.ReactNode;
28
33
  expiresAt?: Date;
29
- onCtaClick: () => void;
34
+ onCtaClick?: () => void;
30
35
  className?: string;
31
36
  }
32
37
  export declare function GrantedPanel({ label, fallbackMessage, ctaLabel, expiresAt, onCtaClick, className, }: GrantedPanelProps): import("react/jsx-runtime").JSX.Element;
@@ -1,5 +1,6 @@
1
1
  import { BotMitigationState, RoutingChallenge } from '@fanfare-io/fanfare-sdk-core/challenges';
2
- import { CheckoutNextAction, CheckoutProcessor, FanfareCheckoutResult, JourneyHandle, JourneySnapshot, JourneyView, PaymentInput, PaymentMethodSummary, ReservationPaymentAffordance, SequenceView } from '@fanfare-io/fanfare-sdk-core/experiences';
2
+ import { SDKEvents } from '@fanfare-io/fanfare-sdk-core/events';
3
+ import { CheckoutNextAction, FanfareCheckoutResult, JourneyHandle, JourneySnapshot, JourneyView, PaymentInput, PaymentMethodSummary, SequenceView } from '@fanfare-io/fanfare-sdk-core/experiences';
3
4
  import { BrandTheme, WidgetVariant } from '../../theme';
4
5
  import { AuthInputMode } from '../auth/auth-input';
5
6
  import { OutcomeAction } from '../compositions/outcome-panel';
@@ -16,6 +17,8 @@ type ParticipatingSlotSequence = Extract<SequenceView, {
16
17
  type GrantedSlotSequence = Extract<SequenceView, {
17
18
  phase: "granted";
18
19
  }>;
20
+ /** How a granted win settles: who consumes the grant, and whether money has already moved for it. */
21
+ type GrantedSettlement = GrantedSlotSequence["settlement"];
19
22
  /** Props passed to slot render functions */
20
23
  export interface SlotProps {
21
24
  snapshot: JourneySnapshot | null;
@@ -60,22 +63,17 @@ export interface GrantedSlotProps extends SlotProps {
60
63
  grant?: string;
61
64
  expiresAt?: number;
62
65
  }
63
- export interface PaymentCollectionSlotProps extends SlotProps {
64
- preAuthAmount: string;
65
- preAuthCurrencyCode: string;
66
+ interface PaymentCollectionBaseSlotProps extends SlotProps {
66
67
  savedPaymentMethods: PaymentMethodSummary[];
67
- /** Rejects on a recoverable payment failure (e.g. a declined card) — the panel owns recovery UI for its own submit. */
68
+ /** Submits pre-auth entry or confirms at-end checkout; rejects when the panel should keep recovery UI mounted. */
68
69
  onEnter: (paymentInput: PaymentInput) => Promise<void>;
69
70
  isEntering: boolean;
70
- /** "enter" collects payment before first entry; "reenter" collects payment to retry after a failed or expired authorization hold. */
71
- intent: "enter" | "reenter";
72
71
  /**
73
- * Client configuration for the processor authorizing this entry, as the server supplied it.
74
- * Carried by the enterable arm only a retry is offered from an ended view, which holds no
75
- * configuration.
72
+ * Client configuration for the internal processor, as the server supplied it. Carried by the
73
+ * enterable pre-auth and granted at-end arms; an ended retry holds no configuration.
76
74
  */
77
75
  paymentProvider?: PaymentProviderConfig;
78
- /** Present while the processor is waiting on an out-of-band action; re-submitting entry resolves it. */
76
+ /** Present while the internal processor is waiting on an out-of-band action. */
79
77
  pendingAction?: CheckoutNextAction;
80
78
  /**
81
79
  * Re-reads the consumer's journeys from the server so a provider configuration that was missing
@@ -84,35 +82,22 @@ export interface PaymentCollectionSlotProps extends SlotProps {
84
82
  */
85
83
  onRetryPaymentConfig?: () => Promise<void>;
86
84
  }
85
+ export type PaymentCollectionSlotProps = PaymentCollectionBaseSlotProps & ({
86
+ intent: "checkout";
87
+ onResume: () => Promise<void>;
88
+ } | {
89
+ intent: "enter" | "reenter";
90
+ preAuthAmount: string;
91
+ preAuthCurrencyCode: string;
92
+ onResume?: never;
93
+ });
87
94
  /**
88
- * The processor's client configuration block, named through the affordance that carries it: core
89
- * re-exports the affordance but not the contract's own name for this shape.
95
+ * The processor's client configuration block, named through an arm that carries it: core names the
96
+ * shape only within those arms, not as a standalone export.
90
97
  */
91
- type PaymentProviderConfig = NonNullable<ReservationPaymentAffordance["paymentProvider"]>;
92
- export interface ReservationCheckoutSlotProps extends SlotProps {
93
- reservation: {
94
- token: string;
95
- expiresAt: number;
96
- };
97
- savedPaymentMethods: PaymentMethodSummary[];
98
- /** Which processor executes this reservation's payment leg; narrow before rendering processor-specific UI. */
99
- processor: CheckoutProcessor;
100
- /** Client configuration for the processor settling this reservation, as the server supplied it. */
101
- paymentProvider?: PaymentProviderConfig;
102
- /** Present while the processor is waiting on an out-of-band action; complete it, then call `onResume`. */
103
- pendingAction?: CheckoutNextAction;
104
- /** Rejects on a recoverable payment failure (e.g. a declined card) — the panel owns recovery UI for its own submit. */
105
- onConfirm: (paymentInput: PaymentInput) => Promise<void>;
106
- /** Re-submits the paused checkout after `pendingAction` has been completed. Idempotent server-side. */
107
- onResume: () => Promise<void>;
108
- isConfirming: boolean;
109
- /**
110
- * Re-reads the consumer's journeys from the server so a provider configuration that was missing
111
- * or unreadable at render can arrive. This is the panel's only recovery when `paymentProvider` is
112
- * absent — the value is a prop, so nothing the panel does to its own state can produce it.
113
- */
114
- onRetryPaymentConfig?: () => Promise<void>;
115
- }
98
+ type PaymentProviderConfig = NonNullable<Extract<GrantedSettlement, {
99
+ mode: "at_end";
100
+ }>["paymentProvider"]>;
116
101
  export type CheckoutProcessingSlotProps = SlotProps;
117
102
  /**
118
103
  * A Fanfare-managed payment is terminal: it produces a receipt, never an admission credential. The
@@ -164,13 +149,18 @@ export interface ExperienceWidgetSlots {
164
149
  participating?: (props: ParticipatingSlotProps) => React.ReactNode;
165
150
  granted?: (props: GrantedSlotProps) => React.ReactNode;
166
151
  paymentCollection?: (props: PaymentCollectionSlotProps) => React.ReactNode;
167
- reservationCheckout?: (props: ReservationCheckoutSlotProps) => React.ReactNode;
152
+ /** Rendered by the at-end checkout surface while a collected payment is settling. */
168
153
  checkoutProcessing?: (props: CheckoutProcessingSlotProps) => React.ReactNode;
169
154
  receipt?: (props: ReceiptSlotProps) => React.ReactNode;
170
155
  expired?: (props: ExpiredSlotProps) => React.ReactNode;
171
156
  ended?: (props: EndedSlotProps) => React.ReactNode;
172
157
  error?: (props: ErrorSlotProps) => React.ReactNode;
173
158
  }
159
+ /**
160
+ * Surface the widget is mounted on, named through the bus payload that carries it: core
161
+ * re-exports the event map but not the contract's own name for this shape.
162
+ */
163
+ type BeaconPageType = SDKEvents["experience:widget-mounted"]["pageType"];
174
164
  /** Render props for full control */
175
165
  export interface ExperienceRenderProps {
176
166
  journey: JourneyHandle | null;
@@ -195,6 +185,11 @@ export interface ExperienceWidgetProps {
195
185
  variant?: WidgetVariant;
196
186
  /** Slots for targeted overrides */
197
187
  slots?: ExperienceWidgetSlots;
188
+ /**
189
+ * Surface this widget renders on, carried on the `experience:widget-mounted` announcement.
190
+ * Defaults to `embed`, the merchant-page case; Fanfare-hosted drop pages pass `hosted`.
191
+ */
192
+ pageType?: BeaconPageType;
198
193
  /** Render prop for full control (ignores slots if provided) */
199
194
  children?: (props: ExperienceRenderProps) => React.ReactNode;
200
195
  /** Checkout URL for granted state */
@@ -208,16 +203,14 @@ export interface ExperienceWidgetProps {
208
203
  onJourneyChange?: (snapshot: JourneySnapshot) => void;
209
204
  /** Called when the journey receives a grant */
210
205
  onGranted?: (grant: string) => void;
211
- /** Called when a Fanfare-managed checkout completes (pre-auth capture or post-win reservation checkout) */
206
+ /** Called when a Fanfare-managed checkout completes */
212
207
  onFanfareCheckout?: (result: FanfareCheckoutResult) => void;
213
- /** Called when the consumer wins a `post_win` distribution and must complete checkout before `expiresAt` */
214
- onReserved?: (expiresAt: number) => void;
215
208
  /** Called when an error occurs */
216
209
  onError?: (error: Error) => void;
217
210
  /** Additional class name */
218
211
  className?: string;
219
212
  }
220
- export declare function ExperienceWidget({ experienceId, autoStart, accessCode, autoEnterWaitlist, theme, variant, slots, children, checkoutUrl, endedAction, onJourneyChange, onGranted, onFanfareCheckout, onReserved, onError, className, }: ExperienceWidgetProps): import("react/jsx-runtime").JSX.Element;
213
+ export declare function ExperienceWidget({ experienceId, autoStart, accessCode, autoEnterWaitlist, theme, variant, slots, pageType, children, checkoutUrl, endedAction, onJourneyChange, onGranted, onFanfareCheckout, onError, className, }: ExperienceWidgetProps): import("react/jsx-runtime").JSX.Element;
221
214
  export declare namespace ExperienceWidget {
222
215
  var displayName: string;
223
216
  }