airwallex-payment-elements 1.89.0 → 1.104.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.gitlab-ci.yml +63 -3
- package/lib/bin/airwallex.cjs.js +2 -2
- package/lib/bin/airwallex.cjs.js.map +1 -1
- package/lib/bin/airwallex.es.js +2 -2
- package/lib/bin/airwallex.es.js.map +1 -1
- package/lib/bin/airwallex.iife.js +2 -2
- package/lib/bin/airwallex.iife.js.map +1 -1
- package/package.json +4 -3
- package/typedoc.config.js +4 -0
- package/types/airwallex.d.ts +95 -18
- package/types/dropInElement.d.ts +12 -0
- package/types/element.d.ts +377 -322
- package/types/index.d.ts +6 -0
package/.gitlab-ci.yml
CHANGED
|
@@ -21,19 +21,26 @@ cache:
|
|
|
21
21
|
- .yarn
|
|
22
22
|
- node_modules
|
|
23
23
|
|
|
24
|
+
.upload_types_script: &upload_types_script
|
|
25
|
+
- gsutil cp dist/types.d.ts gs://${BUCKET_NAME}/temp/types/types.d.ts
|
|
26
|
+
- gsutil -m setmeta -r -h "Cache-Control:no-store,no-cache,max-age=0" gs://${BUCKET_NAME}/temp/types/types.d.ts
|
|
27
|
+
- gsutil -m rsync -r gs://${BUCKET_NAME}/temp/ gs://${BUCKET_NAME}/
|
|
28
|
+
- gsutil -m rm -r gs://${BUCKET_NAME}/temp
|
|
29
|
+
|
|
30
|
+
|
|
24
31
|
stages:
|
|
25
32
|
- test
|
|
26
33
|
- build
|
|
27
34
|
- deploy-doc-dev
|
|
28
35
|
- deploy-doc-staging
|
|
29
36
|
- publish-gitlab-package
|
|
30
|
-
- build-types
|
|
31
|
-
- upload-types-
|
|
37
|
+
- build-types
|
|
38
|
+
- upload-types-staging
|
|
32
39
|
- approve
|
|
33
40
|
- deploy-doc-demo
|
|
34
41
|
- deploy-doc-prod
|
|
35
42
|
- publish-npm-package
|
|
36
|
-
- upload-types-
|
|
43
|
+
- upload-types-prod
|
|
37
44
|
|
|
38
45
|
# Unit Test
|
|
39
46
|
test:
|
|
@@ -117,3 +124,56 @@ publish-npm-package:
|
|
|
117
124
|
- echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" >> .npmrc
|
|
118
125
|
- cat .npmrc
|
|
119
126
|
- npm publish
|
|
127
|
+
|
|
128
|
+
build-types:
|
|
129
|
+
image: node:18-alpine
|
|
130
|
+
stage: build-types
|
|
131
|
+
variables:
|
|
132
|
+
KUBERNETES_CPU_REQUEST: 12
|
|
133
|
+
KUBERNETES_CPU_LIMIT: 12
|
|
134
|
+
KUBERNETES_MEMORY_REQUEST: 12Gi
|
|
135
|
+
KUBERNETES_MEMORY_LIMIT: 12Gi
|
|
136
|
+
only:
|
|
137
|
+
- tags
|
|
138
|
+
script:
|
|
139
|
+
- yarn
|
|
140
|
+
- yarn bundle-types || true
|
|
141
|
+
artifacts:
|
|
142
|
+
paths:
|
|
143
|
+
- dist
|
|
144
|
+
|
|
145
|
+
upload-types-staging:
|
|
146
|
+
image: gcr.io/google.com/cloudsdktool/cloud-sdk:alpine
|
|
147
|
+
tags:
|
|
148
|
+
- acquiring
|
|
149
|
+
- staging
|
|
150
|
+
- pci
|
|
151
|
+
only:
|
|
152
|
+
- tags
|
|
153
|
+
when: manual
|
|
154
|
+
script:
|
|
155
|
+
- *upload_types_script
|
|
156
|
+
stage: upload-types-staging
|
|
157
|
+
variables:
|
|
158
|
+
BUCKET_NAME: checkoutui-staging
|
|
159
|
+
needs:
|
|
160
|
+
- job: build-types
|
|
161
|
+
artifacts: true
|
|
162
|
+
|
|
163
|
+
upload-types-prod:
|
|
164
|
+
image: gcr.io/google.com/cloudsdktool/cloud-sdk:alpine
|
|
165
|
+
tags:
|
|
166
|
+
- acquiring
|
|
167
|
+
- prod
|
|
168
|
+
- pci
|
|
169
|
+
only:
|
|
170
|
+
- tags
|
|
171
|
+
when: manual
|
|
172
|
+
script:
|
|
173
|
+
- *upload_types_script
|
|
174
|
+
stage: upload-types-prod
|
|
175
|
+
variables:
|
|
176
|
+
BUCKET_NAME: checkoutui-prod
|
|
177
|
+
needs:
|
|
178
|
+
- job: build-types
|
|
179
|
+
artifacts: true
|
package/lib/bin/airwallex.cjs.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* Airwallex Checkout Component Version [1.
|
|
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",dev:"checkout-dev.airwallex.com",local:"localhost:3000"},r=r=>`https://${e[r]||e.prod}`,t="/assets/elements.bundle.min.js?version=1.
|
|
1
|
+
/* Airwallex Checkout Component Version [1.104.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",dev:"checkout-dev.airwallex.com",local:"localhost:3000"},r=r=>`https://${e[r]||e.prod}`,t="/assets/elements.bundle.min.js?version=1.104.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)}},y=e=>window.Airwallex.getDeviceFingerprint(e);var u={getGatewayUrl:r,loadAirwallex:n,loadAirwallexJs:o,init:l,redirectToCheckout:a,createElement:i,destroyElement:w,getDeviceFingerprint:y,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=u,exports.destroyElement=w,exports.getDeviceFingerprint=y,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 dev: 'checkout-dev.airwallex.com',\n local: '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","dev","local","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,IAAK,6BACLC,MAAO,kBAoBIC,EAAiBC,GAA8B,WAAWP,EAASO,IAAQP,EAASC,OAE3FO,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,QAAU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,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 dev: 'checkout-dev.airwallex.com',\n local: '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","dev","local","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,IAAK,6BACLC,MAAO,kBAoBIC,EAAiBC,GAA8B,WAAWP,EAASO,IAAQP,EAASC,OAE3FO,EAAgB,iDAWTC,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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M,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"}
|
package/lib/bin/airwallex.es.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* Airwallex Checkout Component Version [1.
|
|
2
|
-
const e={prod:"checkout.airwallex.com",demo:"checkout-demo.airwallex.com",staging:"checkout-staging.airwallex.com",dev:"checkout-dev.airwallex.com",local:"localhost:3000"},r=r=>`https://${e[r]||e.prod}`,o="/assets/elements.bundle.min.js?version=1.
|
|
1
|
+
/* Airwallex Checkout Component Version [1.104.0] */
|
|
2
|
+
const e={prod:"checkout.airwallex.com",demo:"checkout-demo.airwallex.com",staging:"checkout-staging.airwallex.com",dev:"checkout-dev.airwallex.com",local:"localhost:3000"},r=r=>`https://${e[r]||e.prod}`,o="/assets/elements.bundle.min.js?version=1.104.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},l=async e=>{if("undefined"==typeof window)return null;if(window.Airwallex)return window.Airwallex;let l=0;const t=async()=>{const l=document.querySelector(`script[src="${o}"], script[src="${o}/"]`)||n(r((null==e?void 0:e.env)||"prod"));return new Promise(((r,o)=>{l.addEventListener("load",(()=>{window.Airwallex?(window.Airwallex.init(e),r(window.Airwallex)):o(new Error("Failed to load Airwallex on load event"))})),l.addEventListener("error",(()=>{o(new Error("Failed to load Airwallex scripts")),l.remove&&l.remove()}))}))};for(;l<3;)try{return await t()}catch(e){l++,await new Promise((e=>window.setTimeout(e,500)))}return null},t=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:l,loadAirwallexJs:n,init:t,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,t as init,l 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 dev: 'checkout-dev.airwallex.com',\n local: '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","dev","local","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,IAAK,6BACLC,MAAO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EACAI,qBAAAA,EACAR,qBAAAA,EACAG,kCAAAA"}
|
|
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 dev: 'checkout-dev.airwallex.com',\n local: '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","dev","local","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,IAAK,6BACLC,MAAO,kBAoBIC,EAAiBC,GAA8B,WAAWP,EAASO,IAAQP,EAASC,OAE3FO,EAAgB,iDAWTC,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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,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,3 +1,3 @@
|
|
|
1
|
-
/* Airwallex Checkout Component Version [1.
|
|
2
|
-
var Airwallex=function(e){"use strict";const r={prod:"checkout.airwallex.com",demo:"checkout-demo.airwallex.com",staging:"checkout-staging.airwallex.com",dev:"checkout-dev.airwallex.com",local:"localhost:3000"},n=e=>`https://${r[e]||r.prod}`,t="/assets/elements.bundle.min.js?version=1.
|
|
1
|
+
/* Airwallex Checkout Component Version [1.104.0] */
|
|
2
|
+
var Airwallex=function(e){"use strict";const r={prod:"checkout.airwallex.com",demo:"checkout-demo.airwallex.com",staging:"checkout-staging.airwallex.com",dev:"checkout-dev.airwallex.com",local:"localhost:3000"},n=e=>`https://${r[e]||r.prod}`,t="/assets/elements.bundle.min.js?version=1.104.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)}},A=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)}},u=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:A,createPaymentMethod:x,createPaymentConsent:u,confirmPaymentIntent:s,confirmPaymentIntentWithSavedCard:m};return e.confirmPaymentIntent=s,e.confirmPaymentIntentWithSavedCard=m,e.createElement=w,e.createPaymentConsent=u,e.createPaymentMethod=x,e.default=f,e.destroyElement=d,e.getDeviceFingerprint=y,e.getElement=c,e.getGatewayUrl=n,e.getPaymentIntent=A,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 dev: 'checkout-dev.airwallex.com',\n local: '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","dev","local","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,IAAK,6BACLC,MAAO,kBAoBIC,EAAiBC,GAA8B,WAAWP,EAASO,IAAQP,EAASC,OAE3FO,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,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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,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"}
|
|
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 dev: 'checkout-dev.airwallex.com',\n local: '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","dev","local","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","getPaym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BAAAA,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.
|
|
3
|
+
"version": "1.104.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",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
},
|
|
41
41
|
"author": "Charlie.Lang",
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@airwallex/typedoc-plugin": "^1.
|
|
43
|
+
"@airwallex/typedoc-plugin": "^1.71.0",
|
|
44
44
|
"@babel/core": "^7.12.17",
|
|
45
45
|
"@commitlint/cli": "^11.0.0",
|
|
46
46
|
"@commitlint/config-conventional": "^11.0.0",
|
|
@@ -100,6 +100,7 @@
|
|
|
100
100
|
"dependencies": {
|
|
101
101
|
"@types/applepayjs": "^14.0.9",
|
|
102
102
|
"@types/googlepay": "^0.7.6",
|
|
103
|
-
"csstype": "^3.0.6"
|
|
103
|
+
"csstype": "^3.0.6",
|
|
104
|
+
"eslint-plugin-tsdoc": "^0.4.0"
|
|
104
105
|
}
|
|
105
106
|
}
|
package/typedoc.config.js
CHANGED
|
@@ -32,6 +32,10 @@ const config = {
|
|
|
32
32
|
'https://developers.google.com/pay/api/web/reference/request-objects#PaymentDataRequest',
|
|
33
33
|
'google.payments.api.PaymentDataRequest.ShippingOptionParameters':
|
|
34
34
|
'https://developers.google.com/pay/api/web/reference/request-objects#ShippingOptionParameters',
|
|
35
|
+
'google.payments.api.DisplayItem':
|
|
36
|
+
'https://developers.google.com/pay/api/web/reference/request-objects#DisplayItem',
|
|
37
|
+
'google.payments.api.PaymentDataError':
|
|
38
|
+
'https://developers.google.com/pay/api/web/reference/response-objects#PaymentDataError',
|
|
35
39
|
},
|
|
36
40
|
csstype: {
|
|
37
41
|
Properties: 'https://www.w3schools.com/cssref/index.php',
|
package/types/airwallex.d.ts
CHANGED
|
@@ -148,8 +148,15 @@ export interface RecurringOptions extends HppRecurringOptions {
|
|
|
148
148
|
connected_account_id?: string;
|
|
149
149
|
/**
|
|
150
150
|
* Set it to `true` if you want to skip 3DS regardless of the risk score and Strong Customer Authentication (SCA) regulation. Only applicable when it's a card recurring flow.
|
|
151
|
+
* @deprecated use {@link three_ds_action} instead
|
|
152
|
+
* @hidden
|
|
151
153
|
*/
|
|
152
154
|
skip_3ds?: boolean;
|
|
155
|
+
/**
|
|
156
|
+
* Set it to `SKIP_3DS` if you want to skip 3DS regardless of the risk score and Strong Customer Authentication (SCA) regulation. Only applicable when it's a card recurring flow.
|
|
157
|
+
* Set it to `FORCE_3DS` if you want to force 3DS regardless of the risk score and Strong Customer Authentication (SCA) regulation. Only applicable when it's a card recurring flow.
|
|
158
|
+
*/
|
|
159
|
+
three_ds_action?: 'SKIP_3DS' | 'FORCE_3DS';
|
|
153
160
|
/**
|
|
154
161
|
* Descriptor that may be displayed to the customer during verification.
|
|
155
162
|
*/
|
|
@@ -331,6 +338,17 @@ export interface HostPaymentPage {
|
|
|
331
338
|
* @defaultValue `false`
|
|
332
339
|
*/
|
|
333
340
|
disableAutoRedirect?: boolean;
|
|
341
|
+
/**
|
|
342
|
+
* Specifies whether the card payment method should be automatically saved for future transactions.
|
|
343
|
+
*
|
|
344
|
+
* This parameter is only effective in payment mode when a `customer_id` is provided.
|
|
345
|
+
*
|
|
346
|
+
* - If set to `true`, the "Save my card for future payments" checkbox will be preselected by default.
|
|
347
|
+
* - If set to `false`, the checkbox will remain unchecked, requiring the shopper to manually opt in.
|
|
348
|
+
*
|
|
349
|
+
* @defaultValue `true`
|
|
350
|
+
*/
|
|
351
|
+
autoSaveCardForFuturePayments?: boolean;
|
|
334
352
|
}
|
|
335
353
|
|
|
336
354
|
/**
|
|
@@ -493,18 +511,43 @@ export interface PaymentMethodOptionsType {
|
|
|
493
511
|
authorization_type?: AuthorizationType;
|
|
494
512
|
};
|
|
495
513
|
}
|
|
514
|
+
|
|
515
|
+
interface PaymentConsent {
|
|
516
|
+
/**
|
|
517
|
+
* Whether the `merchant` or `customer` should trigger subsequent payments.
|
|
518
|
+
*/
|
|
519
|
+
next_triggered_by: 'merchant' | 'customer';
|
|
520
|
+
/**
|
|
521
|
+
* Whether subsequent payments are `'scheduled'` or `'unscheduled'`. Only applicable when `next_triggered_by` is `'merchant'`.
|
|
522
|
+
*
|
|
523
|
+
* @defaultValue `'unscheduled'`
|
|
524
|
+
*/
|
|
525
|
+
merchant_trigger_reason: 'scheduled' | 'unscheduled';
|
|
526
|
+
}
|
|
527
|
+
|
|
496
528
|
/**
|
|
497
|
-
* Interface of the data when `element.confirm(data)`
|
|
529
|
+
* Interface of the data when `element.confirm(data)` is called.
|
|
498
530
|
*/
|
|
499
531
|
export interface PaymentMethodRequestData {
|
|
500
532
|
/**
|
|
501
533
|
* The ID of a payment method if already exists. You can create a new payment method by calling createPaymentMethod().
|
|
534
|
+
* @deprecated use {@link payment_method_id} instead
|
|
502
535
|
*/
|
|
503
536
|
methodId?: string;
|
|
537
|
+
/**
|
|
538
|
+
* The ID of a payment method if already exists. You can create a new payment method by calling createPaymentMethod().
|
|
539
|
+
*/
|
|
540
|
+
payment_method_id?: string;
|
|
504
541
|
/**
|
|
505
542
|
* The `client_secret` of the Payment Intent when Payment Intent is provided. Otherwise, this should be the `client_secret` of the Customer object.
|
|
506
543
|
*/
|
|
507
544
|
client_secret: string;
|
|
545
|
+
/**
|
|
546
|
+
* The payment intent you would like to checkout
|
|
547
|
+
* Refer to [Airwallex Client API](https://www.airwallex.com/docs/api#/Payment_Acceptance/Payment_Intents/Intro)
|
|
548
|
+
* @deprecated use {@link intent_id} instead
|
|
549
|
+
*/
|
|
550
|
+
id?: string;
|
|
508
551
|
/**
|
|
509
552
|
* The ID of the Payment Intent you would like to checkout. Required when `mode` is `'payment'`.
|
|
510
553
|
* Refer to [Airwallex Client API](https://www.airwallex.com/docs/api#/Payment_Acceptance/Payment_Intents/)
|
|
@@ -519,6 +562,11 @@ export interface PaymentMethodRequestData {
|
|
|
519
562
|
* Whether to save this payment method for future payments or not.
|
|
520
563
|
*/
|
|
521
564
|
save_payment_method?: boolean;
|
|
565
|
+
/**
|
|
566
|
+
* The payment consent details.
|
|
567
|
+
* @hidden - It is used in the second initial of recurring in cvc element to reduce multiple card number inputs. Use cvc element for recurring payment is a temporary solution since cvc is not required in this case.
|
|
568
|
+
*/
|
|
569
|
+
payment_consent?: PaymentConsent;
|
|
522
570
|
/**
|
|
523
571
|
* The payment method details returned by calling createPaymentMethod().
|
|
524
572
|
*/
|
|
@@ -548,22 +596,22 @@ export interface PaymentMethodRequestData {
|
|
|
548
596
|
export declare const init: (options?: InitOptions | undefined) => void;
|
|
549
597
|
|
|
550
598
|
/**
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
import { init } from '@airwallex/components-sdk';
|
|
555
|
-
|
|
556
|
-
const {
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
});
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
});
|
|
566
|
-
```
|
|
599
|
+
* Function to redirect the shopper in a Hosted Payment Page(HPP) integration.
|
|
600
|
+
* @example
|
|
601
|
+
```ts
|
|
602
|
+
import { init } from '@airwallex/components-sdk';
|
|
603
|
+
|
|
604
|
+
const { payments } = await init({
|
|
605
|
+
env: 'demo', // Choose the Airwallex environment ('demo' or 'prod')
|
|
606
|
+
enabledElements: ['payments'],
|
|
607
|
+
});
|
|
608
|
+
payments.redirectToCheckout({
|
|
609
|
+
intent_id: 'replace-with-your-intent-id',
|
|
610
|
+
client_secret: 'replace-with-your-client-secret',
|
|
611
|
+
currency: 'replace-with-your-currency',
|
|
612
|
+
country_code: 'replace-with-your-country-code',
|
|
613
|
+
});
|
|
614
|
+
```
|
|
567
615
|
*/
|
|
568
616
|
export declare const redirectToCheckout: (props: HostPaymentPage) => void | string;
|
|
569
617
|
|
|
@@ -872,9 +920,16 @@ export interface PaymentConsentRequestData {
|
|
|
872
920
|
*/
|
|
873
921
|
metadata?: Record<string, unknown>;
|
|
874
922
|
/**
|
|
875
|
-
* Set it to `true` if you want to skip 3DS regardless of the risk score and SCA. Only applicable
|
|
923
|
+
* Set it to `true` if you want to skip 3DS regardless of the risk score and Strong Customer Authentication (SCA) regulation. Only applicable when it's a card recurring flow.
|
|
924
|
+
* @deprecated use {@link threeDsAction} instead
|
|
925
|
+
* @hidden
|
|
876
926
|
*/
|
|
877
927
|
skip_3ds?: boolean;
|
|
928
|
+
/**
|
|
929
|
+
* Set it to `SKIP_3DS` if you want to skip 3DS regardless of the risk score and Strong Customer Authentication (SCA) regulation. Only applicable when it's a card recurring flow.
|
|
930
|
+
* Set it to `FORCE_3DS` if you want to force 3DS regardless of the risk score and Strong Customer Authentication (SCA) regulation. Only applicable when it's a card recurring flow.
|
|
931
|
+
*/
|
|
932
|
+
three_ds_action?: 'SKIP_3DS' | 'FORCE_3DS';
|
|
878
933
|
}
|
|
879
934
|
|
|
880
935
|
/**
|
|
@@ -891,6 +946,28 @@ export interface VerifyConsentRequest {
|
|
|
891
946
|
client_secret: string;
|
|
892
947
|
}
|
|
893
948
|
|
|
949
|
+
/**
|
|
950
|
+
* Interface of the data when `element.createPaymentMethod(data)` is called.
|
|
951
|
+
*/
|
|
952
|
+
export interface CreatePaymentMethodRequest {
|
|
953
|
+
/**
|
|
954
|
+
* The `client_secret` of the Payment Intent when Payment Intent is provided. Otherwise, this should be the `client_secret` of the Customer object.
|
|
955
|
+
*/
|
|
956
|
+
client_secret: string;
|
|
957
|
+
/**
|
|
958
|
+
* The ID of the Customer who intends to pay for the Payment Intent.
|
|
959
|
+
*/
|
|
960
|
+
customer_id?: string;
|
|
961
|
+
/**
|
|
962
|
+
* A set of key-value pairs that can be attached to this Payment Consent.
|
|
963
|
+
*/
|
|
964
|
+
metadata?: Record<string, unknown>;
|
|
965
|
+
/**
|
|
966
|
+
* The payment method details returned by calling createPaymentMethod().
|
|
967
|
+
*/
|
|
968
|
+
payment_method?: PaymentMethodObjType;
|
|
969
|
+
}
|
|
970
|
+
|
|
894
971
|
/**
|
|
895
972
|
* Interface of the response payload when call createPaymentConsent or verifyConsent
|
|
896
973
|
* Interface of the response payload when createPaymentConsent() is called.
|
package/types/dropInElement.d.ts
CHANGED
|
@@ -137,4 +137,16 @@ export interface DropInElementOptions {
|
|
|
137
137
|
* Customize DropIn Element style.
|
|
138
138
|
*/
|
|
139
139
|
theme?: DropinTheme;
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Specifies whether the card payment method should be automatically saved for future transactions.
|
|
143
|
+
*
|
|
144
|
+
* This parameter is only effective in payment mode when a `customer_id` is provided.
|
|
145
|
+
*
|
|
146
|
+
* - If set to `true`, the "Save my card for future payments" checkbox will be preselected by default.
|
|
147
|
+
* - If set to `false`, the checkbox will remain unchecked, requiring the shopper to manually opt in.
|
|
148
|
+
*
|
|
149
|
+
* @defaultValue `true`
|
|
150
|
+
*/
|
|
151
|
+
autoSaveCardForFuturePayments?: boolean;
|
|
140
152
|
}
|