airwallex-payment-elements 1.96.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 +2 -2
- package/types/airwallex.d.ts +60 -3
- package/types/dropInElement.d.ts +12 -0
- package/types/element.d.ts +54 -7
- package/types/index.d.ts +2 -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,QAAUvB,EAAOuB,gBAK9B,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,MADAR,QAAQF,MAAMU,GACR,IAAI1B,MAAM0B,KAoCPM,EAAsD7B,MAAOsB,IACxE,GAAKpB,OAAOC,UAKV,OAAOD,OAAOC,UAAU0B,qBAAqBP,GALxB,CACrB,MAAMC,EAAM,wDAEZ,MADAR,QAAQF,MAAMU,GACR,IAAI1B,MAAM0B,KAiBPO,EAAuDR,GAC3DpB,OAAOC,UAAU2B,qBAAqBR,GAG/C,MAAe,CACbtC,cAAAA,EACAe,cAAAA,EACAZ,gBAAAA,EACAwB,KAAAA,EACAK,mBAAAA,EACAzB,cAAAA,EACA4B,eAAAA,EACAW,qBAAAA,EACAV,WAAAA,EACAO,iBAAAA,EACAF,oBAAAA,EACAI,qBAAAA,EACAR,qBAAAA,EACAG,kCAAAA"}
|
|
1
|
+
{"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,YAAYT,GAEhBA,GAc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QF,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,kBAoBIC,EAAiBC,G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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,KAC/BD,EAAO,IAAI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wB,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,UACT,OAAOD,OAAOC,U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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","getPaymentIntent","id","createPaymentConsent","get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,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",
|
package/types/airwallex.d.ts
CHANGED
|
@@ -338,6 +338,17 @@ export interface HostPaymentPage {
|
|
|
338
338
|
* @defaultValue `false`
|
|
339
339
|
*/
|
|
340
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;
|
|
341
352
|
}
|
|
342
353
|
|
|
343
354
|
/**
|
|
@@ -500,14 +511,33 @@ export interface PaymentMethodOptionsType {
|
|
|
500
511
|
authorization_type?: AuthorizationType;
|
|
501
512
|
};
|
|
502
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
|
+
|
|
503
528
|
/**
|
|
504
|
-
* Interface of the data when `element.confirm(data)`
|
|
529
|
+
* Interface of the data when `element.confirm(data)` is called.
|
|
505
530
|
*/
|
|
506
531
|
export interface PaymentMethodRequestData {
|
|
507
532
|
/**
|
|
508
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
|
|
509
535
|
*/
|
|
510
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;
|
|
511
541
|
/**
|
|
512
542
|
* The `client_secret` of the Payment Intent when Payment Intent is provided. Otherwise, this should be the `client_secret` of the Customer object.
|
|
513
543
|
*/
|
|
@@ -532,6 +562,11 @@ export interface PaymentMethodRequestData {
|
|
|
532
562
|
* Whether to save this payment method for future payments or not.
|
|
533
563
|
*/
|
|
534
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;
|
|
535
570
|
/**
|
|
536
571
|
* The payment method details returned by calling createPaymentMethod().
|
|
537
572
|
*/
|
|
@@ -566,11 +601,11 @@ export declare const init: (options?: InitOptions | undefined) => void;
|
|
|
566
601
|
```ts
|
|
567
602
|
import { init } from '@airwallex/components-sdk';
|
|
568
603
|
|
|
569
|
-
const {
|
|
604
|
+
const { payments } = await init({
|
|
570
605
|
env: 'demo', // Choose the Airwallex environment ('demo' or 'prod')
|
|
571
606
|
enabledElements: ['payments'],
|
|
572
607
|
});
|
|
573
|
-
|
|
608
|
+
payments.redirectToCheckout({
|
|
574
609
|
intent_id: 'replace-with-your-intent-id',
|
|
575
610
|
client_secret: 'replace-with-your-client-secret',
|
|
576
611
|
currency: 'replace-with-your-currency',
|
|
@@ -911,6 +946,28 @@ export interface VerifyConsentRequest {
|
|
|
911
946
|
client_secret: string;
|
|
912
947
|
}
|
|
913
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
|
+
|
|
914
971
|
/**
|
|
915
972
|
* Interface of the response payload when call createPaymentConsent or verifyConsent
|
|
916
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
|
}
|
package/types/element.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
RecurringOptions,
|
|
13
13
|
VerifyConsentRequest,
|
|
14
14
|
PaymentConsentRequestData,
|
|
15
|
+
CreatePaymentMethodRequest,
|
|
15
16
|
} from './airwallex';
|
|
16
17
|
|
|
17
18
|
/**
|
|
@@ -629,6 +630,17 @@ export interface FullFeaturedCardElementOptions {
|
|
|
629
630
|
* The options for the recurring flow. Required when `mode` is `'recurring'`.
|
|
630
631
|
*/
|
|
631
632
|
recurringOptions?: RecurringOptions;
|
|
633
|
+
/**
|
|
634
|
+
* Specifies whether the card payment method should be automatically saved for future transactions.
|
|
635
|
+
*
|
|
636
|
+
* This parameter is only effective in payment mode when a `customer_id` is provided.
|
|
637
|
+
*
|
|
638
|
+
* - If set to `true`, the "Save my card for future payments" checkbox will be preselected by default.
|
|
639
|
+
* - If set to `false`, the checkbox will remain unchecked, requiring the shopper to manually opt in.
|
|
640
|
+
*
|
|
641
|
+
* @defaultValue `true`
|
|
642
|
+
*/
|
|
643
|
+
autoSaveCardForFuturePayments?: boolean;
|
|
632
644
|
}
|
|
633
645
|
|
|
634
646
|
/**
|
|
@@ -1033,6 +1045,7 @@ export type ApplePayButtonColor = 'black' | 'white' | 'white-outline';
|
|
|
1033
1045
|
export interface ApplePayRequestOptions extends ApplePayRequestOriginalOptions {
|
|
1034
1046
|
/**
|
|
1035
1047
|
* Supported methods for presenting the Apple Pay button.
|
|
1048
|
+
*
|
|
1036
1049
|
* A translated button label may appear if a language specified in the
|
|
1037
1050
|
* viewer's browser matches an [available language](https://developer.apple.com/documentation/apple_pay_on_the_web/applepaybuttonlocale).
|
|
1038
1051
|
*/
|
|
@@ -1050,6 +1063,7 @@ export interface ApplePayRequestOptions extends ApplePayRequestOriginalOptions {
|
|
|
1050
1063
|
totalPriceLabel?: string;
|
|
1051
1064
|
/**
|
|
1052
1065
|
* Indicate whether a line item is final or pending.
|
|
1066
|
+
*
|
|
1053
1067
|
* If the mode is `recurring` and if it's a variable subscription, the value should be pending.
|
|
1054
1068
|
*
|
|
1055
1069
|
* @defaultValue `'final'`
|
|
@@ -1057,17 +1071,24 @@ export interface ApplePayRequestOptions extends ApplePayRequestOriginalOptions {
|
|
|
1057
1071
|
totalPriceType?: 'final' | 'pending';
|
|
1058
1072
|
/**
|
|
1059
1073
|
* Card networks supported by the merchant.
|
|
1074
|
+
*
|
|
1060
1075
|
* If not configured, `supportedNetworks` will be based on merchant's account settings.
|
|
1076
|
+
*
|
|
1061
1077
|
* For more details, see https://developer.apple.com/documentation/apple_pay_on_the_web/applepaypaymentrequest/1916122-supportednetworks
|
|
1062
1078
|
*/
|
|
1063
1079
|
supportedNetworks?: string[];
|
|
1064
1080
|
/**
|
|
1065
1081
|
* Payment capabilities supported by the merchant.
|
|
1082
|
+
*
|
|
1066
1083
|
* If not configured, `merchantCapabilities` will be based on merchant's account settings.
|
|
1067
|
-
*
|
|
1068
|
-
*
|
|
1069
|
-
*
|
|
1070
|
-
*
|
|
1084
|
+
*
|
|
1085
|
+
* - supports3DS: **Required**. This value must be supplied.
|
|
1086
|
+
*
|
|
1087
|
+
* - supportsCredit: **Optional**. If present, only transactions that are categorized as credit cards are allowed.
|
|
1088
|
+
*
|
|
1089
|
+
* - supportsDebit: **Optional**. If present, only transactions that are categorized as debit cards are allowed.
|
|
1090
|
+
*
|
|
1091
|
+
* - supportsEMV: Include this value only if you support China Union Pay transactions. (if `supportedNetworks` does not contain chinaUnionPay, don't include it).
|
|
1071
1092
|
*/
|
|
1072
1093
|
merchantCapabilities?: ApplePayJS.ApplePayMerchantCapability[];
|
|
1073
1094
|
}
|
|
@@ -1083,18 +1104,22 @@ interface Amount {
|
|
|
1083
1104
|
export interface ApplePayButtonOptions extends ApplePayRequestOptions {
|
|
1084
1105
|
/**
|
|
1085
1106
|
* The ID of the Payment Intent you would like to checkout.
|
|
1107
|
+
*
|
|
1086
1108
|
* Required when `mode` is set to `'payment'` but optional for `'recurring'`.
|
|
1109
|
+
*
|
|
1087
1110
|
* Refer to [Airwallex Client API](https://www.airwallex.com/docs/api#/Payment_Acceptance/Payment_Intents/)
|
|
1088
1111
|
*
|
|
1089
1112
|
*/
|
|
1090
1113
|
intent_id?: string;
|
|
1091
1114
|
/**
|
|
1092
1115
|
* The `client_secret` of the Payment Intent when Payment Intent is provided. Otherwise, this should be the `client_secret` of the Customer object.
|
|
1116
|
+
*
|
|
1093
1117
|
* Leave it empty if `intent_id` and `customer_id` are not provided as you can provide it in the update() function later.
|
|
1094
1118
|
*/
|
|
1095
1119
|
client_secret?: string;
|
|
1096
1120
|
/**
|
|
1097
1121
|
* The ID of the Customer used in registered user checkout. Refer to [Airwallex Client API](https://www.airwallex.com/docs/api#/Payment_Acceptance/Customers/Intro)
|
|
1122
|
+
*
|
|
1098
1123
|
* This field is required when `mode` is `'recurring'`.
|
|
1099
1124
|
*/
|
|
1100
1125
|
customer_id?: string;
|
|
@@ -1105,18 +1130,22 @@ export interface ApplePayButtonOptions extends ApplePayRequestOptions {
|
|
|
1105
1130
|
mode?: Mode;
|
|
1106
1131
|
/**
|
|
1107
1132
|
* Indicate the amount and currency of the Payment Intent.
|
|
1133
|
+
*
|
|
1108
1134
|
* If the `mode` is set to `'recurring'` and `intent_id` omitted, amount should be `{value: 0, currency: 'Replace with payment currency'}`.
|
|
1109
1135
|
*/
|
|
1110
1136
|
amount: Amount;
|
|
1111
1137
|
/**
|
|
1112
1138
|
* Whether the amount should be captured automatically upon successful payment authorization.
|
|
1139
|
+
*
|
|
1113
1140
|
* Set it to `false` if you want to place a hold on the payment method and capture the funds sometime later.
|
|
1114
1141
|
* @defaultValue `true`
|
|
1115
1142
|
*/
|
|
1116
1143
|
autoCapture?: boolean;
|
|
1117
1144
|
/**
|
|
1118
1145
|
* The authorization type for the card payment.
|
|
1146
|
+
*
|
|
1119
1147
|
* Set it to `'pre_auth'` if you want to place a hold on your customer’s card for more than 7 days, i.e., extend the authorization time window.
|
|
1148
|
+
*
|
|
1120
1149
|
* Currently it's only available when the card brand is Visa or Mastercard. `autoCapture` will be automatically set to `false` if you enable `pre_auth`.
|
|
1121
1150
|
* @defaultValue `'final_auth'`
|
|
1122
1151
|
*/
|
|
@@ -1144,6 +1173,7 @@ export interface ApplePayButtonUpdateOptions extends ApplePayButtonOptions {
|
|
|
1144
1173
|
export interface WechatElementOptions {
|
|
1145
1174
|
/**
|
|
1146
1175
|
* The Payment Intent you would like to checkout.
|
|
1176
|
+
*
|
|
1147
1177
|
* Refer to [Airwallex Client API](https://www.airwallex.com/docs/api#/Payment_Acceptance/Payment_Intents/)
|
|
1148
1178
|
*
|
|
1149
1179
|
*/
|
|
@@ -1183,6 +1213,7 @@ export interface Element {
|
|
|
1183
1213
|
domElement: null | HTMLElement;
|
|
1184
1214
|
/**
|
|
1185
1215
|
* Element integration `step #3`
|
|
1216
|
+
*
|
|
1186
1217
|
* Mounts payment Element to your HTML DOM element for checkout.
|
|
1187
1218
|
*/
|
|
1188
1219
|
mount(domElement: string | HTMLElement): null | HTMLElement;
|
|
@@ -1315,7 +1346,6 @@ export interface CardElementType extends ElementBaseType {
|
|
|
1315
1346
|
* @example
|
|
1316
1347
|
* ```ts
|
|
1317
1348
|
* element.verifyConsent({
|
|
1318
|
-
* consent_id: 'replace-with-your-consent-id',
|
|
1319
1349
|
* client_secret: 'replace-with-your-client-secret',
|
|
1320
1350
|
* currency: 'replace-with-your-currency',
|
|
1321
1351
|
* });
|
|
@@ -1324,6 +1354,7 @@ export interface CardElementType extends ElementBaseType {
|
|
|
1324
1354
|
verifyConsent(data: VerifyConsentRequest): Promise<PaymentConsentResponse | boolean>;
|
|
1325
1355
|
/**
|
|
1326
1356
|
* Using this function to confirm payment intent
|
|
1357
|
+
*
|
|
1327
1358
|
* Confirms the Payment Intent. Call this function when the shopper is ready to make a payment as per the details in the Payment Intent.
|
|
1328
1359
|
* @param data - Payment method request payload
|
|
1329
1360
|
* @example
|
|
@@ -1402,7 +1433,6 @@ export interface CardNumberElementType extends ElementBaseType {
|
|
|
1402
1433
|
* @example
|
|
1403
1434
|
* ```ts
|
|
1404
1435
|
* element.verifyConsent({
|
|
1405
|
-
* consent_id: 'replace-with-your-consent-id',
|
|
1406
1436
|
* client_secret: 'replace-with-your-client-secret',
|
|
1407
1437
|
* currency: 'replace-with-your-currency',
|
|
1408
1438
|
* });
|
|
@@ -1411,6 +1441,7 @@ export interface CardNumberElementType extends ElementBaseType {
|
|
|
1411
1441
|
verifyConsent(data: VerifyConsentRequest): Promise<PaymentConsentResponse | boolean>;
|
|
1412
1442
|
/**
|
|
1413
1443
|
* Using this function to confirm payment intent.
|
|
1444
|
+
*
|
|
1414
1445
|
* Confirms the Payment Intent.
|
|
1415
1446
|
*@example
|
|
1416
1447
|
* ```ts
|
|
@@ -1420,6 +1451,23 @@ export interface CardNumberElementType extends ElementBaseType {
|
|
|
1420
1451
|
* ```
|
|
1421
1452
|
*/
|
|
1422
1453
|
confirm(data: PaymentMethodRequestData): Promise<Intent>;
|
|
1454
|
+
/**
|
|
1455
|
+
* Using this function to create a payment method for future payments. The created payment method can be saved in your system.
|
|
1456
|
+
* @param data - Payment method request payload
|
|
1457
|
+
* @example
|
|
1458
|
+
* ```ts
|
|
1459
|
+
* element.createPaymentMethod({
|
|
1460
|
+
* client_secret: 'replace-with-your-client-secret',
|
|
1461
|
+
* customer_id: 'replace-with-your-customer-id',
|
|
1462
|
+
* payment_method: {
|
|
1463
|
+
* card: {
|
|
1464
|
+
* name: 'John Doe',
|
|
1465
|
+
* },
|
|
1466
|
+
* },
|
|
1467
|
+
* });
|
|
1468
|
+
* ```
|
|
1469
|
+
*/
|
|
1470
|
+
createPaymentMethod(data: CreatePaymentMethodRequest): Promise<PaymentMethodBasicInfo>;
|
|
1423
1471
|
/**
|
|
1424
1472
|
* Using this function to update the element option after create the element.
|
|
1425
1473
|
* @example
|
|
@@ -1838,7 +1886,6 @@ export interface FullFeaturedCardElementType extends ElementBaseType {
|
|
|
1838
1886
|
update(options?: Partial<FullFeaturedCardElementOptions>, initOptions?: Partial<InitOptions>): void;
|
|
1839
1887
|
/**
|
|
1840
1888
|
* Listen to element event.
|
|
1841
|
-
*
|
|
1842
1889
|
* @example
|
|
1843
1890
|
* ```ts
|
|
1844
1891
|
* element.on('change', () => {
|
package/types/index.d.ts
CHANGED
|
@@ -34,6 +34,7 @@ import Airwallex, {
|
|
|
34
34
|
Locale,
|
|
35
35
|
Billing,
|
|
36
36
|
VerifyConsentRequest,
|
|
37
|
+
CreatePaymentMethodRequest,
|
|
37
38
|
} from './airwallex';
|
|
38
39
|
|
|
39
40
|
export {
|
|
@@ -65,6 +66,7 @@ export {
|
|
|
65
66
|
Billing,
|
|
66
67
|
ElementTypeMap,
|
|
67
68
|
VerifyConsentRequest,
|
|
69
|
+
CreatePaymentMethodRequest,
|
|
68
70
|
};
|
|
69
71
|
|
|
70
72
|
/**
|