airwallex-payment-elements 1.9.0 → 1.12.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.
@@ -1,3 +1,3 @@
1
- /* Airwallex Checkout Component Version [1.9.0] */
2
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e={prod:"checkout.airwallex.com",demo:"checkout-demo.airwallex.com",staging:"checkout-staging.airwallex.com",qa:"checkoutui.qa.awx.im",preview:"checkoutui.preview.awx.im",dev:"localhost:3000"},r=r=>`https://${e[r]||e.prod}`,t="/assets/elements.bundle.min.js?version=1.9.0",o=e=>{const r=document.createElement("script");r.src=`${e}${t}`,r.crossOrigin="anonymous";const o=document.head||document.body;if(!o)throw new Error("Airwallex payment scripts requires a <head> or <body> html element in order to be loaded.");return o.appendChild(r),r},n=async e=>{if("undefined"==typeof window)return null;if(window.Airwallex)return window.Airwallex;let n=0;const l=async()=>{const n=document.querySelector(`script[src="${t}"], script[src="${t}/"]`)||o(r((null==e?void 0:e.env)||"prod"));return new Promise(((r,t)=>{n.addEventListener("load",(()=>{window.Airwallex?(window.Airwallex.init(e),r(window.Airwallex)):t(new Error("Failed to load Airwallex on load event"))})),n.addEventListener("error",(()=>{t(new Error("Failed to load Airwallex scripts")),n.remove&&n.remove()}))}))};for(;n<3;)try{return await l()}catch(e){n++,await new Promise((e=>window.setTimeout(e,500)))}return null},l=e=>{window.Airwallex?window.Airwallex.init(e):console.error("Please loadAirwallex() before init();")},a=e=>{if(window.Airwallex)return window.Airwallex.redirectToCheckout(e);console.error("Please loadAirwallex() before redirectToCheckout();")},i=(e,r)=>window.Airwallex?window.Airwallex.createElement(e,r):(console.error("Please loadAirwallex() before createElement();"),null),w=e=>window.Airwallex?window.Airwallex.destroyElement(e):(console.error("Please loadAirwallex() before destroyElement();"),!1),d=e=>window.Airwallex?window.Airwallex.getElement(e):(console.error("Please loadAirwallex() before getElement();"),null),s=async e=>{if(window.Airwallex)return window.Airwallex.confirmPaymentIntent(e);{const e="Please loadAirwallex() before confirmPaymentIntent();";throw console.error(e),new Error(e)}},c=async e=>{if(window.Airwallex)return window.Airwallex.confirmPaymentIntentWithSavedCard(e);{const e="Please loadAirwallex() before confirmPaymentIntentWithSavedCard();";throw console.error(e),new Error(e)}},x=async(e,r)=>{if(window.Airwallex)return window.Airwallex.createPaymentMethod(e,r);{const e="Please loadAirwallex() before createPaymentMethod();";throw console.error(e),new Error(e)}},m=async(e,r)=>{if(window.Airwallex)return window.Airwallex.getPaymentIntent(e,r);{const e="Please loadAirwallex() before getPaymentIntent();";throw console.error(e),new Error(e)}},A=async e=>{if(window.Airwallex)return window.Airwallex.createPaymentConsent(e);{const e="Please loadAirwallex() before createPaymentConsent();";throw console.error(e),new Error(e)}},u=e=>window.Airwallex.getDeviceFingerprint(e);var y={getGatewayUrl:r,loadAirwallex:n,loadAirwallexJs:o,init:l,redirectToCheckout:a,createElement:i,destroyElement:w,getDeviceFingerprint:u,getElement:d,getPaymentIntent:m,createPaymentMethod:x,createPaymentConsent:A,confirmPaymentIntent:s,confirmPaymentIntentWithSavedCard:c};exports.confirmPaymentIntent=s,exports.confirmPaymentIntentWithSavedCard=c,exports.createElement=i,exports.createPaymentConsent=A,exports.createPaymentMethod=x,exports.default=y,exports.destroyElement=w,exports.getDeviceFingerprint=u,exports.getElement=d,exports.getGatewayUrl=r,exports.getPaymentIntent=m,exports.init=l,exports.loadAirwallex=n,exports.loadAirwallexJs=o,exports.redirectToCheckout=a;
1
+ /* Airwallex Checkout Component Version [1.12.0] */
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e={prod:"checkout.airwallex.com",demo:"checkout-demo.airwallex.com",staging:"checkout-staging.airwallex.com",qa:"checkoutui.qa.awx.im",preview:"checkoutui.preview.awx.im",dev:"localhost:3000"},r=r=>`https://${e[r]||e.prod}`,t="/assets/elements.bundle.min.js?version=1.12.0",o=e=>{const r=document.createElement("script");r.src=`${e}${t}`,r.crossOrigin="anonymous";const o=document.head||document.body;if(!o)throw new Error("Airwallex payment scripts requires a <head> or <body> html element in order to be loaded.");return o.appendChild(r),r},n=async e=>{if("undefined"==typeof window)return null;if(window.Airwallex)return window.Airwallex;let n=0;const l=async()=>{const n=document.querySelector(`script[src="${t}"], script[src="${t}/"]`)||o(r((null==e?void 0:e.env)||"prod"));return new Promise(((r,t)=>{n.addEventListener("load",(()=>{window.Airwallex?(window.Airwallex.init(e),r(window.Airwallex)):t(new Error("Failed to load Airwallex on load event"))})),n.addEventListener("error",(()=>{t(new Error("Failed to load Airwallex scripts")),n.remove&&n.remove()}))}))};for(;n<3;)try{return await l()}catch(e){n++,await new Promise((e=>window.setTimeout(e,500)))}return null},l=e=>{window.Airwallex?window.Airwallex.init(e):console.error("Please loadAirwallex() before init();")},a=e=>{if(window.Airwallex)return window.Airwallex.redirectToCheckout(e);console.error("Please loadAirwallex() before redirectToCheckout();")},i=(e,r)=>window.Airwallex?window.Airwallex.createElement(e,r):(console.error("Please loadAirwallex() before createElement();"),null),w=e=>window.Airwallex?window.Airwallex.destroyElement(e):(console.error("Please loadAirwallex() before destroyElement();"),!1),d=e=>window.Airwallex?window.Airwallex.getElement(e):(console.error("Please loadAirwallex() before getElement();"),null),s=async e=>{if(window.Airwallex)return window.Airwallex.confirmPaymentIntent(e);{const e="Please loadAirwallex() before confirmPaymentIntent();";throw console.error(e),new Error(e)}},c=async e=>{if(window.Airwallex)return window.Airwallex.confirmPaymentIntentWithSavedCard(e);{const e="Please loadAirwallex() before confirmPaymentIntentWithSavedCard();";throw console.error(e),new Error(e)}},x=async(e,r)=>{if(window.Airwallex)return window.Airwallex.createPaymentMethod(e,r);{const e="Please loadAirwallex() before createPaymentMethod();";throw console.error(e),new Error(e)}},m=async(e,r)=>{if(window.Airwallex)return window.Airwallex.getPaymentIntent(e,r);{const e="Please loadAirwallex() before getPaymentIntent();";throw console.error(e),new Error(e)}},A=async e=>{if(window.Airwallex)return window.Airwallex.createPaymentConsent(e);{const e="Please loadAirwallex() before createPaymentConsent();";throw console.error(e),new Error(e)}},u=e=>window.Airwallex.getDeviceFingerprint(e);var y={getGatewayUrl:r,loadAirwallex:n,loadAirwallexJs:o,init:l,redirectToCheckout:a,createElement:i,destroyElement:w,getDeviceFingerprint:u,getElement:d,getPaymentIntent:m,createPaymentMethod:x,createPaymentConsent:A,confirmPaymentIntent:s,confirmPaymentIntentWithSavedCard:c};exports.confirmPaymentIntent=s,exports.confirmPaymentIntentWithSavedCard=c,exports.createElement=i,exports.createPaymentConsent=A,exports.createPaymentMethod=x,exports.default=y,exports.destroyElement=w,exports.getDeviceFingerprint=u,exports.getElement=d,exports.getGatewayUrl=r,exports.getPaymentIntent=m,exports.init=l,exports.loadAirwallex=n,exports.loadAirwallexJs=o,exports.redirectToCheckout=a;
3
3
  //# sourceMappingURL=airwallex.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"airwallex.cjs.js","sources":["../../src/index.ts"],"sourcesContent":["import Airwallex, {\n init as initFn,\n redirectToCheckout as redirectToCheckoutFn,\n createElement as createElementFn,\n destroyElement as destroyElementFn,\n getElement as getElementFn,\n confirmPaymentIntent as confirmPaymentIntentFn,\n confirmPaymentIntentWithSavedCard as confirmPaymentIntentWithSavedCardFn,\n createPaymentMethod as createPaymentMethodFn,\n getPaymentIntent as getPaymentIntentFn,\n createPaymentConsent as createPaymentConsentFn,\n AirwallexEnv,\n} from '../types/airwallex';\nimport { getDeviceFingerprint as getDeviceFingerprintFn } from '../types/fraud';\nimport { loadAirwallex as loadAirwallexFn } from '../types/index';\nimport { version } from '../package.json';\n\nconst ENV_HOST = {\n prod: 'checkout.airwallex.com',\n demo: 'checkout-demo.airwallex.com',\n staging: 'checkout-staging.airwallex.com',\n /**\n * Below env only for the npm package development\n * Should not using them when integrate with Airwallex\n */\n qa: 'checkoutui.qa.awx.im',\n preview: 'checkoutui.preview.awx.im',\n dev: 'localhost:3000',\n};\n\ndeclare global {\n interface Window {\n Airwallex: Airwallex;\n ReactNativeWebView: {\n postMessage: (message: string) => void;\n };\n }\n}\n\n/**\n * @example\n * ```ts \nimport { gatewayUrl } from 'airwallex-payment-elements';\nconst gatewayUrl = getGatewayUrl('prod');\n```\n */\n\nexport const getGatewayUrl = (env: AirwallexEnv): string => `https://${ENV_HOST[env] || ENV_HOST.prod}`;\n\nconst STATIC_JS_URL = `/assets/elements.bundle.min.js?version=${version}`;\n\n/**\n * @example\n * ```ts \nimport { loadAirwallexJs } from 'airwallex-payment-elements';\nconst gatewayUrl = getGatewayUrl('prod');\nloadAirwallexJs(gatewayUrl);\n```\n */\n\nexport const loadAirwallexJs = (gatewayUrl: string): HTMLScriptElement => {\n const script = document.createElement('script');\n script.src = `${gatewayUrl}${STATIC_JS_URL}`;\n script.crossOrigin = 'anonymous';\n\n const headOrBody = document.head || document.body;\n\n if (!headOrBody) {\n throw new Error('Airwallex payment scripts requires a <head> or <body> html element in order to be loaded.');\n }\n\n headOrBody.appendChild(script);\n\n return script;\n};\n\n/**\n * @example\n * ```ts \nimport { loadAirwallex } from 'airwallex-payment-elements';\nloadAirwallex({\n env: 'prod',\n locale: 'en',\n});\n```\n */\n\nexport const loadAirwallex: typeof loadAirwallexFn = async (options) => {\n if (typeof window === 'undefined') {\n return null;\n }\n\n if (window.Airwallex) {\n return window.Airwallex;\n }\n\n const MAX_RETRY_COUNT = 3;\n let RETRY_COUNT = 0;\n const sleep = () => new Promise((resolve) => window.setTimeout(resolve, 500));\n\n const tryToResolve = async (): Promise<Airwallex> => {\n const script: HTMLScriptElement =\n document.querySelector(`script[src=\"${STATIC_JS_URL}\"], script[src=\"${STATIC_JS_URL}/\"]`) ||\n loadAirwallexJs(getGatewayUrl(options?.env || 'prod'));\n\n return new Promise((resolve, reject) => {\n script.addEventListener('load', () => {\n if (window.Airwallex) {\n window.Airwallex.init(options);\n resolve(window.Airwallex);\n } else {\n reject(new Error('Failed to load Airwallex on load event'));\n }\n });\n\n script.addEventListener('error', () => {\n reject(new Error('Failed to load Airwallex scripts'));\n script.remove && script.remove();\n });\n });\n };\n\n while (RETRY_COUNT < MAX_RETRY_COUNT) {\n try {\n return await tryToResolve();\n } catch (error) {\n RETRY_COUNT++;\n await sleep();\n }\n }\n\n return null;\n};\n\n/**\n * @example\n * ```ts \nimport { init } from 'airwallex-payment-elements';\ninit({\n env: 'prod',\n locale: 'en',\n});\n```\n */\n\nexport const init: typeof initFn = (options) => {\n if (!window.Airwallex) {\n console.error('Please loadAirwallex() before init();');\n } else {\n window.Airwallex.init(options);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { redirectToCheckout } from 'airwallex-payment-elements';\nredirectToCheckout({\n env: 'prod',\n intent_id: 'replace-with-your-intent_id',\n client_secret: 'replace-with-your-client-secret',,\n successUrl: `${window.location.origin}/checkout-success?isTesting=N`,\n locale: 'replace-with-your-language',\n showTermLink: true,\n theme: {\n variant: 'bootstrap',\n fonts: [\n {\n src: 'https://checkout.airwallex.com/fonts/CircularXXWeb/CircularXXSub-BoldSubset.woff2',\n family: 'AxLLCircular',\n weight: '700',\n },\n {\n src: 'https://checkout.airwallex.com/fonts/CircularXXWeb/CircularXXWeb-Regular.woff2',\n family: 'AxLLCircular',\n weight: '400',\n },\n ],\n popupWidth: 418,\n popupHeight: 549,\n },\n applePayRequestOptions: {\n countryCode: 'US',\n },\n googlePayRequestOptions: {\n countryCode: 'US',\n },\n requiredBillingContactFields: ['email', 'name'],\n currency: 'HKD',\n});\n```\n */\n\nexport const redirectToCheckout: typeof redirectToCheckoutFn = (props) => {\n if (!window.Airwallex) {\n console.error('Please loadAirwallex() before redirectToCheckout();');\n } else {\n return window.Airwallex.redirectToCheckout(props);\n }\n};\n\n/**\n * We encourage to use `dropIn` element, since it's easy to scale new payment methods\n * We suggest to NOT use `applePayButton`, `googlePayButton`, `wechat`, `qrcode`, `redirect`, `fullFeaturedCard` and `directDebit` elements\n * \n * @example\n * ```ts \nimport { createElement } from 'airwallex-payment-elements';\nconst element = createElement('dropIn', {\n intent_id: 'replace-with-your-intent_id',\n client_secret: 'replace-with-your-client-secret',\n currency: 'replace-with-your-intent-currency',\n // if you want to use apple pay, please pass merchant country code in applePayRequestOptions\n applePayRequestOptions: {\n countryCode: 'replace-with-your-country-code',\n },\n // if you want to use google pay, please pass merchant country code in googlePayRequestOptions\n googlePayRequestOptions: {\n countryCode: 'replace-with-your-country-code',\n },\n});\n```\n */\n\nexport const createElement: typeof createElementFn = (type, options) => {\n if (!window.Airwallex) {\n console.error('Please loadAirwallex() before createElement();');\n return null;\n } else {\n return window.Airwallex.createElement(type, options);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { destroyElement } from 'airwallex-payment-elements';\ndestroyElement('dropIn');\n```\n */\n\nexport const destroyElement: typeof destroyElementFn = (type) => {\n if (!window.Airwallex) {\n console.error('Please loadAirwallex() before destroyElement();');\n return false;\n } else {\n return window.Airwallex.destroyElement(type);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { getElement } from 'airwallex-payment-elements';\ngetElement('dropIn');\n```\n */\n\nexport const getElement: typeof getElementFn = (type) => {\n if (!window.Airwallex) {\n console.error('Please loadAirwallex() before getElement();');\n return null;\n } else {\n return window.Airwallex.getElement(type);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { confirmPaymentIntent } from 'airwallex-payment-elements';\nconfirmPaymentIntent({\n element: card, // Provide Card element\n intent_id: 'replace-with-your-intent_id', // Payment Intent ID\n client_secret: 'replace-with-your-client-secret', // Client Secret\n payment_method_options: {\n card: {\n auto_capture: true,\n },\n },\n})\n```\n */\n\nexport const confirmPaymentIntent: typeof confirmPaymentIntentFn = async (data) => {\n if (!window.Airwallex) {\n const err = 'Please loadAirwallex() before confirmPaymentIntent();';\n console.error(err);\n throw new Error(err);\n } else {\n return window.Airwallex.confirmPaymentIntent(data);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { confirmPaymentIntentWithSavedCard } from 'airwallex-payment-elements';\nconfirmPaymentIntentWithSavedCard({\n element: card, // Provide Card element\n customer_id: 'replace-with-your-customer-id',\n methodId: 'replace-with-your-method-id',\n intent_id: 'replace-with-your-intent_id', // Payment Intent ID\n client_secret: 'replace-with-your-client-secret', // Client Secret\n})\n```\n */\n\nexport const confirmPaymentIntentWithSavedCard: typeof confirmPaymentIntentWithSavedCardFn = async (data) => {\n if (!window.Airwallex) {\n const err = 'Please loadAirwallex() before confirmPaymentIntentWithSavedCard();';\n console.error(err);\n throw new Error(err);\n } else {\n return window.Airwallex.confirmPaymentIntentWithSavedCard(data);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { createPaymentMethod } from 'airwallex-payment-elements';\ncreatePaymentMethod('replace-with-your-client-secret', {\n element: card, // Provide Card element\n customer_id: 'replace-with-your-customer-id',\n})\n```\n */\n\nexport const createPaymentMethod: typeof createPaymentMethodFn = async (client_secret, data) => {\n if (!window.Airwallex) {\n const err = 'Please loadAirwallex() before createPaymentMethod();';\n console.error(err);\n throw new Error(err);\n } else {\n return window.Airwallex.createPaymentMethod(client_secret, data);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { getPaymentIntent } from 'airwallex-payment-elements';\ngetPaymentIntent('replace-with-your-intent_id', 'replace-with-your-client_secret')\n```\n */\n\nexport const getPaymentIntent: typeof getPaymentIntentFn = async (id, client_secret) => {\n if (!window.Airwallex) {\n const err = 'Please loadAirwallex() before getPaymentIntent();';\n console.error(err);\n throw new Error(err);\n } else {\n return window.Airwallex.getPaymentIntent(id, client_secret);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { createPaymentConsent } from 'airwallex-payment-elements';\ncreatePaymentConsent({\n intent_id: 'replace-with-your-intent_id',\n customer_id: 'replace-with-your-customer_id',\n cardname: 'replace-with-your-card_name',\n client_secret: 'replace-with-your-client_secret',\n currency: 'HKD,\n element: cardNumberElement,\n next_triggered_by: 'customer',\n billing: {\n email: 'test@airwallex.com',\n first_name: 'TEST',\n last_name: 'TEST',\n date_of_birth: '2020-07-05',\n phone_number: '13333333333',\n address: {\n city: 'shanghai',\n country_code: 'CN',\n postcode: '200000',\n state: 'Shanghai',\n street: 'Street',\n },\n },\n})\n```\n */\n\nexport const createPaymentConsent: typeof createPaymentConsentFn = async (data) => {\n if (!window.Airwallex) {\n const err = 'Please loadAirwallex() before createPaymentConsent();';\n console.error(err);\n throw new Error(err);\n } else {\n return window.Airwallex.createPaymentConsent(data);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { getDeviceFingerprint } from 'airwallex-payment-elements';\ngetDeviceFingerprint({\n intent_id: 'replace-with-your-intent_id',\n env: 'prod',\n})\n```\n */\n\nexport const getDeviceFingerprint: typeof getDeviceFingerprintFn = (data) => {\n return window.Airwallex.getDeviceFingerprint(data);\n};\n\nexport default {\n getGatewayUrl,\n loadAirwallex,\n loadAirwallexJs,\n init,\n redirectToCheckout,\n createElement,\n destroyElement,\n getDeviceFingerprint,\n getElement,\n getPaymentIntent,\n createPaymentMethod,\n createPaymentConsent,\n confirmPaymentIntent,\n confirmPaymentIntentWithSavedCard,\n};\n"],"names":["ENV_HOST","prod","demo","staging","qa","preview","dev","getGatewayUrl","env","STATIC_JS_URL","loadAirwallexJs","gatewayUrl","script","document","createElement","src","crossOrigin","headOrBody","head","body","Error","appendChild","loadAirwallex","async","options","window","Airwallex","RETRY_COUNT","tryToResolve","querySelector","Promise","resolve","reject","addEventListener","init","remove","error","setTimeout","console","redirectToCheckout","props","type","destroyElement","getElement","confirmPaymentIntent","data","err","confirmPaymentIntentWithSavedCard","createPaymentMethod","client_secret","getPaymentIntent","id","createPaymentConsent","getDeviceFingerprint"],"mappings":";oEAiBA,MAAMA,EAAW,CACfC,KAAM,yBACNC,KAAM,8BACNC,QAAS,iCAKTC,GAAI,uBACJC,QAAS,4BACTC,IAAK,kBAoBMC,EAAiBC,GAA8B,WAAWR,EAASQ,IAAQR,EAASC,OAE3FQ,EAAgB,+CAWTC,EAAmBC,IAC9B,MAAMC,EAASC,SAASC,cAAc,UACtCF,EAAOG,IAAM,GAAGJ,IAAaF,IAC7BG,EAAOI,YAAc,YAErB,MAAMC,EAAaJ,SAASK,MAA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,OAAOC,UAKV,OAAOD,OAAOC,UAAUkB,qBAAqBC,GALxB,CACrB,MAAMC,EAAM,wDAEZ,MADAR,QAAQF,MAAMU,GACR,IAAI1B,MAAM0B,KAoBPC,EAAgFxB,MAAOsB,IAClG,GAAKpB,OAAOC,UAKV,OAAOD,OAAOC,UAAUqB,kCAAkCF,GALrC,CACrB,MAAMC,EAAM,qEAEZ,MADAR,QAAQF,MAAMU,GACR,IAAI1B,MAAM0B,KAiBPE,EAAoDzB,MAAO0B,EAAeJ,KACrF,GAAKpB,OAAOC,UAKV,OAAOD,OAAOC,UAAUsB,oBAAoBC,EAAeJ,GALtC,CACrB,MAAMC,EAAM,uDAEZ,MADAR,QAAQF,MAAMU,GACR,IAAI1B,MAAM0B,KAcPI,EAA8C3B,MAAO4B,EAAIF,KACpE,GAAKxB,OAAOC,UAKV,OAAOD,OAAOC,UAAUwB,iBAAiBC,EAAIF,GALxB,CACrB,MAAMH,EAAM,oDAEZ,MADAR,QAAQF,MAAMU,GACR,IAAI1B,MAAM0B,KAoCPM,EAAsD7B,MAAOsB,IACxE,GAAKpB,OAAOC,UAKV,OAAOD,OAAOC,UAAU0B,qBAAqBP,GALxB,CACrB,MAAMC,EAAM,wDAEZ,MADAR,QAAQF,MAAMU,GACR,IAAI1B,MAAM0B,KAiBPO,EAAuDR,GAC3DpB,OAAOC,UAAU2B,qBAAqBR,GAG/C,MAAe,CACbtC,cAAAA,EACAe,cAAAA,EACAZ,gBAAAA,EACAwB,KAAAA,EACAK,mBAAAA,EACAzB,cAAAA,EACA4B,eAAAA,EACAW,qBAAAA,EACAV,WAAAA,EACAO,iBAAAA,EACAF,oBAAAA,EACAI,qBAAAA,EACAR,qBAAAA,EACAG,kCAAAA"}
1
+ {"version":3,"file":"airwallex.cjs.js","sources":["../../src/index.ts"],"sourcesContent":["import Airwallex, {\n init as initFn,\n redirectToCheckout as redirectToCheckoutFn,\n createElement as createElementFn,\n destroyElement as destroyElementFn,\n getElement as getElementFn,\n confirmPaymentIntent as confirmPaymentIntentFn,\n confirmPaymentIntentWithSavedCard as confirmPaymentIntentWithSavedCardFn,\n createPaymentMethod as createPaymentMethodFn,\n getPaymentIntent as getPaymentIntentFn,\n createPaymentConsent as createPaymentConsentFn,\n AirwallexEnv,\n} from '../types/airwallex';\nimport { getDeviceFingerprint as getDeviceFingerprintFn } from '../types/fraud';\nimport { loadAirwallex as loadAirwallexFn } from '../types/index';\nimport { version } from '../package.json';\n\nconst ENV_HOST = {\n prod: 'checkout.airwallex.com',\n demo: 'checkout-demo.airwallex.com',\n staging: 'checkout-staging.airwallex.com',\n /**\n * Below env only for the npm package development\n * Should not using them when integrate with Airwallex\n */\n qa: 'checkoutui.qa.awx.im',\n preview: 'checkoutui.preview.awx.im',\n dev: 'localhost:3000',\n};\n\ndeclare global {\n interface Window {\n Airwallex: Airwallex;\n ReactNativeWebView: {\n postMessage: (message: string) => void;\n };\n }\n}\n\n/**\n * @example\n * ```ts \nimport { gatewayUrl } from 'airwallex-payment-elements';\nconst gatewayUrl = getGatewayUrl('prod');\n```\n */\n\nexport const getGatewayUrl = (env: AirwallexEnv): string => `https://${ENV_HOST[env] || ENV_HOST.prod}`;\n\nconst STATIC_JS_URL = `/assets/elements.bundle.min.js?version=${version}`;\n\n/**\n * @example\n * ```ts \nimport { loadAirwallexJs } from 'airwallex-payment-elements';\nconst gatewayUrl = getGatewayUrl('prod');\nloadAirwallexJs(gatewayUrl);\n```\n */\n\nexport const loadAirwallexJs = (gatewayUrl: string): HTMLScriptElement => {\n const script = document.createElement('script');\n script.src = `${gatewayUrl}${STATIC_JS_URL}`;\n script.crossOrigin = 'anonymous';\n\n const headOrBody = document.head || document.body;\n\n if (!headOrBody) {\n throw new Error('Airwallex payment scripts requires a <head> or <body> html element in order to be loaded.');\n }\n\n headOrBody.appendChild(script);\n\n return script;\n};\n\n/**\n * @example\n * ```ts \nimport { loadAirwallex } from 'airwallex-payment-elements';\nloadAirwallex({\n env: 'prod',\n locale: 'en',\n});\n```\n */\n\nexport const loadAirwallex: typeof loadAirwallexFn = async (options) => {\n if (typeof window === 'undefined') {\n return null;\n }\n\n if (window.Airwallex) {\n return window.Airwallex;\n }\n\n const MAX_RETRY_COUNT = 3;\n let RETRY_COUNT = 0;\n const sleep = () => new Promise((resolve) => window.setTimeout(resolve, 500));\n\n const tryToResolve = async (): Promise<Airwallex> => {\n const script: HTMLScriptElement =\n document.querySelector(`script[src=\"${STATIC_JS_URL}\"], script[src=\"${STATIC_JS_URL}/\"]`) ||\n loadAirwallexJs(getGatewayUrl(options?.env || 'prod'));\n\n return new Promise((resolve, reject) => {\n script.addEventListener('load', () => {\n if (window.Airwallex) {\n window.Airwallex.init(options);\n resolve(window.Airwallex);\n } else {\n reject(new Error('Failed to load Airwallex on load event'));\n }\n });\n\n script.addEventListener('error', () => {\n reject(new Error('Failed to load Airwallex scripts'));\n script.remove && script.remove();\n });\n });\n };\n\n while (RETRY_COUNT < MAX_RETRY_COUNT) {\n try {\n return await tryToResolve();\n } catch (error) {\n RETRY_COUNT++;\n await sleep();\n }\n }\n\n return null;\n};\n\n/**\n * @example\n * ```ts \nimport { init } from 'airwallex-payment-elements';\ninit({\n env: 'prod',\n locale: 'en',\n});\n```\n */\n\nexport const init: typeof initFn = (options) => {\n if (!window.Airwallex) {\n console.error('Please loadAirwallex() before init();');\n } else {\n window.Airwallex.init(options);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { redirectToCheckout } from 'airwallex-payment-elements';\nredirectToCheckout({\n env: 'prod',\n intent_id: 'replace-with-your-intent_id',\n client_secret: 'replace-with-your-client-secret',,\n successUrl: `${window.location.origin}/checkout-success?isTesting=N`,\n locale: 'replace-with-your-language',\n showTermLink: true,\n theme: {\n variant: 'bootstrap',\n fonts: [\n {\n src: 'https://checkout.airwallex.com/fonts/CircularXXWeb/CircularXXSub-BoldSubset.woff2',\n family: 'AxLLCircular',\n weight: '700',\n },\n {\n src: 'https://checkout.airwallex.com/fonts/CircularXXWeb/CircularXXWeb-Regular.woff2',\n family: 'AxLLCircular',\n weight: '400',\n },\n ],\n popupWidth: 418,\n popupHeight: 549,\n },\n applePayRequestOptions: {\n countryCode: 'US',\n },\n googlePayRequestOptions: {\n countryCode: 'US',\n },\n requiredBillingContactFields: ['email', 'name'],\n currency: 'HKD',\n});\n```\n */\n\nexport const redirectToCheckout: typeof redirectToCheckoutFn = (props) => {\n if (!window.Airwallex) {\n console.error('Please loadAirwallex() before redirectToCheckout();');\n } else {\n return window.Airwallex.redirectToCheckout(props);\n }\n};\n\n/**\n * We encourage to use `dropIn` element, since it's easy to scale new payment methods\n * We suggest to NOT use `applePayButton`, `googlePayButton`, `wechat`, `qrcode`, `redirect`, `fullFeaturedCard` and `directDebit` elements\n * \n * @example\n * ```ts \nimport { createElement } from 'airwallex-payment-elements';\nconst element = createElement('dropIn', {\n intent_id: 'replace-with-your-intent_id',\n client_secret: 'replace-with-your-client-secret',\n currency: 'replace-with-your-intent-currency',\n // if you want to use apple pay, please pass merchant country code in applePayRequestOptions\n applePayRequestOptions: {\n countryCode: 'replace-with-your-country-code',\n },\n // if you want to use google pay, please pass merchant country code in googlePayRequestOptions\n googlePayRequestOptions: {\n countryCode: 'replace-with-your-country-code',\n },\n});\n```\n */\n\nexport const createElement: typeof createElementFn = (type, options) => {\n if (!window.Airwallex) {\n console.error('Please loadAirwallex() before createElement();');\n return null;\n } else {\n return window.Airwallex.createElement(type, options);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { destroyElement } from 'airwallex-payment-elements';\ndestroyElement('dropIn');\n```\n */\n\nexport const destroyElement: typeof destroyElementFn = (type) => {\n if (!window.Airwallex) {\n console.error('Please loadAirwallex() before destroyElement();');\n return false;\n } else {\n return window.Airwallex.destroyElement(type);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { getElement } from 'airwallex-payment-elements';\ngetElement('dropIn');\n```\n */\n\nexport const getElement: typeof getElementFn = (type) => {\n if (!window.Airwallex) {\n console.error('Please loadAirwallex() before getElement();');\n return null;\n } else {\n return window.Airwallex.getElement(type);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { confirmPaymentIntent } from 'airwallex-payment-elements';\nconfirmPaymentIntent({\n element: card, // Provide Card element\n intent_id: 'replace-with-your-intent_id', // Payment Intent ID\n client_secret: 'replace-with-your-client-secret', // Client Secret\n payment_method_options: {\n card: {\n auto_capture: true,\n },\n },\n})\n```\n */\n\nexport const confirmPaymentIntent: typeof confirmPaymentIntentFn = async (data) => {\n if (!window.Airwallex) {\n const err = 'Please loadAirwallex() before confirmPaymentIntent();';\n console.error(err);\n throw new Error(err);\n } else {\n return window.Airwallex.confirmPaymentIntent(data);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { confirmPaymentIntentWithSavedCard } from 'airwallex-payment-elements';\nconfirmPaymentIntentWithSavedCard({\n element: card, // Provide Card element\n customer_id: 'replace-with-your-customer-id',\n methodId: 'replace-with-your-method-id',\n intent_id: 'replace-with-your-intent_id', // Payment Intent ID\n client_secret: 'replace-with-your-client-secret', // Client Secret\n})\n```\n */\n\nexport const confirmPaymentIntentWithSavedCard: typeof confirmPaymentIntentWithSavedCardFn = async (data) => {\n if (!window.Airwallex) {\n const err = 'Please loadAirwallex() before confirmPaymentIntentWithSavedCard();';\n console.error(err);\n throw new Error(err);\n } else {\n return window.Airwallex.confirmPaymentIntentWithSavedCard(data);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { createPaymentMethod } from 'airwallex-payment-elements';\ncreatePaymentMethod('replace-with-your-client-secret', {\n element: card, // Provide Card element\n customer_id: 'replace-with-your-customer-id',\n})\n```\n */\n\nexport const createPaymentMethod: typeof createPaymentMethodFn = async (client_secret, data) => {\n if (!window.Airwallex) {\n const err = 'Please loadAirwallex() before createPaymentMethod();';\n console.error(err);\n throw new Error(err);\n } else {\n return window.Airwallex.createPaymentMethod(client_secret, data);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { getPaymentIntent } from 'airwallex-payment-elements';\ngetPaymentIntent('replace-with-your-intent_id', 'replace-with-your-client_secret')\n```\n */\n\nexport const getPaymentIntent: typeof getPaymentIntentFn = async (id, client_secret) => {\n if (!window.Airwallex) {\n const err = 'Please loadAirwallex() before getPaymentIntent();';\n console.error(err);\n throw new Error(err);\n } else {\n return window.Airwallex.getPaymentIntent(id, client_secret);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { createPaymentConsent } from 'airwallex-payment-elements';\ncreatePaymentConsent({\n intent_id: 'replace-with-your-intent_id',\n customer_id: 'replace-with-your-customer_id',\n cardname: 'replace-with-your-card_name',\n client_secret: 'replace-with-your-client_secret',\n currency: 'HKD,\n element: cardNumberElement,\n next_triggered_by: 'customer',\n billing: {\n email: 'test@airwallex.com',\n first_name: 'TEST',\n last_name: 'TEST',\n date_of_birth: '2020-07-05',\n phone_number: '13333333333',\n address: {\n city: 'shanghai',\n country_code: 'CN',\n postcode: '200000',\n state: 'Shanghai',\n street: 'Street',\n },\n },\n})\n```\n */\n\nexport const createPaymentConsent: typeof createPaymentConsentFn = async (data) => {\n if (!window.Airwallex) {\n const err = 'Please loadAirwallex() before createPaymentConsent();';\n console.error(err);\n throw new Error(err);\n } else {\n return window.Airwallex.createPaymentConsent(data);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { getDeviceFingerprint } from 'airwallex-payment-elements';\ngetDeviceFingerprint({\n intent_id: 'replace-with-your-intent_id',\n env: 'prod',\n})\n```\n */\n\nexport const getDeviceFingerprint: typeof getDeviceFingerprintFn = (data) => {\n return window.Airwallex.getDeviceFingerprint(data);\n};\n\nexport default {\n getGatewayUrl,\n loadAirwallex,\n loadAirwallexJs,\n init,\n redirectToCheckout,\n createElement,\n destroyElement,\n getDeviceFingerprint,\n getElement,\n getPaymentIntent,\n createPaymentMethod,\n createPaymentConsent,\n confirmPaymentIntent,\n confirmPaymentIntentWithSavedCard,\n};\n"],"names":["ENV_HOST","prod","demo","staging","qa","preview","dev","getGatewayUrl","env","STATIC_JS_URL","loadAirwallexJs","gatewayUrl","script","document","createElement","src","crossOrigin","headOrBody","head","body","Error","appendChild","loadAirwallex","async","options","window","Airwallex","RETRY_COUNT","tryToResolve","querySelector","Promise","resolve","reject","addEventListener","init","remove","error","setTimeout","console","redirectToCheckout","props","type","destroyElement","getElement","confirmPaymentIntent","data","err","confirmPaymentIntentWithSavedCard","createPaymentMethod","client_secret","getPaymentIntent","id","createPaymentConsent","getDeviceFingerprint"],"mappings":";oEAiBA,MAAMA,EAAW,CACfC,KAAM,yBACNC,KAAM,8BACNC,QAAS,iCAKTC,GAAI,uBACJC,QAAS,4BACTC,IAAK,kBAoBMC,EAAiBC,GAA8B,WAAWR,EAASQ,IAAQR,EAASC,OAE3FQ,EAAgB,gDAWTC,EAAmBC,IAC9B,MAAMC,EAASC,SAASC,cAAc,UACtCF,EAAOG,IAAM,GAAGJ,IAAaF,IAC7BG,EAAOI,YAAc,YAErB,MAAMC,EAAaJ,SAASK,MAAQL,SAASM,KAE7C,IAAKF,EACH,MAAM,IAAIG,MAAM,6FAKlB,OAFAH,EAAWI,YAAYT,GAEhBA,GAcIU,EAAwCC,MAAOC,IAC1D,GAAsB,oBAAXC,OACT,OAAO,KAGT,GAAIA,OAAOC,UACT,OAAOD,OAAOC,UAIhB,IAAIC,EAAc,EAClB,MAEMC,EAAeL,UACnB,MAAMX,EACJC,SAASgB,cAAc,eAAepB,oBAAgCA,SACtEC,EAAgBH,GAAciB,MAAAA,SAAAA,EAAShB,MAAO,SAEhD,OAAO,IAAIsB,SAAQ,CAACC,EAASC,KAC3BpB,EAAOqB,iBAAiB,QAAQ,KAC1BR,OAAOC,WACTD,OAAOC,UAAUQ,KAAKV,GACtBO,EAAQN,OAAOC,YAEfM,EAAO,IAAIZ,MAAM,8CAIrBR,EAAOqB,iBAAiB,SAAS,KAC/BD,EAAO,IAAIZ,MAAM,qCACjBR,EAAOuB,QAAUvB,EAAOuB,gBAK9B,KAAOR,EA1BiB,GA2BtB,IACE,aAAaC,IACb,MAAOQ,GACPT,UA5BgB,IAAIG,SAASC,GAAYN,OAAOY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C,UAKV,OAAOD,OAAOC,UAAU0B,qBAAqBP,GALxB,CACrB,MAAMC,EAAM,wDAEZ,MADAR,QAAQF,MAAMU,GACR,IAAI1B,MAAM0B,KAiBPO,EAAuDR,GAC3DpB,OAAOC,UAAU2B,qBAAqBR,GAG/C,MAAe,CACbtC,cAAAA,EACAe,cAAAA,EACAZ,gBAAAA,EACAwB,KAAAA,EACAK,mBAAAA,EACAzB,cAAAA,EACA4B,eAAAA,EACAW,qBAAAA,EACAV,WAAAA,EACAO,iBAAAA,EACAF,oBAAAA,EACAI,qBAAAA,EACAR,qBAAAA,EACAG,kCAAAA"}
@@ -1,3 +1,3 @@
1
- /* Airwallex Checkout Component Version [1.9.0] */
2
- const e={prod:"checkout.airwallex.com",demo:"checkout-demo.airwallex.com",staging:"checkout-staging.airwallex.com",qa:"checkoutui.qa.awx.im",preview:"checkoutui.preview.awx.im",dev:"localhost:3000"},r=r=>`https://${e[r]||e.prod}`,o="/assets/elements.bundle.min.js?version=1.9.0",n=e=>{const r=document.createElement("script");r.src=`${e}${o}`,r.crossOrigin="anonymous";const n=document.head||document.body;if(!n)throw new Error("Airwallex payment scripts requires a <head> or <body> html element in order to be loaded.");return n.appendChild(r),r},t=async e=>{if("undefined"==typeof window)return null;if(window.Airwallex)return window.Airwallex;let t=0;const l=async()=>{const t=document.querySelector(`script[src="${o}"], script[src="${o}/"]`)||n(r((null==e?void 0:e.env)||"prod"));return new Promise(((r,o)=>{t.addEventListener("load",(()=>{window.Airwallex?(window.Airwallex.init(e),r(window.Airwallex)):o(new Error("Failed to load Airwallex on load event"))})),t.addEventListener("error",(()=>{o(new Error("Failed to load Airwallex scripts")),t.remove&&t.remove()}))}))};for(;t<3;)try{return await l()}catch(e){t++,await new Promise((e=>window.setTimeout(e,500)))}return null},l=e=>{window.Airwallex?window.Airwallex.init(e):console.error("Please loadAirwallex() before init();")},a=e=>{if(window.Airwallex)return window.Airwallex.redirectToCheckout(e);console.error("Please loadAirwallex() before redirectToCheckout();")},i=(e,r)=>window.Airwallex?window.Airwallex.createElement(e,r):(console.error("Please loadAirwallex() before createElement();"),null),w=e=>window.Airwallex?window.Airwallex.destroyElement(e):(console.error("Please loadAirwallex() before destroyElement();"),!1),d=e=>window.Airwallex?window.Airwallex.getElement(e):(console.error("Please loadAirwallex() before getElement();"),null),c=async e=>{if(window.Airwallex)return window.Airwallex.confirmPaymentIntent(e);{const e="Please loadAirwallex() before confirmPaymentIntent();";throw console.error(e),new Error(e)}},s=async e=>{if(window.Airwallex)return window.Airwallex.confirmPaymentIntentWithSavedCard(e);{const e="Please loadAirwallex() before confirmPaymentIntentWithSavedCard();";throw console.error(e),new Error(e)}},m=async(e,r)=>{if(window.Airwallex)return window.Airwallex.createPaymentMethod(e,r);{const e="Please loadAirwallex() before createPaymentMethod();";throw console.error(e),new Error(e)}},x=async(e,r)=>{if(window.Airwallex)return window.Airwallex.getPaymentIntent(e,r);{const e="Please loadAirwallex() before getPaymentIntent();";throw console.error(e),new Error(e)}},A=async e=>{if(window.Airwallex)return window.Airwallex.createPaymentConsent(e);{const e="Please loadAirwallex() before createPaymentConsent();";throw console.error(e),new Error(e)}},u=e=>window.Airwallex.getDeviceFingerprint(e);var y={getGatewayUrl:r,loadAirwallex:t,loadAirwallexJs:n,init:l,redirectToCheckout:a,createElement:i,destroyElement:w,getDeviceFingerprint:u,getElement:d,getPaymentIntent:x,createPaymentMethod:m,createPaymentConsent:A,confirmPaymentIntent:c,confirmPaymentIntentWithSavedCard:s};export default y;export{c as confirmPaymentIntent,s as confirmPaymentIntentWithSavedCard,i as createElement,A as createPaymentConsent,m as createPaymentMethod,w as destroyElement,u as getDeviceFingerprint,d as getElement,r as getGatewayUrl,x as getPaymentIntent,l as init,t as loadAirwallex,n as loadAirwallexJs,a as redirectToCheckout};
1
+ /* Airwallex Checkout Component Version [1.12.0] */
2
+ const e={prod:"checkout.airwallex.com",demo:"checkout-demo.airwallex.com",staging:"checkout-staging.airwallex.com",qa:"checkoutui.qa.awx.im",preview:"checkoutui.preview.awx.im",dev:"localhost:3000"},r=r=>`https://${e[r]||e.prod}`,o="/assets/elements.bundle.min.js?version=1.12.0",n=e=>{const r=document.createElement("script");r.src=`${e}${o}`,r.crossOrigin="anonymous";const n=document.head||document.body;if(!n)throw new Error("Airwallex payment scripts requires a <head> or <body> html element in order to be loaded.");return n.appendChild(r),r},t=async e=>{if("undefined"==typeof window)return null;if(window.Airwallex)return window.Airwallex;let t=0;const l=async()=>{const t=document.querySelector(`script[src="${o}"], script[src="${o}/"]`)||n(r((null==e?void 0:e.env)||"prod"));return new Promise(((r,o)=>{t.addEventListener("load",(()=>{window.Airwallex?(window.Airwallex.init(e),r(window.Airwallex)):o(new Error("Failed to load Airwallex on load event"))})),t.addEventListener("error",(()=>{o(new Error("Failed to load Airwallex scripts")),t.remove&&t.remove()}))}))};for(;t<3;)try{return await l()}catch(e){t++,await new Promise((e=>window.setTimeout(e,500)))}return null},l=e=>{window.Airwallex?window.Airwallex.init(e):console.error("Please loadAirwallex() before init();")},a=e=>{if(window.Airwallex)return window.Airwallex.redirectToCheckout(e);console.error("Please loadAirwallex() before redirectToCheckout();")},i=(e,r)=>window.Airwallex?window.Airwallex.createElement(e,r):(console.error("Please loadAirwallex() before createElement();"),null),w=e=>window.Airwallex?window.Airwallex.destroyElement(e):(console.error("Please loadAirwallex() before destroyElement();"),!1),d=e=>window.Airwallex?window.Airwallex.getElement(e):(console.error("Please loadAirwallex() before getElement();"),null),c=async e=>{if(window.Airwallex)return window.Airwallex.confirmPaymentIntent(e);{const e="Please loadAirwallex() before confirmPaymentIntent();";throw console.error(e),new Error(e)}},s=async e=>{if(window.Airwallex)return window.Airwallex.confirmPaymentIntentWithSavedCard(e);{const e="Please loadAirwallex() before confirmPaymentIntentWithSavedCard();";throw console.error(e),new Error(e)}},m=async(e,r)=>{if(window.Airwallex)return window.Airwallex.createPaymentMethod(e,r);{const e="Please loadAirwallex() before createPaymentMethod();";throw console.error(e),new Error(e)}},x=async(e,r)=>{if(window.Airwallex)return window.Airwallex.getPaymentIntent(e,r);{const e="Please loadAirwallex() before getPaymentIntent();";throw console.error(e),new Error(e)}},A=async e=>{if(window.Airwallex)return window.Airwallex.createPaymentConsent(e);{const e="Please loadAirwallex() before createPaymentConsent();";throw console.error(e),new Error(e)}},u=e=>window.Airwallex.getDeviceFingerprint(e);var y={getGatewayUrl:r,loadAirwallex:t,loadAirwallexJs:n,init:l,redirectToCheckout:a,createElement:i,destroyElement:w,getDeviceFingerprint:u,getElement:d,getPaymentIntent:x,createPaymentMethod:m,createPaymentConsent:A,confirmPaymentIntent:c,confirmPaymentIntentWithSavedCard:s};export default y;export{c as confirmPaymentIntent,s as confirmPaymentIntentWithSavedCard,i as createElement,A as createPaymentConsent,m as createPaymentMethod,w as destroyElement,u as getDeviceFingerprint,d as getElement,r as getGatewayUrl,x as getPaymentIntent,l as init,t as loadAirwallex,n as loadAirwallexJs,a as redirectToCheckout};
3
3
  //# sourceMappingURL=airwallex.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"airwallex.es.js","sources":["../../src/index.ts"],"sourcesContent":["import Airwallex, {\n init as initFn,\n redirectToCheckout as redirectToCheckoutFn,\n createElement as createElementFn,\n destroyElement as destroyElementFn,\n getElement as getElementFn,\n confirmPaymentIntent as confirmPaymentIntentFn,\n confirmPaymentIntentWithSavedCard as confirmPaymentIntentWithSavedCardFn,\n createPaymentMethod as createPaymentMethodFn,\n getPaymentIntent as getPaymentIntentFn,\n createPaymentConsent as createPaymentConsentFn,\n AirwallexEnv,\n} from '../types/airwallex';\nimport { getDeviceFingerprint as getDeviceFingerprintFn } from '../types/fraud';\nimport { loadAirwallex as loadAirwallexFn } from '../types/index';\nimport { version } from '../package.json';\n\nconst ENV_HOST = {\n prod: 'checkout.airwallex.com',\n demo: 'checkout-demo.airwallex.com',\n staging: 'checkout-staging.airwallex.com',\n /**\n * Below env only for the npm package development\n * Should not using them when integrate with Airwallex\n */\n qa: 'checkoutui.qa.awx.im',\n preview: 'checkoutui.preview.awx.im',\n dev: 'localhost:3000',\n};\n\ndeclare global {\n interface Window {\n Airwallex: Airwallex;\n ReactNativeWebView: {\n postMessage: (message: string) => void;\n };\n }\n}\n\n/**\n * @example\n * ```ts \nimport { gatewayUrl } from 'airwallex-payment-elements';\nconst gatewayUrl = getGatewayUrl('prod');\n```\n */\n\nexport const getGatewayUrl = (env: AirwallexEnv): string => `https://${ENV_HOST[env] || ENV_HOST.prod}`;\n\nconst STATIC_JS_URL = `/assets/elements.bundle.min.js?version=${version}`;\n\n/**\n * @example\n * ```ts \nimport { loadAirwallexJs } from 'airwallex-payment-elements';\nconst gatewayUrl = getGatewayUrl('prod');\nloadAirwallexJs(gatewayUrl);\n```\n */\n\nexport const loadAirwallexJs = (gatewayUrl: string): HTMLScriptElement => {\n const script = document.createElement('script');\n script.src = `${gatewayUrl}${STATIC_JS_URL}`;\n script.crossOrigin = 'anonymous';\n\n const headOrBody = document.head || document.body;\n\n if (!headOrBody) {\n throw new Error('Airwallex payment scripts requires a <head> or <body> html element in order to be loaded.');\n }\n\n headOrBody.appendChild(script);\n\n return script;\n};\n\n/**\n * @example\n * ```ts \nimport { loadAirwallex } from 'airwallex-payment-elements';\nloadAirwallex({\n env: 'prod',\n locale: 'en',\n});\n```\n */\n\nexport const loadAirwallex: typeof loadAirwallexFn = async (options) => {\n if (typeof window === 'undefined') {\n return null;\n }\n\n if (window.Airwallex) {\n return window.Airwallex;\n }\n\n const MAX_RETRY_COUNT = 3;\n let RETRY_COUNT = 0;\n const sleep = () => new Promise((resolve) => window.setTimeout(resolve, 500));\n\n const tryToResolve = async (): Promise<Airwallex> => {\n const script: HTMLScriptElement =\n document.querySelector(`script[src=\"${STATIC_JS_URL}\"], script[src=\"${STATIC_JS_URL}/\"]`) ||\n loadAirwallexJs(getGatewayUrl(options?.env || 'prod'));\n\n return new Promise((resolve, reject) => {\n script.addEventListener('load', () => {\n if (window.Airwallex) {\n window.Airwallex.init(options);\n resolve(window.Airwallex);\n } else {\n reject(new Error('Failed to load Airwallex on load event'));\n }\n });\n\n script.addEventListener('error', () => {\n reject(new Error('Failed to load Airwallex scripts'));\n script.remove && script.remove();\n });\n });\n };\n\n while (RETRY_COUNT < MAX_RETRY_COUNT) {\n try {\n return await tryToResolve();\n } catch (error) {\n RETRY_COUNT++;\n await sleep();\n }\n }\n\n return null;\n};\n\n/**\n * @example\n * ```ts \nimport { init } from 'airwallex-payment-elements';\ninit({\n env: 'prod',\n locale: 'en',\n});\n```\n */\n\nexport const init: typeof initFn = (options) => {\n if (!window.Airwallex) {\n console.error('Please loadAirwallex() before init();');\n } else {\n window.Airwallex.init(options);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { redirectToCheckout } from 'airwallex-payment-elements';\nredirectToCheckout({\n env: 'prod',\n intent_id: 'replace-with-your-intent_id',\n client_secret: 'replace-with-your-client-secret',,\n successUrl: `${window.location.origin}/checkout-success?isTesting=N`,\n locale: 'replace-with-your-language',\n showTermLink: true,\n theme: {\n variant: 'bootstrap',\n fonts: [\n {\n src: 'https://checkout.airwallex.com/fonts/CircularXXWeb/CircularXXSub-BoldSubset.woff2',\n family: 'AxLLCircular',\n weight: '700',\n },\n {\n src: 'https://checkout.airwallex.com/fonts/CircularXXWeb/CircularXXWeb-Regular.woff2',\n family: 'AxLLCircular',\n weight: '400',\n },\n ],\n popupWidth: 418,\n popupHeight: 549,\n },\n applePayRequestOptions: {\n countryCode: 'US',\n },\n googlePayRequestOptions: {\n countryCode: 'US',\n },\n requiredBillingContactFields: ['email', 'name'],\n currency: 'HKD',\n});\n```\n */\n\nexport const redirectToCheckout: typeof redirectToCheckoutFn = (props) => {\n if (!window.Airwallex) {\n console.error('Please loadAirwallex() before redirectToCheckout();');\n } else {\n return window.Airwallex.redirectToCheckout(props);\n }\n};\n\n/**\n * We encourage to use `dropIn` element, since it's easy to scale new payment methods\n * We suggest to NOT use `applePayButton`, `googlePayButton`, `wechat`, `qrcode`, `redirect`, `fullFeaturedCard` and `directDebit` elements\n * \n * @example\n * ```ts \nimport { createElement } from 'airwallex-payment-elements';\nconst element = createElement('dropIn', {\n intent_id: 'replace-with-your-intent_id',\n client_secret: 'replace-with-your-client-secret',\n currency: 'replace-with-your-intent-currency',\n // if you want to use apple pay, please pass merchant country code in applePayRequestOptions\n applePayRequestOptions: {\n countryCode: 'replace-with-your-country-code',\n },\n // if you want to use google pay, please pass merchant country code in googlePayRequestOptions\n googlePayRequestOptions: {\n countryCode: 'replace-with-your-country-code',\n },\n});\n```\n */\n\nexport const createElement: typeof createElementFn = (type, options) => {\n if (!window.Airwallex) {\n console.error('Please loadAirwallex() before createElement();');\n return null;\n } else {\n return window.Airwallex.createElement(type, options);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { destroyElement } from 'airwallex-payment-elements';\ndestroyElement('dropIn');\n```\n */\n\nexport const destroyElement: typeof destroyElementFn = (type) => {\n if (!window.Airwallex) {\n console.error('Please loadAirwallex() before destroyElement();');\n return false;\n } else {\n return window.Airwallex.destroyElement(type);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { getElement } from 'airwallex-payment-elements';\ngetElement('dropIn');\n```\n */\n\nexport const getElement: typeof getElementFn = (type) => {\n if (!window.Airwallex) {\n console.error('Please loadAirwallex() before getElement();');\n return null;\n } else {\n return window.Airwallex.getElement(type);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { confirmPaymentIntent } from 'airwallex-payment-elements';\nconfirmPaymentIntent({\n element: card, // Provide Card element\n intent_id: 'replace-with-your-intent_id', // Payment Intent ID\n client_secret: 'replace-with-your-client-secret', // Client Secret\n payment_method_options: {\n card: {\n auto_capture: true,\n },\n },\n})\n```\n */\n\nexport const confirmPaymentIntent: typeof confirmPaymentIntentFn = async (data) => {\n if (!window.Airwallex) {\n const err = 'Please loadAirwallex() before confirmPaymentIntent();';\n console.error(err);\n throw new Error(err);\n } else {\n return window.Airwallex.confirmPaymentIntent(data);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { confirmPaymentIntentWithSavedCard } from 'airwallex-payment-elements';\nconfirmPaymentIntentWithSavedCard({\n element: card, // Provide Card element\n customer_id: 'replace-with-your-customer-id',\n methodId: 'replace-with-your-method-id',\n intent_id: 'replace-with-your-intent_id', // Payment Intent ID\n client_secret: 'replace-with-your-client-secret', // Client Secret\n})\n```\n */\n\nexport const confirmPaymentIntentWithSavedCard: typeof confirmPaymentIntentWithSavedCardFn = async (data) => {\n if (!window.Airwallex) {\n const err = 'Please loadAirwallex() before confirmPaymentIntentWithSavedCard();';\n console.error(err);\n throw new Error(err);\n } else {\n return window.Airwallex.confirmPaymentIntentWithSavedCard(data);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { createPaymentMethod } from 'airwallex-payment-elements';\ncreatePaymentMethod('replace-with-your-client-secret', {\n element: card, // Provide Card element\n customer_id: 'replace-with-your-customer-id',\n})\n```\n */\n\nexport const createPaymentMethod: typeof createPaymentMethodFn = async (client_secret, data) => {\n if (!window.Airwallex) {\n const err = 'Please loadAirwallex() before createPaymentMethod();';\n console.error(err);\n throw new Error(err);\n } else {\n return window.Airwallex.createPaymentMethod(client_secret, data);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { getPaymentIntent } from 'airwallex-payment-elements';\ngetPaymentIntent('replace-with-your-intent_id', 'replace-with-your-client_secret')\n```\n */\n\nexport const getPaymentIntent: typeof getPaymentIntentFn = async (id, client_secret) => {\n if (!window.Airwallex) {\n const err = 'Please loadAirwallex() before getPaymentIntent();';\n console.error(err);\n throw new Error(err);\n } else {\n return window.Airwallex.getPaymentIntent(id, client_secret);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { createPaymentConsent } from 'airwallex-payment-elements';\ncreatePaymentConsent({\n intent_id: 'replace-with-your-intent_id',\n customer_id: 'replace-with-your-customer_id',\n cardname: 'replace-with-your-card_name',\n client_secret: 'replace-with-your-client_secret',\n currency: 'HKD,\n element: cardNumberElement,\n next_triggered_by: 'customer',\n billing: {\n email: 'test@airwallex.com',\n first_name: 'TEST',\n last_name: 'TEST',\n date_of_birth: '2020-07-05',\n phone_number: '13333333333',\n address: {\n city: 'shanghai',\n country_code: 'CN',\n postcode: '200000',\n state: 'Shanghai',\n street: 'Street',\n },\n },\n})\n```\n */\n\nexport const createPaymentConsent: typeof createPaymentConsentFn = async (data) => {\n if (!window.Airwallex) {\n const err = 'Please loadAirwallex() before createPaymentConsent();';\n console.error(err);\n throw new Error(err);\n } else {\n return window.Airwallex.createPaymentConsent(data);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { getDeviceFingerprint } from 'airwallex-payment-elements';\ngetDeviceFingerprint({\n intent_id: 'replace-with-your-intent_id',\n env: 'prod',\n})\n```\n */\n\nexport const getDeviceFingerprint: typeof getDeviceFingerprintFn = (data) => {\n return window.Airwallex.getDeviceFingerprint(data);\n};\n\nexport default {\n getGatewayUrl,\n loadAirwallex,\n loadAirwallexJs,\n init,\n redirectToCheckout,\n createElement,\n destroyElement,\n getDeviceFingerprint,\n getElement,\n getPaymentIntent,\n createPaymentMethod,\n createPaymentConsent,\n confirmPaymentIntent,\n confirmPaymentIntentWithSavedCard,\n};\n"],"names":["ENV_HOST","prod","demo","staging","qa","preview","dev","getGatewayUrl","env","STATIC_JS_URL","loadAirwallexJs","gatewayUrl","script","document","createElement","src","crossOrigin","headOrBody","head","body","Error","appendChild","loadAirwallex","async","options","window","Airwallex","RETRY_COUNT","tryToResolve","querySelector","Promise","resolve","reject","addEventListener","init","remove","error","setTimeout","console","redirectToCheckout","props","type","destroyElement","getElement","confirmPaymentIntent","data","err","confirmPaymentIntentWithSavedCard","createPaymentMethod","client_secret","getPaymentIntent","id","createPaymentConsent","getDeviceFingerprint"],"mappings":";AAiBA,MAAMA,EAAW,CACfC,KAAM,yBACNC,KAAM,8BACNC,QAAS,iCAKTC,GAAI,uBACJC,QAAS,4BACTC,IAAK,kBAoBMC,EAAiBC,GAA8B,WAAWR,EAASQ,IAAQR,EAASC,OAE3FQ,EAAgB,+CAWTC,EAAmBC,IAC9B,MAAMC,EAASC,SAASC,cA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as initFn,\n redirectToCheckout as redirectToCheckoutFn,\n createElement as createElementFn,\n destroyElement as destroyElementFn,\n getElement as getElementFn,\n confirmPaymentIntent as confirmPaymentIntentFn,\n confirmPaymentIntentWithSavedCard as confirmPaymentIntentWithSavedCardFn,\n createPaymentMethod as createPaymentMethodFn,\n getPaymentIntent as getPaymentIntentFn,\n createPaymentConsent as createPaymentConsentFn,\n AirwallexEnv,\n} from '../types/airwallex';\nimport { getDeviceFingerprint as getDeviceFingerprintFn } from '../types/fraud';\nimport { loadAirwallex as loadAirwallexFn } from '../types/index';\nimport { version } from '../package.json';\n\nconst ENV_HOST = {\n prod: 'checkout.airwallex.com',\n demo: 'checkout-demo.airwallex.com',\n staging: 'checkout-staging.airwallex.com',\n /**\n * Below env only for the npm package development\n * Should not using them when integrate with Airwallex\n */\n qa: 'checkoutui.qa.awx.im',\n preview: 'checkoutui.preview.awx.im',\n dev: 'localhost:3000',\n};\n\ndeclare global {\n interface Window {\n Airwallex: Airwallex;\n ReactNativeWebView: {\n postMessage: (message: string) => void;\n };\n }\n}\n\n/**\n * @example\n * ```ts \nimport { gatewayUrl } from 'airwallex-payment-elements';\nconst gatewayUrl = getGatewayUrl('prod');\n```\n */\n\nexport const getGatewayUrl = (env: AirwallexEnv): string => `https://${ENV_HOST[env] || ENV_HOST.prod}`;\n\nconst STATIC_JS_URL = `/assets/elements.bundle.min.js?version=${version}`;\n\n/**\n * @example\n * ```ts \nimport { loadAirwallexJs } from 'airwallex-payment-elements';\nconst gatewayUrl = getGatewayUrl('prod');\nloadAirwallexJs(gatewayUrl);\n```\n */\n\nexport const loadAirwallexJs = (gatewayUrl: string): HTMLScriptElement => {\n const script = document.createElement('script');\n script.src = `${gatewayUrl}${STATIC_JS_URL}`;\n script.crossOrigin = 'anonymous';\n\n const headOrBody = document.head || document.body;\n\n if (!headOrBody) {\n throw new Error('Airwallex payment scripts requires a <head> or <body> html element in order to be loaded.');\n }\n\n headOrBody.appendChild(script);\n\n return script;\n};\n\n/**\n * @example\n * ```ts \nimport { loadAirwallex } from 'airwallex-payment-elements';\nloadAirwallex({\n env: 'prod',\n locale: 'en',\n});\n```\n */\n\nexport const loadAirwallex: typeof loadAirwallexFn = async (options) => {\n if (typeof window === 'undefined') {\n return null;\n }\n\n if (window.Airwallex) {\n return window.Airwallex;\n }\n\n const MAX_RETRY_COUNT = 3;\n let RETRY_COUNT = 0;\n const sleep = () => new Promise((resolve) => window.setTimeout(resolve, 500));\n\n const tryToResolve = async (): Promise<Airwallex> => {\n const script: HTMLScriptElement =\n document.querySelector(`script[src=\"${STATIC_JS_URL}\"], script[src=\"${STATIC_JS_URL}/\"]`) ||\n loadAirwallexJs(getGatewayUrl(options?.env || 'prod'));\n\n return new Promise((resolve, reject) => {\n script.addEventListener('load', () => {\n if (window.Airwallex) {\n window.Airwallex.init(options);\n resolve(window.Airwallex);\n } else {\n reject(new Error('Failed to load Airwallex on load event'));\n }\n });\n\n script.addEventListener('error', () => {\n reject(new Error('Failed to load Airwallex scripts'));\n script.remove && script.remove();\n });\n });\n };\n\n while (RETRY_COUNT < MAX_RETRY_COUNT) {\n try {\n return await tryToResolve();\n } catch (error) {\n RETRY_COUNT++;\n await sleep();\n }\n }\n\n return null;\n};\n\n/**\n * @example\n * ```ts \nimport { init } from 'airwallex-payment-elements';\ninit({\n env: 'prod',\n locale: 'en',\n});\n```\n */\n\nexport const init: typeof initFn = (options) => {\n if (!window.Airwallex) {\n console.error('Please loadAirwallex() before init();');\n } else {\n window.Airwallex.init(options);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { redirectToCheckout } from 'airwallex-payment-elements';\nredirectToCheckout({\n env: 'prod',\n intent_id: 'replace-with-your-intent_id',\n client_secret: 'replace-with-your-client-secret',,\n successUrl: `${window.location.origin}/checkout-success?isTesting=N`,\n locale: 'replace-with-your-language',\n showTermLink: true,\n theme: {\n variant: 'bootstrap',\n fonts: [\n {\n src: 'https://checkout.airwallex.com/fonts/CircularXXWeb/CircularXXSub-BoldSubset.woff2',\n family: 'AxLLCircular',\n weight: '700',\n },\n {\n src: 'https://checkout.airwallex.com/fonts/CircularXXWeb/CircularXXWeb-Regular.woff2',\n family: 'AxLLCircular',\n weight: '400',\n },\n ],\n popupWidth: 418,\n popupHeight: 549,\n },\n applePayRequestOptions: {\n countryCode: 'US',\n },\n googlePayRequestOptions: {\n countryCode: 'US',\n },\n requiredBillingContactFields: ['email', 'name'],\n currency: 'HKD',\n});\n```\n */\n\nexport const redirectToCheckout: typeof redirectToCheckoutFn = (props) => {\n if (!window.Airwallex) {\n console.error('Please loadAirwallex() before redirectToCheckout();');\n } else {\n return window.Airwallex.redirectToCheckout(props);\n }\n};\n\n/**\n * We encourage to use `dropIn` element, since it's easy to scale new payment methods\n * We suggest to NOT use `applePayButton`, `googlePayButton`, `wechat`, `qrcode`, `redirect`, `fullFeaturedCard` and `directDebit` elements\n * \n * @example\n * ```ts \nimport { createElement } from 'airwallex-payment-elements';\nconst element = createElement('dropIn', {\n intent_id: 'replace-with-your-intent_id',\n client_secret: 'replace-with-your-client-secret',\n currency: 'replace-with-your-intent-currency',\n // if you want to use apple pay, please pass merchant country code in applePayRequestOptions\n applePayRequestOptions: {\n countryCode: 'replace-with-your-country-code',\n },\n // if you want to use google pay, please pass merchant country code in googlePayRequestOptions\n googlePayRequestOptions: {\n countryCode: 'replace-with-your-country-code',\n },\n});\n```\n */\n\nexport const createElement: typeof createElementFn = (type, options) => {\n if (!window.Airwallex) {\n console.error('Please loadAirwallex() before createElement();');\n return null;\n } else {\n return window.Airwallex.createElement(type, options);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { destroyElement } from 'airwallex-payment-elements';\ndestroyElement('dropIn');\n```\n */\n\nexport const destroyElement: typeof destroyElementFn = (type) => {\n if (!window.Airwallex) {\n console.error('Please loadAirwallex() before destroyElement();');\n return false;\n } else {\n return window.Airwallex.destroyElement(type);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { getElement } from 'airwallex-payment-elements';\ngetElement('dropIn');\n```\n */\n\nexport const getElement: typeof getElementFn = (type) => {\n if (!window.Airwallex) {\n console.error('Please loadAirwallex() before getElement();');\n return null;\n } else {\n return window.Airwallex.getElement(type);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { confirmPaymentIntent } from 'airwallex-payment-elements';\nconfirmPaymentIntent({\n element: card, // Provide Card element\n intent_id: 'replace-with-your-intent_id', // Payment Intent ID\n client_secret: 'replace-with-your-client-secret', // Client Secret\n payment_method_options: {\n card: {\n auto_capture: true,\n },\n },\n})\n```\n */\n\nexport const confirmPaymentIntent: typeof confirmPaymentIntentFn = async (data) => {\n if (!window.Airwallex) {\n const err = 'Please loadAirwallex() before confirmPaymentIntent();';\n console.error(err);\n throw new Error(err);\n } else {\n return window.Airwallex.confirmPaymentIntent(data);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { confirmPaymentIntentWithSavedCard } from 'airwallex-payment-elements';\nconfirmPaymentIntentWithSavedCard({\n element: card, // Provide Card element\n customer_id: 'replace-with-your-customer-id',\n methodId: 'replace-with-your-method-id',\n intent_id: 'replace-with-your-intent_id', // Payment Intent ID\n client_secret: 'replace-with-your-client-secret', // Client Secret\n})\n```\n */\n\nexport const confirmPaymentIntentWithSavedCard: typeof confirmPaymentIntentWithSavedCardFn = async (data) => {\n if (!window.Airwallex) {\n const err = 'Please loadAirwallex() before confirmPaymentIntentWithSavedCard();';\n console.error(err);\n throw new Error(err);\n } else {\n return window.Airwallex.confirmPaymentIntentWithSavedCard(data);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { createPaymentMethod } from 'airwallex-payment-elements';\ncreatePaymentMethod('replace-with-your-client-secret', {\n element: card, // Provide Card element\n customer_id: 'replace-with-your-customer-id',\n})\n```\n */\n\nexport const createPaymentMethod: typeof createPaymentMethodFn = async (client_secret, data) => {\n if (!window.Airwallex) {\n const err = 'Please loadAirwallex() before createPaymentMethod();';\n console.error(err);\n throw new Error(err);\n } else {\n return window.Airwallex.createPaymentMethod(client_secret, data);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { getPaymentIntent } from 'airwallex-payment-elements';\ngetPaymentIntent('replace-with-your-intent_id', 'replace-with-your-client_secret')\n```\n */\n\nexport const getPaymentIntent: typeof getPaymentIntentFn = async (id, client_secret) => {\n if (!window.Airwallex) {\n const err = 'Please loadAirwallex() before getPaymentIntent();';\n console.error(err);\n throw new Error(err);\n } else {\n return window.Airwallex.getPaymentIntent(id, client_secret);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { createPaymentConsent } from 'airwallex-payment-elements';\ncreatePaymentConsent({\n intent_id: 'replace-with-your-intent_id',\n customer_id: 'replace-with-your-customer_id',\n cardname: 'replace-with-your-card_name',\n client_secret: 'replace-with-your-client_secret',\n currency: 'HKD,\n element: cardNumberElement,\n next_triggered_by: 'customer',\n billing: {\n email: 'test@airwallex.com',\n first_name: 'TEST',\n last_name: 'TEST',\n date_of_birth: '2020-07-05',\n phone_number: '13333333333',\n address: {\n city: 'shanghai',\n country_code: 'CN',\n postcode: '200000',\n state: 'Shanghai',\n street: 'Street',\n },\n },\n})\n```\n */\n\nexport const createPaymentConsent: typeof createPaymentConsentFn = async (data) => {\n if (!window.Airwallex) {\n const err = 'Please loadAirwallex() before createPaymentConsent();';\n console.error(err);\n throw new Error(err);\n } else {\n return window.Airwallex.createPaymentConsent(data);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { getDeviceFingerprint } from 'airwallex-payment-elements';\ngetDeviceFingerprint({\n intent_id: 'replace-with-your-intent_id',\n env: 'prod',\n})\n```\n */\n\nexport const getDeviceFingerprint: typeof getDeviceFingerprintFn = (data) => {\n return window.Airwallex.getDeviceFingerprint(data);\n};\n\nexport default {\n getGatewayUrl,\n loadAirwallex,\n loadAirwallexJs,\n init,\n redirectToCheckout,\n createElement,\n destroyElement,\n getDeviceFingerprint,\n getElement,\n getPaymentIntent,\n createPaymentMethod,\n createPaymentConsent,\n confirmPaymentIntent,\n confirmPaymentIntentWithSavedCard,\n};\n"],"names":["ENV_HOST","prod","demo","staging","qa","preview","dev","getGatewayUrl","env","STATIC_JS_URL","loadAirwallexJs","gatewayUrl","script","document","createElement","src","crossOrigin","headOrBody","head","body","Error","appendChild","loadAirwallex","async","options","window","Airwallex","RETRY_COUNT","tryToResolve","querySelector","Promise","resolve","reject","addEventListener","init","remove","error","setTimeout","console","redirectToCheckout","props","type","destroyElement","getElement","confirmPaymentIntent","data","err","confirmPaymentIntentWithSavedCard","createPaymentMethod","client_secret","getPaymentIntent","id","createPaymentConsent","getDeviceFingerprint"],"mappings":";AAiBA,MAAMA,EAAW,CACfC,KAAM,yBACNC,KAAM,8BACNC,QAAS,iCAKTC,GAAI,uBACJC,QAAS,4BACTC,IAAK,kBAoBMC,EAAiBC,GAA8B,WAAWR,EAASQ,IAAQR,EAASC,OAE3FQ,EAAgB,gDAWTC,EAAmBC,IAC9B,MAAMC,EAASC,SAASC,cAAc,UACtCF,EAAOG,IAAM,GAAGJ,IAAaF,IAC7BG,EAAOI,YAAc,YAErB,MAAMC,EAAaJ,SAASK,MAAQL,SAASM,KAE7C,IAAKF,EACH,MAAM,IAAIG,MAAM,6FAKlB,OAFAH,EAAWI,YAAYT,GAEhBA,GAcIU,EAAwCC,MAAOC,IAC1D,GAAsB,oBAAXC,OACT,OAAO,KAGT,GAAIA,OAAOC,UACT,OAAOD,OAAOC,UAIhB,IAAIC,EAAc,EAClB,MAEMC,EAAeL,UACnB,MAAMX,EACJC,SAASgB,cAAc,eAAepB,oBAAgCA,SACtEC,EAAgBH,GAAciB,MAAAA,SAAAA,EAAShB,MAAO,SAEhD,OAAO,IAAIsB,SAAQ,CAACC,EAASC,KAC3BpB,EAAOqB,iBAAiB,QAAQ,KAC1BR,OAAOC,WACTD,OAAOC,UAAUQ,KAAKV,GACtBO,EAAQN,OAAOC,YAEfM,EAAO,IAAIZ,MAAM,8CAIrBR,EAAOqB,iBAAiB,SAAS,KAC/BD,EAAO,IAAIZ,MAAM,qCACjBR,EAAOuB,QAAUvB,EAAOuB,gBAK9B,K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,MADAR,QAAQF,MAAMU,GACR,IAAI1B,MAAM0B,KAoCPM,EAAsD7B,MAAOsB,IACxE,GAAKpB,OAAOC,UAKV,OAAOD,OAAOC,UAAU0B,qBAAqBP,GALxB,CACrB,MAAMC,EAAM,wDAEZ,MADAR,QAAQF,MAAMU,GACR,IAAI1B,MAAM0B,KAiBPO,EAAuDR,GAC3DpB,OAAOC,UAAU2B,qBAAqBR,GAG/C,MAAe,CACbtC,cAAAA,EACAe,cAAAA,EACAZ,gBAAAA,EACAwB,KAAAA,EACAK,mBAAAA,EACAzB,cAAAA,EACA4B,eAAAA,EACAW,qBAAAA,EACAV,WAAAA,EACAO,iBAAAA,EACAF,oBAAAA,EACAI,qBAAAA,EACAR,qBAAAA,EACAG,kCAAAA"}
@@ -1,3 +1,3 @@
1
- /* Airwallex Checkout Component Version [1.9.0] */
2
- var Airwallex=function(e){"use strict";const r={prod:"checkout.airwallex.com",demo:"checkout-demo.airwallex.com",staging:"checkout-staging.airwallex.com",qa:"checkoutui.qa.awx.im",preview:"checkoutui.preview.awx.im",dev:"localhost:3000"},n=e=>`https://${r[e]||r.prod}`,t="/assets/elements.bundle.min.js?version=1.9.0",o=e=>{const r=document.createElement("script");r.src=`${e}${t}`,r.crossOrigin="anonymous";const n=document.head||document.body;if(!n)throw new Error("Airwallex payment scripts requires a <head> or <body> html element in order to be loaded.");return n.appendChild(r),r},l=async e=>{if("undefined"==typeof window)return null;if(window.Airwallex)return window.Airwallex;let r=0;const l=async()=>{const r=document.querySelector(`script[src="${t}"], script[src="${t}/"]`)||o(n((null==e?void 0:e.env)||"prod"));return new Promise(((n,t)=>{r.addEventListener("load",(()=>{window.Airwallex?(window.Airwallex.init(e),n(window.Airwallex)):t(new Error("Failed to load Airwallex on load event"))})),r.addEventListener("error",(()=>{t(new Error("Failed to load Airwallex scripts")),r.remove&&r.remove()}))}))};for(;r<3;)try{return await l()}catch(e){r++,await new Promise((e=>window.setTimeout(e,500)))}return null},a=e=>{window.Airwallex?window.Airwallex.init(e):console.error("Please loadAirwallex() before init();")},i=e=>{if(window.Airwallex)return window.Airwallex.redirectToCheckout(e);console.error("Please loadAirwallex() before redirectToCheckout();")},w=(e,r)=>window.Airwallex?window.Airwallex.createElement(e,r):(console.error("Please loadAirwallex() before createElement();"),null),d=e=>window.Airwallex?window.Airwallex.destroyElement(e):(console.error("Please loadAirwallex() before destroyElement();"),!1),c=e=>window.Airwallex?window.Airwallex.getElement(e):(console.error("Please loadAirwallex() before getElement();"),null),s=async e=>{if(window.Airwallex)return window.Airwallex.confirmPaymentIntent(e);{const e="Please loadAirwallex() before confirmPaymentIntent();";throw console.error(e),new Error(e)}},m=async e=>{if(window.Airwallex)return window.Airwallex.confirmPaymentIntentWithSavedCard(e);{const e="Please loadAirwallex() before confirmPaymentIntentWithSavedCard();";throw console.error(e),new Error(e)}},x=async(e,r)=>{if(window.Airwallex)return window.Airwallex.createPaymentMethod(e,r);{const e="Please loadAirwallex() before createPaymentMethod();";throw console.error(e),new Error(e)}},u=async(e,r)=>{if(window.Airwallex)return window.Airwallex.getPaymentIntent(e,r);{const e="Please loadAirwallex() before getPaymentIntent();";throw console.error(e),new Error(e)}},A=async e=>{if(window.Airwallex)return window.Airwallex.createPaymentConsent(e);{const e="Please loadAirwallex() before createPaymentConsent();";throw console.error(e),new Error(e)}},y=e=>window.Airwallex.getDeviceFingerprint(e);var f={getGatewayUrl:n,loadAirwallex:l,loadAirwallexJs:o,init:a,redirectToCheckout:i,createElement:w,destroyElement:d,getDeviceFingerprint:y,getElement:c,getPaymentIntent:u,createPaymentMethod:x,createPaymentConsent:A,confirmPaymentIntent:s,confirmPaymentIntentWithSavedCard:m};return e.confirmPaymentIntent=s,e.confirmPaymentIntentWithSavedCard=m,e.createElement=w,e.createPaymentConsent=A,e.createPaymentMethod=x,e.default=f,e.destroyElement=d,e.getDeviceFingerprint=y,e.getElement=c,e.getGatewayUrl=n,e.getPaymentIntent=u,e.init=a,e.loadAirwallex=l,e.loadAirwallexJs=o,e.redirectToCheckout=i,Object.defineProperty(e,"__esModule",{value:!0}),e}({});
1
+ /* Airwallex Checkout Component Version [1.12.0] */
2
+ var Airwallex=function(e){"use strict";const r={prod:"checkout.airwallex.com",demo:"checkout-demo.airwallex.com",staging:"checkout-staging.airwallex.com",qa:"checkoutui.qa.awx.im",preview:"checkoutui.preview.awx.im",dev:"localhost:3000"},n=e=>`https://${r[e]||r.prod}`,t="/assets/elements.bundle.min.js?version=1.12.0",o=e=>{const r=document.createElement("script");r.src=`${e}${t}`,r.crossOrigin="anonymous";const n=document.head||document.body;if(!n)throw new Error("Airwallex payment scripts requires a <head> or <body> html element in order to be loaded.");return n.appendChild(r),r},l=async e=>{if("undefined"==typeof window)return null;if(window.Airwallex)return window.Airwallex;let r=0;const l=async()=>{const r=document.querySelector(`script[src="${t}"], script[src="${t}/"]`)||o(n((null==e?void 0:e.env)||"prod"));return new Promise(((n,t)=>{r.addEventListener("load",(()=>{window.Airwallex?(window.Airwallex.init(e),n(window.Airwallex)):t(new Error("Failed to load Airwallex on load event"))})),r.addEventListener("error",(()=>{t(new Error("Failed to load Airwallex scripts")),r.remove&&r.remove()}))}))};for(;r<3;)try{return await l()}catch(e){r++,await new Promise((e=>window.setTimeout(e,500)))}return null},a=e=>{window.Airwallex?window.Airwallex.init(e):console.error("Please loadAirwallex() before init();")},i=e=>{if(window.Airwallex)return window.Airwallex.redirectToCheckout(e);console.error("Please loadAirwallex() before redirectToCheckout();")},w=(e,r)=>window.Airwallex?window.Airwallex.createElement(e,r):(console.error("Please loadAirwallex() before createElement();"),null),d=e=>window.Airwallex?window.Airwallex.destroyElement(e):(console.error("Please loadAirwallex() before destroyElement();"),!1),c=e=>window.Airwallex?window.Airwallex.getElement(e):(console.error("Please loadAirwallex() before getElement();"),null),s=async e=>{if(window.Airwallex)return window.Airwallex.confirmPaymentIntent(e);{const e="Please loadAirwallex() before confirmPaymentIntent();";throw console.error(e),new Error(e)}},m=async e=>{if(window.Airwallex)return window.Airwallex.confirmPaymentIntentWithSavedCard(e);{const e="Please loadAirwallex() before confirmPaymentIntentWithSavedCard();";throw console.error(e),new Error(e)}},x=async(e,r)=>{if(window.Airwallex)return window.Airwallex.createPaymentMethod(e,r);{const e="Please loadAirwallex() before createPaymentMethod();";throw console.error(e),new Error(e)}},u=async(e,r)=>{if(window.Airwallex)return window.Airwallex.getPaymentIntent(e,r);{const e="Please loadAirwallex() before getPaymentIntent();";throw console.error(e),new Error(e)}},A=async e=>{if(window.Airwallex)return window.Airwallex.createPaymentConsent(e);{const e="Please loadAirwallex() before createPaymentConsent();";throw console.error(e),new Error(e)}},y=e=>window.Airwallex.getDeviceFingerprint(e);var f={getGatewayUrl:n,loadAirwallex:l,loadAirwallexJs:o,init:a,redirectToCheckout:i,createElement:w,destroyElement:d,getDeviceFingerprint:y,getElement:c,getPaymentIntent:u,createPaymentMethod:x,createPaymentConsent:A,confirmPaymentIntent:s,confirmPaymentIntentWithSavedCard:m};return e.confirmPaymentIntent=s,e.confirmPaymentIntentWithSavedCard=m,e.createElement=w,e.createPaymentConsent=A,e.createPaymentMethod=x,e.default=f,e.destroyElement=d,e.getDeviceFingerprint=y,e.getElement=c,e.getGatewayUrl=n,e.getPaymentIntent=u,e.init=a,e.loadAirwallex=l,e.loadAirwallexJs=o,e.redirectToCheckout=i,Object.defineProperty(e,"__esModule",{value:!0}),e}({});
3
3
  //# sourceMappingURL=airwallex.iife.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"airwallex.iife.js","sources":["../../src/index.ts"],"sourcesContent":["import Airwallex, {\n init as initFn,\n redirectToCheckout as redirectToCheckoutFn,\n createElement as createElementFn,\n destroyElement as destroyElementFn,\n getElement as getElementFn,\n confirmPaymentIntent as confirmPaymentIntentFn,\n confirmPaymentIntentWithSavedCard as confirmPaymentIntentWithSavedCardFn,\n createPaymentMethod as createPaymentMethodFn,\n getPaymentIntent as getPaymentIntentFn,\n createPaymentConsent as createPaymentConsentFn,\n AirwallexEnv,\n} from '../types/airwallex';\nimport { getDeviceFingerprint as getDeviceFingerprintFn } from '../types/fraud';\nimport { loadAirwallex as loadAirwallexFn } from '../types/index';\nimport { version } from '../package.json';\n\nconst ENV_HOST = {\n prod: 'checkout.airwallex.com',\n demo: 'checkout-demo.airwallex.com',\n staging: 'checkout-staging.airwallex.com',\n /**\n * Below env only for the npm package development\n * Should not using them when integrate with Airwallex\n */\n qa: 'checkoutui.qa.awx.im',\n preview: 'checkoutui.preview.awx.im',\n dev: 'localhost:3000',\n};\n\ndeclare global {\n interface Window {\n Airwallex: Airwallex;\n ReactNativeWebView: {\n postMessage: (message: string) => void;\n };\n }\n}\n\n/**\n * @example\n * ```ts \nimport { gatewayUrl } from 'airwallex-payment-elements';\nconst gatewayUrl = getGatewayUrl('prod');\n```\n */\n\nexport const getGatewayUrl = (env: AirwallexEnv): string => `https://${ENV_HOST[env] || ENV_HOST.prod}`;\n\nconst STATIC_JS_URL = `/assets/elements.bundle.min.js?version=${version}`;\n\n/**\n * @example\n * ```ts \nimport { loadAirwallexJs } from 'airwallex-payment-elements';\nconst gatewayUrl = getGatewayUrl('prod');\nloadAirwallexJs(gatewayUrl);\n```\n */\n\nexport const loadAirwallexJs = (gatewayUrl: string): HTMLScriptElement => {\n const script = document.createElement('script');\n script.src = `${gatewayUrl}${STATIC_JS_URL}`;\n script.crossOrigin = 'anonymous';\n\n const headOrBody = document.head || document.body;\n\n if (!headOrBody) {\n throw new Error('Airwallex payment scripts requires a <head> or <body> html element in order to be loaded.');\n }\n\n headOrBody.appendChild(script);\n\n return script;\n};\n\n/**\n * @example\n * ```ts \nimport { loadAirwallex } from 'airwallex-payment-elements';\nloadAirwallex({\n env: 'prod',\n locale: 'en',\n});\n```\n */\n\nexport const loadAirwallex: typeof loadAirwallexFn = async (options) => {\n if (typeof window === 'undefined') {\n return null;\n }\n\n if (window.Airwallex) {\n return window.Airwallex;\n }\n\n const MAX_RETRY_COUNT = 3;\n let RETRY_COUNT = 0;\n const sleep = () => new Promise((resolve) => window.setTimeout(resolve, 500));\n\n const tryToResolve = async (): Promise<Airwallex> => {\n const script: HTMLScriptElement =\n document.querySelector(`script[src=\"${STATIC_JS_URL}\"], script[src=\"${STATIC_JS_URL}/\"]`) ||\n loadAirwallexJs(getGatewayUrl(options?.env || 'prod'));\n\n return new Promise((resolve, reject) => {\n script.addEventListener('load', () => {\n if (window.Airwallex) {\n window.Airwallex.init(options);\n resolve(window.Airwallex);\n } else {\n reject(new Error('Failed to load Airwallex on load event'));\n }\n });\n\n script.addEventListener('error', () => {\n reject(new Error('Failed to load Airwallex scripts'));\n script.remove && script.remove();\n });\n });\n };\n\n while (RETRY_COUNT < MAX_RETRY_COUNT) {\n try {\n return await tryToResolve();\n } catch (error) {\n RETRY_COUNT++;\n await sleep();\n }\n }\n\n return null;\n};\n\n/**\n * @example\n * ```ts \nimport { init } from 'airwallex-payment-elements';\ninit({\n env: 'prod',\n locale: 'en',\n});\n```\n */\n\nexport const init: typeof initFn = (options) => {\n if (!window.Airwallex) {\n console.error('Please loadAirwallex() before init();');\n } else {\n window.Airwallex.init(options);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { redirectToCheckout } from 'airwallex-payment-elements';\nredirectToCheckout({\n env: 'prod',\n intent_id: 'replace-with-your-intent_id',\n client_secret: 'replace-with-your-client-secret',,\n successUrl: `${window.location.origin}/checkout-success?isTesting=N`,\n locale: 'replace-with-your-language',\n showTermLink: true,\n theme: {\n variant: 'bootstrap',\n fonts: [\n {\n src: 'https://checkout.airwallex.com/fonts/CircularXXWeb/CircularXXSub-BoldSubset.woff2',\n family: 'AxLLCircular',\n weight: '700',\n },\n {\n src: 'https://checkout.airwallex.com/fonts/CircularXXWeb/CircularXXWeb-Regular.woff2',\n family: 'AxLLCircular',\n weight: '400',\n },\n ],\n popupWidth: 418,\n popupHeight: 549,\n },\n applePayRequestOptions: {\n countryCode: 'US',\n },\n googlePayRequestOptions: {\n countryCode: 'US',\n },\n requiredBillingContactFields: ['email', 'name'],\n currency: 'HKD',\n});\n```\n */\n\nexport const redirectToCheckout: typeof redirectToCheckoutFn = (props) => {\n if (!window.Airwallex) {\n console.error('Please loadAirwallex() before redirectToCheckout();');\n } else {\n return window.Airwallex.redirectToCheckout(props);\n }\n};\n\n/**\n * We encourage to use `dropIn` element, since it's easy to scale new payment methods\n * We suggest to NOT use `applePayButton`, `googlePayButton`, `wechat`, `qrcode`, `redirect`, `fullFeaturedCard` and `directDebit` elements\n * \n * @example\n * ```ts \nimport { createElement } from 'airwallex-payment-elements';\nconst element = createElement('dropIn', {\n intent_id: 'replace-with-your-intent_id',\n client_secret: 'replace-with-your-client-secret',\n currency: 'replace-with-your-intent-currency',\n // if you want to use apple pay, please pass merchant country code in applePayRequestOptions\n applePayRequestOptions: {\n countryCode: 'replace-with-your-country-code',\n },\n // if you want to use google pay, please pass merchant country code in googlePayRequestOptions\n googlePayRequestOptions: {\n countryCode: 'replace-with-your-country-code',\n },\n});\n```\n */\n\nexport const createElement: typeof createElementFn = (type, options) => {\n if (!window.Airwallex) {\n console.error('Please loadAirwallex() before createElement();');\n return null;\n } else {\n return window.Airwallex.createElement(type, options);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { destroyElement } from 'airwallex-payment-elements';\ndestroyElement('dropIn');\n```\n */\n\nexport const destroyElement: typeof destroyElementFn = (type) => {\n if (!window.Airwallex) {\n console.error('Please loadAirwallex() before destroyElement();');\n return false;\n } else {\n return window.Airwallex.destroyElement(type);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { getElement } from 'airwallex-payment-elements';\ngetElement('dropIn');\n```\n */\n\nexport const getElement: typeof getElementFn = (type) => {\n if (!window.Airwallex) {\n console.error('Please loadAirwallex() before getElement();');\n return null;\n } else {\n return window.Airwallex.getElement(type);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { confirmPaymentIntent } from 'airwallex-payment-elements';\nconfirmPaymentIntent({\n element: card, // Provide Card element\n intent_id: 'replace-with-your-intent_id', // Payment Intent ID\n client_secret: 'replace-with-your-client-secret', // Client Secret\n payment_method_options: {\n card: {\n auto_capture: true,\n },\n },\n})\n```\n */\n\nexport const confirmPaymentIntent: typeof confirmPaymentIntentFn = async (data) => {\n if (!window.Airwallex) {\n const err = 'Please loadAirwallex() before confirmPaymentIntent();';\n console.error(err);\n throw new Error(err);\n } else {\n return window.Airwallex.confirmPaymentIntent(data);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { confirmPaymentIntentWithSavedCard } from 'airwallex-payment-elements';\nconfirmPaymentIntentWithSavedCard({\n element: card, // Provide Card element\n customer_id: 'replace-with-your-customer-id',\n methodId: 'replace-with-your-method-id',\n intent_id: 'replace-with-your-intent_id', // Payment Intent ID\n client_secret: 'replace-with-your-client-secret', // Client Secret\n})\n```\n */\n\nexport const confirmPaymentIntentWithSavedCard: typeof confirmPaymentIntentWithSavedCardFn = async (data) => {\n if (!window.Airwallex) {\n const err = 'Please loadAirwallex() before confirmPaymentIntentWithSavedCard();';\n console.error(err);\n throw new Error(err);\n } else {\n return window.Airwallex.confirmPaymentIntentWithSavedCard(data);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { createPaymentMethod } from 'airwallex-payment-elements';\ncreatePaymentMethod('replace-with-your-client-secret', {\n element: card, // Provide Card element\n customer_id: 'replace-with-your-customer-id',\n})\n```\n */\n\nexport const createPaymentMethod: typeof createPaymentMethodFn = async (client_secret, data) => {\n if (!window.Airwallex) {\n const err = 'Please loadAirwallex() before createPaymentMethod();';\n console.error(err);\n throw new Error(err);\n } else {\n return window.Airwallex.createPaymentMethod(client_secret, data);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { getPaymentIntent } from 'airwallex-payment-elements';\ngetPaymentIntent('replace-with-your-intent_id', 'replace-with-your-client_secret')\n```\n */\n\nexport const getPaymentIntent: typeof getPaymentIntentFn = async (id, client_secret) => {\n if (!window.Airwallex) {\n const err = 'Please loadAirwallex() before getPaymentIntent();';\n console.error(err);\n throw new Error(err);\n } else {\n return window.Airwallex.getPaymentIntent(id, client_secret);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { createPaymentConsent } from 'airwallex-payment-elements';\ncreatePaymentConsent({\n intent_id: 'replace-with-your-intent_id',\n customer_id: 'replace-with-your-customer_id',\n cardname: 'replace-with-your-card_name',\n client_secret: 'replace-with-your-client_secret',\n currency: 'HKD,\n element: cardNumberElement,\n next_triggered_by: 'customer',\n billing: {\n email: 'test@airwallex.com',\n first_name: 'TEST',\n last_name: 'TEST',\n date_of_birth: '2020-07-05',\n phone_number: '13333333333',\n address: {\n city: 'shanghai',\n country_code: 'CN',\n postcode: '200000',\n state: 'Shanghai',\n street: 'Street',\n },\n },\n})\n```\n */\n\nexport const createPaymentConsent: typeof createPaymentConsentFn = async (data) => {\n if (!window.Airwallex) {\n const err = 'Please loadAirwallex() before createPaymentConsent();';\n console.error(err);\n throw new Error(err);\n } else {\n return window.Airwallex.createPaymentConsent(data);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { getDeviceFingerprint } from 'airwallex-payment-elements';\ngetDeviceFingerprint({\n intent_id: 'replace-with-your-intent_id',\n env: 'prod',\n})\n```\n */\n\nexport const getDeviceFingerprint: typeof getDeviceFingerprintFn = (data) => {\n return window.Airwallex.getDeviceFingerprint(data);\n};\n\nexport default {\n getGatewayUrl,\n loadAirwallex,\n loadAirwallexJs,\n init,\n redirectToCheckout,\n createElement,\n destroyElement,\n getDeviceFingerprint,\n getElement,\n getPaymentIntent,\n createPaymentMethod,\n createPaymentConsent,\n confirmPaymentIntent,\n confirmPaymentIntentWithSavedCard,\n};\n"],"names":["ENV_HOST","prod","demo","staging","qa","preview","dev","getGatewayUrl","env","STATIC_JS_URL","loadAirwallexJs","gatewayUrl","script","document","createElement","src","crossOrigin","headOrBody","head","body","Error","appendChild","loadAirwallex","async","options","window","Airwallex","RETRY_COUNT","tryToResolve","querySelector","Promise","resolve","reject","addEventListener","init","remove","error","setTimeout","console","redirectToCheckout","props","type","destroyElement","getElement","confirmPaymentIntent","data","err","confirmPaymentIntentWithSavedCard","createPaymentMethod","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AAA,EACAe,cAAAA,EACAZ,gBAAAA,EACAwB,KAAAA,EACAK,mBAAAA,EACAzB,cAAAA,EACA4B,eAAAA,EACAW,qBAAAA,EACAV,WAAAA,EACAO,iBAAAA,EACAF,oBAAAA,EACAI,qBAAAA,EACAR,qBAAAA,EACAG,kCAAAA"}
1
+ {"version":3,"file":"airwallex.iife.js","sources":["../../src/index.ts"],"sourcesContent":["import Airwallex, {\n init as initFn,\n redirectToCheckout as redirectToCheckoutFn,\n createElement as createElementFn,\n destroyElement as destroyElementFn,\n getElement as getElementFn,\n confirmPaymentIntent as confirmPaymentIntentFn,\n confirmPaymentIntentWithSavedCard as confirmPaymentIntentWithSavedCardFn,\n createPaymentMethod as createPaymentMethodFn,\n getPaymentIntent as getPaymentIntentFn,\n createPaymentConsent as createPaymentConsentFn,\n AirwallexEnv,\n} from '../types/airwallex';\nimport { getDeviceFingerprint as getDeviceFingerprintFn } from '../types/fraud';\nimport { loadAirwallex as loadAirwallexFn } from '../types/index';\nimport { version } from '../package.json';\n\nconst ENV_HOST = {\n prod: 'checkout.airwallex.com',\n demo: 'checkout-demo.airwallex.com',\n staging: 'checkout-staging.airwallex.com',\n /**\n * Below env only for the npm package development\n * Should not using them when integrate with Airwallex\n */\n qa: 'checkoutui.qa.awx.im',\n preview: 'checkoutui.preview.awx.im',\n dev: 'localhost:3000',\n};\n\ndeclare global {\n interface Window {\n Airwallex: Airwallex;\n ReactNativeWebView: {\n postMessage: (message: string) => void;\n };\n }\n}\n\n/**\n * @example\n * ```ts \nimport { gatewayUrl } from 'airwallex-payment-elements';\nconst gatewayUrl = getGatewayUrl('prod');\n```\n */\n\nexport const getGatewayUrl = (env: AirwallexEnv): string => `https://${ENV_HOST[env] || ENV_HOST.prod}`;\n\nconst STATIC_JS_URL = `/assets/elements.bundle.min.js?version=${version}`;\n\n/**\n * @example\n * ```ts \nimport { loadAirwallexJs } from 'airwallex-payment-elements';\nconst gatewayUrl = getGatewayUrl('prod');\nloadAirwallexJs(gatewayUrl);\n```\n */\n\nexport const loadAirwallexJs = (gatewayUrl: string): HTMLScriptElement => {\n const script = document.createElement('script');\n script.src = `${gatewayUrl}${STATIC_JS_URL}`;\n script.crossOrigin = 'anonymous';\n\n const headOrBody = document.head || document.body;\n\n if (!headOrBody) {\n throw new Error('Airwallex payment scripts requires a <head> or <body> html element in order to be loaded.');\n }\n\n headOrBody.appendChild(script);\n\n return script;\n};\n\n/**\n * @example\n * ```ts \nimport { loadAirwallex } from 'airwallex-payment-elements';\nloadAirwallex({\n env: 'prod',\n locale: 'en',\n});\n```\n */\n\nexport const loadAirwallex: typeof loadAirwallexFn = async (options) => {\n if (typeof window === 'undefined') {\n return null;\n }\n\n if (window.Airwallex) {\n return window.Airwallex;\n }\n\n const MAX_RETRY_COUNT = 3;\n let RETRY_COUNT = 0;\n const sleep = () => new Promise((resolve) => window.setTimeout(resolve, 500));\n\n const tryToResolve = async (): Promise<Airwallex> => {\n const script: HTMLScriptElement =\n document.querySelector(`script[src=\"${STATIC_JS_URL}\"], script[src=\"${STATIC_JS_URL}/\"]`) ||\n loadAirwallexJs(getGatewayUrl(options?.env || 'prod'));\n\n return new Promise((resolve, reject) => {\n script.addEventListener('load', () => {\n if (window.Airwallex) {\n window.Airwallex.init(options);\n resolve(window.Airwallex);\n } else {\n reject(new Error('Failed to load Airwallex on load event'));\n }\n });\n\n script.addEventListener('error', () => {\n reject(new Error('Failed to load Airwallex scripts'));\n script.remove && script.remove();\n });\n });\n };\n\n while (RETRY_COUNT < MAX_RETRY_COUNT) {\n try {\n return await tryToResolve();\n } catch (error) {\n RETRY_COUNT++;\n await sleep();\n }\n }\n\n return null;\n};\n\n/**\n * @example\n * ```ts \nimport { init } from 'airwallex-payment-elements';\ninit({\n env: 'prod',\n locale: 'en',\n});\n```\n */\n\nexport const init: typeof initFn = (options) => {\n if (!window.Airwallex) {\n console.error('Please loadAirwallex() before init();');\n } else {\n window.Airwallex.init(options);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { redirectToCheckout } from 'airwallex-payment-elements';\nredirectToCheckout({\n env: 'prod',\n intent_id: 'replace-with-your-intent_id',\n client_secret: 'replace-with-your-client-secret',,\n successUrl: `${window.location.origin}/checkout-success?isTesting=N`,\n locale: 'replace-with-your-language',\n showTermLink: true,\n theme: {\n variant: 'bootstrap',\n fonts: [\n {\n src: 'https://checkout.airwallex.com/fonts/CircularXXWeb/CircularXXSub-BoldSubset.woff2',\n family: 'AxLLCircular',\n weight: '700',\n },\n {\n src: 'https://checkout.airwallex.com/fonts/CircularXXWeb/CircularXXWeb-Regular.woff2',\n family: 'AxLLCircular',\n weight: '400',\n },\n ],\n popupWidth: 418,\n popupHeight: 549,\n },\n applePayRequestOptions: {\n countryCode: 'US',\n },\n googlePayRequestOptions: {\n countryCode: 'US',\n },\n requiredBillingContactFields: ['email', 'name'],\n currency: 'HKD',\n});\n```\n */\n\nexport const redirectToCheckout: typeof redirectToCheckoutFn = (props) => {\n if (!window.Airwallex) {\n console.error('Please loadAirwallex() before redirectToCheckout();');\n } else {\n return window.Airwallex.redirectToCheckout(props);\n }\n};\n\n/**\n * We encourage to use `dropIn` element, since it's easy to scale new payment methods\n * We suggest to NOT use `applePayButton`, `googlePayButton`, `wechat`, `qrcode`, `redirect`, `fullFeaturedCard` and `directDebit` elements\n * \n * @example\n * ```ts \nimport { createElement } from 'airwallex-payment-elements';\nconst element = createElement('dropIn', {\n intent_id: 'replace-with-your-intent_id',\n client_secret: 'replace-with-your-client-secret',\n currency: 'replace-with-your-intent-currency',\n // if you want to use apple pay, please pass merchant country code in applePayRequestOptions\n applePayRequestOptions: {\n countryCode: 'replace-with-your-country-code',\n },\n // if you want to use google pay, please pass merchant country code in googlePayRequestOptions\n googlePayRequestOptions: {\n countryCode: 'replace-with-your-country-code',\n },\n});\n```\n */\n\nexport const createElement: typeof createElementFn = (type, options) => {\n if (!window.Airwallex) {\n console.error('Please loadAirwallex() before createElement();');\n return null;\n } else {\n return window.Airwallex.createElement(type, options);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { destroyElement } from 'airwallex-payment-elements';\ndestroyElement('dropIn');\n```\n */\n\nexport const destroyElement: typeof destroyElementFn = (type) => {\n if (!window.Airwallex) {\n console.error('Please loadAirwallex() before destroyElement();');\n return false;\n } else {\n return window.Airwallex.destroyElement(type);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { getElement } from 'airwallex-payment-elements';\ngetElement('dropIn');\n```\n */\n\nexport const getElement: typeof getElementFn = (type) => {\n if (!window.Airwallex) {\n console.error('Please loadAirwallex() before getElement();');\n return null;\n } else {\n return window.Airwallex.getElement(type);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { confirmPaymentIntent } from 'airwallex-payment-elements';\nconfirmPaymentIntent({\n element: card, // Provide Card element\n intent_id: 'replace-with-your-intent_id', // Payment Intent ID\n client_secret: 'replace-with-your-client-secret', // Client Secret\n payment_method_options: {\n card: {\n auto_capture: true,\n },\n },\n})\n```\n */\n\nexport const confirmPaymentIntent: typeof confirmPaymentIntentFn = async (data) => {\n if (!window.Airwallex) {\n const err = 'Please loadAirwallex() before confirmPaymentIntent();';\n console.error(err);\n throw new Error(err);\n } else {\n return window.Airwallex.confirmPaymentIntent(data);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { confirmPaymentIntentWithSavedCard } from 'airwallex-payment-elements';\nconfirmPaymentIntentWithSavedCard({\n element: card, // Provide Card element\n customer_id: 'replace-with-your-customer-id',\n methodId: 'replace-with-your-method-id',\n intent_id: 'replace-with-your-intent_id', // Payment Intent ID\n client_secret: 'replace-with-your-client-secret', // Client Secret\n})\n```\n */\n\nexport const confirmPaymentIntentWithSavedCard: typeof confirmPaymentIntentWithSavedCardFn = async (data) => {\n if (!window.Airwallex) {\n const err = 'Please loadAirwallex() before confirmPaymentIntentWithSavedCard();';\n console.error(err);\n throw new Error(err);\n } else {\n return window.Airwallex.confirmPaymentIntentWithSavedCard(data);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { createPaymentMethod } from 'airwallex-payment-elements';\ncreatePaymentMethod('replace-with-your-client-secret', {\n element: card, // Provide Card element\n customer_id: 'replace-with-your-customer-id',\n})\n```\n */\n\nexport const createPaymentMethod: typeof createPaymentMethodFn = async (client_secret, data) => {\n if (!window.Airwallex) {\n const err = 'Please loadAirwallex() before createPaymentMethod();';\n console.error(err);\n throw new Error(err);\n } else {\n return window.Airwallex.createPaymentMethod(client_secret, data);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { getPaymentIntent } from 'airwallex-payment-elements';\ngetPaymentIntent('replace-with-your-intent_id', 'replace-with-your-client_secret')\n```\n */\n\nexport const getPaymentIntent: typeof getPaymentIntentFn = async (id, client_secret) => {\n if (!window.Airwallex) {\n const err = 'Please loadAirwallex() before getPaymentIntent();';\n console.error(err);\n throw new Error(err);\n } else {\n return window.Airwallex.getPaymentIntent(id, client_secret);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { createPaymentConsent } from 'airwallex-payment-elements';\ncreatePaymentConsent({\n intent_id: 'replace-with-your-intent_id',\n customer_id: 'replace-with-your-customer_id',\n cardname: 'replace-with-your-card_name',\n client_secret: 'replace-with-your-client_secret',\n currency: 'HKD,\n element: cardNumberElement,\n next_triggered_by: 'customer',\n billing: {\n email: 'test@airwallex.com',\n first_name: 'TEST',\n last_name: 'TEST',\n date_of_birth: '2020-07-05',\n phone_number: '13333333333',\n address: {\n city: 'shanghai',\n country_code: 'CN',\n postcode: '200000',\n state: 'Shanghai',\n street: 'Street',\n },\n },\n})\n```\n */\n\nexport const createPaymentConsent: typeof createPaymentConsentFn = async (data) => {\n if (!window.Airwallex) {\n const err = 'Please loadAirwallex() before createPaymentConsent();';\n console.error(err);\n throw new Error(err);\n } else {\n return window.Airwallex.createPaymentConsent(data);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { getDeviceFingerprint } from 'airwallex-payment-elements';\ngetDeviceFingerprint({\n intent_id: 'replace-with-your-intent_id',\n env: 'prod',\n})\n```\n */\n\nexport const getDeviceFingerprint: typeof getDeviceFingerprintFn = (data) => {\n return window.Airwallex.getDeviceFingerprint(data);\n};\n\nexport default {\n getGatewayUrl,\n loadAirwallex,\n loadAirwallexJs,\n init,\n redirectToCheckout,\n createElement,\n destroyElement,\n getDeviceFingerprint,\n getElement,\n getPaymentIntent,\n createPaymentMethod,\n createPaymentConsent,\n confirmPaymentIntent,\n confirmPaymentIntentWithSavedCard,\n};\n"],"names":["ENV_HOST","prod","demo","staging","qa","preview","dev","getGatewayUrl","env","STATIC_JS_URL","loadAirwallexJs","gatewayUrl","script","document","createElement","src","crossOrigin","headOrBody","head","body","Error","appendChild","loadAirwallex","async","options","window","Airwallex","RETRY_COUNT","tryToResolve","querySelector","Promise","resolve","reject","addEventListener","init","remove","error","setTimeout","console","redirectToCheckout","props","type","destroyElement","getElement","confirmPaymentIntent","data","err","confirmPaymentIntentWithSavedCard","createPaymentMethod","client_secret","getPaymentIntent","id","createPaymentConsent","getDeviceFingerprint"],"mappings":";uCAiBA,MAAMA,EAAW,CACfC,KAAM,yBACNC,KAAM,8BACNC,QAAS,iCAKTC,GAAI,uBACJC,QAAS,4BACTC,IAAK,kBAoBMC,EAAiBC,GAA8B,WAAWR,EAASQ,IAAQR,EAASC,OAE3FQ,EAAgB,gDAWTC,EAAmBC,IAC9B,MAAMC,EAASC,SAASC,cAAc,UACtCF,EAAOG,IAAM,GAAGJ,IAAaF,IAC7BG,EAAOI,YAAc,YAErB,MAAMC,EAAaJ,SAASK,MAAQL,SAASM,KAE7C,IAAKF,EACH,MAAM,IAAIG,MAAM,6FAKlB,OAFAH,EAAWI,YAAYT,GAEhBA,GAcIU,EAAwCC,MAAOC,IAC1D,GAAsB,oBAAXC,OACT,OAAO,KAGT,GAAIA,OAAOC,UACT,OAAOD,OAAOC,UAIhB,IAAIC,EAAc,EAClB,MAEMC,EAAeL,UACnB,MAAMX,EACJC,SAASgB,cAAc,eAAepB,oBAAgCA,SACtEC,EAAgBH,GAAciB,MAAAA,SAAAA,EAAShB,MAAO,SAEhD,O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B,OAAOC,UAKV,OAAOD,OAAOC,UAAUsB,oBAAoBC,EAAeJ,GALtC,CACrB,MAAMC,EAAM,uDAEZ,MADAR,QAAQF,MAAMU,GACR,IAAI1B,MAAM0B,KAcPI,EAA8C3B,MAAO4B,EAAIF,KACpE,GAAKxB,OAAOC,UAKV,OAAOD,OAAOC,UAAUwB,iBAAiBC,EAAIF,GALxB,CACrB,MAAMH,EAAM,oDAEZ,MADAR,QAAQF,MAAMU,GACR,IAAI1B,MAAM0B,KAoCPM,EAAsD7B,MAAOsB,IACxE,GAAKpB,OAAOC,UAKV,OAAOD,OAAOC,UAAU0B,qBAAqBP,GALxB,CACrB,MAAMC,EAAM,wDAEZ,MADAR,QAAQF,MAAMU,GACR,IAAI1B,MAAM0B,KAiBPO,EAAuDR,GAC3DpB,OAAOC,UAAU2B,qBAAqBR,SAGhC,CACbtC,cAAAA,EACAe,cAAAA,EACAZ,gBAAAA,EACAwB,KAAAA,EACAK,mBAAAA,EACAzB,cAAAA,EACA4B,eAAAA,EACAW,qBAAAA,EACAV,WAAAA,EACAO,iBAAAA,EACAF,oBAAAA,EACAI,qBAAAA,EACAR,qBAAAA,EACAG,kCAAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "airwallex-payment-elements",
3
- "version": "1.9.0",
3
+ "version": "1.12.0",
4
4
  "module": "lib/bin/airwallex.es.js",
5
5
  "main": "lib/bin/airwallex.cjs.js",
6
6
  "bin": "lib/bin/airwallex.cjs.js",
@@ -8,6 +8,7 @@ import {
8
8
  FullFeaturedCardElementOptions,
9
9
  WechatElementOptions,
10
10
  ApplePayButtonOptions,
11
+ GooglePayButtonOptions,
11
12
  } from './element';
12
13
  import { QrcodeElementOptions } from './qrcodeElement';
13
14
  import { Intent, PaymentMethodBasicInfo } from './cardNumber';
@@ -69,6 +70,8 @@ export type AirwallexEnv = 'dev' | 'preview' | 'qa' | 'staging' | 'demo' | 'prod
69
70
 
70
71
  export type Mode = 'payment' | 'recurring';
71
72
 
73
+ export type AuthorizationType = 'pre_auth' | 'final_auth';
74
+
72
75
  /**
73
76
  * Global init option config for Airwallex javascript SDK
74
77
  */
@@ -187,9 +190,15 @@ export interface HostPaymentPage {
187
190
  */
188
191
  methods?: Array<PaymentMethodType>;
189
192
  /**
190
- * Only support for card payment, indicate whether to capture immediate when authentication success
193
+ * Specifies whether the funds should be requested automatically after the payment is authorized. Set it to `false` if you want to capture the funds sometime later.
194
+ * @defaultValue `true` if authorization type is `final_auth` and `false` for `pre_auth`.
191
195
  */
192
196
  autoCapture?: boolean;
197
+ /**
198
+ * The authorization type of the card payment. Set it to `pre_auth` if you want to place a hold on your customer’s card for more than 7 days. Currently it's only available when the card brand is visa or mastercard. You should also set `auto_capture` to be false if you want to enable pre-auth.
199
+ * @defaultValue `final_auth`
200
+ */
201
+ authorizationType?: AuthorizationType;
193
202
  /**
194
203
  * The success return url after shopper succeeded the payment
195
204
  */
@@ -379,9 +388,15 @@ export interface PaymentMethod {
379
388
  */
380
389
  card?: {
381
390
  /**
382
- * Only support for card payment, indicate whether to capture immediate when authentication success
391
+ * Specifies whether the funds should be requested automatically after the payment is authorized. Set it to `false` if you want to capture the funds sometime later.
392
+ * @defaultValue `true` if authorization type is `final_auth` and `false` for `pre_auth`.
383
393
  */
384
394
  auto_capture?: boolean;
395
+ /**
396
+ * The authorization type.
397
+ * @defaultValue `final_auth`
398
+ */
399
+ authorization_type?: AuthorizationType;
385
400
  };
386
401
  };
387
402
  /**
@@ -415,52 +430,56 @@ export declare const init: (options?: InitOptions | undefined) => void;
415
430
  export declare const redirectToCheckout: (props: HostPaymentPage) => void | string;
416
431
 
417
432
  /**
418
- * The definition mapping of supported integration element type with it's props options used to customize the element, merchant can check on each element options type for details
419
- * We encourage to use `dropIn` element, since it's easy to scale new payment methods
420
- * We suggest to NOT use `applePayButton`, `googlePayButton`, `wechat`, `qrcode`, `redirect` and `fullFeaturedCard` elements
433
+ * The definition that maps the supported integration element type with its props options used to customize the element. The merchant can check on each element options type for details.
434
+ * We encourage to use `dropIn` element since it scales to new payment methods easily.
435
+ * We suggest to NOT use `applePayButton`, `googlePayButton`, `wechat`, `qrcode`, `redirect` and `fullFeaturedCard` elements.
421
436
  */
422
437
  export interface ElementOptionsTypeMap {
423
438
  /**
424
- * Define card number input element type and it's mapped option type, apply to split card element integration
425
- * Using together with `expiry` and `cvc` element to gain maximum customization
439
+ * Define card number input element type and its mapped option type, apply to split card element integration
440
+ * Use it together with `expiry` and `cvc` element to gain maximum customization.
426
441
  */
427
442
  cardNumber: CardNumberElementOptions;
428
443
  /**
429
- * Define expiry input element type and it's mapped option type, apply to split card element integration
430
- * Using together with `cardNumber` and `cvc` element to gain maximum customization
444
+ * Define expiry input element type and its mapped option type, apply to split card element integration
445
+ * Use it together with `cardNumber` and `cvc` element to gain maximum customization.
431
446
  */
432
447
  expiry: ExpiryDateElementOptions;
433
448
  /**
434
- * Define cvc input element type and it's mapped option type, apply to split card element integration
435
- * Using together with `cardNumber` and `expiry` element to gain maximum customization
449
+ * Define cvc input element type and its mapped option type. It applies to split card element integration.
450
+ * Use it together with `cardNumber` and `expiry` element to gain maximum customization.
436
451
  */
437
452
  cvc: CvcElementOptions;
438
453
  /**
439
- * Define apple pay element type and it's mapped option type
454
+ * Define apple pay element type and its mapped option type.
440
455
  */
441
456
  applePayButton: ApplePayButtonOptions;
442
457
  /**
443
- * Define card element type and it's mapped option type, this integration make the card PCI input (card number / cvc / expiry) behavior like a single input
458
+ * Define google pay element type and its mapped option type.
459
+ */
460
+ googlePayButton: GooglePayButtonOptions;
461
+ /**
462
+ * Define card element type and its mapped option type. This integration makes the card PCI input (card number / cvc / expiry) behave like a single input.
444
463
  */
445
464
  card: CardElementOptions;
446
465
  /**
447
- * Define WeChat element type and it's mapped option type
466
+ * Define WeChat element type and its mapped option type.
448
467
  */
449
468
  wechat: WechatElementOptions;
450
469
  /**
451
- * Define Qrcode element type and it's mapped option type
470
+ * Define Qrcode element type and its mapped option type.
452
471
  */
453
472
  qrcode: QrcodeElementOptions;
454
473
  /**
455
- * Define Redirect element type and it's mapped option type
474
+ * Define Redirect element type and its mapped option type.
456
475
  */
457
476
  redirect: RedirectElementOptions;
458
477
  /**
459
- * Define dropIn element type and it's mapped option type, this integration make integrate with Airwallex supported card and APM (alternative payment method like WeChat etc.) payment method like a single widget
478
+ * Define dropIn element type and its mapped option type. This integration makes integrating with Airwallex supported card and APM (alternative payment method like WeChat etc.) payment method like a single widget.
460
479
  */
461
480
  dropIn: DropInElementOptions;
462
481
  /**
463
- * Define full featured card element type and it's mapped option type, this integration make integrate with Airwallex supported card payment method like a single widget
482
+ * Define full featured card element type and its mapped option type. This integration makes integrating with Airwallex supported card payment method like a single widget.
464
483
  */
465
484
  fullFeaturedCard: FullFeaturedCardElementOptions;
466
485
  }
@@ -538,7 +557,7 @@ export interface Consent {
538
557
  * We encourage to use `dropIn` element, since it's easy to scale new payment methods
539
558
  * We suggest to NOT use `applePayButton`, `googlePayButton`, `wechat`, `qrcode`, `redirect` and `fullFeaturedCard` elements
540
559
  */
541
- export declare function createElement<T extends ElementType>(
560
+ export declare function createElement<T extends keyof ElementOptionsTypeMap>(
542
561
  type: T,
543
562
  options?: ElementOptionsTypeMap[T],
544
563
  ): Element | null;
@@ -78,7 +78,14 @@ export interface PaymentMethodBasicInfo {
78
78
  created_at: string;
79
79
  customer_id: string;
80
80
  status: 'CREATED' | 'VERIFIED' | 'DISABLED';
81
- type: 'card' | 'applepay' | 'googlepay' | 'ach_direct_debit' | 'bacs_direct_debit' | 'becs_direct_debit' | 'sepa_direct_debit';
81
+ type:
82
+ | 'card'
83
+ | 'applepay'
84
+ | 'googlepay'
85
+ | 'ach_direct_debit'
86
+ | 'bacs_direct_debit'
87
+ | 'becs_direct_debit'
88
+ | 'sepa_direct_debit';
82
89
  updated_at: string;
83
90
  card: {
84
91
  avs_check?: string;
@@ -1,5 +1,5 @@
1
1
  import { ElementOptions, PaymentMethodType, BoxStyle } from './element';
2
- import { Mode, RecurringOptions, Billing } from './airwallex';
2
+ import { Mode, RecurringOptions, Billing, AuthorizationType } from './airwallex';
3
3
  import { ApplePayHppOrDropInRequestOptions, GooglePayRequestOptions, ContactField } from './element';
4
4
 
5
5
  /**
@@ -30,9 +30,15 @@ export interface DropInElementOptions extends ElementOptions {
30
30
  */
31
31
  methods?: Array<PaymentMethodType>;
32
32
  /**
33
- * Indicate whether to capture immediate when authentication success
33
+ * Specifies whether the funds should be requested automatically after the payment is authorized. Set it to `false` if you want to capture the funds sometime later.
34
+ * @defaultValue `true` if authorization type is `final_auth` and `false` for `pre_auth`.
34
35
  */
35
36
  autoCapture?: boolean;
37
+ /**
38
+ * The authorization type of the card payment. Set it to `pre_auth` if you want to place a hold on your customer’s card for more than 7 days. Currently it's only available when the card brand is visa or mastercard. You should also set `auto_capture` to be false if you want to enable pre-auth.
39
+ * @defaultValue `final_auth`
40
+ */
41
+ authorizationType?: AuthorizationType;
36
42
  /**
37
43
  * The options of apple pay
38
44
  * If you want to integrate with apple pay, you need to provide the following options
@@ -1,7 +1,7 @@
1
1
  import { Intent, PaymentMethodBasicInfo } from './cardNumber';
2
2
  import { Properties } from 'csstype';
3
3
  import { PaymentMethodWithQrcode, QrcodeElementOptions } from './qrcodeElement';
4
- import { RecurringOptions } from './airwallex';
4
+ import { AuthorizationType, RecurringOptions } from './airwallex';
5
5
  import { DropInElementOptions } from './dropInElement';
6
6
  import { RedirectElementOptions } from './redirectElement';
7
7
  import { Mode, InitOptions } from './airwallex';
@@ -291,6 +291,7 @@ export type ExtendEventDetail = EventDetail & {
291
291
  cardBin?: string;
292
292
  status?: string;
293
293
  auto_capture?: boolean;
294
+ authorization_type?: AuthorizationType;
294
295
  paymentMethod?: PaymentMethodBasicInfo;
295
296
  next_action?: NextAction;
296
297
  testCard?: string;
@@ -404,9 +405,15 @@ export interface CardElementOptions extends ElementOptions {
404
405
  */
405
406
  disabled?: boolean;
406
407
  /**
407
- * Indicate whether to capture immediate when authentication success
408
+ * Specifies whether the funds should be requested automatically after the payment is authorized. Set it to `false` if you want to capture the funds sometime later.
409
+ * @defaultValue `true` if authorization type is `final_auth` and `false` for `pre_auth`.
408
410
  */
409
411
  autoCapture?: boolean;
412
+ /**
413
+ * The authorization type of the card payment. Set it to `pre_auth` if you want to place a hold on your customer’s card for more than 7 days. Currently it's only available when the card brand is visa or mastercard. You should also set `auto_capture` to be false if you want to enable pre-auth.
414
+ * @defaultValue `final_auth`
415
+ */
416
+ authorizationType?: AuthorizationType;
410
417
  /**
411
418
  * One or more card networks that you support.
412
419
  */
@@ -436,9 +443,15 @@ export interface CardNumberElementOptions extends ElementOptions {
436
443
  */
437
444
  intent?: Intent;
438
445
  /**
439
- * Indicate whether to capture immediate when authentication success
446
+ * Specifies whether the funds should be requested automatically after the payment is authorized. Set it to `false` if you want to capture the funds sometime later.
447
+ * @defaultValue `true` if authorization type is `final_auth` and `false` for `pre_auth`.
440
448
  */
441
449
  autoCapture?: boolean;
450
+ /**
451
+ * The authorization type of the card payment. Set it to `pre_auth` if you want to place a hold on your customer’s card for more than 7 days. Currently it's only available when the card brand is visa or mastercard. You should also set `auto_capture` to be false if you want to enable pre-auth.
452
+ * @defaultValue `final_auth`
453
+ */
454
+ authorizationType?: AuthorizationType;
442
455
  /**
443
456
  * One or more card networks that you support.
444
457
  */
@@ -525,9 +538,15 @@ export interface FullFeaturedCardElementOptions extends ElementOptions {
525
538
  */
526
539
  intent?: Intent;
527
540
  /**
528
- * Indicate whether to capture immediate when authentication success, apply when shopper using card payment method
541
+ * Specifies whether the funds should be requested automatically after the payment is authorized. Set it to `false` if you want to capture the funds sometime later.
542
+ * @defaultValue `true` if authorization type is `final_auth` and `false` for `pre_auth`.
529
543
  */
530
544
  autoCapture?: boolean;
545
+ /**
546
+ * The authorization type of the card payment. Set it to `pre_auth` if you want to place a hold on your customer’s card for more than 7 days. Currently it's only available when the card brand is visa or mastercard. You should also set `auto_capture` to be false if you want to enable pre-auth.
547
+ * @defaultValue `final_auth`
548
+ */
549
+ authorizationType?: AuthorizationType;
531
550
  /**
532
551
  * Indicate to improve 3DS experience, indicate if the payment form will collect billing info from shopper
533
552
  */
@@ -846,9 +865,15 @@ export interface GooglePayButtonOptions extends GooglePayRequestOptions, Element
846
865
  };
847
866
 
848
867
  /**
849
- * Indicate whether to capture immediate when authentication success
868
+ * Specifies whether the funds should be requested automatically after the payment is authorized. Set it to `false` if you want to capture the funds sometime later.
869
+ * @defaultValue `true` if authorization type is `final_auth` and `false` for `pre_auth`.
850
870
  */
851
871
  autoCapture?: boolean;
872
+ /**
873
+ * The authorization type of the card payment. Set it to `pre_auth` if you want to place a hold on your customer’s card for more than 7 days. Currently it's only available when the card brand is visa or mastercard. You should also set `auto_capture` to be false if you want to enable pre-auth.
874
+ * @defaultValue `final_auth`
875
+ */
876
+ authorizationType?: AuthorizationType;
852
877
  /**
853
878
  * Container for authentication form, it's an element id
854
879
  */
@@ -924,9 +949,15 @@ export interface ApplePayButtonOptions extends ElementOptions, ApplePayRequestOp
924
949
  currency: string;
925
950
  };
926
951
  /**
927
- * Indicate whether to capture immediate when authentication success
952
+ * Specifies whether the funds should be requested automatically after the payment is authorized. Set it to `false` if you want to capture the funds sometime later.
953
+ * @defaultValue `true` if authorization type is `final_auth` and `false` for `pre_auth`.
928
954
  */
929
955
  autoCapture?: boolean;
956
+ /**
957
+ * The authorization type of the card payment. Set it to `pre_auth` if you want to place a hold on your customer’s card for more than 7 days. Currently it's only available when the card brand is visa or mastercard. You should also set `auto_capture` to be false if you want to enable pre-auth.
958
+ * @defaultValue `final_auth`
959
+ */
960
+ authorizationType?: AuthorizationType;
930
961
  }
931
962
 
932
963
  /**
package/types/fraud.d.ts CHANGED
@@ -1,7 +1,3 @@
1
- import { AirwallexEnv } from './airwallex';
2
- import { Intent } from './cardNumber';
3
- import { ExtendEventDetail } from './element';
4
-
5
1
  /**
6
2
  * The request payload for getDeviceFingerprint
7
3
  *