@movmo/express-checkout-button 0.1.7 → 0.1.9

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
@@ -39,7 +39,7 @@ function MyBookingPage() {
39
39
  apiKey="your-movmo-api-key"
40
40
  dataSource="amadeus" // Use string literal: "amadeus" or "sabre"
41
41
  flightOffer={flightOffer}
42
- isProd={false} // Set to true for production
42
+ isProd={false} // Set to true for production environment
43
43
  />
44
44
  </div>
45
45
  );
@@ -56,7 +56,7 @@ export default MyBookingPage;
56
56
  | `apiKey` | string | Yes | Your Movmo API key |
57
57
  | `dataSource` | string | Yes | The source of flight data, must be either "amadeus" or "sabre" |
58
58
  | `flightOffer` | object | Yes | The flight offer data object |
59
- | `isProd` | boolean | No | Whether to use production environment (default: false) |
59
+ | `isProd` | boolean | No | Whether to use production endpoints (default: false). When true, uses production API and booking URLs; when false, uses e2e (testing) endpoints. |
60
60
 
61
61
  ## Data Source Options
62
62
 
@@ -68,6 +68,18 @@ The `dataSource` prop accepts the following string values:
68
68
  "sabre" // For Sabre flight data
69
69
  ```
70
70
 
71
+ ## Environment Configuration
72
+
73
+ The `isProd` prop controls which Movmo endpoints are used:
74
+
75
+ - When `isProd={false}` (default):
76
+ - API endpoint: `https://e2e.api.movmo.io`
77
+ - Booking UI: `https://booking.e2e.movmo.io`
78
+
79
+ - When `isProd={true}`:
80
+ - API endpoint: `https://api.movmo.io`
81
+ - Booking UI: `https://booking.movmo.io`
82
+
71
83
  ## CSS Integration
72
84
 
73
85
  You must import the component's CSS for proper styling:
@@ -1 +1 @@
1
- export declare function showMovmoOverlay(queryParams: string): void;
1
+ export declare function showMovmoOverlay(queryParams: string, isProd?: boolean): void;
package/dist/index.cjs.js CHANGED
@@ -1,8 +1,8 @@
1
1
  /**
2
- * @movmo/express-checkout-button v0.1.7
2
+ * @movmo/express-checkout-button v0.1.9
3
3
  * React component plugin for embedding Movmo Express Checkout on airline websites.
4
4
  * (c) 2025 Movmo
5
5
  * @license MIT
6
6
  */
7
- "use strict";var e=require("react/jsx-runtime"),t=require("react"),n=require("axios");function o(e){if(document.getElementById("movmo-checkout"))return;const t=document.createElement("div");t.id="movmo-checkout",t.style.cssText="\n position: fixed;\n top: 0;\n left: 0;\n width: 100vw;\n height: 100vh;\n background: white;\n z-index: 9999;\n ",t.innerHTML=`\n <iframe \n src="https://booking.e2e.movmo.io/booking?${e}"\n width="100%" \n height="100%" \n style="border: none;">\n </iframe>\n `,document.body.appendChild(t)}window.addEventListener("popstate",(()=>{const e=document.getElementById("movmo-checkout");!window.history.state?.checkoutOpen&&e&&e.remove()})),window.addEventListener("DOMContentLoaded",(()=>{if(window.location.pathname.startsWith("/movmo/checkout")){const e=window.location.search.substring(1);window.history.replaceState({checkoutOpen:!0},"",window.location.href),o(e)}}));exports.MovmoCheckoutButton=({customerId:i,apiKey:r,dataSource:a,flightOffer:c,isProd:s=!1})=>{const[d,u]=t.useState(!1),h=((e,t=!1)=>{const o=t?"https://api.movmo.io":"https://e2e.api.movmo.io";return n.create({baseURL:o,headers:{Accept:"application/json","Content-Type":"application/json","x-api-key":e},withCredentials:!0,timeout:3e4})})(r,s),m=`\n px-7 py-5 \n font-inter font-semibold text-lg \n rounded-xl \n text-white \n border-none\n cursor-pointer\n transition-all duration-200\n outline-none focus:ring-2 focus:ring-[#F63D68] focus:ring-opacity-50\n ${d?"bg-gradient-hover":"bg-gradient-normal"}\n `.trim(),p="\n ml-2 px-2 py-1\n bg-white \n text-[#171412] \n rounded-md \n text-lg\n ".trim();return e.jsxs("button",{onClick:async()=>{const e={dataSource:a,rawOffer:c},t=await(async(e,t)=>await t.post("/v1/flight_offers",e).then((e=>e.data.id)).catch((e=>null)))(e,h);if(!t)return;const n=new URLSearchParams({offerId:t,airlineRef:i}).toString();window.history.pushState({checkoutOpen:!0},"",`/movmo/checkout?${n}`),o(n)},onMouseEnter:()=>u(!0),onMouseLeave:()=>u(!1),className:m,children:["Express Checkout",e.jsx("span",{className:p,children:"Movmo"})]})};
7
+ "use strict";var e=require("react/jsx-runtime"),o=require("react"),t=require("axios");window.addEventListener("popstate",(()=>{const e=document.getElementById("movmo-checkout");!window.history.state?.checkoutOpen&&e&&e.remove()}));exports.MovmoCheckoutButton=({customerId:n,apiKey:i,dataSource:r,flightOffer:s,isProd:a=!1})=>{const[c,d]=o.useState(!1),m=((e,o=!1)=>{const n=o?"https://api.movmo.io":"https://e2e.api.movmo.io";return t.create({baseURL:n,headers:{Accept:"application/json","Content-Type":"application/json","x-api-key":e},withCredentials:!0,timeout:3e4})})(i,a),u=`\n px-7 py-5 \n font-inter font-semibold text-lg \n rounded-xl \n text-white \n border-none\n cursor-pointer\n transition-all duration-200\n outline-none focus:ring-2 focus:ring-[#F63D68] focus:ring-opacity-50\n ${c?"bg-gradient-hover":"bg-gradient-normal"}\n `.trim(),h="\n ml-2 px-2 py-1\n bg-white \n text-[#171412] \n rounded-md \n text-lg\n ".trim();return e.jsxs("button",{onClick:async()=>{const e={dataSource:r,rawOffer:s},o=await(async(e,o)=>await o.post("/v1/flight_offers",e).then((e=>e.data.id)).catch((e=>null)))(e,m);if(!o)return;const t=new URLSearchParams({offerId:o,airlineRef:n}).toString();window.history.pushState({checkoutOpen:!0},"",`/movmo/checkout?${t}`),function(e,o=!1){if(document.getElementById("movmo-checkout"))return;const t=document.createElement("div");t.id="movmo-checkout",t.style.cssText="\n position: fixed;\n top: 0;\n left: 0;\n width: 100vw;\n height: 100vh;\n background: white;\n z-index: 9999;\n ";const n=o?"https://booking.movmo.io":"https://booking.e2e.movmo.io";t.innerHTML=`\n <iframe \n src="${n}/booking?${e}"\n width="100%" \n height="100%" \n style="border: none;"\n id="movmo-checkout-iframe">\n </iframe>\n `,document.body.appendChild(t),window.addEventListener("message",(e=>{if(["https://booking.movmo.io","https://booking.e2e.movmo.io"].includes(e.origin)&&"MOVMO_BOOKING_COMPLETE"===e.data?.type){const{bookingId:o,airlineRef:t}=e.data;o&&window.history.pushState({checkoutOpen:!0,bookingComplete:!0,bookingId:o},"",`/movmo/checkout/booking/${o}?airlineRef=${t||""}`)}}))}(t,a)},onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),className:u,children:["Express Checkout",e.jsx("span",{className:h,children:"Movmo"})]})};
8
8
  //# sourceMappingURL=index.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":["../src/MovmoCheckoutOverlay.tsx","../src/MovmoCheckoutButton.tsx","../src/api.ts"],"sourcesContent":["export function showMovmoOverlay(queryParams: string) {\n if (document.getElementById('movmo-checkout')) return;\n\n const container = document.createElement('div');\n container.id = 'movmo-checkout';\n container.style.cssText = `\n position: fixed;\n top: 0;\n left: 0;\n width: 100vw;\n height: 100vh;\n background: white;\n z-index: 9999;\n `;\n\n container.innerHTML = `\n <iframe \n src=\"https://booking.e2e.movmo.io/booking?${queryParams}\"\n width=\"100%\" \n height=\"100%\" \n style=\"border: none;\">\n </iframe>\n `;\n\n document.body.appendChild(container);\n}\n\n// Clean up when back button is used\nwindow.addEventListener('popstate', () => {\n const container = document.getElementById('movmo-checkout');\n if (!window.history.state?.checkoutOpen && container) {\n container.remove();\n }\n});\n\n// Show overlay again if loaded directly\nwindow.addEventListener('DOMContentLoaded', () => {\n const isMovmoPath = window.location.pathname.startsWith('/movmo/checkout');\n if (isMovmoPath) {\n const queryParams = window.location.search.substring(1);\n window.history.replaceState({ checkoutOpen: true }, '', window.location.href);\n showMovmoOverlay(queryParams);\n }\n});\n","import React, { useState } from 'react';\n\nimport { createAxiosClient, FlightOfferRequest, saveFlightOffer } from './api';\nimport { showMovmoOverlay } from './MovmoCheckoutOverlay';\n\ninterface MovmoCheckoutButtonProps {\n customerId: string;\n apiKey: string;\n dataSource: \"amadeus\" | \"sabre\";\n // TODO: support fare splitting\n flightOffer: object;\n isProd?: boolean;\n}\n\nexport const MovmoCheckoutButton: React.FC<MovmoCheckoutButtonProps> = ({\n customerId,\n apiKey,\n dataSource,\n flightOffer,\n isProd = false,\n}) => {\n const [isHovered, setIsHovered] = useState(false);\n const client = createAxiosClient(apiKey, isProd);\n\n const handleClick = async () => {\n const payload: FlightOfferRequest = {\n dataSource,\n rawOffer: flightOffer,\n };\n const offerId = await saveFlightOffer(payload, client);\n if (!offerId) {\n // TODO: handle error by displaying a message to the user\n return;\n }\n\n const queryParams = new URLSearchParams({\n offerId,\n airlineRef: customerId,\n }).toString();\n\n window.history.pushState({ checkoutOpen: true }, '', `/movmo/checkout?${queryParams}`);\n showMovmoOverlay(queryParams);\n };\n\n const buttonClasses = `\n px-7 py-5 \n font-inter font-semibold text-lg \n rounded-xl \n text-white \n border-none\n cursor-pointer\n transition-all duration-200\n outline-none focus:ring-2 focus:ring-[#F63D68] focus:ring-opacity-50\n ${isHovered ? 'bg-gradient-hover' : 'bg-gradient-normal'}\n `.trim();\n\n const badgeClasses = `\n ml-2 px-2 py-1\n bg-white \n text-[#171412] \n rounded-md \n text-lg\n `.trim();\n\n return (\n <button\n onClick={handleClick}\n onMouseEnter={() => setIsHovered(true)}\n onMouseLeave={() => setIsHovered(false)}\n className={buttonClasses}\n >\n Express Checkout\n <span className={badgeClasses}>\n Movmo\n </span>\n </button>\n );\n};\n","import axios, { AxiosInstance } from \"axios\";\n\n\nexport const createAxiosClient = (apiKey: string, isProd: boolean = false) => {\n const baseUrl = isProd ? \"https://api.movmo.io\" : \"https://e2e.api.movmo.io\";\n\n const client = axios.create({\n baseURL: baseUrl,\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\",\n \"x-api-key\": apiKey,\n },\n // Allow cookies to be sent with requests\n withCredentials: true,\n timeout: 30000,\n });\n\n return client;\n};\n\nexport interface FlightOfferRequest {\n dataSource: string;\n // The raw offer object from the data source; does not currently support fare splitting\n rawOffer: object;\n}\n\nexport const saveFlightOffer = async (payload: FlightOfferRequest, client: AxiosInstance): Promise<string | null> => {\n return await client.post(\"/v1/flight_offers\", payload)\n .then((res) => res.data.id)\n .catch((err) => {\n console.error(err);\n return null;\n });\n};\n"],"names":["showMovmoOverlay","queryParams","document","getElementById","container","createElement","id","style","cssText","innerHTML","body","appendChild","window","addEventListener","history","state","checkoutOpen","remove","location","pathname","startsWith","search","substring","replaceState","href","customerId","apiKey","dataSource","flightOffer","isProd","isHovered","setIsHovered","useState","client","baseUrl","axios","create","baseURL","headers","Accept","withCredentials","timeout","createAxiosClient","buttonClasses","trim","badgeClasses","_jsxs","onClick","async","payload","rawOffer","offerId","post","then","res","data","catch","err","saveFlightOffer","URLSearchParams","airlineRef","toString","pushState","onMouseEnter","onMouseLeave","className","children","_jsx"],"mappings":";;;;;;sFAAM,SAAUA,EAAiBC,GAC7B,GAAIC,SAASC,eAAe,kBAAmB,OAE/C,MAAMC,EAAYF,SAASG,cAAc,OACzCD,EAAUE,GAAK,iBACfF,EAAUG,MAAMC,QAAU,yKAU1BJ,EAAUK,UAAY,6EAE8BR,yHAOpDC,SAASQ,KAAKC,YAAYP,EAC9B,CAGAQ,OAAOC,iBAAiB,YAAY,KAChC,MAAMT,EAAYF,SAASC,eAAe,mBACrCS,OAAOE,QAAQC,OAAOC,cAAgBZ,GACvCA,EAAUa,YAKlBL,OAAOC,iBAAiB,oBAAoB,KAExC,GADoBD,OAAOM,SAASC,SAASC,WAAW,mBACvC,CACb,MAAMnB,EAAcW,OAAOM,SAASG,OAAOC,UAAU,GACrDV,OAAOE,QAAQS,aAAa,CAAEP,cAAc,GAAQ,GAAIJ,OAAOM,SAASM,MACxExB,EAAiBC,mCC3B8C,EACnEwB,aACAC,SACAC,aACAC,cACAC,UAAS,MAET,MAAOC,EAAWC,GAAgBC,EAAAA,UAAS,GACrCC,ECnBuB,EAACP,EAAgBG,GAAkB,KAChE,MAAMK,EAAUL,EAAS,uBAAyB,2BAclD,OAZeM,EAAMC,OAAO,CACxBC,QAASH,EACTI,QAAS,CACLC,OAAQ,mBACR,eAAgB,mBAChB,YAAab,GAGjBc,iBAAiB,EACjBC,QAAS,KAGA,EDIEC,CAAkBhB,EAAQG,GAsBnCc,EAAgB,sRAShBb,EAAY,oBAAsB,6BACtCc,OAEIC,EAAe,mHAMnBD,OAEF,OACIE,OACI,SAAA,CAAAC,QA1CYC,UAChB,MAAMC,EAA8B,CAChCtB,aACAuB,SAAUtB,GAERuB,OCFiBH,OAAOC,EAA6BhB,UAClDA,EAAOmB,KAAK,oBAAqBH,GACzCI,MAAMC,GAAQA,EAAIC,KAAKjD,KACvBkD,OAAOC,GAEG,ODHWC,CAAgBT,EAAShB,GAC/C,IAAKkB,EAED,OAGJ,MAAMlD,EAAc,IAAI0D,gBAAgB,CACpCR,UACAS,WAAYnC,IACboC,WAEHjD,OAAOE,QAAQgD,UAAU,CAAE9C,cAAc,GAAQ,GAAI,mBAAmBf,KACxED,EAAiBC,EAAY,EA0BzB8D,aAAc,IAAMhC,GAAa,GACjCiC,aAAc,IAAMjC,GAAa,GACjCkC,UAAWtB,EAAauB,SAAA,CAAA,mBAGxBC,cAAMF,UAAWpB,EAEVqB,SAAA,YACF"}
1
+ {"version":3,"file":"index.cjs.js","sources":["../src/MovmoCheckoutOverlay.tsx","../src/MovmoCheckoutButton.tsx","../src/api.ts"],"sourcesContent":["export function showMovmoOverlay(queryParams: string, isProd: boolean = false) {\n if (document.getElementById('movmo-checkout')) return;\n\n const container = document.createElement('div');\n container.id = 'movmo-checkout';\n container.style.cssText = `\n position: fixed;\n top: 0;\n left: 0;\n width: 100vw;\n height: 100vh;\n background: white;\n z-index: 9999;\n `;\n\n // Use production or development URL based on isProd flag\n const baseUrl = isProd ? \"https://booking.movmo.io\" : \"https://booking.e2e.movmo.io\";\n\n container.innerHTML = `\n <iframe \n src=\"${baseUrl}/booking?${queryParams}\"\n width=\"100%\" \n height=\"100%\" \n style=\"border: none;\"\n id=\"movmo-checkout-iframe\">\n </iframe>\n `;\n\n document.body.appendChild(container);\n\n // Setup communication channel with iframe\n window.addEventListener('message', (event) => {\n // Verify origin for security\n const allowedOrigins = [\n 'https://booking.movmo.io',\n 'https://booking.e2e.movmo.io'\n ];\n\n if (allowedOrigins.includes(event.origin) && event.data?.type === 'MOVMO_BOOKING_COMPLETE') {\n const { bookingId, airlineRef } = event.data;\n if (bookingId) {\n // Update the parent URL to reflect booking completion\n window.history.pushState(\n { checkoutOpen: true, bookingComplete: true, bookingId },\n '',\n `/movmo/checkout/booking/${bookingId}?airlineRef=${airlineRef || ''}`\n );\n }\n }\n });\n}\n\n// Clean up when back button is used\nwindow.addEventListener('popstate', () => {\n const container = document.getElementById('movmo-checkout');\n if (!window.history.state?.checkoutOpen && container) {\n container.remove();\n }\n});\n","import React, { useState } from 'react';\n\nimport { createAxiosClient, FlightOfferRequest, saveFlightOffer } from './api';\nimport { showMovmoOverlay } from './MovmoCheckoutOverlay';\n\ninterface MovmoCheckoutButtonProps {\n customerId: string;\n apiKey: string;\n dataSource: \"amadeus\" | \"sabre\";\n // TODO: support fare splitting\n flightOffer: object;\n isProd?: boolean;\n}\n\nexport const MovmoCheckoutButton: React.FC<MovmoCheckoutButtonProps> = ({\n customerId,\n apiKey,\n dataSource,\n flightOffer,\n isProd = false,\n}) => {\n const [isHovered, setIsHovered] = useState(false);\n const client = createAxiosClient(apiKey, isProd);\n\n const handleClick = async () => {\n const payload: FlightOfferRequest = {\n dataSource,\n rawOffer: flightOffer,\n };\n const offerId = await saveFlightOffer(payload, client);\n if (!offerId) {\n // TODO: handle error by displaying a message to the user\n return;\n }\n\n const queryParams = new URLSearchParams({\n offerId,\n airlineRef: customerId,\n }).toString();\n\n window.history.pushState({ checkoutOpen: true }, '', `/movmo/checkout?${queryParams}`);\n showMovmoOverlay(queryParams, isProd);\n };\n\n const buttonClasses = `\n px-7 py-5 \n font-inter font-semibold text-lg \n rounded-xl \n text-white \n border-none\n cursor-pointer\n transition-all duration-200\n outline-none focus:ring-2 focus:ring-[#F63D68] focus:ring-opacity-50\n ${isHovered ? 'bg-gradient-hover' : 'bg-gradient-normal'}\n `.trim();\n\n const badgeClasses = `\n ml-2 px-2 py-1\n bg-white \n text-[#171412] \n rounded-md \n text-lg\n `.trim();\n\n return (\n <button\n onClick={handleClick}\n onMouseEnter={() => setIsHovered(true)}\n onMouseLeave={() => setIsHovered(false)}\n className={buttonClasses}\n >\n Express Checkout\n <span className={badgeClasses}>\n Movmo\n </span>\n </button>\n );\n};\n","import axios, { AxiosInstance } from \"axios\";\n\n\nexport const createAxiosClient = (apiKey: string, isProd: boolean = false) => {\n const baseUrl = isProd ? \"https://api.movmo.io\" : \"https://e2e.api.movmo.io\";\n\n const client = axios.create({\n baseURL: baseUrl,\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\",\n \"x-api-key\": apiKey,\n },\n // Allow cookies to be sent with requests\n withCredentials: true,\n timeout: 30000,\n });\n\n return client;\n};\n\nexport interface FlightOfferRequest {\n dataSource: string;\n // The raw offer object from the data source; does not currently support fare splitting\n rawOffer: object;\n}\n\nexport const saveFlightOffer = async (payload: FlightOfferRequest, client: AxiosInstance): Promise<string | null> => {\n return await client.post(\"/v1/flight_offers\", payload)\n .then((res) => res.data.id)\n .catch((err) => {\n console.error(err);\n return null;\n });\n};\n"],"names":["window","addEventListener","container","document","getElementById","history","state","checkoutOpen","remove","customerId","apiKey","dataSource","flightOffer","isProd","isHovered","setIsHovered","useState","client","baseUrl","axios","create","baseURL","headers","Accept","withCredentials","timeout","createAxiosClient","buttonClasses","trim","badgeClasses","_jsxs","onClick","async","payload","rawOffer","offerId","post","then","res","data","id","catch","err","saveFlightOffer","queryParams","URLSearchParams","airlineRef","toString","pushState","createElement","style","cssText","innerHTML","body","appendChild","event","includes","origin","type","bookingId","bookingComplete","showMovmoOverlay","onMouseEnter","onMouseLeave","className","children","_jsx"],"mappings":";;;;;;sFAqDAA,OAAOC,iBAAiB,YAAY,KAChC,MAAMC,EAAYC,SAASC,eAAe,mBACrCJ,OAAOK,QAAQC,OAAOC,cAAgBL,GACvCA,EAAUM,wCC1CqD,EACnEC,aACAC,SACAC,aACAC,cACAC,UAAS,MAET,MAAOC,EAAWC,GAA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b,GAAc,SAKrF,CCTQe,CAAiBjB,EAAa/B,EAAO,EA0BjCiD,aAAc,IAAM/C,GAAa,GACjCgD,aAAc,IAAMhD,GAAa,GACjCiD,UAAWrC,EAAasC,SAAA,CAAA,mBAGxBC,cAAMF,UAAWnC,EAEVoC,SAAA,YACF"}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @movmo/express-checkout-button v0.1.7
2
+ * @movmo/express-checkout-button v0.1.9
3
3
  * React component plugin for embedding Movmo Express Checkout on airline websites.
4
4
  * (c) 2025 Movmo
5
5
  * @license MIT
package/dist/index.es.js CHANGED
@@ -1,8 +1,8 @@
1
1
  /**
2
- * @movmo/express-checkout-button v0.1.7
2
+ * @movmo/express-checkout-button v0.1.9
3
3
  * React component plugin for embedding Movmo Express Checkout on airline websites.
4
4
  * (c) 2025 Movmo
5
5
  * @license MIT
6
6
  */
7
- import{jsxs as t,jsx as n}from"react/jsx-runtime";import{useState as e}from"react";import o from"axios";function i(t){if(document.getElementById("movmo-checkout"))return;const n=document.createElement("div");n.id="movmo-checkout",n.style.cssText="\n position: fixed;\n top: 0;\n left: 0;\n width: 100vw;\n height: 100vh;\n background: white;\n z-index: 9999;\n ",n.innerHTML=`\n <iframe \n src="https://booking.e2e.movmo.io/booking?${t}"\n width="100%" \n height="100%" \n style="border: none;">\n </iframe>\n `,document.body.appendChild(n)}window.addEventListener("popstate",(()=>{const t=document.getElementById("movmo-checkout");!window.history.state?.checkoutOpen&&t&&t.remove()})),window.addEventListener("DOMContentLoaded",(()=>{if(window.location.pathname.startsWith("/movmo/checkout")){const t=window.location.search.substring(1);window.history.replaceState({checkoutOpen:!0},"",window.location.href),i(t)}}));const r=({customerId:r,apiKey:a,dataSource:c,flightOffer:s,isProd:d=!1})=>{const[m,h]=e(!1),p=((t,n=!1)=>{const e=n?"https://api.movmo.io":"https://e2e.api.movmo.io";return o.create({baseURL:e,headers:{Accept:"application/json","Content-Type":"application/json","x-api-key":t},withCredentials:!0,timeout:3e4})})(a,d),u=`\n px-7 py-5 \n font-inter font-semibold text-lg \n rounded-xl \n text-white \n border-none\n cursor-pointer\n transition-all duration-200\n outline-none focus:ring-2 focus:ring-[#F63D68] focus:ring-opacity-50\n ${m?"bg-gradient-hover":"bg-gradient-normal"}\n `.trim(),l="\n ml-2 px-2 py-1\n bg-white \n text-[#171412] \n rounded-md \n text-lg\n ".trim();return t("button",{onClick:async()=>{const t={dataSource:c,rawOffer:s},n=await(async(t,n)=>await n.post("/v1/flight_offers",t).then((t=>t.data.id)).catch((t=>null)))(t,p);if(!n)return;const e=new URLSearchParams({offerId:n,airlineRef:r}).toString();window.history.pushState({checkoutOpen:!0},"",`/movmo/checkout?${e}`),i(e)},onMouseEnter:()=>h(!0),onMouseLeave:()=>h(!1),className:u,children:["Express Checkout",n("span",{className:l,children:"Movmo"})]})};export{r as MovmoCheckoutButton};
7
+ import{jsxs as o,jsx as e}from"react/jsx-runtime";import{useState as t}from"react";import n from"axios";window.addEventListener("popstate",(()=>{const o=document.getElementById("movmo-checkout");!window.history.state?.checkoutOpen&&o&&o.remove()}));const i=({customerId:i,apiKey:r,dataSource:a,flightOffer:c,isProd:s=!1})=>{const[m,d]=t(!1),h=((o,e=!1)=>{const t=e?"https://api.movmo.io":"https://e2e.api.movmo.io";return n.create({baseURL:t,headers:{Accept:"application/json","Content-Type":"application/json","x-api-key":o},withCredentials:!0,timeout:3e4})})(r,s),p=`\n px-7 py-5 \n font-inter font-semibold text-lg \n rounded-xl \n text-white \n border-none\n cursor-pointer\n transition-all duration-200\n outline-none focus:ring-2 focus:ring-[#F63D68] focus:ring-opacity-50\n ${m?"bg-gradient-hover":"bg-gradient-normal"}\n `.trim(),u="\n ml-2 px-2 py-1\n bg-white \n text-[#171412] \n rounded-md \n text-lg\n ".trim();return o("button",{onClick:async()=>{const o={dataSource:a,rawOffer:c},e=await(async(o,e)=>await e.post("/v1/flight_offers",o).then((o=>o.data.id)).catch((o=>null)))(o,h);if(!e)return;const t=new URLSearchParams({offerId:e,airlineRef:i}).toString();window.history.pushState({checkoutOpen:!0},"",`/movmo/checkout?${t}`),function(o,e=!1){if(document.getElementById("movmo-checkout"))return;const t=document.createElement("div");t.id="movmo-checkout",t.style.cssText="\n position: fixed;\n top: 0;\n left: 0;\n width: 100vw;\n height: 100vh;\n background: white;\n z-index: 9999;\n ";const n=e?"https://booking.movmo.io":"https://booking.e2e.movmo.io";t.innerHTML=`\n <iframe \n src="${n}/booking?${o}"\n width="100%" \n height="100%" \n style="border: none;"\n id="movmo-checkout-iframe">\n </iframe>\n `,document.body.appendChild(t),window.addEventListener("message",(o=>{if(["https://booking.movmo.io","https://booking.e2e.movmo.io"].includes(o.origin)&&"MOVMO_BOOKING_COMPLETE"===o.data?.type){const{bookingId:e,airlineRef:t}=o.data;e&&window.history.pushState({checkoutOpen:!0,bookingComplete:!0,bookingId:e},"",`/movmo/checkout/booking/${e}?airlineRef=${t||""}`)}}))}(t,s)},onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),className:p,children:["Express Checkout",e("span",{className:u,children:"Movmo"})]})};export{i as MovmoCheckoutButton};
8
8
  //# sourceMappingURL=index.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.es.js","sources":["../src/MovmoCheckoutOverlay.tsx","../src/MovmoCheckoutButton.tsx","../src/api.ts"],"sourcesContent":["export function showMovmoOverlay(queryParams: string) {\n if (document.getElementById('movmo-checkout')) return;\n\n const container = document.createElement('div');\n container.id = 'movmo-checkout';\n container.style.cssText = `\n position: fixed;\n top: 0;\n left: 0;\n width: 100vw;\n height: 100vh;\n background: white;\n z-index: 9999;\n `;\n\n container.innerHTML = `\n <iframe \n src=\"https://booking.e2e.movmo.io/booking?${queryParams}\"\n width=\"100%\" \n height=\"100%\" \n style=\"border: none;\">\n </iframe>\n `;\n\n document.body.appendChild(container);\n}\n\n// Clean up when back button is used\nwindow.addEventListener('popstate', () => {\n const container = document.getElementById('movmo-checkout');\n if (!window.history.state?.checkoutOpen && container) {\n container.remove();\n }\n});\n\n// Show overlay again if loaded directly\nwindow.addEventListener('DOMContentLoaded', () => {\n const isMovmoPath = window.location.pathname.startsWith('/movmo/checkout');\n if (isMovmoPath) {\n const queryParams = window.location.search.substring(1);\n window.history.replaceState({ checkoutOpen: true }, '', window.location.href);\n showMovmoOverlay(queryParams);\n }\n});\n","import React, { useState } from 'react';\n\nimport { createAxiosClient, FlightOfferRequest, saveFlightOffer } from './api';\nimport { showMovmoOverlay } from './MovmoCheckoutOverlay';\n\ninterface MovmoCheckoutButtonProps {\n customerId: string;\n apiKey: string;\n dataSource: \"amadeus\" | \"sabre\";\n // TODO: support fare splitting\n flightOffer: object;\n isProd?: boolean;\n}\n\nexport const MovmoCheckoutButton: React.FC<MovmoCheckoutButtonProps> = ({\n customerId,\n apiKey,\n dataSource,\n flightOffer,\n isProd = false,\n}) => {\n const [isHovered, setIsHovered] = useState(false);\n const client = createAxiosClient(apiKey, isProd);\n\n const handleClick = async () => {\n const payload: FlightOfferRequest = {\n dataSource,\n rawOffer: flightOffer,\n };\n const offerId = await saveFlightOffer(payload, client);\n if (!offerId) {\n // TODO: handle error by displaying a message to the user\n return;\n }\n\n const queryParams = new URLSearchParams({\n offerId,\n airlineRef: customerId,\n }).toString();\n\n window.history.pushState({ checkoutOpen: true }, '', `/movmo/checkout?${queryParams}`);\n showMovmoOverlay(queryParams);\n };\n\n const buttonClasses = `\n px-7 py-5 \n font-inter font-semibold text-lg \n rounded-xl \n text-white \n border-none\n cursor-pointer\n transition-all duration-200\n outline-none focus:ring-2 focus:ring-[#F63D68] focus:ring-opacity-50\n ${isHovered ? 'bg-gradient-hover' : 'bg-gradient-normal'}\n `.trim();\n\n const badgeClasses = `\n ml-2 px-2 py-1\n bg-white \n text-[#171412] \n rounded-md \n text-lg\n `.trim();\n\n return (\n <button\n onClick={handleClick}\n onMouseEnter={() => setIsHovered(true)}\n onMouseLeave={() => setIsHovered(false)}\n className={buttonClasses}\n >\n Express Checkout\n <span className={badgeClasses}>\n Movmo\n </span>\n </button>\n );\n};\n","import axios, { AxiosInstance } from \"axios\";\n\n\nexport const createAxiosClient = (apiKey: string, isProd: boolean = false) => {\n const baseUrl = isProd ? \"https://api.movmo.io\" : \"https://e2e.api.movmo.io\";\n\n const client = axios.create({\n baseURL: baseUrl,\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\",\n \"x-api-key\": apiKey,\n },\n // Allow cookies to be sent with requests\n withCredentials: true,\n timeout: 30000,\n });\n\n return client;\n};\n\nexport interface FlightOfferRequest {\n dataSource: string;\n // The raw offer object from the data source; does not currently support fare splitting\n rawOffer: object;\n}\n\nexport const saveFlightOffer = async (payload: FlightOfferRequest, client: AxiosInstance): Promise<string | null> => {\n return await client.post(\"/v1/flight_offers\", payload)\n .then((res) => res.data.id)\n .catch((err) => {\n console.error(err);\n return null;\n });\n};\n"],"names":["showMovmoOverlay","queryParams","document","getElementById","container","createElement","id","style","cssText","innerHTML","body","appendChild","window","addEventListener","history","state","checkoutOpen","remove","location","pathname","startsWith","search","substring","replaceState","href","MovmoCheckoutButton","customerId","apiKey","dataSource","flightOffer","isProd","isHovered","setIsHovered","useState","client","baseUrl","axios","create","baseURL","headers","Accept","withCredentials","timeout","createAxiosClient","buttonClasses","trim","badgeClasses","_jsxs","onClick","async","payload","rawOffer","offerId","post","then","res","data","catch","err","saveFlightOffer","URLSearchParams","airlineRef","toString","pushState","onMouseEnter","onMouseLeave","className","children","_jsx"],"mappings":";;;;;;wGAAM,SAAUA,EAAiBC,GAC7B,GAAIC,SAASC,eAAe,kBAAmB,OAE/C,MAAMC,EAAYF,SAASG,cAAc,OACzCD,EAAUE,GAAK,iBACfF,EAAUG,MAAMC,QAAU,yKAU1BJ,EAAUK,UAAY,6EAE8BR,yHAOpDC,SAASQ,KAAKC,YAAYP,EAC9B,CAGAQ,OAAOC,iBAAiB,YAAY,KAChC,MAAMT,EAAYF,SAASC,eAAe,mBACrCS,OAAOE,QAAQC,OAAOC,cAAgBZ,G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.tsx","../src/api.ts"],"sourcesContent":["export function showMovmoOverlay(queryParams: string, isProd: boolean = false) {\n if (document.getElementById('movmo-checkout')) return;\n\n const container = document.createElement('div');\n container.id = 'movmo-checkout';\n container.style.cssText = `\n position: fixed;\n top: 0;\n left: 0;\n width: 100vw;\n height: 100vh;\n background: white;\n z-index: 9999;\n `;\n\n // Use production or development URL based on isProd flag\n const baseUrl = isProd ? \"https://booking.movmo.io\" : \"https://booking.e2e.movmo.io\";\n\n container.innerHTML = `\n <iframe \n src=\"${baseUrl}/booking?${queryParams}\"\n width=\"100%\" \n height=\"100%\" \n style=\"border: none;\"\n id=\"movmo-checkout-iframe\">\n </iframe>\n `;\n\n document.body.appendChild(container);\n\n // Setup communication channel with iframe\n window.addEventListener('message', (event) => {\n // Verify origin for security\n const allowedOrigins = [\n 'https://booking.movmo.io',\n 'https://booking.e2e.movmo.io'\n ];\n\n if (allowedOrigins.includes(event.origin) && event.data?.type === 'MOVMO_BOOKING_COMPLETE') {\n const { bookingId, airlineRef } = event.data;\n if (bookingId) {\n // Update the parent URL to reflect booking completion\n window.history.pushState(\n { checkoutOpen: true, bookingComplete: true, bookingId },\n '',\n `/movmo/checkout/booking/${bookingId}?airlineRef=${airlineRef || ''}`\n );\n }\n }\n });\n}\n\n// Clean up when back button is used\nwindow.addEventListener('popstate', () => {\n const container = document.getElementById('movmo-checkout');\n if (!window.history.state?.checkoutOpen && container) {\n container.remove();\n }\n});\n","import React, { useState } from 'react';\n\nimport { createAxiosClient, FlightOfferRequest, saveFlightOffer } from './api';\nimport { showMovmoOverlay } from './MovmoCheckoutOverlay';\n\ninterface MovmoCheckoutButtonProps {\n customerId: string;\n apiKey: string;\n dataSource: \"amadeus\" | \"sabre\";\n // TODO: support fare splitting\n flightOffer: object;\n isProd?: boolean;\n}\n\nexport const MovmoCheckoutButton: React.FC<MovmoCheckoutButtonProps> = ({\n customerId,\n apiKey,\n dataSource,\n flightOffer,\n isProd = false,\n}) => {\n const [isHovered, setIsHovered] = useState(false);\n const client = createAxiosClient(apiKey, isProd);\n\n const handleClick = async () => {\n const payload: FlightOfferRequest = {\n dataSource,\n rawOffer: flightOffer,\n };\n const offerId = await saveFlightOffer(payload, client);\n if (!offerId) {\n // TODO: handle error by displaying a message to the user\n return;\n }\n\n const queryParams = new URLSearchParams({\n offerId,\n airlineRef: customerId,\n }).toString();\n\n window.history.pushState({ checkoutOpen: true }, '', `/movmo/checkout?${queryParams}`);\n showMovmoOverlay(queryParams, isProd);\n };\n\n const buttonClasses = `\n px-7 py-5 \n font-inter font-semibold text-lg \n rounded-xl \n text-white \n border-none\n cursor-pointer\n transition-all duration-200\n outline-none focus:ring-2 focus:ring-[#F63D68] focus:ring-opacity-50\n ${isHovered ? 'bg-gradient-hover' : 'bg-gradient-normal'}\n `.trim();\n\n const badgeClasses = `\n ml-2 px-2 py-1\n bg-white \n text-[#171412] \n rounded-md \n text-lg\n `.trim();\n\n return (\n <button\n onClick={handleClick}\n onMouseEnter={() => setIsHovered(true)}\n onMouseLeave={() => setIsHovered(false)}\n className={buttonClasses}\n >\n Express Checkout\n <span className={badgeClasses}>\n Movmo\n </span>\n </button>\n );\n};\n","import axios, { AxiosInstance } from \"axios\";\n\n\nexport const createAxiosClient = (apiKey: string, isProd: boolean = false) => {\n const baseUrl = isProd ? \"https://api.movmo.io\" : \"https://e2e.api.movmo.io\";\n\n const client = axios.create({\n baseURL: baseUrl,\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\",\n \"x-api-key\": apiKey,\n },\n // Allow cookies to be sent with requests\n withCredentials: true,\n timeout: 30000,\n });\n\n return client;\n};\n\nexport interface FlightOfferRequest {\n dataSource: string;\n // The raw offer object from the data source; does not currently support fare splitting\n rawOffer: object;\n}\n\nexport const saveFlightOffer = async (payload: FlightOfferRequest, client: AxiosInstance): Promise<string | null> => {\n return await client.post(\"/v1/flight_offers\", payload)\n .then((res) => res.data.id)\n .catch((err) => {\n console.error(err);\n return null;\n });\n};\n"],"names":["window","addEventListener","container","document","getElementById","history","state","checkoutOpen","remove","MovmoCheckoutButton","customerId","apiKey","dataSource","flightOffer","isProd","isHovered","setIsHovered","useState","client","baseUrl","axios","create","baseURL","headers","Accept","withCredentials","timeout","createAxiosClient","buttonClasses","trim","badgeClasses","_jsxs","onClick","async","payload","rawOffer","offerId","post","then","res","data","id","catch","err","saveFlightOffer","queryParams","URLSearchParams","airlineRef","toString","pushState","createElement","style","cssText","innerHTML","body","appendChild","event","includes","origin","type","bookingId","bookingComplete","showMovmoOverlay","onMouseEnter","onMouseLeave","className","children","_jsx"],"mappings":";;;;;;wGAqDAA,OAAOC,iBAAiB,YAAY,KAChC,MAAMC,EAAYC,SAASC,eAAe,mBACrCJ,OAAOK,QAAQC,OAAOC,cAAgBL,GACvCA,EAAUM,YC1CL,MAAAC,EAA0D,EACnEC,aACAC,SACAC,aACAC,cACAC,UAAS,MAET,MAAOC,EAAWC,GAAgBC,GAAS,GACrCC,ECnBuB,EAACP,EAAgBG,GAAkB,KAChE,MAAMK,EAAUL,EAAS,uBAAyB,2BAclD,OAZeM,EAAMC,OAAO,CACxBC,QAASH,EACTI,QAAS,CACLC,OAAQ,mBACR,eAAgB,mBAChB,YAAab,GAGjBc,iBAAiB,EACjBC,QAAS,KAGA,EDIEC,CAAkBhB,EAAQG,GAsBnCc,EAAgB,sRAShBb,EAAY,oBAAsB,6BACtCc,OAEIC,EAAe,mHAMnBD,OAEF,OACIE,EACI,SAAA,CAAAC,QA1CYC,UAChB,MAAMC,EAA8B,CAChCtB,aACAuB,SAAUtB,GAERuB,OCFiBH,OAAOC,EAA6BhB,UAClDA,EAAOmB,KAAK,oBAAqBH,GACzCI,MAAMC,GAAQA,EAAIC,KAAKC,KACvBC,OAAOC,GAEG,ODHWC,CAAgBV,EAAShB,GAC/C,IAAKkB,EAED,OAGJ,MAAMS,EAAc,IAAIC,gBAAgB,CACpCV,UACAW,WAAYrC,IACbsC,WAEHhD,OAAOK,QAAQ4C,UAAU,CAAE1C,cAAc,GAAQ,GAAI,mBAAmBsC,cDxC/CA,EAAqB/B,GAAkB,GACpE,GAAIX,SAASC,eAAe,kBAAmB,OAE/C,MAAMF,EAAYC,SAAS+C,cAAc,OACzChD,EAAUuC,GAAK,iBACfvC,EAAUiD,MAAMC,QAAU,yKAW1B,MAAMjC,EAAUL,EAAS,2BAA6B,+BAEtDZ,EAAUmD,UAAY,wCAEPlC,aAAmB0B,iKAQlC1C,SAASmD,KAAKC,YAAYrD,GAG1BF,OAAOC,iBAAiB,WAAYuD,IAOhC,GALuB,CACnB,2BACA,gCAGeC,SAASD,EAAME,SAAgC,2BAArBF,EAAMhB,MAAMmB,KAAmC,CACxF,MAAMC,UAAEA,EAASb,WAAEA,GAAeS,EAAMhB,KACpCoB,GAEA5D,OAAOK,QAAQ4C,UACX,CAAE1C,cAAc,EAAMsD,iBAAiB,EAAMD,aAC7C,GACA,2BAA2BA,gBAAwBb,GAAc,SAKrF,CCTQe,CAAiBjB,EAAa/B,EAAO,EA0BjCiD,aAAc,IAAM/C,GAAa,GACjCgD,aAAc,IAAMhD,GAAa,GACjCiD,UAAWrC,EAAasC,SAAA,CAAA,mBAGxBC,UAAMF,UAAWnC,EAEVoC,SAAA,YACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@movmo/express-checkout-button",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "description": "React component plugin for embedding Movmo Express Checkout on airline websites.",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs.js",