@movmo/express-checkout-button 1.10.1 → 1.11.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/README.md CHANGED
@@ -89,6 +89,8 @@ export default MyBookingPage;
89
89
  | `flightOffer` | object | No\* | The raw flight offer data object from the provider. Required if `flightOfferID` is not provided |
90
90
  | `flightOfferID` | string | No\* | The ID of a pre-saved flight offer. Required if `flightOffer` is not provided |
91
91
  | `isProd` | boolean | No | Whether to use production endpoints (default: false). When true, uses production API and flights URLs; when false, uses e2e (testing) endpoints |
92
+ | `className` | string | No | Extra CSS classes merged onto the button element |
93
+ | `onExit` | function| No | `(info: MovmoCheckoutExitInfo) => void` — called when the checkout overlay hands control back to your page. `info.reason` is `'booking_confirmed'` (traveler clicked "Return to airline" after a successful booking — a booking-complete callback already fired for it), `'offer_unavailable'` (the offer expired/became unbookable), or `'search_again'` |
92
94
 
93
95
  \*Note: Either `flightOffer` or `flightOfferID` must be provided, but not both.
94
96
 
@@ -117,6 +119,45 @@ The `isProd` prop controls which Movmo endpoints are used:
117
119
  - API endpoint: `https://api.movmo.io`
118
120
  - Flights UI: `https://flights.movmo.io`
119
121
 
122
+ ## Vanilla JS / `<script>` tag (no React required)
123
+
124
+ The package also ships a self-contained UMD bundle (`dist/express-checkout.umd.js`, exposed via
125
+ the package's `unpkg` field) for host pages without React or a bundler. It defines
126
+ `window.MovmoExpressCheckout`:
127
+
128
+ ```html
129
+ <div id="movmo-checkout"></div>
130
+ <!-- Production: pin an exact version and add Subresource Integrity so a CDN compromise
131
+ can't alter the script (generate the hash from the pinned file, e.g.
132
+ `openssl dgst -sha384 -binary express-checkout.umd.js | openssl base64 -A`): -->
133
+ <script
134
+ src="https://unpkg.com/@movmo/express-checkout-button@1.11.0/dist/express-checkout.umd.js"
135
+ integrity="sha384-<hash-of-the-pinned-file>"
136
+ crossorigin="anonymous"
137
+ ></script>
138
+ <script>
139
+ var handle = window.MovmoExpressCheckout.mount('#movmo-checkout', {
140
+ iataCode: 'AA',
141
+ apiKey: 'your-movmo-api-key',
142
+ providerID: 'sabre',
143
+ flightOffer: rawOffer,
144
+ // isProd: true — add when you go live
145
+ });
146
+ // handle.unmount() removes the button; window.MovmoExpressCheckout.version reports the SDK version
147
+ </script>
148
+ ```
149
+
150
+ `mount(target, options)` accepts a CSS selector or an Element (it throws a clear error when a
151
+ selector matches nothing) and takes the same options as the React component's props. React,
152
+ styling, and all dependencies are bundled — nothing else to include.
153
+
154
+ ## Internal / QA traffic flagging
155
+
156
+ When the host page URL carries `?mv_internal=1`, the button flags its own analytics events as
157
+ internal traffic and appends `mv_internal=1` to the checkout URL, so the entire embedded session
158
+ (button + Movmo checkout iframe) is excluded from partner-facing KPIs. Use it on demo, QA, and
159
+ test pages; it is sticky per tab and entirely fail-open.
160
+
120
161
  ## Analytics (scoped)
121
162
 
122
163
  `MovmoCheckoutButton` self-instruments the pre-iframe funnel — from the button rendering on
@@ -171,6 +212,19 @@ You must import the component's CSS for proper styling:
171
212
  import '@movmo/express-checkout-button/dist/index.css';
172
213
  ```
173
214
 
215
+ Every class the package emits is namespaced with a `movmo-` prefix (for example `.movmo-px-7`,
216
+ `.focus\:movmo-ring-2`) as of 1.11.0, so the stylesheet cannot collide with your page's own
217
+ Tailwind or utility CSS — and vice versa. This applies to the `<script>` tag build too, which
218
+ injects the same stylesheet into your page. The `className` prop is passed through untouched:
219
+ your own classes are never prefixed.
220
+
221
+ If you previously styled the button by targeting one of its internal class names (for example
222
+ `.bg-gradient-normal`), switch to a descendant selector on your own wrapper — `.my-wrapper button`
223
+ for the button, `.my-wrapper button > span` for the Movmo badge — which is stable across versions.
224
+
225
+ The package has no runtime HTTP dependency: the offer-save call uses the platform `fetch`. If your
226
+ project relied on the transitive `axios` install that older versions pulled in, declare it yourself.
227
+
174
228
  ## Development
175
229
 
176
230
  ### Running Storybook
package/dist/dts/api.d.ts CHANGED
@@ -1,3 +1,12 @@
1
- import { AxiosInstance } from 'axios';
2
- export declare const createAxiosClient: (apiKey: string, airlineRef: string, isProd?: boolean) => AxiosInstance;
3
- export declare const saveProviderOffer: (providerID: string, rawOffer: object, client: AxiosInstance) => Promise<string | null>;
1
+ /**
2
+ * Minimal JSON POST client for the Movmo checkout proxy.
3
+ *
4
+ * Replaces axios (MOVMO-517) — the package's only runtime HTTP dependency,
5
+ * ~14 KB gzip of the UMD bundle. Deliberately NOT a general-purpose HTTP
6
+ * client: one method, one content type, one caller (`saveProviderOffer`).
7
+ */
8
+ export interface ApiClient {
9
+ post<T>(path: string, body: unknown): Promise<T>;
10
+ }
11
+ export declare const createApiClient: (apiKey: string, airlineRef: string, isProd?: boolean) => ApiClient;
12
+ export declare const saveProviderOffer: (providerID: string, rawOffer: object, client: ApiClient) => Promise<string | null>;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Reads a build-time environment override without assuming a `process` global.
3
+ *
4
+ * Create React App inlines `process.env.REACT_APP_*`; Vite, Parcel, esbuild, Remix/Astro
5
+ * on Vite and plain `<script type="module">` pages have no `process` in the browser, and a
6
+ * bare `process.env.X` read throws `ReferenceError: process is not defined` at mount — which
7
+ * unmounts the host page's whole tree. Always read overrides through this helper.
8
+ */
9
+ export declare function readEnv(name: string): string | undefined;