@movmo/express-checkout-button 0.1.8 → 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/dist/index.cjs.js CHANGED
@@ -1,8 +1,8 @@
1
1
  /**
2
- * @movmo/express-checkout-button v0.1.8
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");window.addEventListener("popstate",(()=>{const e=document.getElementById("movmo-checkout");!window.history.state?.checkoutOpen&&e&&e.remove()}));exports.MovmoCheckoutButton=({customerId:o,apiKey:i,dataSource:r,flightOffer:s,isProd:a=!1})=>{const[c,d]=t.useState(!1),u=((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})})(i,a),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 ${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},t=await(async(e,t)=>await t.post("/v1/flight_offers",e).then((e=>e.data.id)).catch((e=>null)))(e,u);if(!t)return;const n=new URLSearchParams({offerId:t,airlineRef:o}).toString();window.history.pushState({checkoutOpen:!0},"",`/movmo/checkout?${n}`),function(e,t=!1){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 ";const o=t?"https://booking.movmo.io":"https://booking.e2e.movmo.io";n.innerHTML=`\n <iframe \n src="${o}/booking?${e}"\n width="100%" \n height="100%" \n style="border: none;">\n </iframe>\n `,document.body.appendChild(n)}(n,a)},onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),className:m,children:["Express Checkout",e.jsx("span",{className:h,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, 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 </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","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","showMovmoOverlay","onMouseEnter","onMouseLeave","className","children","_jsx"],"mappings":";;;;;;sFA+BAA,OAAOC,iBAAiB,YAAY,KAChC,MAAMC,EAAYC,SAASC,eAAe,mBACrCJ,OAAOK,QAAQC,OAAOC,cAAgBL,GACvCA,EAAUM,wCCpBqD,EACnEC,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,KAAKC,KACvBC,OAAOC,GAEG,ODHWC,CAAgBV,EAAShB,GAC/C,IAAKkB,EAED,OAGJ,MAAMS,EAAc,IAAIC,gBAAgB,CACpCV,UACAW,WAAYrC,IACbsC,WAEH/C,OAAOK,QAAQ2C,UAAU,CAAEzC,cAAc,GAAQ,GAAI,mBAAmBqC,cDxC/CA,EAAqB/B,GAAkB,GACpE,GAAIV,SAASC,eAAe,kBAAmB,OAE/C,MAAMF,EAAYC,SAAS8C,cAAc,OACzC/C,EAAUsC,GAAK,iBACftC,EAAUgD,MAAMC,QAAU,yKAW1B,MAAMjC,EAAUL,EAAS,2BAA6B,+BAEtDX,EAAUkD,UAAY,wCAEPlC,aAAmB0B,yHAOlCzC,SAASkD,KAAKC,YAAYpD,EAC9B,CCaQqD,CAAiBX,EAAa/B,EAAO,EA0BjC2C,aAAc,IAAMzC,GAAa,GACjC0C,aAAc,IAAM1C,GAAa,GACjC2C,UAAW/B,EAAagC,SAAA,CAAA,mBAGxBC,cAAMF,UAAW7B,EAEV8B,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,GAAgBC,EAAAA,UAAS,GACrCC,ECnBuB,EAACP,EAAgBG,GAAkB,KAChE,MAAMK,EAAUL,EAAS,uBAAyB,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c,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.8
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.8
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";window.addEventListener("popstate",(()=>{const t=document.getElementById("movmo-checkout");!window.history.state?.checkoutOpen&&t&&t.remove()}));const i=({customerId:i,apiKey:r,dataSource:a,flightOffer:c,isProd:s=!1})=>{const[m,d]=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})})(r,s),h=`\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 t("button",{onClick:async()=>{const t={dataSource:a,rawOffer:c},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:i}).toString();window.history.pushState({checkoutOpen:!0},"",`/movmo/checkout?${e}`),function(t,n=!1){if(document.getElementById("movmo-checkout"))return;const e=document.createElement("div");e.id="movmo-checkout",e.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 o=n?"https://booking.movmo.io":"https://booking.e2e.movmo.io";e.innerHTML=`\n <iframe \n src="${o}/booking?${t}"\n width="100%" \n height="100%" \n style="border: none;">\n </iframe>\n `,document.body.appendChild(e)}(e,s)},onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),className:h,children:["Express Checkout",n("span",{className:u,children:"Movmo"})]})};export{i 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, 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 </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","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","showMovmoOverlay","onMouseEnter","onMouseLeave","className","children","_jsx"],"mappings":";;;;;;wGA+BAA,OAAOC,iBAAiB,YAAY,KAChC,MAAMC,EAAYC,SAASC,eAAe,mBACrCJ,OAAOK,QAAQC,OAAOC,cAAgBL,GACvCA,EAAUM,YCpBL,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,yHAOlC1C,SAASmD,KAAKC,YAAYrD,EAC9B,CCaQsD,CAAiBX,EAAa/B,EAAO,EA0BjC2C,aAAc,IAAMzC,GAAa,GACjC0C,aAAc,IAAM1C,GAAa,GACjC2C,UAAW/B,EAAagC,SAAA,CAAA,mBAGxBC,UAAMF,UAAW7B,EAEV8B,SAAA,YACF"}
1
+ {"version":3,"file":"index.es.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","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,QA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MhB,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.8",
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",