airwallex-payment-elements 0.2.92 → 0.2.99
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 +52 -4
- package/catalog-info.yaml +66 -0
- package/lib/bin/airwallex.cjs.js +1 -1
- package/lib/bin/airwallex.cjs.js.map +1 -1
- package/lib/bin/airwallex.es.js +1 -1
- package/lib/bin/airwallex.es.js.map +1 -1
- package/lib/bin/airwallex.iife.js +1 -1
- package/lib/bin/airwallex.iife.js.map +1 -1
- package/package.json +13 -6
- package/typedocconfig.js +42 -0
- package/types/airwallex.d.ts +19 -1
- package/types/cardNumber.d.ts +2 -2
- package/types/dropInElement.d.ts +5 -1
- package/types/element.d.ts +11 -1
- package/types/qrcodeElement.d.ts +19 -2
package/.gitlab-ci.yml
CHANGED
|
@@ -13,12 +13,20 @@ cache:
|
|
|
13
13
|
stages:
|
|
14
14
|
- test
|
|
15
15
|
- build
|
|
16
|
+
- deploy-doc-staging
|
|
16
17
|
- publish-github-package
|
|
17
18
|
- publish-npm-package
|
|
18
19
|
# Unit Test
|
|
20
|
+
|
|
21
|
+
.bucket_deploy_script: &bucket_deploy_script |-
|
|
22
|
+
cd docs
|
|
23
|
+
gsutil -m cp -r ./public/* gs://${BUCKET_NAME}
|
|
24
|
+
gsutil -m setmeta -r -h "Cache-Control:no-store,no-cache,max-age=0" gs://${BUCKET_NAME}/index.html
|
|
25
|
+
|
|
26
|
+
|
|
19
27
|
test:
|
|
20
28
|
coverage: /All\sfiles.*?\s+(\d+.\d+)/
|
|
21
|
-
image: node:
|
|
29
|
+
image: node:16.13-alpine
|
|
22
30
|
variables:
|
|
23
31
|
KUBERNETES_MEMORY_REQUEST: 8Gi
|
|
24
32
|
KUBERNETES_MEMORY_LIMIT: 8Gi
|
|
@@ -31,8 +39,9 @@ test:
|
|
|
31
39
|
artifacts:
|
|
32
40
|
paths:
|
|
33
41
|
- coverage
|
|
42
|
+
|
|
34
43
|
build:
|
|
35
|
-
image: node:
|
|
44
|
+
image: node:16.13-alpine
|
|
36
45
|
stage: build
|
|
37
46
|
script:
|
|
38
47
|
- yarn build
|
|
@@ -40,9 +49,48 @@ build:
|
|
|
40
49
|
paths:
|
|
41
50
|
- dist
|
|
42
51
|
- lib
|
|
52
|
+
- public
|
|
53
|
+
|
|
54
|
+
build-doc:
|
|
55
|
+
image: node:18.1-alpine
|
|
56
|
+
stage: build
|
|
57
|
+
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
|
+
- yarn build
|
|
64
|
+
artifacts:
|
|
65
|
+
paths:
|
|
66
|
+
- dist
|
|
67
|
+
- lib
|
|
68
|
+
- 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
|
+
|
|
43
91
|
# Publish github package
|
|
44
92
|
publish-github-package:
|
|
45
|
-
image: node:
|
|
93
|
+
image: node:16.13-alpine
|
|
46
94
|
stage: publish-github-package
|
|
47
95
|
only:
|
|
48
96
|
- master
|
|
@@ -52,7 +100,7 @@ publish-github-package:
|
|
|
52
100
|
- npm publish
|
|
53
101
|
# Publish npm package
|
|
54
102
|
publish-npm-package:
|
|
55
|
-
image: node:
|
|
103
|
+
image: node:16.13-alpine
|
|
56
104
|
stage: publish-npm-package
|
|
57
105
|
only:
|
|
58
106
|
- master
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# This file is only used by DevHub devhub.awx.im to display software metadata.
|
|
2
|
+
# It can contain multiple catalog entities, separated by ---.
|
|
3
|
+
|
|
4
|
+
# To learn more about configuring this file, see:
|
|
5
|
+
# - Backstage official Doc: https://backstage.io/docs/features/software-catalog/descriptor-format
|
|
6
|
+
# - Backstage System Model: https://backstage.io/docs/features/software-catalog/system-model
|
|
7
|
+
# - Airwallex catalog files: https://gitlab.awx.im/common/backstage-catalog
|
|
8
|
+
# - Airwallex FAQ and troubleshooting Doc: https://gitlab.awx.im/common/backstage-catalog/-/tree/master/docs
|
|
9
|
+
|
|
10
|
+
# To onboard your software to DevHub,
|
|
11
|
+
# 1. Remove the first # symbol in the following lines
|
|
12
|
+
# 2. Replace the Change_Me placeholder with your custom values
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
#apiVersion: backstage.io/v1alpha1 # [required]
|
|
16
|
+
#kind: Component # [required] https://backstage.io/docs/features/software-catalog/descriptor-format#kind-component
|
|
17
|
+
#metadata: # [required]
|
|
18
|
+
# # Note: The name should be a K8s service name or a library name because a GitLab repository can contain multiple services.
|
|
19
|
+
# name: Change_Me # [required] Must be unique per Kind. Must consist of sequences of [a-z0-9A-Z] possibly separated by one of [-_.].
|
|
20
|
+
#
|
|
21
|
+
# # description: Change_Me_Or_Comment_Out_This_Line # [optional] A human readable description of the entity, to be shown in DevHub.
|
|
22
|
+
#
|
|
23
|
+
# annotations: # [optional] Consumed by plugins.
|
|
24
|
+
# # Used by GitLab plugins to display PRs, Pipelines and so on. The value format is <gitlab-group>/<gitlab-repo-name>, e.g. gtpn/airwallex-ocs.
|
|
25
|
+
# gitlab.com/project-slug: acquiring/airwallex-payment-elements
|
|
26
|
+
# # Used by Kubernetes plugin to display k8s serviceboards. The value is your k8s service name.
|
|
27
|
+
# backstage.io/kubernetes-id: Change_Me_Or_Comment_Out_This_Line
|
|
28
|
+
# # Used by Opsgenie plugin to display Who Is On-Call. The value is Opsgenie team name, e.g. "CN DevOps".
|
|
29
|
+
# opsgenie.com/team: Change_Me_Or_Comment_Out_This_Line
|
|
30
|
+
# # Used by Opsgenie plugin to display alerts
|
|
31
|
+
# # This annotation accepts any valid Opsgenie Search queries for alerts, see
|
|
32
|
+
# # https://support.atlassian.com/opsgenie/docs/search-queries-for-alerts/
|
|
33
|
+
# opsgenie.com/component-selector: 'Change_Me_Or_Comment_Out_This_Line'
|
|
34
|
+
#
|
|
35
|
+
# links: # [optional] A list of links to be shown on entity page.
|
|
36
|
+
# - url: https://gitlab.awx.im/acquiring/airwallex-payment-elements
|
|
37
|
+
# title: GitLab Repo
|
|
38
|
+
# icon: github # [optional] Available icons: chat, dashboard, docs, email, github, group, help, search, user, warning
|
|
39
|
+
#
|
|
40
|
+
# # labels: # [optional] Labels are optional key/value pairs that are attached to the entity.
|
|
41
|
+
# # key1: value2
|
|
42
|
+
# # key2: value2
|
|
43
|
+
#
|
|
44
|
+
# # tags: # [optional] A list of single-valued strings.
|
|
45
|
+
# # - value1
|
|
46
|
+
# # - value2
|
|
47
|
+
#
|
|
48
|
+
#spec: # [required]
|
|
49
|
+
# type: service # [required] The value is service, library and so on.
|
|
50
|
+
# lifecycle: production # [required] The value is one of the experimental, production, deprecated.
|
|
51
|
+
# # Note: Use only the available group names at https://devhub.awx.im/catalog?filters%5Bkind%5D=group&filters%5Buser%5D=all
|
|
52
|
+
# owner: Change_Me_Only_Use_Group_Name_in_DevHub # [required] Group or User in DevHub, e.g. a feature team team-cloud-infra, or a user email prefix andy.wang.
|
|
53
|
+
#
|
|
54
|
+
# # system: Change_Me_Or_Comment_Out_This_Line # [optional] An entity reference to the system that the component belongs to.
|
|
55
|
+
#
|
|
56
|
+
# # dependsOn: # [optional] An array of entity references to the components and resources that the component depends on.
|
|
57
|
+
# # - resource:default/Change_Me
|
|
58
|
+
# # - component:default/Change_Me
|
|
59
|
+
#
|
|
60
|
+
# # providesApis: # [optional] An array of entity references to the APIs that are provided by the component.
|
|
61
|
+
# # - Change_Me
|
|
62
|
+
# # - Change_Me
|
|
63
|
+
#
|
|
64
|
+
# # consumesApis: # [optional] An array of entity references to the APIs that are consumed by the component.
|
|
65
|
+
# # - Change_Me
|
|
66
|
+
# # - Change_Me
|
package/lib/bin/airwallex.cjs.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* Airwallex Checkout Component Version [0.2.
|
|
1
|
+
/* Airwallex Checkout Component Version [0.2.99] */
|
|
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",t=e=>{const r=document.createElement("script");r.src=`${e}${o}`;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();")};
|
|
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';\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';\n\nexport const loadAirwallexJs = (gatewayUrl: string): HTMLScriptElement => {\n const script = document.createElement('script');\n script.src = `${gatewayUrl}${STATIC_JS_URL}`;\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\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/**\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/**\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","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":";oEAqBA,MAAMA,EAAW,CACfC,KAAM,yBACNC,KAAM,8BACNC,QAAS,iCAKTC,GAAI,uBACJC,QAAS,4BACTC,IAAK,kBAYMC,EAAiBC,GAA8B,WAAWR,EAASQ,IAAQR,EAASC,OAE3FQ,EAAgB,iCAETC,EAAmBC,IAC9B,MAAMC,EAASC,SAASC,cAAc,UACtCF,EAAOG,IAAM,GAAGJ,IAAaF,IAE7B,MAAMO,EAAaH,SAASI,MAAQJ,SAASK,KAE7C,IAAKF,EACH,MAAM,IAAIG,MAAM,6FAKlB,OAFAH,EAAWI,YAAYR,GAEhBA,gCA6F0DS,MAAOC,IACxE,GAAKC,OAAOC,UAKV,OAAOD,OAAOC,UAAUC,qBAAqBH,GALxB,CACrB,MAAMI,EAAM,wDAEZ,MADAC,QAAQC,MAAMF,GACR,IAAIP,MAAMO,+CAMyEL,MAAOC,IAClG,GAAKC,OAAOC,UAKV,OAAOD,OAAOC,UAAUK,kCAAkCP,GALrC,CACrB,MAAMI,EAAM,qEAEZ,MADAC,QAAQC,MAAMF,GACR,IAAIP,MAAMO,2BAzCiC,CAACI,EAAMC,IACrDR,OAAOC,UAIHD,OAAOC,UAAUV,cAAcgB,EAAMC,IAH5CJ,QAAQC,MAAM,kDACP,mCAgEwDP,MAAOC,IACxE,GAAKC,OAAOC,UAKV,OAAOD,OAAOC,UAAUQ,qBAAqBV,GALxB,CACrB,MAAMI,EAAM,wDAEZ,MADAC,QAAQC,MAAMF,GACR,IAAIP,MAAMO,iCAxB6CL,MAAOY,EAAeX,KACrF,GAAKC,OAAOC,UAKV,OAAOD,OAAOC,UAAUU,oBAAoBD,EAAeX,GALtC,CACrB,MAAMI,EAAM,uDAEZ,MADAC,QAAQC,MAAMF,GACR,IAAIP,MAAMO,4BA1CoCI,GACjDP,OAAOC,UAIHD,O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AU8B,mBAAmBD,GAF3C1B,QAAQC,MAAM"}
|
|
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';\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';\n\nexport const loadAirwallexJs = (gatewayUrl: string): HTMLScriptElement => {\n const script = document.createElement('script');\n script.src = `${gatewayUrl}${STATIC_JS_URL}`;\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","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":";oEAqBA,MAAMA,EAAW,CACfC,KAAM,yBACNC,KAAM,8BACNC,QAAS,iCAKTC,GAAI,uBACJC,QAAS,4BACTC,IAAK,kBAYMC,EAAiBC,GAA8B,WAAWR,EAASQ,IAAQR,EAASC,OAE3FQ,EAAgB,iCAETC,EAAmBC,IAC9B,MAAMC,EAASC,SAASC,cAAc,UACtCF,EAAOG,IAAM,GAAGJ,IAAaF,IAE7B,MAAMO,EAAaH,SAASI,MAAQJ,SAASK,KAE7C,IAAKF,EACH,MAAM,IAAIG,MAAM,6FAKlB,OAFAH,EAAWI,YAAYR,GAEhBA,gCAgH0DS,MAAOC,IACxE,GAAKC,OAAOC,UAKV,OAAOD,OAAOC,UAAUC,qBAAqBH,GALxB,CACrB,MAAMI,EAAM,wDAEZ,MADAC,QAAQC,MAAMF,GACR,IAAIP,MAAMO,+CAMyEL,MAAOC,IAClG,GAAKC,OAAOC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exB,UACnB,MAAMT,EACJC,SAASiC,cAAc,eAAerC,oBAAgCA,SACtEC,EAAgBH,GAAcwB,MAAAA,SAAAA,EAASvB,MAAO,SAEhD,OAAO,IAAIuC,SAAQ,CAACC,EAASC,KAC3BrC,EAAOsC,iBAAiB,QAAQ,KAC1B3B,OAAOC,WACTD,OAAOC,UAAUmB,KAAKZ,GACtBiB,EAAQzB,OAAOC,YAEfyB,EAAO,IAAI9B,MAAM,8CAIrBP,EAAOsC,iBAAiB,SAAS,KAC/BD,EAAO,IAAI9B,MAAM,qCACjBP,EAAOuC,QAAUvC,EAAOuC,gBAK9B,KAAOP,EA1BiB,GA2BtB,IACE,aAAaC,IACb,MAAOjB,GACPgB,UA5BgB,IAAIG,SAASC,GAAYzB,OAAO6B,WAAWJ,EAAS,OAiCxE,OAAO,2DAWuDK,IAC9D,GAAK9B,OAAOC,UAGV,OAAOD,OAAOC,UAAU8B,mBAAmBD,GAF3C1B,QAAQC,MAAM"}
|
package/lib/bin/airwallex.es.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* Airwallex Checkout Component Version [0.2.
|
|
1
|
+
/* Airwallex Checkout Component Version [0.2.99] */
|
|
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",l=e=>{const r=document.createElement("script");r.src=`${e}${o}`;const l=document.head||document.body;if(!l)throw new Error("Airwallex payment scripts requires a <head> or <body> html element in order to be loaded.");return l.appendChild(r),r},n=async e=>{if("undefined"==typeof window)return null;if(window.Airwallex)return window.Airwallex;let n=0;const i=async()=>{const n=document.querySelector(`script[src="${o}"], script[src="${o}/"]`)||l(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 i()}catch(e){n++,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),h=e=>window.Airwallex.get3dsReturnUrl(e),y=e=>window.Airwallex.handle3ds(e);export{c as confirmPaymentIntent,s as confirmPaymentIntentWithSavedCard,w as createElement,A as createPaymentConsent,x as createPaymentMethod,a as destroyElement,h as get3dsReturnUrl,u as getBrowserInfo,f as getDeviceFingerprint,d as getElement,r as getGatewayUrl,m as getPaymentIntent,y as handle3ds,i as init,n as loadAirwallex,l as loadAirwallexJs,t 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';\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';\n\nexport const loadAirwallexJs = (gatewayUrl: string): HTMLScriptElement => {\n const script = document.createElement('script');\n script.src = `${gatewayUrl}${STATIC_JS_URL}`;\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\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/**\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/**\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","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":";AAqBA,MAAMA,EAAW,CACfC,KAAM,yBACNC,KAAM,8BACNC,QAAS,iCAKTC,GAAI,uBACJC,QAAS,4BACTC,IAAK,kBAYMC,EAAiBC,GAA8B,WAAWR,EAASQ,IAAQR,EAASC,OAE3FQ,EAAgB,iCAETC,EAAmBC,IAC9B,MAAMC,EAASC,SAASC,cAAc,UACtCF,EAAOG,IAAM,GAAGJ,IAAaF,IAE7B,MAAMO,EAAaH,SAASI,MAAQJ,SAASK,KAE7C,IAAKF,EACH,MAAM,IAAIG,MAAM,6FAKlB,OAFAH,EAAWI,YAAYR,GAEhBA,GAGIS,EAAwCC,MAAOC,IAC1D,GAAsB,oBAAXC,OACT,OAAO,KAGT,GAAIA,OAAOC,UACT,OAAOD,OAAOC,UAIhB,IAAIC,EAAc,EAClB,MAEMC,EAAeL,UACnB,MAAMV,EACJC,SAASe,cAAc,eAAenB,oBAAgCA,SACtEC,EAAgBH,GAAcgB,MAAAA,SAAAA,EAASf,MAAO,SAEhD,OAAO,IAAIqB,SAAQ,CAACC,EAASC,KAC3BnB,EAAOoB,iBAAiB,QAAQ,KAC1BR,OAAOC,WACTD,OAAOC,UAAUQ,KAAKV,GACtBO,EAAQN,OAAOC,YAEfM,EAAO,IAAIZ,MAAM,8CAIrBP,E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,OAAOC,UAKV,OAAOD,OAAOC,UAAUwB,iBAAiBC,EAAIF,GALxB,CACrB,MAAMH,EAAM,oDAEZ,MADAR,QAAQF,MAAMU,GACR,IAAI1B,MAAM0B,KAMPM,EAAsD7B,MAAOsB,IACxE,GAAKpB,OAAOC,UAKV,OAAOD,OAAOC,UAAU0B,qBAAqBP,GALxB,CACrB,MAAMC,EAAM,wDAEZ,MADAR,QAAQF,MAAMU,GACR,IAAI1B,MAAM0B,KAMPO,EAA2CR,GAC/CpB,OAAOC,UAAU2B,eAAeR,GAG5BS,EAAuDT,GAC3DpB,OAAOC,UAAU4B,qBAAqBT,GAMlCU,EAA6CV,GACjDpB,OAAOC,UAAU6B,gBAAgBV,GAM7BW,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 {\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';\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';\n\nexport const loadAirwallexJs = (gatewayUrl: string): HTMLScriptElement => {\n const script = document.createElement('script');\n script.src = `${gatewayUrl}${STATIC_JS_URL}`;\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","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":";AAqBA,MAAMA,EAAW,CACfC,KAAM,yBACNC,KAAM,8BACNC,QAAS,iCAKTC,GAAI,uBACJC,QAAS,4BACTC,IAAK,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Component Version [0.2.
|
|
1
|
+
/* Airwallex Checkout Component Version [0.2.99] */
|
|
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",l=e=>{const r=document.createElement("script");r.src=`${e}${o}`;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}({});
|
|
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';\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';\n\nexport const loadAirwallexJs = (gatewayUrl: string): HTMLScriptElement => {\n const script = document.createElement('script');\n script.src = `${gatewayUrl}${STATIC_JS_URL}`;\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\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/**\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/**\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","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":";uCAqBA,MAAMA,EAAW,CACfC,KAAM,yBACNC,KAAM,8BACNC,QAAS,iCAKTC,GAAI,uBACJC,QAAS,4BACTC,IAAK,kBAYMC,EAAiBC,GAA8B,WAAWR,EAASQ,IAAQR,EAASC,OAE3FQ,EAAgB,iCAETC,EAAmBC,IAC9B,MAAMC,EAASC,SAASC,cAAc,UACtCF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D,EAAIP,GALxB,CACrB,MAAMP,EAAM,oDAEZ,MADAC,QAAQC,MAAMF,GACR,IAAIP,MAAMO,iBAkC0BJ,GACrCC,OAAOC,UAAUkB,UAAUpB,UAhHAS,IAC7BR,OAAOC,UAGVD,OAAOC,UAAUmB,KAAKZ,GAFtBJ,QAAQC,MAAM,0DAjDmCP,MAAOU,IAC1D,GAAsB,oBAAXR,OACT,OAAO,KAGT,GAAIA,OAAOC,UACT,OAAOD,OAAOC,UAIhB,IAAIoB,EAAc,EAClB,MAEMC,EAAexB,UACnB,MAAMT,EACJC,SAASiC,cAAc,eAAerC,oBAAgCA,SACtEC,EAAgBH,GAAcwB,MAAAA,SAAAA,EAASvB,MAAO,SAEhD,OAAO,IAAIuC,SAAQ,CAACC,EAASC,KAC3BrC,EAAOsC,iBAAiB,QAAQ,KAC1B3B,OAAOC,WACTD,OAAOC,UAAUmB,KAAKZ,GACtBiB,EAAQzB,OAAOC,YAEfyB,EAAO,IAAI9B,MAAM,8CAIrBP,EAAOsC,iBAAiB,SAAS,KAC/BD,EAAO,IAAI9B,MAAM,qCACjBP,EAAOuC,QAAUvC,EAAOuC,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 {\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';\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';\n\nexport const loadAirwallexJs = (gatewayUrl: string): HTMLScriptElement => {\n const script = document.createElement('script');\n script.src = `${gatewayUrl}${STATIC_JS_URL}`;\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","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":";uCAqBA,MAAMA,EAAW,CACfC,KAAM,yBACNC,KAAM,8BACNC,QAAS,iCAKTC,GAAI,uBACJC,QAAS,4BACTC,IAAK,kBAYMC,EAAiBC,GAA8B,WAAWR,EAASQ,IAAQR,EAASC,OAE3FQ,EAAgB,iCAETC,EAAmBC,IAC9B,MAAMC,EAASC,SAASC,cAAc,UACtCF,EAAOG,IAAM,GAAGJ,IAAaF,IAE7B,MAAMO,EAAaH,SAASI,MAAQJ,SAASK,KAE7C,IAAKF,EACH,MAAM,IAAIG,MAAM,6FAKlB,OAFAH,EAAWI,YAAYR,GAEhBA,iCAgH0DS,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,UAAUV,cAAcgB,EAAMC,IAH5CJ,QAAQC,MAAM,kDACP,6BAgEwDP,MAAOC,IACxE,GAAKC,OAAOC,UAKV,OAAOD,OAAOC,UAAUQ,qBAAqBV,GALxB,CACrB,MAAMI,EAAM,wDAEZ,MADAC,QAAQ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M,qCACjBP,EAAOuC,QAAUvC,EAAOuC,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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "airwallex-payment-elements",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.99",
|
|
4
4
|
"module": "lib/bin/airwallex.es.js",
|
|
5
5
|
"main": "lib/bin/airwallex.cjs.js",
|
|
6
6
|
"bin": "lib/bin/airwallex.cjs.js",
|
|
@@ -36,7 +36,9 @@
|
|
|
36
36
|
"semantic-release": "semantic-release",
|
|
37
37
|
"type-coverage": "type-coverage --detail",
|
|
38
38
|
"test": "jest --verbose --forceExit --coverage --watchAll=false --silent",
|
|
39
|
-
"test-watch": "jest -o --verbose false -u --watch"
|
|
39
|
+
"test-watch": "jest -o --verbose false -u --watch",
|
|
40
|
+
"typedoc": "typedoc --options ./typedocconfig.js",
|
|
41
|
+
"typedoc-watch": "typedoc --options ./typedocconfig.js --watch & serve ./output"
|
|
40
42
|
},
|
|
41
43
|
"author": "Charlie.Lang",
|
|
42
44
|
"devDependencies": {
|
|
@@ -69,13 +71,16 @@
|
|
|
69
71
|
"rollup-plugin-terser": "^7.0.2",
|
|
70
72
|
"rollup-plugin-typescript2": "^0.30.0",
|
|
71
73
|
"semantic-release": "^17.3.9",
|
|
72
|
-
"serve": "^
|
|
74
|
+
"serve": "^14.0.1",
|
|
73
75
|
"sonarqube-scanner": "^2.8.0",
|
|
74
76
|
"ts-jest": "^26.5.1",
|
|
75
77
|
"tslint-config-prettier": "^1.18.0",
|
|
76
78
|
"tslint-eslint-rules": "^5.4.0",
|
|
77
79
|
"tslint-plugin-prettier": "^2.3.0",
|
|
78
|
-
"
|
|
80
|
+
"typedoc": "^0.23.18",
|
|
81
|
+
"typedoc-plugin-extras": "^2.3.0",
|
|
82
|
+
"typedoc-plugin-missing-exports": "^1.0.0",
|
|
83
|
+
"typescript": "4.8.3"
|
|
79
84
|
},
|
|
80
85
|
"husky": {
|
|
81
86
|
"hooks": {
|
|
@@ -95,8 +100,10 @@
|
|
|
95
100
|
]
|
|
96
101
|
},
|
|
97
102
|
"dependencies": {
|
|
98
|
-
"@types/googlepay": "^0.6.4",
|
|
99
103
|
"@types/applepayjs": "^3.0.3",
|
|
100
|
-
"
|
|
104
|
+
"@types/googlepay": "^0.6.4",
|
|
105
|
+
"csstype": "^3.0.6",
|
|
106
|
+
"typedoc-plugin-markdown": "^3.14.0",
|
|
107
|
+
"typedoc-plugin-merge-modules": "^4.0.1"
|
|
101
108
|
}
|
|
102
109
|
}
|
package/typedocconfig.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
entryPoints: ['src/index.ts'],
|
|
3
|
+
entryPointStrategy: 'Expand',
|
|
4
|
+
tsconfig: 'tsconfig.json',
|
|
5
|
+
out: './docs/source/sdk-reference',
|
|
6
|
+
excludePrivate: true,
|
|
7
|
+
excludeProtected: true,
|
|
8
|
+
excludeExternals: true,
|
|
9
|
+
includeVersion: true,
|
|
10
|
+
readme: 'README.md',
|
|
11
|
+
name: 'airwallex-payment-elements',
|
|
12
|
+
favicon: 'public/favicon.ico',
|
|
13
|
+
categorizeByGroup: true,
|
|
14
|
+
mergeModulesRenameDefaults: true,
|
|
15
|
+
allReflectionsHaveOwnDocument: true,
|
|
16
|
+
categoryOrder: ['modules', 'functions', 'interfaces', 'types'],
|
|
17
|
+
mergeModulesMergeMode: 'off',
|
|
18
|
+
hideBreadcrumbs: 'true',
|
|
19
|
+
externalSymbolLinkMappings: {
|
|
20
|
+
// used by {@link !Promise}
|
|
21
|
+
global: {
|
|
22
|
+
Promise: 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise',
|
|
23
|
+
},
|
|
24
|
+
// used by type Foo = Promise<string>
|
|
25
|
+
typescript: {
|
|
26
|
+
Promise: 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise',
|
|
27
|
+
},
|
|
28
|
+
'@types/applepayjs': {
|
|
29
|
+
'ApplePayJS.ApplePayPaymentContact': 'https://reactjs.org/docs/react-component.html',
|
|
30
|
+
'ApplePayJS.ApplePayLineItem': 'https://developer.apple.com/documentation/apple_pay_on_the_web/applepaylineitem',
|
|
31
|
+
'ApplePayJS.ApplePayContactField':
|
|
32
|
+
'https://developer.apple.com/documentation/apple_pay_on_the_web/applepaycontactfield',
|
|
33
|
+
'ApplePayJS.ApplePayShippingType':
|
|
34
|
+
'https://developer.apple.com/documentation/apple_pay_on_the_web/applepayshippingtype',
|
|
35
|
+
'ApplePayJS.ApplePayShippingMethod':
|
|
36
|
+
'https://developer.apple.com/documentation/apple_pay_on_the_web/applepayshippingmethod',
|
|
37
|
+
'ApplePayJS.ApplePayMerchantCapability':
|
|
38
|
+
'https://developer.apple.com/documentation/apple_pay_on_the_web/applepaymerchantcapability',
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
pretty: true,
|
|
42
|
+
};
|
package/types/airwallex.d.ts
CHANGED
|
@@ -12,7 +12,13 @@ import {
|
|
|
12
12
|
} from './element';
|
|
13
13
|
import { QrcodeElementOptions } from './qrcodeElement';
|
|
14
14
|
import { Intent, PaymentMethodBasicInfo } from './cardNumber';
|
|
15
|
-
import {
|
|
15
|
+
import {
|
|
16
|
+
BoxStyle,
|
|
17
|
+
PaymentMethodType,
|
|
18
|
+
ApplePayHppOrDropInRequestOptions,
|
|
19
|
+
GooglePayHppRequestOptions,
|
|
20
|
+
ContactField,
|
|
21
|
+
} from './element';
|
|
16
22
|
import { getBrowserInfo, getDeviceFingerprint, get3dsReturnUrl, handle3ds } from './fraud';
|
|
17
23
|
import { DropInElementOptions } from './dropInElement';
|
|
18
24
|
import { RedirectElementOptions } from './redirectElement';
|
|
@@ -93,6 +99,10 @@ export interface RecurringOptions extends HppRecurringOptions {
|
|
|
93
99
|
* It is to be used by the platform to indicate the connected entity in the transaction where platform is the owner of transaction.
|
|
94
100
|
*/
|
|
95
101
|
connected_account_id?: string;
|
|
102
|
+
/**
|
|
103
|
+
* Set it to true if you want to skip 3DS regardless of the risk score and SCA. Only applicable when it's card recurring flow.
|
|
104
|
+
*/
|
|
105
|
+
skip_3ds?: boolean;
|
|
96
106
|
}
|
|
97
107
|
|
|
98
108
|
/**
|
|
@@ -187,6 +197,10 @@ export interface HostPaymentPage {
|
|
|
187
197
|
* Apply only for card, to improve 3DS experience, indicate if the payment form will collect billing info from shopper
|
|
188
198
|
*/
|
|
189
199
|
withBilling?: boolean;
|
|
200
|
+
/**
|
|
201
|
+
* The billing information that you require from the user in order to process the transaction.
|
|
202
|
+
*/
|
|
203
|
+
requiredBillingContactFields?: ContactField[];
|
|
190
204
|
/**
|
|
191
205
|
* Checkout mode, can be one of payment, recurring
|
|
192
206
|
* @default payment
|
|
@@ -615,6 +629,10 @@ export interface PaymentConsentRequest {
|
|
|
615
629
|
* A set of key-value pairs that can be attached to this PaymentConsent
|
|
616
630
|
*/
|
|
617
631
|
metadata?: Record<string, unknown>;
|
|
632
|
+
/**
|
|
633
|
+
* Set it to true if you want to skip 3DS regardless of the risk score and SCA. Only applicable when it's card recurring flow.
|
|
634
|
+
*/
|
|
635
|
+
skip_3ds?: boolean;
|
|
618
636
|
}
|
|
619
637
|
|
|
620
638
|
/**
|
package/types/cardNumber.d.ts
CHANGED
|
@@ -50,7 +50,7 @@ export interface Intent {
|
|
|
50
50
|
brand: string;
|
|
51
51
|
bin: string;
|
|
52
52
|
last4: string;
|
|
53
|
-
|
|
53
|
+
number_type: 'AIRWALLEX_NETWORK_TOKEN' | 'EXTERNAL_NETWORK_TOKEN' | 'PAN';
|
|
54
54
|
fingerprint: string;
|
|
55
55
|
};
|
|
56
56
|
};
|
|
@@ -61,7 +61,7 @@ export interface Intent {
|
|
|
61
61
|
brand: string;
|
|
62
62
|
bin: string;
|
|
63
63
|
last4: string;
|
|
64
|
-
|
|
64
|
+
number_type: 'AIRWALLEX_NETWORK_TOKEN' | 'EXTERNAL_NETWORK_TOKEN' | 'PAN';
|
|
65
65
|
fingerprint: string;
|
|
66
66
|
};
|
|
67
67
|
}[];
|
package/types/dropInElement.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ElementOptions, PaymentMethodType, BoxStyle } from './element';
|
|
2
2
|
import { Mode, RecurringOptions, Billing } from './airwallex';
|
|
3
|
-
import { ApplePayHppOrDropInRequestOptions, GooglePayRequestOptions } from './element';
|
|
3
|
+
import { ApplePayHppOrDropInRequestOptions, GooglePayRequestOptions, ContactField } from './element';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Apply to dropIn element type integration, interface used when call createElement with type `dropIn`
|
|
@@ -47,6 +47,10 @@ export interface DropInElementOptions extends ElementOptions {
|
|
|
47
47
|
* Indicate to improve 3DS experience, indicate if the payment form will collect billing info from shopper
|
|
48
48
|
*/
|
|
49
49
|
withBilling?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* The billing information that you require from the user in order to process the transaction.
|
|
52
|
+
*/
|
|
53
|
+
requiredBillingContactFields?: ContactField[];
|
|
50
54
|
/**
|
|
51
55
|
* Style for dropIn element
|
|
52
56
|
*/
|
package/types/element.d.ts
CHANGED
|
@@ -6,6 +6,9 @@ import { DropInElementOptions } from './dropInElement';
|
|
|
6
6
|
import { RedirectElementOptions } from './redirectElement';
|
|
7
7
|
import { NextAction } from './fraud';
|
|
8
8
|
import { Mode } from './airwallex';
|
|
9
|
+
|
|
10
|
+
export type ContactField = 'name' | 'email' | 'address';
|
|
11
|
+
|
|
9
12
|
/**
|
|
10
13
|
* Supported integration element type
|
|
11
14
|
*/
|
|
@@ -110,6 +113,7 @@ export type PaymentMethodType =
|
|
|
110
113
|
| 'applepay'
|
|
111
114
|
| 'card'
|
|
112
115
|
| 'wechatpay'
|
|
116
|
+
| 'airwallex_pay'
|
|
113
117
|
| PaymentMethodWithRedirect
|
|
114
118
|
| DirectDebitPaymentMethod;
|
|
115
119
|
|
|
@@ -258,7 +262,7 @@ export type ExtendEventDetail = EventDetail & {
|
|
|
258
262
|
* The event object your checkout page can listen to by below implementation:
|
|
259
263
|
*
|
|
260
264
|
* Using html [CustomEvent](https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent)
|
|
261
|
-
*
|
|
265
|
+
* @example
|
|
262
266
|
* window.addEventListener(code: EventCode, (event: { detail: ElementEvent }) => /* Your code here *\/ );
|
|
263
267
|
*/
|
|
264
268
|
export interface ElementEvent {
|
|
@@ -475,6 +479,10 @@ export interface FullFeaturedCardPaymentOptions extends ElementOptions {
|
|
|
475
479
|
* Indicate to improve 3DS experience, indicate if the payment form will collect billing info from shopper
|
|
476
480
|
*/
|
|
477
481
|
withBilling?: boolean;
|
|
482
|
+
/**
|
|
483
|
+
* The billing information that you require from the user in order to process the transaction.
|
|
484
|
+
*/
|
|
485
|
+
requiredBillingContactFields?: ContactField[];
|
|
478
486
|
/**
|
|
479
487
|
* Style for fullFeaturedCard element
|
|
480
488
|
*/
|
|
@@ -794,6 +802,7 @@ export interface GooglePayButtonOptions extends GooglePayRequestOptions, Element
|
|
|
794
802
|
mode?: Mode;
|
|
795
803
|
/**
|
|
796
804
|
* Indicate the amount and currency of the intent.
|
|
805
|
+
* @example
|
|
797
806
|
* If the mode is recurring and there is no intent_id provided, amount should be {value: 0, currency: 'Replace with payment currency'}.
|
|
798
807
|
*/
|
|
799
808
|
amount: {
|
|
@@ -872,6 +881,7 @@ export interface ApplePayButtonOptions extends ElementOptions, ApplePayRequestOp
|
|
|
872
881
|
mode?: Mode;
|
|
873
882
|
/**
|
|
874
883
|
* Indicate the amount and currency of the intent.
|
|
884
|
+
* @example
|
|
875
885
|
* If the mode is recurring and there is no intent_id provided, amount should be {value: 0, currency: 'Replace with payment currency'}.
|
|
876
886
|
*/
|
|
877
887
|
amount: {
|
package/types/qrcodeElement.d.ts
CHANGED
|
@@ -4,17 +4,34 @@ import { Intent } from './cardNumber';
|
|
|
4
4
|
/**
|
|
5
5
|
* All payment method options for qrcode element, those payment method type integration will render qrcode from your checkout site to specific provider’s authentication page.
|
|
6
6
|
*/
|
|
7
|
-
export type PaymentMethodWithQrcode = 'alipayhk' | 'kakaopay' | 'wechatpay';
|
|
7
|
+
export type PaymentMethodWithQrcode = 'alipayhk' | 'kakaopay' | 'wechatpay' | 'fps';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Apply to qrcode element type integration, interface used when call createElement with type `qrcode`
|
|
11
11
|
*/
|
|
12
|
-
export interface
|
|
12
|
+
export interface QrcodeElementPaymentOptions extends ElementOptions {
|
|
13
13
|
/**
|
|
14
14
|
* The payment intent you would like to checkout
|
|
15
15
|
* Refer to [Airwallex Client API](https://www.airwallex.com/docs/api#/Payment_Acceptance/Payment_Intents/Intro)
|
|
16
16
|
*
|
|
17
17
|
*/
|
|
18
|
+
/**
|
|
19
|
+
* @deprecated Please use `intent_id` and `client_secret` instead.
|
|
20
|
+
*/
|
|
18
21
|
intent?: Intent;
|
|
19
22
|
qrcodeMethod?: PaymentMethodWithQrcode;
|
|
23
|
+
intent_id: string;
|
|
24
|
+
client_secret: string;
|
|
25
|
+
mode: 'payment';
|
|
20
26
|
}
|
|
27
|
+
|
|
28
|
+
export interface QrcodeElementRecurringOptions extends ElementOptions {
|
|
29
|
+
mode: 'recurring';
|
|
30
|
+
client_secret: string;
|
|
31
|
+
currency: string;
|
|
32
|
+
customer_id: string;
|
|
33
|
+
qrcodeMethod: 'wechatpay';
|
|
34
|
+
merchant_trigger_reason?: 'scheduled' | 'unscheduled';
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export type QrcodeElementOptions = QrcodeElementPaymentOptions | QrcodeElementRecurringOptions;
|