@movmo/express-checkout-button 2.0.3 → 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 +8 -0
- package/dist/dts/MovmoCheckoutButton.d.ts +32 -6
- package/dist/dts/api.d.ts +17 -1
- package/dist/dts/index.d.ts +1 -1
- package/dist/dts/redirect.d.ts +17 -0
- package/dist/dts/returnHandler.d.ts +7 -0
- package/dist/dts/umd.d.ts +2 -1
- package/dist/express-checkout.umd.js +5 -5
- package/dist/express-checkout.umd.js.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +58 -24
- package/dist/index.es.js +2 -2
- package/dist/index.es.js.map +1 -1
- package/package.json +1 -1
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:
|
|
@@ -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`
|
|
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
|
-
|
|
18
|
-
|
|
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
|
|
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>;
|
package/dist/dts/index.d.ts
CHANGED
|
@@ -1,6 +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
6
|
export type { MovmoBookingCompleteInfo, MovmoCheckoutExitInfo, MovmoCheckoutReturnOptions, MovmoExitReason, } from './returnHandler';
|
package/dist/dts/redirect.d.ts
CHANGED
|
@@ -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
|
|
@@ -10,6 +10,8 @@ export interface MovmoBookingCompleteInfo {
|
|
|
10
10
|
/** Airline IATA / company code, not the PNR. */
|
|
11
11
|
airlineRef?: string;
|
|
12
12
|
providerId?: string;
|
|
13
|
+
/** Events checkouts: the seller ref that started the checkout. */
|
|
14
|
+
sellerRef?: string;
|
|
13
15
|
}
|
|
14
16
|
export interface MovmoCheckoutReturnOptions {
|
|
15
17
|
/**
|
|
@@ -18,6 +20,11 @@ export interface MovmoCheckoutReturnOptions {
|
|
|
18
20
|
* is pending, taking the values from the record.
|
|
19
21
|
*/
|
|
20
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;
|
|
21
28
|
providerID?: string;
|
|
22
29
|
/** The pre-saved offer id, when known, to tell two buttons with the same airline apart. */
|
|
23
30
|
offerId?: string;
|
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`
|
|
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;
|