@movmo/express-checkout-button 2.0.2 → 2.1.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.
package/README.md CHANGED
@@ -172,6 +172,14 @@ Notes:
172
172
  - If `crypto` is unavailable the redirect still happens without a `state`, and the return is
173
173
  ignored (callbacks need a verified nonce).
174
174
 
175
+ ## Events mode
176
+
177
+ Pass `sellerRef` and `eventTicket={{ eventId, listingId, quantity }}` (quantity a whole number 1 to 20)
178
+ instead of the flight props to start an events checkout; `apiKey`, `providerID`, `returnUrl` and the
179
+ callbacks work as above (`onError` stage may also be `invalid_options` or `not_available`). A return carries `bookingId` (no `airlinePnr`). Not available in production
180
+ yet: `onError` fires on click, and no analytics or other request is sent. A page-level
181
+ `consumeReturn` for events must pass `sellerRef`; without it the call is a flights call.
182
+
175
183
  ## Provider Options
176
184
 
177
185
  The `providerID` prop accepts provider identifiers as strings. Common providers include:
@@ -266,7 +274,7 @@ test pages; it is sticky per tab and entirely fail-open.
266
274
 
267
275
  `MovmoCheckoutButton` self-instruments the partner-page funnel — from the button rendering on
268
276
  the airline page through the redirect to Movmo and the return — using
269
- `@movmo_app/analytics` in **scoped mode**. Scoped mode disables every document-level listener
277
+ Movmo's bundled analytics SDK in **scoped mode**. Scoped mode disables every document-level listener
270
278
  the SDK would otherwise install (click/rage-click/hover/scroll/field/section autocapture);
271
279
  the button only ever attaches listeners to its own DOM node. It never observes the partner's
272
280
  page, reads partner form fields, or inspects anything outside that element. The airline
@@ -1,8 +1,10 @@
1
1
  import React from 'react';
2
+ import type { EventTicketSelection } from './api';
2
3
  import { MovmoBookingCompleteInfo, MovmoCheckoutExitInfo } from './returnHandler';
3
4
  /**
4
5
  * A user-facing failure the button could not recover from on its own (MOVMO-673).
5
- * `stage` is `'save_offer'` — the click-time raw-offer save failed (CORS from an
6
+ * `stage` may also be `'invalid_options'` or `'not_available'` (events mode: a bad ticket choice, or
7
+ * production, which is not supported yet). `stage` is `'save_offer'` — the click-time raw-offer save failed (CORS from an
6
8
  * unregistered origin, a 4xx/5xx from the proxy, or a timeout) — or `'missing_offer'`
7
9
  * — neither `flightOfferID` nor `flightOffer` was provided. `status` is the HTTP
8
10
  * status when the failure was a non-2xx response; it is omitted for network errors,
@@ -10,16 +12,14 @@ import { MovmoBookingCompleteInfo, MovmoCheckoutExitInfo } from './returnHandler
10
12
  * `message`/`error` field, falling back to a generic error string.
11
13
  */
12
14
  export type MovmoCheckoutError = {
13
- stage: 'save_offer' | 'missing_offer';
15
+ stage: 'save_offer' | 'missing_offer' | 'invalid_options' | 'not_available';
14
16
  status?: number;
15
17
  message: string;
16
18
  };
17
- export interface MovmoCheckoutButtonProps {
18
- iataCode: string;
19
+ /** Props shared by the flights and events modes. */
20
+ export interface MovmoCheckoutCommonProps {
19
21
  apiKey: string;
20
22
  providerID: string;
21
- flightOffer?: object;
22
- flightOfferID?: string;
23
23
  isProd?: boolean;
24
24
  className?: string;
25
25
  /**
@@ -57,4 +57,30 @@ export interface MovmoCheckoutButtonProps {
57
57
  */
58
58
  onError?: (error: MovmoCheckoutError) => void;
59
59
  }
60
+ /** Flights mode: an airline page starts a flight checkout. */
61
+ export interface MovmoFlightCheckoutProps extends MovmoCheckoutCommonProps {
62
+ iataCode: string;
63
+ flightOffer?: object;
64
+ flightOfferID?: string;
65
+ sellerRef?: never;
66
+ eventTicket?: never;
67
+ }
68
+ /** The ticket choice an events checkout starts from (quantity is a whole number, 1 to 20). */
69
+ export type MovmoEventTicket = EventTicketSelection;
70
+ /**
71
+ * Events mode: a ticket seller's page starts an events checkout. `sellerRef` is the seller
72
+ * Movmo registered for `providerID`. Not available in production yet (`onError` fires).
73
+ */
74
+ export interface MovmoEventCheckoutProps extends MovmoCheckoutCommonProps {
75
+ sellerRef: string;
76
+ eventTicket: MovmoEventTicket;
77
+ iataCode?: never;
78
+ flightOffer?: never;
79
+ flightOfferID?: never;
80
+ }
81
+ export type MovmoCheckoutButtonProps = MovmoFlightCheckoutProps | MovmoEventCheckoutProps;
82
+ export declare const EVENTS_PROD_UNAVAILABLE_MESSAGE = "Movmo events checkout is not available in production yet.";
83
+ export declare const MAX_EVENT_TICKET_QUANTITY = 20;
84
+ /** Why an events ticket is unusable, or null when it is fine. Shared with the UMD `mount`. */
85
+ export declare function eventTicketProblem(ticket: unknown): string | null;
60
86
  export declare const MovmoCheckoutButton: React.FC<MovmoCheckoutButtonProps>;
package/dist/dts/api.d.ts CHANGED
@@ -8,7 +8,12 @@
8
8
  export interface ApiClient {
9
9
  post<T>(path: string, body: unknown): Promise<T>;
10
10
  }
11
- export declare const createApiClient: (apiKey: string, airlineRef: string, isProd?: boolean) => ApiClient;
11
+ export type CheckoutProduct = 'flights' | 'events';
12
+ /**
13
+ * `customerRef` is sent as `movmo-customer-id`: the airline IATA code for flights, the seller
14
+ * ref for events. Events calls go to the events host and ignore the flights-only API override.
15
+ */
16
+ export declare const createApiClient: (apiKey: string, customerRef: string, isProd?: boolean, product?: CheckoutProduct) => ApiClient;
12
17
  /**
13
18
  * Discriminated result of {@link saveProviderOffer} (MOVMO-673). Replaces the earlier
14
19
  * `string | null` contract so the button (and, via `onError`, the partner page) can
@@ -26,3 +31,14 @@ export type SaveOfferResult = {
26
31
  cause?: unknown;
27
32
  };
28
33
  export declare const saveProviderOffer: (providerID: string, rawOffer: object, client: ApiClient) => Promise<SaveOfferResult>;
34
+ /** The ticket choice an events checkout starts from. */
35
+ export interface EventTicketSelection {
36
+ eventId: string;
37
+ listingId: string;
38
+ quantity: number;
39
+ }
40
+ /**
41
+ * Events save: the answer's `checkout_url` is deliberately ignored (the SDK builds the redirect
42
+ * itself and never follows an address from the server); only `offer_id` is used.
43
+ */
44
+ export declare const saveEventWebsiteOffer: (providerID: string, ticket: EventTicketSelection, client: ApiClient) => Promise<SaveOfferResult>;
@@ -1,7 +1,6 @@
1
1
  import './index.css';
2
2
  export { MovmoCheckoutButton } from './MovmoCheckoutButton';
3
- export type { MovmoCheckoutButtonProps, MovmoCheckoutError } from './MovmoCheckoutButton';
3
+ export type { MovmoCheckoutButtonProps, MovmoCheckoutCommonProps, MovmoCheckoutError, MovmoEventCheckoutProps, MovmoEventTicket, MovmoFlightCheckoutProps, } from './MovmoCheckoutButton';
4
4
  export type { SaveOfferResult } from './api';
5
5
  export { consumeMovmoCheckoutReturn } from './returnHandler';
6
- export type { MovmoBookingCompleteInfo, MovmoCheckoutExitInfo, MovmoCheckoutReturnOptions, } from './returnHandler';
7
- export type { MovmoExitReason } from '@movmo_app/types';
6
+ export type { MovmoBookingCompleteInfo, MovmoCheckoutExitInfo, MovmoCheckoutReturnOptions, MovmoExitReason, } from './returnHandler';
@@ -10,6 +10,10 @@ export interface PendingCheckout {
10
10
  airlineRef?: string;
11
11
  /** Environment the button was mounted with; selects the analytics collector on return. */
12
12
  isProd?: boolean;
13
+ /** Absent means flights, so records written by older versions keep working. */
14
+ product?: 'flights' | 'events';
15
+ /** Events only: the seller that started the checkout. */
16
+ sellerRef?: string;
13
17
  }
14
18
  /** A pending record older than this is ignored (an abandoned checkout, or a stale tab). */
15
19
  export declare const PENDING_TTL_MS: number;
@@ -28,6 +32,19 @@ export interface BuildCheckoutUrlParams {
28
32
  }
29
33
  /** Checkout origin: the build-time override, else prod or e2e. Path routing, not a hash route. */
30
34
  export declare function checkoutBaseUrl(isProd: boolean): string;
35
+ export interface BuildEventsCheckoutUrlParams {
36
+ offerId: string;
37
+ providerId: string;
38
+ sellerRef: string;
39
+ mvs?: string | null;
40
+ internal?: boolean;
41
+ returnUrl: string;
42
+ state?: string | null;
43
+ isProd: boolean;
44
+ }
45
+ /** Events checkout origin: the validated build-time override (ESM/CJS only), else prod or e2e. */
46
+ export declare function eventsCheckoutBaseUrl(isProd: boolean): string;
47
+ export declare function buildEventsCheckoutUrl(params: BuildEventsCheckoutUrlParams): string;
31
48
  export declare function buildCheckoutUrl(params: BuildCheckoutUrlParams): string;
32
49
  /**
33
50
  * The return URL sent to Movmo (it lands in CloudFront logs): the current page URL with every
@@ -1,4 +1,3 @@
1
- import type { MovmoExitReason } from '@movmo_app/types';
2
1
  /** Passed to the airline's onExit callback when the traveler returns from Movmo. */
3
2
  export interface MovmoCheckoutExitInfo {
4
3
  reason: MovmoExitReason;
@@ -11,6 +10,8 @@ export interface MovmoBookingCompleteInfo {
11
10
  /** Airline IATA / company code, not the PNR. */
12
11
  airlineRef?: string;
13
12
  providerId?: string;
13
+ /** Events checkouts: the seller ref that started the checkout. */
14
+ sellerRef?: string;
14
15
  }
15
16
  export interface MovmoCheckoutReturnOptions {
16
17
  /**
@@ -19,6 +20,11 @@ export interface MovmoCheckoutReturnOptions {
19
20
  * is pending, taking the values from the record.
20
21
  */
21
22
  iataCode?: string;
23
+ /**
24
+ * Events: the seller ref. Giving it makes this an events call, which only claims an events
25
+ * return for that seller; a call with only `iataCode` only claims a flights return.
26
+ */
27
+ sellerRef?: string;
22
28
  providerID?: string;
23
29
  /** The pre-saved offer id, when known, to tell two buttons with the same airline apart. */
24
30
  offerId?: string;
@@ -30,6 +36,9 @@ export interface MovmoCheckoutReturnOptions {
30
36
  onExit?: (info: MovmoCheckoutExitInfo) => void;
31
37
  onBookingComplete?: (info: MovmoBookingCompleteInfo) => void;
32
38
  }
39
+ /** Why the checkout handed control back to the airline page (`onExit`). */
40
+ declare const REASONS: readonly ["search_again", "offer_unavailable", "booking_confirmed"];
41
+ export type MovmoExitReason = (typeof REASONS)[number];
33
42
  /** @internal Test hook: forget any parsed or claimed return. Not exported from the package entry. */
34
43
  export declare function __resetForTests(): void;
35
44
  /**
@@ -46,3 +55,4 @@ export declare function __resetForTests(): void;
46
55
  * it as early as possible, before analytics or session-replay scripts read the URL.
47
56
  */
48
57
  export declare function consumeMovmoCheckoutReturn(options?: MovmoCheckoutReturnOptions): boolean;
58
+ export {};
@@ -1,5 +1,3 @@
1
- import { EVENTS } from '@movmo_app/analytics';
2
- export { EVENTS };
3
1
  /**
4
2
  * Scoped-mode analytics for the partner page (MOVMO-464). Autocapture stays OFF —
5
3
  * we never observe the partner's DOM or inputs; listeners attach only to
package/dist/dts/umd.d.ts CHANGED
@@ -27,6 +27,7 @@ export interface MovmoMountHandle {
27
27
  * handle instead of creating a second root.
28
28
  * @throws If `target` is a selector that matches no element, or if a required
29
29
  * option (`apiKey`, `iataCode`, `providerID`, and one of
30
- * `flightOffer`/`flightOfferID`) is missing.
30
+ * `flightOffer`/`flightOfferID`; or for events `apiKey`, `sellerRef`, `providerID`
31
+ * and a valid `eventTicket`) is missing.
31
32
  */
32
33
  export declare function mount(target: string | Element, options: MovmoCheckoutButtonProps): MovmoMountHandle;