airwallex-payment-elements 0.3.2 → 1.6.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 CHANGED
@@ -1,7 +1,14 @@
1
+ include:
2
+ - project: 'acquiring/gatsby-theme-airwallex-docs'
3
+ ref: master
4
+ file: '/.gitlab-ci-doc.yml'
5
+
1
6
  variables:
2
7
  SONAR_LOGIN: $SONAR_TOKEN
3
8
  PUSH_REPO: "https://gitlab.awx.im/acquiring/airwallex-payment-elements.git"
4
9
  GITLAB_ONLY_REPO: "true"
10
+ DOC_PATH_PREFIX: "payment-elements"
11
+ GCS_UPLOAD_TAG: "acquiring"
5
12
  cache:
6
13
  key:
7
14
  files:
@@ -10,29 +17,36 @@ cache:
10
17
  paths:
11
18
  - .yarn
12
19
  - node_modules
20
+
13
21
  stages:
14
22
  - test
15
23
  - build
16
- - deploy-doc-staging
17
24
  - publish-gitlab-package
18
25
  - publish-npm-package
26
+ - build-doc
27
+ - deploy-doc-staging-bucket
28
+ - approve
29
+ - deploy-doc-prod-bucket
19
30
  # Unit Test
20
31
 
21
- .bucket_deploy_script: &bucket_deploy_script |-
22
- cd docs
23
- gsutil -m cp -r ./public/* gs://${BUCKET_NAME}/payment-elements
24
- gsutil -m setmeta -r -h "Cache-Control:no-store,no-cache,max-age=0" gs://${BUCKET_NAME}/index.html
25
-
26
-
27
32
  test:
28
33
  coverage: /All\sfiles.*?\s+(\d+.\d+)/
29
- image: node:16.13-alpine
34
+ image: node:18-alpine
30
35
  variables:
31
36
  KUBERNETES_MEMORY_REQUEST: 8Gi
32
37
  KUBERNETES_MEMORY_LIMIT: 8Gi
33
38
  KUBERNETES_CPU_REQUEST: 8
34
39
  KUBERNETES_CPU_LIMIT: 8
35
40
  stage: test
41
+ rules:
42
+ - if: '$CI_COMMIT_REF_NAME == "master"'
43
+ changes:
44
+ - "*"
45
+ - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
46
+ when: never
47
+ - if: '$CI_COMMIT_MESSAGE !~ /^chore\(release\):/'
48
+ changes:
49
+ - "*"
36
50
  script:
37
51
  - yarn
38
52
  - yarn test
@@ -41,72 +55,64 @@ test:
41
55
  - coverage
42
56
 
43
57
  build:
44
- image: node:16.13-alpine
45
- stage: build
46
- script:
47
- - yarn build
48
- artifacts:
49
- paths:
50
- - dist
51
- - lib
52
- - public
53
-
54
- build-doc:
55
- image: node:18.1-alpine
58
+ image: node:18-alpine
56
59
  stage: build
57
60
  script:
58
- - yarn typedoc
59
- - cd docs
60
- - yarn
61
- - yarn typedoc-prepare
62
- - apk update && apk upgrade && apk add --no-cache bash git openssh
63
61
  - yarn build
62
+ rules:
63
+ - if: '$CI_COMMIT_REF_NAME == "master"'
64
+ changes:
65
+ - "*"
66
+ - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
67
+ when: never
68
+ - if: '$CI_COMMIT_MESSAGE !~ /^chore\(release\):/'
69
+ changes:
70
+ - "*"
64
71
  artifacts:
65
72
  paths:
66
73
  - dist
67
74
  - lib
68
75
  - public
69
- - docs
70
-
71
- deploy-doc-staging:
72
- image: gcr.io/google.com/cloudsdktool/cloud-sdk:alpine
73
- tags:
74
- - acquiring
75
- - staging
76
- only:
77
- - master
78
- when: manual
79
- artifacts:
80
- paths:
81
- - docs
82
- script:
83
- - *bucket_deploy_script
84
- stage: deploy-doc-staging
85
- variables:
86
- BUCKET_NAME: awx-staging-asia-element-integration-doc
87
- needs:
88
- - job: build-doc
89
- artifacts: true
90
76
 
91
77
  # Publish github package
92
78
  publish-gitlab-package:
93
- image: node:16.13-alpine
79
+ image: node:18-alpine
94
80
  stage: publish-gitlab-package
95
- only:
96
- - master
81
+ variables:
82
+ GIT_GLOBAL_USER_EMAIL: "devops@airwallex.com"
83
+ GIT_GLOBAL_USER: "Gitlab Runner"
84
+ GIT_REPO: "https://gitlab-ci-token:${GITLAB_TOKEN}@gitlab.awx.im/acquiring/airwallex-payment-elements.git"
85
+ rules:
86
+ - if: '$CI_COMMIT_REF_NAME == "master" && $CI_COMMIT_MESSAGE !~ /^chore\(release\):/'
87
+ changes:
88
+ - "*"
97
89
  when: manual
90
+ before_script:
91
+ - apk update
92
+ - apk add --no-cache git bash curl perl
93
+ - which ssh-agent || ( apk update && apk add openssh-client )
94
+ - yarn --pure-lockfile --ignore-engines --cache-folder .yarn
95
+ - eval $(ssh-agent -s)
96
+ - echo "${SSH_PRIVATE_KEY}" | tr -d '\r' | ssh-add -
97
+ - mkdir -p ~/.ssh
98
+ - chmod 700 ~/.ssh
99
+ - echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
100
+ - git config --global user.email ${GIT_GLOBAL_USER_EMAIL?}
101
+ - git config --global user.name ${GIT_GLOBAL_USER?}
98
102
  script:
99
103
  - ls
100
- - npm publish
104
+ - git remote set-url origin "${GIT_REPO}"
105
+ - yarn semantic-release
101
106
  # Publish npm package
102
107
  publish-npm-package:
103
- image: node:16.13-alpine
108
+ image: node:18-alpine
104
109
  stage: publish-npm-package
105
- only:
106
- - master
107
110
  when: manual
111
+ only:
112
+ - tags
108
113
  script:
109
114
  - ls
115
+ - yarn build
110
116
  - rm .npmrc
111
117
  - sed -i 's/@airwallex\/airwallex-payment-elements/airwallex-payment-elements/g' package.json
112
118
  - cat package.json
package/README.md CHANGED
@@ -111,18 +111,6 @@ window.addEventListener(EVENT_TYPE, (event) => {
111
111
  });
112
112
  ```
113
113
 
114
- # Documentation
115
-
116
- See the documentation for Airwallex functions [here](https://github.com/airwallex/airwallex-payment-demo/tree/master/docs), or for more specific payment integrations:
117
-
118
- - [**Card**](https://github.com/airwallex/airwallex-payment-demo/blob/master/docs/card.md)
119
- - [**HPP (Hosted Payment Page)**](https://github.com/airwallex/airwallex-payment-demo/blob/master/docs/hpp.md)
120
- - [**Drop in**](https://github.com/airwallex/airwallex-payment-demo/blob/master/docs/dropin.md)
121
- - [**Full Featured Card**](https://github.com/airwallex/airwallex-payment-demo/blob/master/docs/fullfeaturedcard.md)
122
- - [**Split Card**](https://github.com/airwallex/airwallex-payment-demo/blob/master/docs/splitcard.md)
123
- - [**Wechat**](https://github.com/airwallex/airwallex-payment-demo/blob/master/docs/wechat.md)
124
- - **Redirect** (coming soon...)
125
-
126
114
  # Integration
127
115
 
128
116
  Each payment processing method requires different customizations. Check out our examples of web integrations with the [airwallex-payment-demo](https://github.com/airwallex/airwallex-payment-demo) library.
@@ -1,3 +1,3 @@
1
- /* Airwallex Checkout Component Version [0.3.2] */
2
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e={prod:"checkout.airwallex.com",demo:"checkout-demo.airwallex.com",staging:"checkout-staging.airwallex.com",qa:"checkoutui.qa.awx.im",preview:"checkoutui.preview.awx.im",dev:"localhost:3000"},r=r=>`https://${e[r]||e.prod}`,o="/assets/elements.bundle.min.js?version=0.3.2",t=e=>{const r=document.createElement("script");r.src=`${e}${o}`,r.crossOrigin="anonymous";const t=document.head||document.body;if(!t)throw new Error("Airwallex payment scripts requires a <head> or <body> html element in order to be loaded.");return t.appendChild(r),r};exports.confirmPaymentIntent=async e=>{if(window.Airwallex)return window.Airwallex.confirmPaymentIntent(e);{const e="Please loadAirwallex() before confirmPaymentIntent();";throw console.error(e),new Error(e)}},exports.confirmPaymentIntentWithSavedCard=async e=>{if(window.Airwallex)return window.Airwallex.confirmPaymentIntentWithSavedCard(e);{const e="Please loadAirwallex() before confirmPaymentIntentWithSavedCard();";throw console.error(e),new Error(e)}},exports.createElement=(e,r)=>window.Airwallex?window.Airwallex.createElement(e,r):(console.error("Please loadAirwallex() before createElement();"),null),exports.createPaymentConsent=async e=>{if(window.Airwallex)return window.Airwallex.createPaymentConsent(e);{const e="Please loadAirwallex() before createPaymentConsent();";throw console.error(e),new Error(e)}},exports.createPaymentMethod=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)}},exports.destroyElement=e=>window.Airwallex?window.Airwallex.destroyElement(e):(console.error("Please loadAirwallex() before destroyElement();"),!1),exports.get3dsReturnUrl=e=>window.Airwallex.get3dsReturnUrl(e),exports.getBrowserInfo=e=>window.Airwallex.getBrowserInfo(e),exports.getDeviceFingerprint=e=>window.Airwallex.getDeviceFingerprint(e),exports.getElement=e=>window.Airwallex?window.Airwallex.getElement(e):(console.error("Please loadAirwallex() before getElement();"),null),exports.getGatewayUrl=r,exports.getPaymentIntent=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)}},exports.handle3ds=e=>window.Airwallex.handle3ds(e),exports.init=e=>{window.Airwallex?window.Airwallex.init(e):console.error("Please loadAirwallex() before init();")},exports.loadAirwallex=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="${o}"], script[src="${o}/"]`)||t(r((null==e?void 0:e.env)||"prod"));return new Promise(((r,o)=>{n.addEventListener("load",(()=>{window.Airwallex?(window.Airwallex.init(e),r(window.Airwallex)):o(new Error("Failed to load Airwallex on load event"))})),n.addEventListener("error",(()=>{o(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},exports.loadAirwallexJs=t,exports.redirectToCheckout=e=>{if(window.Airwallex)return window.Airwallex.redirectToCheckout(e);console.error("Please loadAirwallex() before redirectToCheckout();")};
1
+ /* Airwallex Checkout Component Version [1.6.0] */
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e={prod:"checkout.airwallex.com",demo:"checkout-demo.airwallex.com",staging:"checkout-staging.airwallex.com",qa:"checkoutui.qa.awx.im",preview:"checkoutui.preview.awx.im",dev:"localhost:3000"},r=r=>`https://${e[r]||e.prod}`,t="/assets/elements.bundle.min.js?version=1.6.0",o=e=>{const r=document.createElement("script");r.src=`${e}${t}`,r.crossOrigin="anonymous";const o=document.head||document.body;if(!o)throw new Error("Airwallex payment scripts requires a <head> or <body> html element in order to be loaded.");return o.appendChild(r),r},n=async e=>{if("undefined"==typeof window)return null;if(window.Airwallex)return window.Airwallex;let n=0;const l=async()=>{const n=document.querySelector(`script[src="${t}"], script[src="${t}/"]`)||o(r((null==e?void 0:e.env)||"prod"));return new Promise(((r,t)=>{n.addEventListener("load",(()=>{window.Airwallex?(window.Airwallex.init(e),r(window.Airwallex)):t(new Error("Failed to load Airwallex on load event"))})),n.addEventListener("error",(()=>{t(new Error("Failed to load Airwallex scripts")),n.remove&&n.remove()}))}))};for(;n<3;)try{return await l()}catch(e){n++,await new Promise((e=>window.setTimeout(e,500)))}return null},l=e=>{window.Airwallex?window.Airwallex.init(e):console.error("Please loadAirwallex() before init();")},a=e=>{if(window.Airwallex)return window.Airwallex.redirectToCheckout(e);console.error("Please loadAirwallex() before redirectToCheckout();")},i=(e,r)=>window.Airwallex?window.Airwallex.createElement(e,r):(console.error("Please loadAirwallex() before createElement();"),null),w=e=>window.Airwallex?window.Airwallex.destroyElement(e):(console.error("Please loadAirwallex() before destroyElement();"),!1),d=e=>window.Airwallex?window.Airwallex.getElement(e):(console.error("Please loadAirwallex() before getElement();"),null),s=async e=>{if(window.Airwallex)return window.Airwallex.confirmPaymentIntent(e);{const e="Please loadAirwallex() before confirmPaymentIntent();";throw console.error(e),new Error(e)}},c=async e=>{if(window.Airwallex)return window.Airwallex.confirmPaymentIntentWithSavedCard(e);{const e="Please loadAirwallex() before confirmPaymentIntentWithSavedCard();";throw console.error(e),new Error(e)}},x=async(e,r)=>{if(window.Airwallex)return window.Airwallex.createPaymentMethod(e,r);{const e="Please loadAirwallex() before createPaymentMethod();";throw console.error(e),new Error(e)}},m=async(e,r)=>{if(window.Airwallex)return window.Airwallex.getPaymentIntent(e,r);{const e="Please loadAirwallex() before getPaymentIntent();";throw console.error(e),new Error(e)}},A=async e=>{if(window.Airwallex)return window.Airwallex.createPaymentConsent(e);{const e="Please loadAirwallex() before createPaymentConsent();";throw console.error(e),new Error(e)}},u=e=>window.Airwallex.getDeviceFingerprint(e);var y={getGatewayUrl:r,loadAirwallex:n,loadAirwallexJs:o,init:l,redirectToCheckout:a,createElement:i,destroyElement:w,getDeviceFingerprint:u,getElement:d,getPaymentIntent:m,createPaymentMethod:x,createPaymentConsent:A,confirmPaymentIntent:s,confirmPaymentIntentWithSavedCard:c};exports.confirmPaymentIntent=s,exports.confirmPaymentIntentWithSavedCard=c,exports.createElement=i,exports.createPaymentConsent=A,exports.createPaymentMethod=x,exports.default=y,exports.destroyElement=w,exports.getDeviceFingerprint=u,exports.getElement=d,exports.getGatewayUrl=r,exports.getPaymentIntent=m,exports.init=l,exports.loadAirwallex=n,exports.loadAirwallexJs=o,exports.redirectToCheckout=a;
3
3
  //# sourceMappingURL=airwallex.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"airwallex.cjs.js","sources":["../../src/index.ts"],"sourcesContent":["import Airwallex, {\n init as initFn,\n redirectToCheckout as redirectToCheckoutFn,\n createElement as createElementFn,\n destroyElement as destroyElementFn,\n getElement as getElementFn,\n confirmPaymentIntent as confirmPaymentIntentFn,\n confirmPaymentIntentWithSavedCard as confirmPaymentIntentWithSavedCardFn,\n createPaymentMethod as createPaymentMethodFn,\n getPaymentIntent as getPaymentIntentFn,\n createPaymentConsent as createPaymentConsentFn,\n AirwallexEnv,\n} from '../types/airwallex';\nimport {\n getBrowserInfo as getBrowserInfoFn,\n getDeviceFingerprint as getDeviceFingerprintFn,\n get3dsReturnUrl as get3dsReturnUrlFn,\n handle3ds as handle3dsFn,\n} from '../types/fraud';\nimport { loadAirwallex as loadAirwallexFn } from '../types/index';\nimport { version } from '../package.json';\n\nconst ENV_HOST = {\n prod: 'checkout.airwallex.com',\n demo: 'checkout-demo.airwallex.com',\n staging: 'checkout-staging.airwallex.com',\n /**\n * Below env only for the npm package development\n * Should not using them when integrate with Airwallex\n */\n qa: 'checkoutui.qa.awx.im',\n preview: 'checkoutui.preview.awx.im',\n dev: 'localhost:3000',\n};\n\ndeclare global {\n interface Window {\n Airwallex: Airwallex;\n ReactNativeWebView: {\n postMessage: (message: string) => void;\n };\n }\n}\n\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\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\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\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\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 * @example\n * ```ts \nconst element = Airwallex.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\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\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\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\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\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\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\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\nexport const getBrowserInfo: typeof getBrowserInfoFn = (data) => {\n return window.Airwallex.getBrowserInfo(data);\n};\n\nexport const getDeviceFingerprint: typeof getDeviceFingerprintFn = (data) => {\n return window.Airwallex.getDeviceFingerprint(data);\n};\n\n// eslint-disable-next-line valid-jsdoc\n/**\n * @deprecated this function would need exactly the same API version for merchant and element, so better to not use it\n */\nexport const get3dsReturnUrl: typeof get3dsReturnUrlFn = (data) => {\n return window.Airwallex.get3dsReturnUrl(data);\n};\n\n// eslint-disable-next-line valid-jsdoc\n/**\n * @deprecated this function would need exactly the same API version for merchant and element, so better to not use it\n */\nexport const handle3ds: typeof handle3dsFn = (data) => {\n return window.Airwallex.handle3ds(data);\n};\n"],"names":["ENV_HOST","prod","demo","staging","qa","preview","dev","getGatewayUrl","env","STATIC_JS_URL","loadAirwallexJs","gatewayUrl","script","document","createElement","src","crossOrigin","headOrBody","head","body","Error","appendChild","async","data","window","Airwallex","confirmPaymentIntent","err","console","error","confirmPaymentIntentWithSavedCard","type","options","createPaymentConsent","client_secret","createPaymentMethod","destroyElement","get3dsReturnUrl","getBrowserInfo","getDeviceFingerprint","getElement","id","getPaymentIntent","handle3ds","init","RETRY_COUNT","tryToResolve","querySelector","Promise","resolve","reject","addEventListener","remove","setTimeout","props","redirectToCheckout"],"mappings":";oEAsBA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Airwallex, {\n init as initFn,\n redirectToCheckout as redirectToCheckoutFn,\n createElement as createElementFn,\n destroyElement as destroyElementFn,\n getElement as getElementFn,\n confirmPaymentIntent as confirmPaymentIntentFn,\n confirmPaymentIntentWithSavedCard as confirmPaymentIntentWithSavedCardFn,\n createPaymentMethod as createPaymentMethodFn,\n getPaymentIntent as getPaymentIntentFn,\n createPaymentConsent as createPaymentConsentFn,\n AirwallexEnv,\n} from '../types/airwallex';\nimport { getDeviceFingerprint as getDeviceFingerprintFn } from '../types/fraud';\nimport { loadAirwallex as loadAirwallexFn } from '../types/index';\nimport { version } from '../package.json';\n\nconst ENV_HOST = {\n prod: 'checkout.airwallex.com',\n demo: 'checkout-demo.airwallex.com',\n staging: 'checkout-staging.airwallex.com',\n /**\n * Below env only for the npm package development\n * Should not using them when integrate with Airwallex\n */\n qa: 'checkoutui.qa.awx.im',\n preview: 'checkoutui.preview.awx.im',\n dev: 'localhost:3000',\n};\n\ndeclare global {\n interface Window {\n Airwallex: Airwallex;\n ReactNativeWebView: {\n postMessage: (message: string) => void;\n };\n }\n}\n\n/**\n * @example\n * ```ts \nimport { gatewayUrl } from 'airwallex-payment-elements';\nconst gatewayUrl = getGatewayUrl('prod');\n```\n */\n\nexport const getGatewayUrl = (env: AirwallexEnv): string => `https://${ENV_HOST[env] || ENV_HOST.prod}`;\n\nconst STATIC_JS_URL = `/assets/elements.bundle.min.js?version=${version}`;\n\n/**\n * @example\n * ```ts \nimport { loadAirwallexJs } from 'airwallex-payment-elements';\nconst gatewayUrl = getGatewayUrl('prod');\nloadAirwallexJs(gatewayUrl);\n```\n */\n\nexport const loadAirwallexJs = (gatewayUrl: string): HTMLScriptElement => {\n const script = document.createElement('script');\n script.src = `${gatewayUrl}${STATIC_JS_URL}`;\n script.crossOrigin = 'anonymous';\n\n const headOrBody = document.head || document.body;\n\n if (!headOrBody) {\n throw new Error('Airwallex payment scripts requires a <head> or <body> html element in order to be loaded.');\n }\n\n headOrBody.appendChild(script);\n\n return script;\n};\n\n/**\n * @example\n * ```ts \nimport { loadAirwallex } from 'airwallex-payment-elements';\nloadAirwallex({\n env: 'prod',\n locale: 'en',\n});\n```\n */\n\nexport const loadAirwallex: typeof loadAirwallexFn = async (options) => {\n if (typeof window === 'undefined') {\n return null;\n }\n\n if (window.Airwallex) {\n return window.Airwallex;\n }\n\n const MAX_RETRY_COUNT = 3;\n let RETRY_COUNT = 0;\n const sleep = () => new Promise((resolve) => window.setTimeout(resolve, 500));\n\n const tryToResolve = async (): Promise<Airwallex> => {\n const script: HTMLScriptElement =\n document.querySelector(`script[src=\"${STATIC_JS_URL}\"], script[src=\"${STATIC_JS_URL}/\"]`) ||\n loadAirwallexJs(getGatewayUrl(options?.env || 'prod'));\n\n return new Promise((resolve, reject) => {\n script.addEventListener('load', () => {\n if (window.Airwallex) {\n window.Airwallex.init(options);\n resolve(window.Airwallex);\n } else {\n reject(new Error('Failed to load Airwallex on load event'));\n }\n });\n\n script.addEventListener('error', () => {\n reject(new Error('Failed to load Airwallex scripts'));\n script.remove && script.remove();\n });\n });\n };\n\n while (RETRY_COUNT < MAX_RETRY_COUNT) {\n try {\n return await tryToResolve();\n } catch (error) {\n RETRY_COUNT++;\n await sleep();\n }\n }\n\n return null;\n};\n\n/**\n * @example\n * ```ts \nimport { init } from 'airwallex-payment-elements';\ninit({\n env: 'prod',\n locale: 'en',\n});\n```\n */\n\nexport const init: typeof initFn = (options) => {\n if (!window.Airwallex) {\n console.error('Please loadAirwallex() before init();');\n } else {\n window.Airwallex.init(options);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { redirectToCheckout } from 'airwallex-payment-elements';\nredirectToCheckout({\n env: 'prod',\n intent_id: 'replace-with-your-intent_id',\n client_secret: 'replace-with-your-client-secret',,\n successUrl: `${window.location.origin}/checkout-success?isTesting=N`,\n locale: 'replace-with-your-language',\n showTermLink: true,\n theme: {\n variant: 'bootstrap',\n fonts: [\n {\n src: 'https://checkout.airwallex.com/fonts/CircularXXWeb/CircularXXSub-BoldSubset.woff2',\n family: 'AxLLCircular',\n weight: '700',\n },\n {\n src: 'https://checkout.airwallex.com/fonts/CircularXXWeb/CircularXXWeb-Regular.woff2',\n family: 'AxLLCircular',\n weight: '400',\n },\n ],\n popupWidth: 418,\n popupHeight: 549,\n },\n applePayRequestOptions: {\n countryCode: 'US',\n },\n googlePayRequestOptions: {\n countryCode: 'US',\n },\n requiredBillingContactFields: ['email', 'name'],\n currency: 'HKD',\n});\n```\n */\n\nexport const redirectToCheckout: typeof redirectToCheckoutFn = (props) => {\n if (!window.Airwallex) {\n console.error('Please loadAirwallex() before redirectToCheckout();');\n } else {\n return window.Airwallex.redirectToCheckout(props);\n }\n};\n\n/**\n * We encourage to use `dropIn` element, since it's easy to scale new payment methods\n * We suggest to NOT use `applePayButton`, `googlePayButton`, `wechat`, `qrcode`, `redirect`, `fullFeaturedCard` and `directDebit` elements\n * \n * @example\n * ```ts \nimport { createElement } from 'airwallex-payment-elements';\nconst element = createElement('dropIn', {\n intent_id: 'replace-with-your-intent_id',\n client_secret: 'replace-with-your-client-secret',\n currency: 'replace-with-your-intent-currency',\n // if you want to use apple pay, please pass merchant country code in applePayRequestOptions\n applePayRequestOptions: {\n countryCode: 'replace-with-your-country-code',\n },\n // if you want to use google pay, please pass merchant country code in googlePayRequestOptions\n googlePayRequestOptions: {\n countryCode: 'replace-with-your-country-code',\n },\n});\n```\n */\n\nexport const createElement: typeof createElementFn = (type, options) => {\n if (!window.Airwallex) {\n console.error('Please loadAirwallex() before createElement();');\n return null;\n } else {\n return window.Airwallex.createElement(type, options);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { destroyElement } from 'airwallex-payment-elements';\ndestroyElement('dropIn');\n```\n */\n\nexport const destroyElement: typeof destroyElementFn = (type) => {\n if (!window.Airwallex) {\n console.error('Please loadAirwallex() before destroyElement();');\n return false;\n } else {\n return window.Airwallex.destroyElement(type);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { getElement } from 'airwallex-payment-elements';\ngetElement('dropIn');\n```\n */\n\nexport const getElement: typeof getElementFn = (type) => {\n if (!window.Airwallex) {\n console.error('Please loadAirwallex() before getElement();');\n return null;\n } else {\n return window.Airwallex.getElement(type);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { confirmPaymentIntent } from 'airwallex-payment-elements';\nconfirmPaymentIntent({\n element: card, // Provide Card element\n intent_id: 'replace-with-your-intent_id', // Payment Intent ID\n client_secret: 'replace-with-your-client-secret', // Client Secret\n payment_method_options: {\n card: {\n auto_capture: true,\n },\n },\n})\n```\n */\n\nexport const confirmPaymentIntent: typeof confirmPaymentIntentFn = async (data) => {\n if (!window.Airwallex) {\n const err = 'Please loadAirwallex() before confirmPaymentIntent();';\n console.error(err);\n throw new Error(err);\n } else {\n return window.Airwallex.confirmPaymentIntent(data);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { confirmPaymentIntentWithSavedCard } from 'airwallex-payment-elements';\nconfirmPaymentIntentWithSavedCard({\n element: card, // Provide Card element\n customer_id: 'replace-with-your-customer-id',\n methodId: 'replace-with-your-method-id',\n intent_id: 'replace-with-your-intent_id', // Payment Intent ID\n client_secret: 'replace-with-your-client-secret', // Client Secret\n})\n```\n */\n\nexport const confirmPaymentIntentWithSavedCard: typeof confirmPaymentIntentWithSavedCardFn = async (data) => {\n if (!window.Airwallex) {\n const err = 'Please loadAirwallex() before confirmPaymentIntentWithSavedCard();';\n console.error(err);\n throw new Error(err);\n } else {\n return window.Airwallex.confirmPaymentIntentWithSavedCard(data);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { createPaymentMethod } from 'airwallex-payment-elements';\ncreatePaymentMethod('replace-with-your-client-secret', {\n element: card, // Provide Card element\n customer_id: 'replace-with-your-customer-id',\n})\n```\n */\n\nexport const createPaymentMethod: typeof createPaymentMethodFn = async (client_secret, data) => {\n if (!window.Airwallex) {\n const err = 'Please loadAirwallex() before createPaymentMethod();';\n console.error(err);\n throw new Error(err);\n } else {\n return window.Airwallex.createPaymentMethod(client_secret, data);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { getPaymentIntent } from 'airwallex-payment-elements';\ngetPaymentIntent('replace-with-your-intent_id', 'replace-with-your-client_secret')\n```\n */\n\nexport const getPaymentIntent: typeof getPaymentIntentFn = async (id, client_secret) => {\n if (!window.Airwallex) {\n const err = 'Please loadAirwallex() before getPaymentIntent();';\n console.error(err);\n throw new Error(err);\n } else {\n return window.Airwallex.getPaymentIntent(id, client_secret);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { createPaymentConsent } from 'airwallex-payment-elements';\ncreatePaymentConsent({\n intent_id: 'replace-with-your-intent_id',\n customer_id: 'replace-with-your-customer_id',\n cardname: 'replace-with-your-card_name',\n client_secret: 'replace-with-your-client_secret',\n currency: 'HKD,\n element: cardNumberElement,\n next_triggered_by: 'customer',\n billing: {\n email: 'test@airwallex.com',\n first_name: 'TEST',\n last_name: 'TEST',\n date_of_birth: '2020-07-05',\n phone_number: '13333333333',\n address: {\n city: 'shanghai',\n country_code: 'CN',\n postcode: '200000',\n state: 'Shanghai',\n street: 'Street',\n },\n },\n})\n```\n */\n\nexport const createPaymentConsent: typeof createPaymentConsentFn = async (data) => {\n if (!window.Airwallex) {\n const err = 'Please loadAirwallex() before createPaymentConsent();';\n console.error(err);\n throw new Error(err);\n } else {\n return window.Airwallex.createPaymentConsent(data);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { getDeviceFingerprint } from 'airwallex-payment-elements';\ngetDeviceFingerprint({\n intent_id: 'replace-with-your-intent_id',\n env: 'prod',\n})\n```\n */\n\nexport const getDeviceFingerprint: typeof getDeviceFingerprintFn = (data) => {\n return window.Airwallex.getDeviceFingerprint(data);\n};\n\nexport default {\n getGatewayUrl,\n loadAirwallex,\n loadAirwallexJs,\n init,\n redirectToCheckout,\n createElement,\n destroyElement,\n getDeviceFingerprint,\n getElement,\n getPaymentIntent,\n createPaymentMethod,\n createPaymentConsent,\n confirmPaymentIntent,\n confirmPaymentIntentWithSavedCard,\n};\n"],"names":["ENV_HOST","prod","demo","staging","qa","preview","dev","getGatewayUrl","env","STATIC_JS_URL","loadAirwallexJs","gatewayUrl","script","document","createElement","src","crossOrigin","headOrBody","head","body","Error","appendChild","loadAirwallex","async","options","window","Airwallex","RETRY_COUNT","tryToResolve","querySelector","Promise","resolve","reject","addEventListener","init","remove","error","setTimeout","console","redirectToCheckout","props","type","destroyElement","getElement","confirmPaymentIntent","data","err","confirmPaymentIntentWithSavedCard","createPaymentMethod","client_secret","getPaymentIntent","id","createPaymentConsent","getDeviceFingerprint"],"mappings":";oEAiBA,MAAMA,EAAW,CACfC,KAAM,yBACNC,KAAM,8BACNC,QAAS,iCAKTC,GAAI,uBACJC,QAAS,4BACTC,IAAK,kBAoBMC,EAAiBC,GAA8B,WAAWR,EAASQ,IAAQR,EAASC,OAE3FQ,EAAgB,+CAWTC,EAAmBC,IAC9B,MAAMC,EAASC,SAASC,cAAc,UACtCF,EAAOG,IAAM,GAAGJ,IAAaF,IAC7BG,EAAOI,YAAc,YAErB,MAAMC,EAAaJ,SAASK,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,EAAO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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 [0.3.2] */
2
- const e={prod:"checkout.airwallex.com",demo:"checkout-demo.airwallex.com",staging:"checkout-staging.airwallex.com",qa:"checkoutui.qa.awx.im",preview:"checkoutui.preview.awx.im",dev:"localhost:3000"},r=r=>`https://${e[r]||e.prod}`,o="/assets/elements.bundle.min.js?version=0.3.2",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 i=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 i()}catch(e){l++,await new Promise((e=>window.setTimeout(e,500)))}return null},i=e=>{window.Airwallex?window.Airwallex.init(e):console.error("Please loadAirwallex() before init();")},t=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),a=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)}},x=async(e,r)=>{if(window.Airwallex)return window.Airwallex.createPaymentMethod(e,r);{const e="Please loadAirwallex() before createPaymentMethod();";throw console.error(e),new Error(e)}},m=async(e,r)=>{if(window.Airwallex)return window.Airwallex.getPaymentIntent(e,r);{const e="Please loadAirwallex() before getPaymentIntent();";throw console.error(e),new Error(e)}},A=async e=>{if(window.Airwallex)return window.Airwallex.createPaymentConsent(e);{const e="Please loadAirwallex() before createPaymentConsent();";throw console.error(e),new Error(e)}},u=e=>window.Airwallex.getBrowserInfo(e),f=e=>window.Airwallex.getDeviceFingerprint(e),y=e=>window.Airwallex.get3dsReturnUrl(e),h=e=>window.Airwallex.handle3ds(e);export{c as confirmPaymentIntent,s as confirmPaymentIntentWithSavedCard,w as createElement,A as createPaymentConsent,x as createPaymentMethod,a as destroyElement,y as get3dsReturnUrl,u as getBrowserInfo,f as getDeviceFingerprint,d as getElement,r as getGatewayUrl,m as getPaymentIntent,h as handle3ds,i as init,l as loadAirwallex,n as loadAirwallexJs,t as redirectToCheckout};
1
+ /* Airwallex Checkout Component Version [1.6.0] */
2
+ const e={prod:"checkout.airwallex.com",demo:"checkout-demo.airwallex.com",staging:"checkout-staging.airwallex.com",qa:"checkoutui.qa.awx.im",preview:"checkoutui.preview.awx.im",dev:"localhost:3000"},r=r=>`https://${e[r]||e.prod}`,o="/assets/elements.bundle.min.js?version=1.6.0",n=e=>{const r=document.createElement("script");r.src=`${e}${o}`,r.crossOrigin="anonymous";const n=document.head||document.body;if(!n)throw new Error("Airwallex payment scripts requires a <head> or <body> html element in order to be loaded.");return n.appendChild(r),r},t=async e=>{if("undefined"==typeof window)return null;if(window.Airwallex)return window.Airwallex;let t=0;const l=async()=>{const t=document.querySelector(`script[src="${o}"], script[src="${o}/"]`)||n(r((null==e?void 0:e.env)||"prod"));return new Promise(((r,o)=>{t.addEventListener("load",(()=>{window.Airwallex?(window.Airwallex.init(e),r(window.Airwallex)):o(new Error("Failed to load Airwallex on load event"))})),t.addEventListener("error",(()=>{o(new Error("Failed to load Airwallex scripts")),t.remove&&t.remove()}))}))};for(;t<3;)try{return await l()}catch(e){t++,await new Promise((e=>window.setTimeout(e,500)))}return null},l=e=>{window.Airwallex?window.Airwallex.init(e):console.error("Please loadAirwallex() before init();")},a=e=>{if(window.Airwallex)return window.Airwallex.redirectToCheckout(e);console.error("Please loadAirwallex() before redirectToCheckout();")},i=(e,r)=>window.Airwallex?window.Airwallex.createElement(e,r):(console.error("Please loadAirwallex() before createElement();"),null),w=e=>window.Airwallex?window.Airwallex.destroyElement(e):(console.error("Please loadAirwallex() before destroyElement();"),!1),d=e=>window.Airwallex?window.Airwallex.getElement(e):(console.error("Please loadAirwallex() before getElement();"),null),c=async e=>{if(window.Airwallex)return window.Airwallex.confirmPaymentIntent(e);{const e="Please loadAirwallex() before confirmPaymentIntent();";throw console.error(e),new Error(e)}},s=async e=>{if(window.Airwallex)return window.Airwallex.confirmPaymentIntentWithSavedCard(e);{const e="Please loadAirwallex() before confirmPaymentIntentWithSavedCard();";throw console.error(e),new Error(e)}},m=async(e,r)=>{if(window.Airwallex)return window.Airwallex.createPaymentMethod(e,r);{const e="Please loadAirwallex() before createPaymentMethod();";throw console.error(e),new Error(e)}},x=async(e,r)=>{if(window.Airwallex)return window.Airwallex.getPaymentIntent(e,r);{const e="Please loadAirwallex() before getPaymentIntent();";throw console.error(e),new Error(e)}},A=async e=>{if(window.Airwallex)return window.Airwallex.createPaymentConsent(e);{const e="Please loadAirwallex() before createPaymentConsent();";throw console.error(e),new Error(e)}},u=e=>window.Airwallex.getDeviceFingerprint(e);var y={getGatewayUrl:r,loadAirwallex:t,loadAirwallexJs:n,init:l,redirectToCheckout:a,createElement:i,destroyElement:w,getDeviceFingerprint:u,getElement:d,getPaymentIntent:x,createPaymentMethod:m,createPaymentConsent:A,confirmPaymentIntent:c,confirmPaymentIntentWithSavedCard:s};export default y;export{c as confirmPaymentIntent,s as confirmPaymentIntentWithSavedCard,i as createElement,A as createPaymentConsent,m as createPaymentMethod,w as destroyElement,u as getDeviceFingerprint,d as getElement,r as getGatewayUrl,x as getPaymentIntent,l as init,t as loadAirwallex,n as loadAirwallexJs,a as redirectToCheckout};
3
3
  //# sourceMappingURL=airwallex.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"airwallex.es.js","sources":["../../src/index.ts"],"sourcesContent":["import Airwallex, {\n init as initFn,\n redirectToCheckout as redirectToCheckoutFn,\n createElement as createElementFn,\n destroyElement as destroyElementFn,\n getElement as getElementFn,\n confirmPaymentIntent as confirmPaymentIntentFn,\n confirmPaymentIntentWithSavedCard as confirmPaymentIntentWithSavedCardFn,\n createPaymentMethod as createPaymentMethodFn,\n getPaymentIntent as getPaymentIntentFn,\n createPaymentConsent as createPaymentConsentFn,\n AirwallexEnv,\n} from '../types/airwallex';\nimport {\n getBrowserInfo as getBrowserInfoFn,\n getDeviceFingerprint as getDeviceFingerprintFn,\n get3dsReturnUrl as get3dsReturnUrlFn,\n handle3ds as handle3dsFn,\n} from '../types/fraud';\nimport { loadAirwallex as loadAirwallexFn } from '../types/index';\nimport { version } from '../package.json';\n\nconst ENV_HOST = {\n prod: 'checkout.airwallex.com',\n demo: 'checkout-demo.airwallex.com',\n staging: 'checkout-staging.airwallex.com',\n /**\n * Below env only for the npm package development\n * Should not using them when integrate with Airwallex\n */\n qa: 'checkoutui.qa.awx.im',\n preview: 'checkoutui.preview.awx.im',\n dev: 'localhost:3000',\n};\n\ndeclare global {\n interface Window {\n Airwallex: Airwallex;\n ReactNativeWebView: {\n postMessage: (message: string) => void;\n };\n }\n}\n\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\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\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\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\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 * @example\n * ```ts \nconst element = Airwallex.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\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\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\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\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\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\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\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\nexport const getBrowserInfo: typeof getBrowserInfoFn = (data) => {\n return window.Airwallex.getBrowserInfo(data);\n};\n\nexport const getDeviceFingerprint: typeof getDeviceFingerprintFn = (data) => {\n return window.Airwallex.getDeviceFingerprint(data);\n};\n\n// eslint-disable-next-line valid-jsdoc\n/**\n * @deprecated this function would need exactly the same API version for merchant and element, so better to not use it\n */\nexport const get3dsReturnUrl: typeof get3dsReturnUrlFn = (data) => {\n return window.Airwallex.get3dsReturnUrl(data);\n};\n\n// eslint-disable-next-line valid-jsdoc\n/**\n * @deprecated this function would need exactly the same API version for merchant and element, so better to not use it\n */\nexport const handle3ds: typeof handle3dsFn = (data) => {\n return window.Airwallex.handle3ds(data);\n};\n"],"names":["ENV_HOST","prod","demo","staging","qa","preview","dev","getGatewayUrl","env","STATIC_JS_URL","loadAirwallexJs","gatewayUrl","script","document","createElement","src","crossOrigin","headOrBody","head","body","Error","appendChild","loadAirwallex","async","options","window","Airwallex","RETRY_COUNT","tryToResolve","querySelector","Promise","resolve","reject","addEventListener","init","remove","error","setTimeout","console","redirectToCheckout","props","type","destroyElement","getElement","confirmPaymentIntent","data","err","confirmPaymentIntentWithSavedCard","createPaymentMethod","client_secret","getPaymentIntent","id","createPaymentConsent","getBrowserInfo","getDeviceFingerprint","get3dsReturnUrl","handle3ds"],"mappings":";AAsBA,MAAMA,EAAW,CACfC,KAAM,yBACNC,KAAM,8BACNC,QAAS,iCAKTC,GAAI,uBACJC,QAAS,4BACTC,IAAK,kBAYMC,EAAiBC,GAA8B,WAAWR,EAASQ,IAAQR,EAASC,OAE3FQ,EAAgB,+CAETC,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,GAGIU,EAAwCC,MAAOC,IAC1D,GAAsB,oBAAXC,OACT,OAAO,KAGT,GAAIA,OAAOC,UACT,OAAOD,OAAOC,UAIhB,IAAIC,EAAc,EAClB,MAEMC,EAAeL,UACnB,MAAMX,EACJC,SAASgB,cAAc,eAAepB,oBAAgCA,SACtEC,EAAgBH,GAAciB,MAAAA,SAAAA,EAAShB,MAAO,SAEhD,OAAO,IAAIsB,SAAQ,CAACC,EAASC,KAC3BpB,EAAOqB,iBAAiB,QAAQ,KAC1BR,OAAOC,WACTD,OAAOC,UAAUQ,KAAKV,GACtBO,EAAQN,OAAOC,YAEfM,EAAO,IAAIZ,MAAM,8CAIrBR,EAAOqB,iBAAiB,SAAS,KAC/BD,EAAO,IAAIZ,MAAM,qCACjBR,EAAOuB,QAAUvB,EAAOuB,gBAK9B,KAAOR,EA1BiB,GA2BtB,IACE,aAAaC,IACb,MAAOQ,GACPT,UA5BgB,IAAIG,SAASC,GAAYN,OAAOY,WAAWN,EAAS,OAiCxE,OAAO,MAGIG,EAAuBV,IAC7BC,OAAOC,UAGVD,OAAOC,UAAUQ,KAAKV,GAFtBc,QAAQF,MAAM,0CAMLG,EA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CR,GAC/CpB,OAAOC,UAAU2B,eAAeR,GAG5BS,EAAuDT,GAC3DpB,OAAOC,UAAU4B,qBAAqBT,GAOlCU,EAA6CV,GACjDpB,OAAOC,UAAU6B,gBAAgBV,GAO7BW,EAAiCX,GACrCpB,OAAOC,UAAU8B,UAAUX"}
1
+ {"version":3,"file":"airwallex.es.js","sources":["../../src/index.ts"],"sourcesContent":["import Airwallex, {\n init as initFn,\n redirectToCheckout as redirectToCheckoutFn,\n createElement as createElementFn,\n destroyElement as destroyElementFn,\n getElement as getElementFn,\n confirmPaymentIntent as confirmPaymentIntentFn,\n confirmPaymentIntentWithSavedCard as confirmPaymentIntentWithSavedCardFn,\n createPaymentMethod as createPaymentMethodFn,\n getPaymentIntent as getPaymentIntentFn,\n createPaymentConsent as createPaymentConsentFn,\n AirwallexEnv,\n} from '../types/airwallex';\nimport { getDeviceFingerprint as getDeviceFingerprintFn } from '../types/fraud';\nimport { loadAirwallex as loadAirwallexFn } from '../types/index';\nimport { version } from '../package.json';\n\nconst ENV_HOST = {\n prod: 'checkout.airwallex.com',\n demo: 'checkout-demo.airwallex.com',\n staging: 'checkout-staging.airwallex.com',\n /**\n * Below env only for the npm package development\n * Should not using them when integrate with Airwallex\n */\n qa: 'checkoutui.qa.awx.im',\n preview: 'checkoutui.preview.awx.im',\n dev: 'localhost:3000',\n};\n\ndeclare global {\n interface Window {\n Airwallex: Airwallex;\n ReactNativeWebView: {\n postMessage: (message: string) => void;\n };\n }\n}\n\n/**\n * @example\n * ```ts \nimport { gatewayUrl } from 'airwallex-payment-elements';\nconst gatewayUrl = getGatewayUrl('prod');\n```\n */\n\nexport const getGatewayUrl = (env: AirwallexEnv): string => `https://${ENV_HOST[env] || ENV_HOST.prod}`;\n\nconst STATIC_JS_URL = `/assets/elements.bundle.min.js?version=${version}`;\n\n/**\n * @example\n * ```ts \nimport { loadAirwallexJs } from 'airwallex-payment-elements';\nconst gatewayUrl = getGatewayUrl('prod');\nloadAirwallexJs(gatewayUrl);\n```\n */\n\nexport const loadAirwallexJs = (gatewayUrl: string): HTMLScriptElement => {\n const script = document.createElement('script');\n script.src = `${gatewayUrl}${STATIC_JS_URL}`;\n script.crossOrigin = 'anonymous';\n\n const headOrBody = document.head || document.body;\n\n if (!headOrBody) {\n throw new Error('Airwallex payment scripts requires a <head> or <body> html element in order to be loaded.');\n }\n\n headOrBody.appendChild(script);\n\n return script;\n};\n\n/**\n * @example\n * ```ts \nimport { loadAirwallex } from 'airwallex-payment-elements';\nloadAirwallex({\n env: 'prod',\n locale: 'en',\n});\n```\n */\n\nexport const loadAirwallex: typeof loadAirwallexFn = async (options) => {\n if (typeof window === 'undefined') {\n return null;\n }\n\n if (window.Airwallex) {\n return window.Airwallex;\n }\n\n const MAX_RETRY_COUNT = 3;\n let RETRY_COUNT = 0;\n const sleep = () => new Promise((resolve) => window.setTimeout(resolve, 500));\n\n const tryToResolve = async (): Promise<Airwallex> => {\n const script: HTMLScriptElement =\n document.querySelector(`script[src=\"${STATIC_JS_URL}\"], script[src=\"${STATIC_JS_URL}/\"]`) ||\n loadAirwallexJs(getGatewayUrl(options?.env || 'prod'));\n\n return new Promise((resolve, reject) => {\n script.addEventListener('load', () => {\n if (window.Airwallex) {\n window.Airwallex.init(options);\n resolve(window.Airwallex);\n } else {\n reject(new Error('Failed to load Airwallex on load event'));\n }\n });\n\n script.addEventListener('error', () => {\n reject(new Error('Failed to load Airwallex scripts'));\n script.remove && script.remove();\n });\n });\n };\n\n while (RETRY_COUNT < MAX_RETRY_COUNT) {\n try {\n return await tryToResolve();\n } catch (error) {\n RETRY_COUNT++;\n await sleep();\n }\n }\n\n return null;\n};\n\n/**\n * @example\n * ```ts \nimport { init } from 'airwallex-payment-elements';\ninit({\n env: 'prod',\n locale: 'en',\n});\n```\n */\n\nexport const init: typeof initFn = (options) => {\n if (!window.Airwallex) {\n console.error('Please loadAirwallex() before init();');\n } else {\n window.Airwallex.init(options);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { redirectToCheckout } from 'airwallex-payment-elements';\nredirectToCheckout({\n env: 'prod',\n intent_id: 'replace-with-your-intent_id',\n client_secret: 'replace-with-your-client-secret',,\n successUrl: `${window.location.origin}/checkout-success?isTesting=N`,\n locale: 'replace-with-your-language',\n showTermLink: true,\n theme: {\n variant: 'bootstrap',\n fonts: [\n {\n src: 'https://checkout.airwallex.com/fonts/CircularXXWeb/CircularXXSub-BoldSubset.woff2',\n family: 'AxLLCircular',\n weight: '700',\n },\n {\n src: 'https://checkout.airwallex.com/fonts/CircularXXWeb/CircularXXWeb-Regular.woff2',\n family: 'AxLLCircular',\n weight: '400',\n },\n ],\n popupWidth: 418,\n popupHeight: 549,\n },\n applePayRequestOptions: {\n countryCode: 'US',\n },\n googlePayRequestOptions: {\n countryCode: 'US',\n },\n requiredBillingContactFields: ['email', 'name'],\n currency: 'HKD',\n});\n```\n */\n\nexport const redirectToCheckout: typeof redirectToCheckoutFn = (props) => {\n if (!window.Airwallex) {\n console.error('Please loadAirwallex() before redirectToCheckout();');\n } else {\n return window.Airwallex.redirectToCheckout(props);\n }\n};\n\n/**\n * We encourage to use `dropIn` element, since it's easy to scale new payment methods\n * We suggest to NOT use `applePayButton`, `googlePayButton`, `wechat`, `qrcode`, `redirect`, `fullFeaturedCard` and `directDebit` elements\n * \n * @example\n * ```ts \nimport { createElement } from 'airwallex-payment-elements';\nconst element = createElement('dropIn', {\n intent_id: 'replace-with-your-intent_id',\n client_secret: 'replace-with-your-client-secret',\n currency: 'replace-with-your-intent-currency',\n // if you want to use apple pay, please pass merchant country code in applePayRequestOptions\n applePayRequestOptions: {\n countryCode: 'replace-with-your-country-code',\n },\n // if you want to use google pay, please pass merchant country code in googlePayRequestOptions\n googlePayRequestOptions: {\n countryCode: 'replace-with-your-country-code',\n },\n});\n```\n */\n\nexport const createElement: typeof createElementFn = (type, options) => {\n if (!window.Airwallex) {\n console.error('Please loadAirwallex() before createElement();');\n return null;\n } else {\n return window.Airwallex.createElement(type, options);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { destroyElement } from 'airwallex-payment-elements';\ndestroyElement('dropIn');\n```\n */\n\nexport const destroyElement: typeof destroyElementFn = (type) => {\n if (!window.Airwallex) {\n console.error('Please loadAirwallex() before destroyElement();');\n return false;\n } else {\n return window.Airwallex.destroyElement(type);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { getElement } from 'airwallex-payment-elements';\ngetElement('dropIn');\n```\n */\n\nexport const getElement: typeof getElementFn = (type) => {\n if (!window.Airwallex) {\n console.error('Please loadAirwallex() before getElement();');\n return null;\n } else {\n return window.Airwallex.getElement(type);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { confirmPaymentIntent } from 'airwallex-payment-elements';\nconfirmPaymentIntent({\n element: card, // Provide Card element\n intent_id: 'replace-with-your-intent_id', // Payment Intent ID\n client_secret: 'replace-with-your-client-secret', // Client Secret\n payment_method_options: {\n card: {\n auto_capture: true,\n },\n },\n})\n```\n */\n\nexport const confirmPaymentIntent: typeof confirmPaymentIntentFn = async (data) => {\n if (!window.Airwallex) {\n const err = 'Please loadAirwallex() before confirmPaymentIntent();';\n console.error(err);\n throw new Error(err);\n } else {\n return window.Airwallex.confirmPaymentIntent(data);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { confirmPaymentIntentWithSavedCard } from 'airwallex-payment-elements';\nconfirmPaymentIntentWithSavedCard({\n element: card, // Provide Card element\n customer_id: 'replace-with-your-customer-id',\n methodId: 'replace-with-your-method-id',\n intent_id: 'replace-with-your-intent_id', // Payment Intent ID\n client_secret: 'replace-with-your-client-secret', // Client Secret\n})\n```\n */\n\nexport const confirmPaymentIntentWithSavedCard: typeof confirmPaymentIntentWithSavedCardFn = async (data) => {\n if (!window.Airwallex) {\n const err = 'Please loadAirwallex() before confirmPaymentIntentWithSavedCard();';\n console.error(err);\n throw new Error(err);\n } else {\n return window.Airwallex.confirmPaymentIntentWithSavedCard(data);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { createPaymentMethod } from 'airwallex-payment-elements';\ncreatePaymentMethod('replace-with-your-client-secret', {\n element: card, // Provide Card element\n customer_id: 'replace-with-your-customer-id',\n})\n```\n */\n\nexport const createPaymentMethod: typeof createPaymentMethodFn = async (client_secret, data) => {\n if (!window.Airwallex) {\n const err = 'Please loadAirwallex() before createPaymentMethod();';\n console.error(err);\n throw new Error(err);\n } else {\n return window.Airwallex.createPaymentMethod(client_secret, data);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { getPaymentIntent } from 'airwallex-payment-elements';\ngetPaymentIntent('replace-with-your-intent_id', 'replace-with-your-client_secret')\n```\n */\n\nexport const getPaymentIntent: typeof getPaymentIntentFn = async (id, client_secret) => {\n if (!window.Airwallex) {\n const err = 'Please loadAirwallex() before getPaymentIntent();';\n console.error(err);\n throw new Error(err);\n } else {\n return window.Airwallex.getPaymentIntent(id, client_secret);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { createPaymentConsent } from 'airwallex-payment-elements';\ncreatePaymentConsent({\n intent_id: 'replace-with-your-intent_id',\n customer_id: 'replace-with-your-customer_id',\n cardname: 'replace-with-your-card_name',\n client_secret: 'replace-with-your-client_secret',\n currency: 'HKD,\n element: cardNumberElement,\n next_triggered_by: 'customer',\n billing: {\n email: 'test@airwallex.com',\n first_name: 'TEST',\n last_name: 'TEST',\n date_of_birth: '2020-07-05',\n phone_number: '13333333333',\n address: {\n city: 'shanghai',\n country_code: 'CN',\n postcode: '200000',\n state: 'Shanghai',\n street: 'Street',\n },\n },\n})\n```\n */\n\nexport const createPaymentConsent: typeof createPaymentConsentFn = async (data) => {\n if (!window.Airwallex) {\n const err = 'Please loadAirwallex() before createPaymentConsent();';\n console.error(err);\n throw new Error(err);\n } else {\n return window.Airwallex.createPaymentConsent(data);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { getDeviceFingerprint } from 'airwallex-payment-elements';\ngetDeviceFingerprint({\n intent_id: 'replace-with-your-intent_id',\n env: 'prod',\n})\n```\n */\n\nexport const getDeviceFingerprint: typeof getDeviceFingerprintFn = (data) => {\n return window.Airwallex.getDeviceFingerprint(data);\n};\n\nexport default {\n getGatewayUrl,\n loadAirwallex,\n loadAirwallexJs,\n init,\n redirectToCheckout,\n createElement,\n destroyElement,\n getDeviceFingerprint,\n getElement,\n getPaymentIntent,\n createPaymentMethod,\n createPaymentConsent,\n confirmPaymentIntent,\n confirmPaymentIntentWithSavedCard,\n};\n"],"names":["ENV_HOST","prod","demo","staging","qa","preview","dev","getGatewayUrl","env","STATIC_JS_URL","loadAirwallexJs","gatewayUrl","script","document","createElement","src","crossOrigin","headOrBody","head","body","Error","appendChild","loadAirwallex","async","options","window","Airwallex","RETRY_COUNT","tryToResolve","querySelector","Promise","resolve","reject","addEventListener","init","remove","error","setTimeout","console","redirectToCheckout","props","type","destroyElement","getElement","confirmPaymentIntent","data","err","confirmPaymentIntentWithSavedCard","createPaymentMethod","client_secret","getPaymentIntent","id","createPaymentConsent","getDeviceFingerprint"],"mappings":";AAiBA,MAAMA,EAAW,CACfC,KAAM,yBACNC,KAAM,8BACNC,QAAS,iCAKTC,GAAI,uBACJC,QAAS,4BACTC,IAAK,kBAoBMC,EAAiBC,GAA8B,WAAWR,EAASQ,IAAQR,EAASC,OAE3FQ,EAAgB,+CAWTC,EAAmBC,IAC9B,MAAMC,EAASC,SAASC,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,IA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C,UAKV,OAAOD,OAAOC,UAAUsB,oBAAoBC,EAAeJ,GALtC,CACrB,MAAMC,EAAM,uDAEZ,MADAR,QAAQF,MAAMU,GACR,IAAI1B,MAAM0B,KAcPI,EAA8C3B,MAAO4B,EAAIF,KACpE,GAAKxB,OAAOC,UAKV,OAAOD,OAAOC,UAAUwB,iBAAiBC,EAAIF,GALxB,CACrB,MAAMH,EAAM,oDAEZ,MADAR,QAAQF,MAAMU,GACR,IAAI1B,MAAM0B,KAoCPM,EAAsD7B,MAAOsB,IACxE,GAAKpB,OAAOC,UAKV,OAAOD,OAAOC,UAAU0B,qBAAqBP,GALxB,CACrB,MAAMC,EAAM,wDAEZ,MADAR,QAAQF,MAAMU,GACR,IAAI1B,MAAM0B,KAiBPO,EAAuDR,GAC3DpB,OAAOC,UAAU2B,qBAAqBR,GAG/C,MAAe,CACbtC,cAAAA,EACAe,cAAAA,EACAZ,gBAAAA,EACAwB,KAAAA,EACAK,mBAAAA,EACAzB,cAAAA,EACA4B,eAAAA,EACAW,qBAAAA,EACAV,WAAAA,EACAO,iBAAAA,EACAF,oBAAAA,EACAI,qBAAAA,EACAR,qBAAAA,EACAG,kCAAAA"}
@@ -1,3 +1,3 @@
1
- /* Airwallex Checkout Component Version [0.3.2] */
2
- var Airwallex=function(e){"use strict";const r={prod:"checkout.airwallex.com",demo:"checkout-demo.airwallex.com",staging:"checkout-staging.airwallex.com",qa:"checkoutui.qa.awx.im",preview:"checkoutui.preview.awx.im",dev:"localhost:3000"},n=e=>`https://${r[e]||r.prod}`,o="/assets/elements.bundle.min.js?version=0.3.2",l=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};return e.confirmPaymentIntent=async e=>{if(window.Airwallex)return window.Airwallex.confirmPaymentIntent(e);{const e="Please loadAirwallex() before confirmPaymentIntent();";throw console.error(e),new Error(e)}},e.confirmPaymentIntentWithSavedCard=async e=>{if(window.Airwallex)return window.Airwallex.confirmPaymentIntentWithSavedCard(e);{const e="Please loadAirwallex() before confirmPaymentIntentWithSavedCard();";throw console.error(e),new Error(e)}},e.createElement=(e,r)=>window.Airwallex?window.Airwallex.createElement(e,r):(console.error("Please loadAirwallex() before createElement();"),null),e.createPaymentConsent=async e=>{if(window.Airwallex)return window.Airwallex.createPaymentConsent(e);{const e="Please loadAirwallex() before createPaymentConsent();";throw console.error(e),new Error(e)}},e.createPaymentMethod=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)}},e.destroyElement=e=>window.Airwallex?window.Airwallex.destroyElement(e):(console.error("Please loadAirwallex() before destroyElement();"),!1),e.get3dsReturnUrl=e=>window.Airwallex.get3dsReturnUrl(e),e.getBrowserInfo=e=>window.Airwallex.getBrowserInfo(e),e.getDeviceFingerprint=e=>window.Airwallex.getDeviceFingerprint(e),e.getElement=e=>window.Airwallex?window.Airwallex.getElement(e):(console.error("Please loadAirwallex() before getElement();"),null),e.getGatewayUrl=n,e.getPaymentIntent=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)}},e.handle3ds=e=>window.Airwallex.handle3ds(e),e.init=e=>{window.Airwallex?window.Airwallex.init(e):console.error("Please loadAirwallex() before init();")},e.loadAirwallex=async e=>{if("undefined"==typeof window)return null;if(window.Airwallex)return window.Airwallex;let r=0;const t=async()=>{const r=document.querySelector(`script[src="${o}"], script[src="${o}/"]`)||l(n((null==e?void 0:e.env)||"prod"));return new Promise(((n,o)=>{r.addEventListener("load",(()=>{window.Airwallex?(window.Airwallex.init(e),n(window.Airwallex)):o(new Error("Failed to load Airwallex on load event"))})),r.addEventListener("error",(()=>{o(new Error("Failed to load Airwallex scripts")),r.remove&&r.remove()}))}))};for(;r<3;)try{return await t()}catch(e){r++,await new Promise((e=>window.setTimeout(e,500)))}return null},e.loadAirwallexJs=l,e.redirectToCheckout=e=>{if(window.Airwallex)return window.Airwallex.redirectToCheckout(e);console.error("Please loadAirwallex() before redirectToCheckout();")},Object.defineProperty(e,"__esModule",{value:!0}),e}({});
1
+ /* Airwallex Checkout Component Version [1.6.0] */
2
+ var Airwallex=function(e){"use strict";const r={prod:"checkout.airwallex.com",demo:"checkout-demo.airwallex.com",staging:"checkout-staging.airwallex.com",qa:"checkoutui.qa.awx.im",preview:"checkoutui.preview.awx.im",dev:"localhost:3000"},n=e=>`https://${r[e]||r.prod}`,t="/assets/elements.bundle.min.js?version=1.6.0",o=e=>{const r=document.createElement("script");r.src=`${e}${t}`,r.crossOrigin="anonymous";const n=document.head||document.body;if(!n)throw new Error("Airwallex payment scripts requires a <head> or <body> html element in order to be loaded.");return n.appendChild(r),r},l=async e=>{if("undefined"==typeof window)return null;if(window.Airwallex)return window.Airwallex;let r=0;const l=async()=>{const r=document.querySelector(`script[src="${t}"], script[src="${t}/"]`)||o(n((null==e?void 0:e.env)||"prod"));return new Promise(((n,t)=>{r.addEventListener("load",(()=>{window.Airwallex?(window.Airwallex.init(e),n(window.Airwallex)):t(new Error("Failed to load Airwallex on load event"))})),r.addEventListener("error",(()=>{t(new Error("Failed to load Airwallex scripts")),r.remove&&r.remove()}))}))};for(;r<3;)try{return await l()}catch(e){r++,await new Promise((e=>window.setTimeout(e,500)))}return null},a=e=>{window.Airwallex?window.Airwallex.init(e):console.error("Please loadAirwallex() before init();")},i=e=>{if(window.Airwallex)return window.Airwallex.redirectToCheckout(e);console.error("Please loadAirwallex() before redirectToCheckout();")},w=(e,r)=>window.Airwallex?window.Airwallex.createElement(e,r):(console.error("Please loadAirwallex() before createElement();"),null),d=e=>window.Airwallex?window.Airwallex.destroyElement(e):(console.error("Please loadAirwallex() before destroyElement();"),!1),c=e=>window.Airwallex?window.Airwallex.getElement(e):(console.error("Please loadAirwallex() before getElement();"),null),s=async e=>{if(window.Airwallex)return window.Airwallex.confirmPaymentIntent(e);{const e="Please loadAirwallex() before confirmPaymentIntent();";throw console.error(e),new Error(e)}},m=async e=>{if(window.Airwallex)return window.Airwallex.confirmPaymentIntentWithSavedCard(e);{const e="Please loadAirwallex() before confirmPaymentIntentWithSavedCard();";throw console.error(e),new Error(e)}},x=async(e,r)=>{if(window.Airwallex)return window.Airwallex.createPaymentMethod(e,r);{const e="Please loadAirwallex() before createPaymentMethod();";throw console.error(e),new Error(e)}},u=async(e,r)=>{if(window.Airwallex)return window.Airwallex.getPaymentIntent(e,r);{const e="Please loadAirwallex() before getPaymentIntent();";throw console.error(e),new Error(e)}},A=async e=>{if(window.Airwallex)return window.Airwallex.createPaymentConsent(e);{const e="Please loadAirwallex() before createPaymentConsent();";throw console.error(e),new Error(e)}},y=e=>window.Airwallex.getDeviceFingerprint(e);var f={getGatewayUrl:n,loadAirwallex:l,loadAirwallexJs:o,init:a,redirectToCheckout:i,createElement:w,destroyElement:d,getDeviceFingerprint:y,getElement:c,getPaymentIntent:u,createPaymentMethod:x,createPaymentConsent:A,confirmPaymentIntent:s,confirmPaymentIntentWithSavedCard:m};return e.confirmPaymentIntent=s,e.confirmPaymentIntentWithSavedCard=m,e.createElement=w,e.createPaymentConsent=A,e.createPaymentMethod=x,e.default=f,e.destroyElement=d,e.getDeviceFingerprint=y,e.getElement=c,e.getGatewayUrl=n,e.getPaymentIntent=u,e.init=a,e.loadAirwallex=l,e.loadAirwallexJs=o,e.redirectToCheckout=i,Object.defineProperty(e,"__esModule",{value:!0}),e}({});
3
3
  //# sourceMappingURL=airwallex.iife.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"airwallex.iife.js","sources":["../../src/index.ts"],"sourcesContent":["import Airwallex, {\n init as initFn,\n redirectToCheckout as redirectToCheckoutFn,\n createElement as createElementFn,\n destroyElement as destroyElementFn,\n getElement as getElementFn,\n confirmPaymentIntent as confirmPaymentIntentFn,\n confirmPaymentIntentWithSavedCard as confirmPaymentIntentWithSavedCardFn,\n createPaymentMethod as createPaymentMethodFn,\n getPaymentIntent as getPaymentIntentFn,\n createPaymentConsent as createPaymentConsentFn,\n AirwallexEnv,\n} from '../types/airwallex';\nimport {\n getBrowserInfo as getBrowserInfoFn,\n getDeviceFingerprint as getDeviceFingerprintFn,\n get3dsReturnUrl as get3dsReturnUrlFn,\n handle3ds as handle3dsFn,\n} from '../types/fraud';\nimport { loadAirwallex as loadAirwallexFn } from '../types/index';\nimport { version } from '../package.json';\n\nconst ENV_HOST = {\n prod: 'checkout.airwallex.com',\n demo: 'checkout-demo.airwallex.com',\n staging: 'checkout-staging.airwallex.com',\n /**\n * Below env only for the npm package development\n * Should not using them when integrate with Airwallex\n */\n qa: 'checkoutui.qa.awx.im',\n preview: 'checkoutui.preview.awx.im',\n dev: 'localhost:3000',\n};\n\ndeclare global {\n interface Window {\n Airwallex: Airwallex;\n ReactNativeWebView: {\n postMessage: (message: string) => void;\n };\n }\n}\n\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\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\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\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\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 * @example\n * ```ts \nconst element = Airwallex.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\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\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\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\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\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\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\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\nexport const getBrowserInfo: typeof getBrowserInfoFn = (data) => {\n return window.Airwallex.getBrowserInfo(data);\n};\n\nexport const getDeviceFingerprint: typeof getDeviceFingerprintFn = (data) => {\n return window.Airwallex.getDeviceFingerprint(data);\n};\n\n// eslint-disable-next-line valid-jsdoc\n/**\n * @deprecated this function would need exactly the same API version for merchant and element, so better to not use it\n */\nexport const get3dsReturnUrl: typeof get3dsReturnUrlFn = (data) => {\n return window.Airwallex.get3dsReturnUrl(data);\n};\n\n// eslint-disable-next-line valid-jsdoc\n/**\n * @deprecated this function would need exactly the same API version for merchant and element, so better to not use it\n */\nexport const handle3ds: typeof handle3dsFn = (data) => {\n return window.Airwallex.handle3ds(data);\n};\n"],"names":["ENV_HOST","prod","demo","staging","qa","preview","dev","getGatewayUrl","env","STATIC_JS_URL","loadAirwallexJs","gatewayUrl","script","document","createElement","src","crossOrigin","headOrBody","head","body","Error","appendChild","async","data","window","Airwallex","confirmPaymentIntent","err","console","error","confirmPaymentIntentWithSavedCard","type","options","createPaymentConsent","client_secret","createPaymentMethod","destroyElement","get3dsReturnUrl","getBrowserInfo","getDeviceFingerprint","getElement","id","getPaymentIntent","handle3ds","init","RETRY_COUNT","tryToResolve","querySelector","Promise","resolve","reject","addEventListener","remove","setTimeout","props","redirectToCheckout"],"mappings":";uCAsBA,MAAMA,EAAW,CACfC,KAAM,yBACNC,KAAM,8BACNC,QAAS,iCAKTC,GAAI,uBACJC,QAAS,4BACTC,IAAK,kBAYMC,EAAiBC,GAA8B,WAAWR,EAASQ,IAAQR,EAASC,OAE3FQ,EAAgB,+CAETC,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,iCAgH0DU,MAAOC,IACxE,GAAKC,OAAOC,UAKV,OAAOD,OAAOC,UAAUC,qBAAqBH,GALxB,CACrB,MAAMI,EAAM,wDAEZ,MADAC,QAAQC,MAAMF,GACR,IAAIP,MAAMO,yCAMyEL,MAAOC,IAClG,GAAKC,OAAOC,UAKV,OAAOD,OAAOC,UAAUK,kCAAkCP,GALrC,CACrB,MAAMI,EAAM,qEAEZ,MADAC,QAAQC,MAAMF,GACR,IAAIP,MAAMO,qBAzCiC,CAACI,EAAMC,IACrDR,OAAOC,UAIHD,OAAOC,UAAUX,cAAciB,EAAMC,IAH5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OC,WACTD,OAAOC,UAAUmB,KAAKZ,GACtBiB,EAAQzB,OAAOC,YAEfyB,EAAO,IAAI9B,MAAM,8CAIrBR,EAAOuC,iBAAiB,SAAS,KAC/BD,EAAO,IAAI9B,MAAM,qCACjBR,EAAOwC,QAAUxC,EAAOwC,gBAK9B,KAAOP,EA1BiB,GA2BtB,IACE,aAAaC,IACb,MAAOjB,GACPgB,UA5BgB,IAAIG,SAASC,GAAYzB,OAAO6B,WAAWJ,EAAS,OAiCxE,OAAO,+CAWuDK,IAC9D,GAAK9B,OAAOC,UAGV,OAAOD,OAAOC,UAAU8B,mBAAmBD,GAF3C1B,QAAQC,MAAM"}
1
+ {"version":3,"file":"airwallex.iife.js","sources":["../../src/index.ts"],"sourcesContent":["import Airwallex, {\n init as initFn,\n redirectToCheckout as redirectToCheckoutFn,\n createElement as createElementFn,\n destroyElement as destroyElementFn,\n getElement as getElementFn,\n confirmPaymentIntent as confirmPaymentIntentFn,\n confirmPaymentIntentWithSavedCard as confirmPaymentIntentWithSavedCardFn,\n createPaymentMethod as createPaymentMethodFn,\n getPaymentIntent as getPaymentIntentFn,\n createPaymentConsent as createPaymentConsentFn,\n AirwallexEnv,\n} from '../types/airwallex';\nimport { getDeviceFingerprint as getDeviceFingerprintFn } from '../types/fraud';\nimport { loadAirwallex as loadAirwallexFn } from '../types/index';\nimport { version } from '../package.json';\n\nconst ENV_HOST = {\n prod: 'checkout.airwallex.com',\n demo: 'checkout-demo.airwallex.com',\n staging: 'checkout-staging.airwallex.com',\n /**\n * Below env only for the npm package development\n * Should not using them when integrate with Airwallex\n */\n qa: 'checkoutui.qa.awx.im',\n preview: 'checkoutui.preview.awx.im',\n dev: 'localhost:3000',\n};\n\ndeclare global {\n interface Window {\n Airwallex: Airwallex;\n ReactNativeWebView: {\n postMessage: (message: string) => void;\n };\n }\n}\n\n/**\n * @example\n * ```ts \nimport { gatewayUrl } from 'airwallex-payment-elements';\nconst gatewayUrl = getGatewayUrl('prod');\n```\n */\n\nexport const getGatewayUrl = (env: AirwallexEnv): string => `https://${ENV_HOST[env] || ENV_HOST.prod}`;\n\nconst STATIC_JS_URL = `/assets/elements.bundle.min.js?version=${version}`;\n\n/**\n * @example\n * ```ts \nimport { loadAirwallexJs } from 'airwallex-payment-elements';\nconst gatewayUrl = getGatewayUrl('prod');\nloadAirwallexJs(gatewayUrl);\n```\n */\n\nexport const loadAirwallexJs = (gatewayUrl: string): HTMLScriptElement => {\n const script = document.createElement('script');\n script.src = `${gatewayUrl}${STATIC_JS_URL}`;\n script.crossOrigin = 'anonymous';\n\n const headOrBody = document.head || document.body;\n\n if (!headOrBody) {\n throw new Error('Airwallex payment scripts requires a <head> or <body> html element in order to be loaded.');\n }\n\n headOrBody.appendChild(script);\n\n return script;\n};\n\n/**\n * @example\n * ```ts \nimport { loadAirwallex } from 'airwallex-payment-elements';\nloadAirwallex({\n env: 'prod',\n locale: 'en',\n});\n```\n */\n\nexport const loadAirwallex: typeof loadAirwallexFn = async (options) => {\n if (typeof window === 'undefined') {\n return null;\n }\n\n if (window.Airwallex) {\n return window.Airwallex;\n }\n\n const MAX_RETRY_COUNT = 3;\n let RETRY_COUNT = 0;\n const sleep = () => new Promise((resolve) => window.setTimeout(resolve, 500));\n\n const tryToResolve = async (): Promise<Airwallex> => {\n const script: HTMLScriptElement =\n document.querySelector(`script[src=\"${STATIC_JS_URL}\"], script[src=\"${STATIC_JS_URL}/\"]`) ||\n loadAirwallexJs(getGatewayUrl(options?.env || 'prod'));\n\n return new Promise((resolve, reject) => {\n script.addEventListener('load', () => {\n if (window.Airwallex) {\n window.Airwallex.init(options);\n resolve(window.Airwallex);\n } else {\n reject(new Error('Failed to load Airwallex on load event'));\n }\n });\n\n script.addEventListener('error', () => {\n reject(new Error('Failed to load Airwallex scripts'));\n script.remove && script.remove();\n });\n });\n };\n\n while (RETRY_COUNT < MAX_RETRY_COUNT) {\n try {\n return await tryToResolve();\n } catch (error) {\n RETRY_COUNT++;\n await sleep();\n }\n }\n\n return null;\n};\n\n/**\n * @example\n * ```ts \nimport { init } from 'airwallex-payment-elements';\ninit({\n env: 'prod',\n locale: 'en',\n});\n```\n */\n\nexport const init: typeof initFn = (options) => {\n if (!window.Airwallex) {\n console.error('Please loadAirwallex() before init();');\n } else {\n window.Airwallex.init(options);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { redirectToCheckout } from 'airwallex-payment-elements';\nredirectToCheckout({\n env: 'prod',\n intent_id: 'replace-with-your-intent_id',\n client_secret: 'replace-with-your-client-secret',,\n successUrl: `${window.location.origin}/checkout-success?isTesting=N`,\n locale: 'replace-with-your-language',\n showTermLink: true,\n theme: {\n variant: 'bootstrap',\n fonts: [\n {\n src: 'https://checkout.airwallex.com/fonts/CircularXXWeb/CircularXXSub-BoldSubset.woff2',\n family: 'AxLLCircular',\n weight: '700',\n },\n {\n src: 'https://checkout.airwallex.com/fonts/CircularXXWeb/CircularXXWeb-Regular.woff2',\n family: 'AxLLCircular',\n weight: '400',\n },\n ],\n popupWidth: 418,\n popupHeight: 549,\n },\n applePayRequestOptions: {\n countryCode: 'US',\n },\n googlePayRequestOptions: {\n countryCode: 'US',\n },\n requiredBillingContactFields: ['email', 'name'],\n currency: 'HKD',\n});\n```\n */\n\nexport const redirectToCheckout: typeof redirectToCheckoutFn = (props) => {\n if (!window.Airwallex) {\n console.error('Please loadAirwallex() before redirectToCheckout();');\n } else {\n return window.Airwallex.redirectToCheckout(props);\n }\n};\n\n/**\n * We encourage to use `dropIn` element, since it's easy to scale new payment methods\n * We suggest to NOT use `applePayButton`, `googlePayButton`, `wechat`, `qrcode`, `redirect`, `fullFeaturedCard` and `directDebit` elements\n * \n * @example\n * ```ts \nimport { createElement } from 'airwallex-payment-elements';\nconst element = createElement('dropIn', {\n intent_id: 'replace-with-your-intent_id',\n client_secret: 'replace-with-your-client-secret',\n currency: 'replace-with-your-intent-currency',\n // if you want to use apple pay, please pass merchant country code in applePayRequestOptions\n applePayRequestOptions: {\n countryCode: 'replace-with-your-country-code',\n },\n // if you want to use google pay, please pass merchant country code in googlePayRequestOptions\n googlePayRequestOptions: {\n countryCode: 'replace-with-your-country-code',\n },\n});\n```\n */\n\nexport const createElement: typeof createElementFn = (type, options) => {\n if (!window.Airwallex) {\n console.error('Please loadAirwallex() before createElement();');\n return null;\n } else {\n return window.Airwallex.createElement(type, options);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { destroyElement } from 'airwallex-payment-elements';\ndestroyElement('dropIn');\n```\n */\n\nexport const destroyElement: typeof destroyElementFn = (type) => {\n if (!window.Airwallex) {\n console.error('Please loadAirwallex() before destroyElement();');\n return false;\n } else {\n return window.Airwallex.destroyElement(type);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { getElement } from 'airwallex-payment-elements';\ngetElement('dropIn');\n```\n */\n\nexport const getElement: typeof getElementFn = (type) => {\n if (!window.Airwallex) {\n console.error('Please loadAirwallex() before getElement();');\n return null;\n } else {\n return window.Airwallex.getElement(type);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { confirmPaymentIntent } from 'airwallex-payment-elements';\nconfirmPaymentIntent({\n element: card, // Provide Card element\n intent_id: 'replace-with-your-intent_id', // Payment Intent ID\n client_secret: 'replace-with-your-client-secret', // Client Secret\n payment_method_options: {\n card: {\n auto_capture: true,\n },\n },\n})\n```\n */\n\nexport const confirmPaymentIntent: typeof confirmPaymentIntentFn = async (data) => {\n if (!window.Airwallex) {\n const err = 'Please loadAirwallex() before confirmPaymentIntent();';\n console.error(err);\n throw new Error(err);\n } else {\n return window.Airwallex.confirmPaymentIntent(data);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { confirmPaymentIntentWithSavedCard } from 'airwallex-payment-elements';\nconfirmPaymentIntentWithSavedCard({\n element: card, // Provide Card element\n customer_id: 'replace-with-your-customer-id',\n methodId: 'replace-with-your-method-id',\n intent_id: 'replace-with-your-intent_id', // Payment Intent ID\n client_secret: 'replace-with-your-client-secret', // Client Secret\n})\n```\n */\n\nexport const confirmPaymentIntentWithSavedCard: typeof confirmPaymentIntentWithSavedCardFn = async (data) => {\n if (!window.Airwallex) {\n const err = 'Please loadAirwallex() before confirmPaymentIntentWithSavedCard();';\n console.error(err);\n throw new Error(err);\n } else {\n return window.Airwallex.confirmPaymentIntentWithSavedCard(data);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { createPaymentMethod } from 'airwallex-payment-elements';\ncreatePaymentMethod('replace-with-your-client-secret', {\n element: card, // Provide Card element\n customer_id: 'replace-with-your-customer-id',\n})\n```\n */\n\nexport const createPaymentMethod: typeof createPaymentMethodFn = async (client_secret, data) => {\n if (!window.Airwallex) {\n const err = 'Please loadAirwallex() before createPaymentMethod();';\n console.error(err);\n throw new Error(err);\n } else {\n return window.Airwallex.createPaymentMethod(client_secret, data);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { getPaymentIntent } from 'airwallex-payment-elements';\ngetPaymentIntent('replace-with-your-intent_id', 'replace-with-your-client_secret')\n```\n */\n\nexport const getPaymentIntent: typeof getPaymentIntentFn = async (id, client_secret) => {\n if (!window.Airwallex) {\n const err = 'Please loadAirwallex() before getPaymentIntent();';\n console.error(err);\n throw new Error(err);\n } else {\n return window.Airwallex.getPaymentIntent(id, client_secret);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { createPaymentConsent } from 'airwallex-payment-elements';\ncreatePaymentConsent({\n intent_id: 'replace-with-your-intent_id',\n customer_id: 'replace-with-your-customer_id',\n cardname: 'replace-with-your-card_name',\n client_secret: 'replace-with-your-client_secret',\n currency: 'HKD,\n element: cardNumberElement,\n next_triggered_by: 'customer',\n billing: {\n email: 'test@airwallex.com',\n first_name: 'TEST',\n last_name: 'TEST',\n date_of_birth: '2020-07-05',\n phone_number: '13333333333',\n address: {\n city: 'shanghai',\n country_code: 'CN',\n postcode: '200000',\n state: 'Shanghai',\n street: 'Street',\n },\n },\n})\n```\n */\n\nexport const createPaymentConsent: typeof createPaymentConsentFn = async (data) => {\n if (!window.Airwallex) {\n const err = 'Please loadAirwallex() before createPaymentConsent();';\n console.error(err);\n throw new Error(err);\n } else {\n return window.Airwallex.createPaymentConsent(data);\n }\n};\n\n/**\n * @example\n * ```ts \nimport { getDeviceFingerprint } from 'airwallex-payment-elements';\ngetDeviceFingerprint({\n intent_id: 'replace-with-your-intent_id',\n env: 'prod',\n})\n```\n */\n\nexport const getDeviceFingerprint: typeof getDeviceFingerprintFn = (data) => {\n return window.Airwallex.getDeviceFingerprint(data);\n};\n\nexport default {\n getGatewayUrl,\n loadAirwallex,\n loadAirwallexJs,\n init,\n redirectToCheckout,\n createElement,\n destroyElement,\n getDeviceFingerprint,\n getElement,\n getPaymentIntent,\n createPaymentMethod,\n createPaymentConsent,\n confirmPaymentIntent,\n confirmPaymentIntentWithSavedCard,\n};\n"],"names":["ENV_HOST","prod","demo","staging","qa","preview","dev","getGatewayUrl","env","STATIC_JS_URL","loadAirwallexJs","gatewayUrl","script","document","createElement","src","crossOrigin","headOrBody","head","body","Error","appendChild","loadAirwallex","async","options","window","Airwallex","RETRY_COUNT","tryToResolve","querySelector","Promise","resolve","reject","addEventListener","init","remove","error","setTimeout","console","redirectToCheckout","props","type","destroyElement","getElement","confirmPaymentIntent","data","err","confirmPaymentIntentWithSavedCard","createPaymentMethod","client_secret","getPaymentIntent","id","createPaymentConsent","getDeviceFingerprint"],"mappings":";uCAiBA,MAAMA,EAAW,CACfC,KAAM,yBACNC,KAAM,8BACNC,QAAS,iCAKTC,GAAI,uBACJC,QAAS,4BACTC,IAAK,kBAoBMC,EAAiBC,GAA8B,WAAWR,EAASQ,IAAQR,EAASC,OAE3FQ,EAAgB,+CAWTC,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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AAM0B,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,SAGhC,CACbtC,cAAAA,EACAe,cAAAA,EACAZ,gBAAAA,EACAwB,KAAAA,EACAK,mBAAAA,EACAzB,cAAAA,EACA4B,eAAAA,EACAW,qBAAAA,EACAV,WAAAA,EACAO,iBAAAA,EACAF,oBAAAA,EACAI,qBAAAA,EACAR,qBAAAA,EACAG,kCAAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "airwallex-payment-elements",
3
- "version": "0.3.2",
3
+ "version": "1.6.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",
@@ -9,10 +9,6 @@
9
9
  "lib": "lib/bin/airwallex.es.js",
10
10
  "bin": "lib/bin/airwallex.cjs.js"
11
11
  },
12
- "repository": {
13
- "type": "git",
14
- "url": "git+https://github.com/airwallex/airwallex-payment-elements.git"
15
- },
16
12
  "license": "MIT",
17
13
  "keywords": [
18
14
  "Airwallex",
@@ -50,8 +46,9 @@
50
46
  "@rollup/plugin-json": "^4.1.0",
51
47
  "@rollup/plugin-node-resolve": "^11.2.0",
52
48
  "@rollup/plugin-replace": "^2.3.4",
53
- "@semantic-release/changelog": "^5.0.1",
54
- "@semantic-release/git": "^9.0.0",
49
+ "@semantic-release/git": "^10.0.1",
50
+ "@semantic-release/gitlab": "^11.0.1",
51
+ "@semantic-release/npm": "^9.0.2",
55
52
  "@types/jest": "^26.0.20",
56
53
  "@typescript-eslint/eslint-plugin": "^4.15.1",
57
54
  "@typescript-eslint/parser": "^4.15.1",
@@ -69,8 +66,8 @@
69
66
  "rollup-plugin-analyzer": "^4.0.0",
70
67
  "rollup-plugin-eslint": "^7.0.0",
71
68
  "rollup-plugin-terser": "^7.0.2",
72
- "rollup-plugin-typescript2": "^0.30.0",
73
- "semantic-release": "^17.3.9",
69
+ "rollup-plugin-typescript2": "^0.34.1",
70
+ "semantic-release": "^20.1.1",
74
71
  "serve": "^14.0.1",
75
72
  "sonarqube-scanner": "^2.8.0",
76
73
  "ts-jest": "^26.5.1",
@@ -79,10 +76,10 @@
79
76
  "tslint-plugin-prettier": "^2.3.0",
80
77
  "typedoc": "^0.23.18",
81
78
  "typedoc-plugin-extras": "^2.3.0",
82
- "typedoc-plugin-missing-exports": "^1.0.0",
83
- "typescript": "4.8.3",
84
79
  "typedoc-plugin-markdown": "^3.14.0",
85
- "typedoc-plugin-merge-modules": "^4.0.1"
80
+ "typedoc-plugin-merge-modules": "^4.0.1",
81
+ "typedoc-plugin-missing-exports": "^1.0.0",
82
+ "typescript": "4.8.3"
86
83
  },
87
84
  "husky": {
88
85
  "hooks": {
@@ -7,7 +7,6 @@ import {
7
7
  CvcElementOptions,
8
8
  FullFeaturedCardElementOptions,
9
9
  WechatElementOptions,
10
- PaymentRequestButtonOptions,
11
10
  ApplePayButtonOptions,
12
11
  } from './element';
13
12
  import { QrcodeElementOptions } from './qrcodeElement';
@@ -19,10 +18,9 @@ import {
19
18
  GooglePayHppRequestOptions,
20
19
  ContactField,
21
20
  } from './element';
22
- import { getBrowserInfo, getDeviceFingerprint, get3dsReturnUrl, handle3ds } from './fraud';
21
+ import { getDeviceFingerprint } from './fraud';
23
22
  import { DropInElementOptions } from './dropInElement';
24
23
  import { RedirectElementOptions } from './redirectElement';
25
- import { DirectDebitElementOptions } from './directDebitElement';
26
24
 
27
25
  export type Locale =
28
26
  | 'en'
@@ -416,6 +414,8 @@ export declare const redirectToCheckout: (props: HostPaymentPage) => void | stri
416
414
 
417
415
  /**
418
416
  * The definition mapping of supported integration element type with it's props options used to customize the element, merchant can check on each element options type for details
417
+ * We encourage to use `dropIn` element, since it's easy to scale new payment methods
418
+ * We suggest to NOT use `applePayButton`, `googlePayButton`, `wechat`, `qrcode`, `redirect` and `fullFeaturedCard` elements
419
419
  */
420
420
  export interface ElementOptionsTypeMap {
421
421
  /**
@@ -433,11 +433,6 @@ export interface ElementOptionsTypeMap {
433
433
  * Using together with `cardNumber` and `expiry` element to gain maximum customization
434
434
  */
435
435
  cvc: CvcElementOptions;
436
- /**
437
- * Define W3C payment request API element type and it's mapped option type
438
- * @deprecated paymentRequestButton is no longer supported by airwallex
439
- */
440
- paymentRequestButton: PaymentRequestButtonOptions;
441
436
  /**
442
437
  * Define apple pay element type and it's mapped option type
443
438
  */
@@ -466,10 +461,6 @@ export interface ElementOptionsTypeMap {
466
461
  * Define full featured card element type and it's mapped option type, this integration make integrate with Airwallex supported card payment method like a single widget
467
462
  */
468
463
  fullFeaturedCard: FullFeaturedCardElementOptions;
469
- /**
470
- * Define direct debit element type and it's mapped option type, this integration make integrate with Airwallex supported direct debit payment method like a single widget
471
- */
472
- directDebit: DirectDebitElementOptions;
473
464
  }
474
465
 
475
466
  /**
@@ -542,6 +533,8 @@ export interface Consent {
542
533
  /**
543
534
  * Element integration `step #2`
544
535
  * Create payment element for checkout
536
+ * We encourage to use `dropIn` element, since it's easy to scale new payment methods
537
+ * We suggest to NOT use `applePayButton`, `googlePayButton`, `wechat`, `qrcode`, `redirect` and `fullFeaturedCard` elements
545
538
  */
546
539
  export declare function createElement<T extends ElementType>(
547
540
  type: T,
@@ -606,8 +599,6 @@ export interface PaymentConsentRequest {
606
599
  /**
607
600
  * If the intent provided, this should be the client_secret of the intent
608
601
  * If no intent provided, this should be the client_secret of the customer
609
- * For `cardNumber` or `card` element, it should be required.
610
- * For `directDebit` element, you needn't provide it.
611
602
  */
612
603
  client_secret?: string;
613
604
  /**
@@ -715,10 +706,7 @@ export interface Airwallex {
715
706
  createPaymentMethod: typeof createPaymentMethod;
716
707
  createPaymentConsent: typeof createPaymentConsent;
717
708
  getPaymentIntent: typeof getPaymentIntent;
718
- getBrowserInfo: typeof getBrowserInfo;
719
709
  getDeviceFingerprint: typeof getDeviceFingerprint;
720
- get3dsReturnUrl: typeof get3dsReturnUrl;
721
- handle3ds: typeof handle3ds;
722
710
  }
723
711
 
724
712
  export default Airwallex;
@@ -6,6 +6,8 @@
6
6
  * This interface only contain the necessary information when shopper checkout
7
7
  * For the detail meaning of each field you can refer to above api document
8
8
  */
9
+ import { Billing } from './airwallex';
10
+
9
11
  export interface Intent {
10
12
  /**
11
13
  * Id of intent
@@ -69,31 +71,30 @@ export interface Intent {
69
71
 
70
72
  /**
71
73
  * Interface for paymentmethod which will return to merchant, trigger by method call with createPaymentConsent
74
+ * Refer to the type description: https://www.airwallex.com/docs/api#/Payment_Acceptance/Payment_Methods/_api_v1_pa_payment_methods_create/post
72
75
  */
73
76
  export interface PaymentMethodBasicInfo {
74
- /**
75
- * The id of the payment method
76
- */
77
77
  id: string;
78
- /**
79
- * The card detail of the payment method
80
- */
78
+ created_at: string;
79
+ customer_id: string;
80
+ status: 'CREATED' | 'VERIFIED' | 'DISABLED';
81
+ type: 'card' | 'applepay' | 'googlepay' | 'ach_direct_debit' | 'bacs_direct_debit' | 'becs_direct_debit' | 'sepa_direct_debit';
82
+ updated_at: string;
81
83
  card: {
82
- /**
83
- * The bin code of the card
84
- */
84
+ avs_check?: string;
85
+ billing?: Billing;
85
86
  bin?: string;
86
- /**
87
- * The last 4 numbers of the card
88
- */
89
- last4?: string;
90
- /**
91
- * The brand of the card
92
- */
93
87
  brand?: string;
94
- /**
95
- * The cardholder name of the card
96
- */
88
+ card_type?: string;
89
+ cvc_check?: string;
90
+ expiry_month?: string;
91
+ expiry_year?: string;
92
+ fingerprint?: string;
93
+ is_commercial: boolean;
94
+ issuer_country_code?: string;
95
+ issuer_name?: string;
96
+ last4?: string;
97
97
  name?: string;
98
+ number_type?: string;
98
99
  };
99
100
  }
@@ -92,4 +92,13 @@ export interface DropInElementOptions extends ElementOptions {
92
92
  * Billing info from merchant
93
93
  */
94
94
  billing?: Billing;
95
+
96
+ /**
97
+ * Customize DropIn Element Style
98
+ */
99
+ theme?: {
100
+ palette?: {
101
+ primary?: string;
102
+ };
103
+ };
95
104
  }
@@ -4,13 +4,16 @@ import { PaymentMethodWithQrcode, QrcodeElementOptions } from './qrcodeElement';
4
4
  import { RecurringOptions } from './airwallex';
5
5
  import { DropInElementOptions } from './dropInElement';
6
6
  import { RedirectElementOptions } from './redirectElement';
7
- import { NextAction } from './fraud';
8
7
  import { Mode, InitOptions } from './airwallex';
9
8
 
10
- export type ContactField = 'name' | 'email' | 'address' | 'phone';
9
+ // address will include country_code, postcode, state, city and street
10
+ // country_code and address only need to pick one
11
+ export type ContactField = 'name' | 'email' | 'country_code' | 'address' | 'phone';
11
12
 
12
13
  /**
13
14
  * Supported integration element type
15
+ * We encourage to use `dropIn` element, since it's easy to scale new payment methods
16
+ * We suggest to NOT use `applePayButton`, `googlePayButton`, `wechat`, `qrcode`, `redirect` and `fullFeaturedCard` elements
14
17
  */
15
18
  export type ElementType =
16
19
  | 'applePayButton'
@@ -18,17 +21,12 @@ export type ElementType =
18
21
  | 'expiry'
19
22
  | 'cvc'
20
23
  | 'googlePayButton'
21
- /**
22
- * @deprecated paymentRequestButton is no longer supported by airwallex
23
- */
24
- | 'paymentRequestButton'
25
24
  | 'card'
26
25
  | 'wechat'
27
26
  | 'qrcode'
28
27
  | 'redirect'
29
28
  | 'dropIn'
30
- | 'fullFeaturedCard'
31
- | 'directDebit';
29
+ | 'fullFeaturedCard';
32
30
 
33
31
  /**
34
32
  * All payment method options for redirect element, those payment method type integration will trigger redirection from your checkout site to specific provider’s authentication page.
@@ -98,7 +96,11 @@ export type PaymentMethodWithRedirect =
98
96
  | 'go_pay'
99
97
  | 'linkaja'
100
98
  | 'jenius_pay'
101
- | 'klarna';
99
+ | 'klarna'
100
+ | 'korean_local_card'
101
+ | 'naver_pay'
102
+ | 'payco'
103
+ | 'samsung_pay';
102
104
 
103
105
  export type DirectDebitPaymentMethod =
104
106
  | 'ach_direct_debit'
@@ -203,6 +205,27 @@ export interface ElementError {
203
205
  * String code, will support in the future
204
206
  */
205
207
  code?: ERROR_CODE;
208
+ /**
209
+ * Error details, only apply for card payment method
210
+ */
211
+ details?: {
212
+ /**
213
+ * Indicate the card brand
214
+ */
215
+ card_brand?: string;
216
+ /**
217
+ * Indicate the card type, CREDIT / DEBIT / PREPAID
218
+ */
219
+ card_type?: string;
220
+ /**
221
+ * Indicate if the card is commercial
222
+ */
223
+ is_commercial?: false;
224
+ /**
225
+ * Indicate the Issuing bank name
226
+ */
227
+ issuing_bank_name: string;
228
+ };
206
229
  }
207
230
 
208
231
  /**
@@ -246,6 +269,20 @@ export interface EventDetail {
246
269
  arrowKey?: 'ArrowLeft' | 'ArrowRight' | 'ArrowTop' | 'ArrowDown';
247
270
  }
248
271
 
272
+ /**
273
+ * The `next_action` field returned from the confirm request
274
+ */
275
+ interface NextAction {
276
+ data: {
277
+ jwt: string;
278
+ stage: string;
279
+ version: string;
280
+ };
281
+ type: string;
282
+ url: string;
283
+ stage?: string;
284
+ }
285
+
249
286
  export type ExtendEventDetail = EventDetail & {
250
287
  code?: string;
251
288
  redirectUrl?: string;
@@ -465,11 +502,24 @@ export interface CvcElementOptions extends ElementOptions {
465
502
  /**
466
503
  * Apply to full featured card element type integration, interface used when call createElement with type `fullFeaturedCard`
467
504
  */
468
- export interface FullFeaturedCardPaymentOptions extends ElementOptions {
505
+ export interface FullFeaturedCardElementOptions extends ElementOptions {
506
+ /**
507
+ * If intent_id provided, this should be the client_secret of the intent
508
+ * If no intent_id provided, this should be the client_secret of the customer
509
+ */
510
+ client_secret: string;
511
+ /**
512
+ * Checkout mode
513
+ */
514
+ mode?: 'payment' | 'recurring';
515
+ /**
516
+ * The payment intent id you would like to checkout, it's required when mode is `payment`
517
+ */
518
+ intent_id?: string;
469
519
  /**
470
520
  * The payment intent you would like to checkout
471
521
  * Refer to [Airwallex Client API](https://www.airwallex.com/docs/api#/Payment_Acceptance/Payment_Intents/Intro)
472
- *
522
+ * @deprecated Please use client_secret and intent_id directly
473
523
  */
474
524
  intent?: Intent;
475
525
  /**
@@ -492,35 +542,17 @@ export interface FullFeaturedCardPaymentOptions extends ElementOptions {
492
542
  * Container for authentication form, it's an element id
493
543
  */
494
544
  authFormContainer?: string;
495
- /**
496
- * Checkout mode
497
- */
498
- mode?: 'payment';
499
- }
500
-
501
- export interface FullFeaturedCardRecurringOptions extends Omit<FullFeaturedCardPaymentOptions, 'mode'> {
502
- /**
503
- * If the intent provided, this should be the client_secret of the intent
504
- * If no intent provided, this should be the client_secret of the customer
505
- */
506
- client_secret: string;
507
- /**
508
- * Checkout mode
509
- */
510
- mode: 'recurring';
511
545
  /**
512
546
  * Checkout for know customer, refer to [Airwallex Client API](https://www.airwallex.com/docs/api#/Payment_Acceptance/Customers/Intro)
513
- * If no intent provided, this field should be required
547
+ * it's required when mode is `recurring`
514
548
  */
515
- customer_id: string;
549
+ customer_id?: string;
516
550
  /**
517
- * The options of recurring flow
551
+ * The options of recurring flow, it's required when mode is `recurring`
518
552
  */
519
- recurringOptions: RecurringOptions;
553
+ recurringOptions?: RecurringOptions;
520
554
  }
521
555
 
522
- export type FullFeaturedCardElementOptions = FullFeaturedCardPaymentOptions | FullFeaturedCardRecurringOptions;
523
-
524
556
  /**
525
557
  * The PaymentShippingOption dictionary has members describing a shipping option.
526
558
  */
@@ -895,47 +927,6 @@ export interface ApplePayButtonOptions extends ElementOptions, ApplePayRequestOp
895
927
  autoCapture?: boolean;
896
928
  }
897
929
 
898
- /**
899
- * Apply to W3C payment request API element type integration, interface used when call createElement with type `paymentRequestButton`
900
- * @deprecated paymentRequestButton is no longer supported by airwallex
901
- */
902
- export interface PaymentRequestButtonOptions extends ElementOptions {
903
- /**
904
- * The payment intent you would like to checkout
905
- * Refer to [Airwallex Client API](https://www.airwallex.com/docs/api#/Payment_Acceptance/Payment_Intents/Intro)
906
- *
907
- */
908
- intent?: Intent;
909
- /**
910
- * Indicate whether to capture immediate when authentication success
911
- */
912
- autoCapture?: boolean;
913
- /**
914
- * Indicate if the payment form collect payer name is required
915
- */
916
- requestPayerName?: boolean;
917
- /**
918
- * Indicate if the payment form collect payer email is required
919
- */
920
- requestPayerEmail?: boolean;
921
- /**
922
- * Indicate if the payment form collect payer phone is required
923
- */
924
- requestPayerPhone?: boolean;
925
- /**
926
- * Indicate if the payment form collect shipping info from shopper is required
927
- */
928
- requestShipping?: boolean;
929
- /**
930
- * The shippingOptions must be supplied when requestShipping is true for the customer to proceed in the flow.
931
- */
932
- shippingOptions?: Array<PaymentShippingOption>;
933
- /**
934
- * Container for authentication form, it's an element id
935
- */
936
- authFormContainer?: string;
937
- }
938
-
939
930
  /**
940
931
  * Apply to wechat element type integration, interface used when call createElement with type `wechat`
941
932
  */
@@ -970,8 +961,7 @@ export interface Element {
970
961
  | DropInElementOptions
971
962
  | WechatElementOptions
972
963
  | QrcodeElementOptions
973
- | RedirectElementOptions
974
- | PaymentRequestButtonOptions;
964
+ | RedirectElementOptions;
975
965
  /**
976
966
  * The iframe element after mount to the DOM
977
967
  */
@@ -1018,8 +1008,7 @@ export interface Element {
1018
1008
  | QrcodeElementOptions
1019
1009
  | RedirectElementOptions
1020
1010
  | ApplePayButtonOptions
1021
- | GooglePayButtonOptions
1022
- | PaymentRequestButtonOptions,
1011
+ | GooglePayButtonOptions,
1023
1012
  initOptions?: InitOptions,
1024
1013
  ): void;
1025
1014
  }
package/types/fraud.d.ts CHANGED
@@ -2,54 +2,6 @@ import { AirwallexEnv } from './airwallex';
2
2
  import { Intent } from './cardNumber';
3
3
  import { ExtendEventDetail } from './element';
4
4
 
5
- /**
6
- * The response of getBrowserInfo
7
- */
8
- export interface GetBrowserInfoResponse {
9
- /**
10
- * The height of the screen
11
- */
12
- screen_height: number;
13
- /**
14
- * The width of the screen
15
- */
16
- screen_width: number;
17
- /**
18
- * The color depth of the screen
19
- */
20
- screen_color_depth: number;
21
- /**
22
- * The language of browser
23
- */
24
- language: string;
25
- /**
26
- * The offset between browser time zone and UTC in minutes
27
- */
28
- timezone: number;
29
- /**
30
- * The browser infos
31
- */
32
- browser: {
33
- /**
34
- * Indicates if the browser supports java
35
- */
36
- java_enabled: boolean;
37
- /**
38
- * Indicates if the browser supports javascript
39
- */
40
- javascript_enabled: boolean;
41
- /**
42
- * The user agent of current session
43
- */
44
- user_agent: string;
45
- };
46
- }
47
-
48
- /**
49
- * Method to get browser info which will be used when confirm payment intent
50
- */
51
- export declare const getBrowserInfo: (props?: GetDeviceFingerprintRequest) => GetBrowserInfoResponse;
52
-
53
5
  /**
54
6
  * The request payload for getDeviceFingerprint
55
7
  *
@@ -73,77 +25,3 @@ export interface GetDeviceFingerprintRequest {
73
25
  * Method to collect device fingerprint
74
26
  */
75
27
  export declare const getDeviceFingerprint: (props: GetDeviceFingerprintRequest) => string;
76
-
77
- /**
78
- * The `next_action` field returned from the confirm request
79
- */
80
- interface NextAction {
81
- data: {
82
- jwt: string;
83
- stage: string;
84
- version: string;
85
- };
86
- type: string;
87
- url: string;
88
- stage?: string;
89
- }
90
-
91
- /**
92
- * The request params when calling handle3ds
93
- */
94
- interface Handle3dsRequest {
95
- /**
96
- * Indicate which airwallex integration env your merchant site would like to connect with
97
- * If not provide default will be prod which point to [Airwallex Checkout](https://checkout.airwallex.com)
98
- */
99
- env: AirwallexEnv;
100
- /**
101
- * The intent that you would like to checkout
102
- */
103
- intent: Intent;
104
- /**
105
- * next_action of the transaction, could got it from confirm response
106
- */
107
- next_action: NextAction;
108
- /**
109
- * the id of the container you would like the 3ds popup to show
110
- */
111
- authFormContainer?: string;
112
- /**
113
- * The size of the 3DS challenge popup
114
- * The available options are below. Any invalid option will map to option '05'
115
- *
116
- * '01': ['250px', '400px']
117
- * '02': ['390px', '400px']
118
- * '03': ['500px', '600px']
119
- * '04': ['600px', '400px']
120
- * '05': ['100%', '100%']
121
- *
122
- */
123
- challengeWindowSize?: string;
124
- }
125
-
126
- /**
127
- * @deprecated this function would need exactly the same API version for merchant and element, so better to not use it
128
- * Method to let airwallex fully handle 3ds flow
129
- */
130
- export declare const handle3ds: (props: Handle3dsRequest) => Promise<ExtendEventDetail>;
131
-
132
- /**
133
- * The request params for get3dsReturnUrl
134
- */
135
- interface Get3dsReturnUrlRequest {
136
- /**
137
- * Indicate which airwallex integration env your merchant site would like to connect with
138
- * If not provide default will be prod which point to [Airwallex Checkout](https://checkout.airwallex.com)
139
- */
140
- env?: AirwallexEnv;
141
- // The origin of the url where user want to checkout, by default will get the window.location.origin
142
- checkoutOrigin?: String;
143
- }
144
-
145
- /**
146
- * @deprecated this function would need exactly the same API version for merchant and element, so better to not use it
147
- * Method to get the return url for 3ds case
148
- */
149
- export declare const get3dsReturnUrl: (props: Get3dsReturnUrlRequest) => string;
package/types/index.d.ts CHANGED
@@ -4,7 +4,6 @@ export * from './qrcodeElement';
4
4
  export * from './fraud';
5
5
  export * from './redirectElement';
6
6
  export * from './dropInElement';
7
- export * from './directDebitElement';
8
7
 
9
8
  import Airwallex, {
10
9
  init,
@@ -1,22 +0,0 @@
1
- import { ElementOptions, DirectDebitPaymentMethod } from './element';
2
-
3
- export interface DirectDebitElementOptions extends ElementOptions {
4
- /**
5
- * If the intent provided, this should be the client_secret of the intent
6
- * If no intent provided, this should be the client_secret of the customer
7
- */
8
- client_secret: string;
9
- /**
10
- * Supported integration payment method type for DirectDebitElement,
11
- * should be one of ['ach_direct_debit', 'sepa_direct_debit', 'bacs_direct_debit', 'becs_direct_debit']
12
- */
13
- method: DirectDebitPaymentMethod;
14
- /**
15
- * Customer name
16
- */
17
- shopper_name?: string;
18
- /**
19
- * Customer email
20
- */
21
- shopper_email?: string;
22
- }