@guestyorg/tokenization-js 1.1.0 → 1.2.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/LICENSE.md +1 -1
- package/README.md +6 -6
- package/lib/cjs/guesty-tokenization-js.js +49 -12
- package/lib/cjs/guesty-tokenization-js.min.js +1 -1
- package/lib/cjs/src/loadScript.d.ts.map +1 -1
- package/lib/cjs/src/namespaceVersion.d.ts +5 -0
- package/lib/cjs/src/namespaceVersion.d.ts.map +1 -0
- package/lib/cjs/src/utils.d.ts +1 -1
- package/lib/cjs/src/utils.d.ts.map +1 -1
- package/lib/esm/guesty-tokenization-js.js +49 -12
- package/lib/esm/guesty-tokenization-js.min.js +1 -1
- package/lib/esm/src/loadScript.d.ts.map +1 -1
- package/lib/esm/src/namespaceVersion.d.ts +5 -0
- package/lib/esm/src/namespaceVersion.d.ts.map +1 -0
- package/lib/esm/src/utils.d.ts +1 -1
- package/lib/esm/src/utils.d.ts.map +1 -1
- package/package.json +1 -1
- package/types/index.d.ts +220 -18
package/LICENSE.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) 2026 Guesty Inc.
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to use the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
6
|
|
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ Add a script tag to your application `head` or `body`.
|
|
|
8
8
|
This loads `guestyTokenization` object to the global `window` scope of the browser
|
|
9
9
|
|
|
10
10
|
```html
|
|
11
|
-
<script src="https://pay.guesty.com/tokenization/
|
|
11
|
+
<script src="https://pay.guesty.com/tokenization/v3/init.js"></script>
|
|
12
12
|
```
|
|
13
13
|
|
|
14
14
|
### Use it as an ES module
|
|
@@ -41,17 +41,17 @@ Import the `loadScript` function for asynchronously loading the Guesty Tokenizat
|
|
|
41
41
|
#### options
|
|
42
42
|
|
|
43
43
|
- `sandbox` - load the SDK in a sandbox mode
|
|
44
|
-
- `version` - SDK version to load (default: `v1`)
|
|
44
|
+
- `version` - SDK version to load (default: `v1`). Supported values: `v1`, `v2`, `v3`
|
|
45
45
|
|
|
46
46
|
```js
|
|
47
|
-
loadScript({ sandbox: true });
|
|
47
|
+
loadScript({ sandbox: true, version: 'v3' });
|
|
48
48
|
```
|
|
49
49
|
|
|
50
50
|
This is equivalent to the following script:
|
|
51
51
|
|
|
52
52
|
```html
|
|
53
53
|
<script
|
|
54
|
-
src="https://pay.guesty.com/tokenization/
|
|
54
|
+
src="https://pay.guesty.com/tokenization/v3/init.js"
|
|
55
55
|
data-env="sandbox"
|
|
56
56
|
></script>
|
|
57
57
|
```
|
|
@@ -62,7 +62,7 @@ This is equivalent to the following script:
|
|
|
62
62
|
import { loadScript } from '@guestyorg/tokenization-js';
|
|
63
63
|
|
|
64
64
|
try {
|
|
65
|
-
const guestyTokenization = await loadScript();
|
|
65
|
+
const guestyTokenization = await loadScript({ version: 'v3' });
|
|
66
66
|
// Guesty Tokenization JS SDK is loaded and ready to use
|
|
67
67
|
} catch (error) {
|
|
68
68
|
console.error('Failed to load the Guesty Tokenization JS SDK script', error);
|
|
@@ -74,7 +74,7 @@ try {
|
|
|
74
74
|
```js
|
|
75
75
|
import { loadScript } from '@guestyorg/tokenization-js';
|
|
76
76
|
|
|
77
|
-
loadScript()
|
|
77
|
+
loadScript({ version: 'v3' })
|
|
78
78
|
.then((guestyTokenization) => {
|
|
79
79
|
// Guesty Tokenization JS SDK is loaded and ready to use
|
|
80
80
|
})
|
|
@@ -1,7 +1,19 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var findScriptElement = function (url) {
|
|
4
|
-
|
|
3
|
+
var findScriptElement = function (url, sandbox) {
|
|
4
|
+
if (sandbox === void 0) { sandbox = false; }
|
|
5
|
+
var scripts = document.querySelectorAll("script[src=\"".concat(url, "\"]"));
|
|
6
|
+
for (var index = 0; index < scripts.length; index += 1) {
|
|
7
|
+
var script = scripts.item(index);
|
|
8
|
+
if (!script) {
|
|
9
|
+
continue;
|
|
10
|
+
}
|
|
11
|
+
var isSandboxScript = script.getAttribute('data-env') === 'sandbox';
|
|
12
|
+
if (isSandboxScript === sandbox) {
|
|
13
|
+
return script;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return null;
|
|
5
17
|
};
|
|
6
18
|
var injectScriptElement = function (_a) {
|
|
7
19
|
var url = _a.url, sandbox = _a.sandbox, onSuccess = _a.onSuccess, onError = _a.onError;
|
|
@@ -18,35 +30,60 @@ var injectScriptElement = function (_a) {
|
|
|
18
30
|
|
|
19
31
|
var NAMESPACE = 'guestyTokenization';
|
|
20
32
|
|
|
33
|
+
var hasHandle3DSChallenge = function (namespace) {
|
|
34
|
+
return 'handle3DSChallenge' in namespace;
|
|
35
|
+
};
|
|
36
|
+
var namespaceMatchesVersion = function (namespace, version) {
|
|
37
|
+
if (!namespace || typeof namespace !== 'object') {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
if (version === 'v3') {
|
|
41
|
+
return hasHandle3DSChallenge(namespace);
|
|
42
|
+
}
|
|
43
|
+
return !hasHandle3DSChallenge(namespace);
|
|
44
|
+
};
|
|
45
|
+
var clearMismatchedNamespace = function (version) {
|
|
46
|
+
var existingNamespace = window[NAMESPACE];
|
|
47
|
+
if (existingNamespace &&
|
|
48
|
+
!namespaceMatchesVersion(existingNamespace, version)) {
|
|
49
|
+
delete window[NAMESPACE];
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
21
53
|
var loadScript = function (options) {
|
|
22
|
-
var _a;
|
|
54
|
+
var _a, _b;
|
|
23
55
|
if (options === void 0) { options = {}; }
|
|
24
56
|
if (typeof window === 'undefined') {
|
|
25
57
|
return Promise.resolve(null);
|
|
26
58
|
}
|
|
27
59
|
var version = (_a = options.version) !== null && _a !== void 0 ? _a : 'v1';
|
|
60
|
+
var sandbox = (_b = options.sandbox) !== null && _b !== void 0 ? _b : false;
|
|
28
61
|
var scriptUrl = "https://pay.guesty.com/tokenization/".concat(version, "/init.js");
|
|
29
|
-
var existingScript = findScriptElement(scriptUrl);
|
|
62
|
+
var existingScript = findScriptElement(scriptUrl, sandbox);
|
|
30
63
|
var existingNamespace = window[NAMESPACE];
|
|
64
|
+
if (existingScript &&
|
|
65
|
+
existingNamespace &&
|
|
66
|
+
namespaceMatchesVersion(existingNamespace, version)) {
|
|
67
|
+
return Promise.resolve(existingNamespace);
|
|
68
|
+
}
|
|
31
69
|
if (existingScript) {
|
|
32
|
-
if (existingNamespace) {
|
|
33
|
-
return Promise.resolve(existingNamespace);
|
|
34
|
-
}
|
|
35
70
|
existingScript.remove();
|
|
36
71
|
}
|
|
72
|
+
clearMismatchedNamespace(version);
|
|
37
73
|
return new Promise(function (resolve, reject) {
|
|
38
|
-
var _a;
|
|
39
74
|
injectScriptElement({
|
|
40
75
|
url: scriptUrl,
|
|
41
|
-
sandbox:
|
|
76
|
+
sandbox: sandbox,
|
|
42
77
|
onSuccess: function () {
|
|
43
78
|
var newNamespace = window[NAMESPACE];
|
|
44
|
-
if (newNamespace) {
|
|
79
|
+
if (newNamespace && namespaceMatchesVersion(newNamespace, version)) {
|
|
45
80
|
resolve(newNamespace);
|
|
81
|
+
return;
|
|
46
82
|
}
|
|
47
|
-
|
|
48
|
-
|
|
83
|
+
if (newNamespace) {
|
|
84
|
+
delete window[NAMESPACE];
|
|
49
85
|
}
|
|
86
|
+
reject(new Error('Guesty Tokenization is not available'));
|
|
50
87
|
},
|
|
51
88
|
onError: function () {
|
|
52
89
|
reject(new Error("The script ".concat(scriptUrl, " failed to load")));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var n="guestyTokenization",e=function(n){return"handle3DSChallenge"in n},o=function(n,o){return!(!n||"object"!=typeof n)&&("v3"===o?e(n):!e(n))};exports.loadScript=function(e){var t,r;if(void 0===e&&(e={}),"undefined"==typeof window)return Promise.resolve(null);var i=null!==(t=e.version)&&void 0!==t?t:"v1",a=null!==(r=e.sandbox)&&void 0!==r&&r,c="https://pay.guesty.com/tokenization/".concat(i,"/init.js"),u=function(n,e){void 0===e&&(e=!1);for(var o=document.querySelectorAll('script[src="'.concat(n,'"]')),t=0;t<o.length;t+=1){var r=o.item(t);if(r&&"sandbox"===r.getAttribute("data-env")===e)return r}return null}(c,a),d=window[n];return u&&d&&o(d,i)?Promise.resolve(d):(u&&u.remove(),function(e){var t=window[n];t&&!o(t,e)&&delete window[n]}(i),new Promise((function(e,t){!function(n){var e=n.url,o=n.sandbox,t=n.onSuccess,r=n.onError,i=document.createElement("script");i.src=e,i.async=!0,i.onerror=r,i.onload=t,o&&i.setAttribute("data-env","sandbox"),document.head.insertBefore(i,document.head.firstElementChild)}({url:c,sandbox:a,onSuccess:function(){var r=window[n];r&&o(r,i)?e(r):(r&&delete window[n],t(new Error("Guesty Tokenization is not available")))},onError:function(){t(new Error("The script ".concat(c," failed to load")))}})})))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadScript.d.ts","sourceRoot":"","sources":["../../src/loadScript.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"loadScript.d.ts","sourceRoot":"","sources":["../../src/loadScript.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAE7C,eAAO,MAAM,UAAU,aAAa,iBAAiB,qBAiDpD,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
type TokenizationVersion = 'v1' | 'v2' | 'v3';
|
|
2
|
+
export declare const namespaceMatchesVersion: (namespace: unknown, version: TokenizationVersion) => boolean;
|
|
3
|
+
export declare const clearMismatchedNamespace: (version: TokenizationVersion) => void;
|
|
4
|
+
export {};
|
|
5
|
+
//# sourceMappingURL=namespaceVersion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"namespaceVersion.d.ts","sourceRoot":"","sources":["../../src/namespaceVersion.ts"],"names":[],"mappings":"AAEA,KAAK,mBAAmB,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAK9C,eAAO,MAAM,uBAAuB,cACvB,OAAO,WACT,mBAAmB,KAC3B,OAUF,CAAC;AAEF,eAAO,MAAM,wBAAwB,YAAa,mBAAmB,SASpE,CAAC"}
|
package/lib/cjs/src/utils.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB,QAAS,MAAM,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB,QAAS,MAAM,sCAkB5C,CAAC;AAEF,MAAM,WAAW,0BAA0B;IACzC,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,eAAO,MAAM,mBAAmB,0CAK7B,0BAA0B,SAY5B,CAAC"}
|
|
@@ -1,5 +1,17 @@
|
|
|
1
|
-
var findScriptElement = function (url) {
|
|
2
|
-
|
|
1
|
+
var findScriptElement = function (url, sandbox) {
|
|
2
|
+
if (sandbox === void 0) { sandbox = false; }
|
|
3
|
+
var scripts = document.querySelectorAll("script[src=\"".concat(url, "\"]"));
|
|
4
|
+
for (var index = 0; index < scripts.length; index += 1) {
|
|
5
|
+
var script = scripts.item(index);
|
|
6
|
+
if (!script) {
|
|
7
|
+
continue;
|
|
8
|
+
}
|
|
9
|
+
var isSandboxScript = script.getAttribute('data-env') === 'sandbox';
|
|
10
|
+
if (isSandboxScript === sandbox) {
|
|
11
|
+
return script;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return null;
|
|
3
15
|
};
|
|
4
16
|
var injectScriptElement = function (_a) {
|
|
5
17
|
var url = _a.url, sandbox = _a.sandbox, onSuccess = _a.onSuccess, onError = _a.onError;
|
|
@@ -16,35 +28,60 @@ var injectScriptElement = function (_a) {
|
|
|
16
28
|
|
|
17
29
|
var NAMESPACE = 'guestyTokenization';
|
|
18
30
|
|
|
31
|
+
var hasHandle3DSChallenge = function (namespace) {
|
|
32
|
+
return 'handle3DSChallenge' in namespace;
|
|
33
|
+
};
|
|
34
|
+
var namespaceMatchesVersion = function (namespace, version) {
|
|
35
|
+
if (!namespace || typeof namespace !== 'object') {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
if (version === 'v3') {
|
|
39
|
+
return hasHandle3DSChallenge(namespace);
|
|
40
|
+
}
|
|
41
|
+
return !hasHandle3DSChallenge(namespace);
|
|
42
|
+
};
|
|
43
|
+
var clearMismatchedNamespace = function (version) {
|
|
44
|
+
var existingNamespace = window[NAMESPACE];
|
|
45
|
+
if (existingNamespace &&
|
|
46
|
+
!namespaceMatchesVersion(existingNamespace, version)) {
|
|
47
|
+
delete window[NAMESPACE];
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
19
51
|
var loadScript = function (options) {
|
|
20
|
-
var _a;
|
|
52
|
+
var _a, _b;
|
|
21
53
|
if (options === void 0) { options = {}; }
|
|
22
54
|
if (typeof window === 'undefined') {
|
|
23
55
|
return Promise.resolve(null);
|
|
24
56
|
}
|
|
25
57
|
var version = (_a = options.version) !== null && _a !== void 0 ? _a : 'v1';
|
|
58
|
+
var sandbox = (_b = options.sandbox) !== null && _b !== void 0 ? _b : false;
|
|
26
59
|
var scriptUrl = "https://pay.guesty.com/tokenization/".concat(version, "/init.js");
|
|
27
|
-
var existingScript = findScriptElement(scriptUrl);
|
|
60
|
+
var existingScript = findScriptElement(scriptUrl, sandbox);
|
|
28
61
|
var existingNamespace = window[NAMESPACE];
|
|
62
|
+
if (existingScript &&
|
|
63
|
+
existingNamespace &&
|
|
64
|
+
namespaceMatchesVersion(existingNamespace, version)) {
|
|
65
|
+
return Promise.resolve(existingNamespace);
|
|
66
|
+
}
|
|
29
67
|
if (existingScript) {
|
|
30
|
-
if (existingNamespace) {
|
|
31
|
-
return Promise.resolve(existingNamespace);
|
|
32
|
-
}
|
|
33
68
|
existingScript.remove();
|
|
34
69
|
}
|
|
70
|
+
clearMismatchedNamespace(version);
|
|
35
71
|
return new Promise(function (resolve, reject) {
|
|
36
|
-
var _a;
|
|
37
72
|
injectScriptElement({
|
|
38
73
|
url: scriptUrl,
|
|
39
|
-
sandbox:
|
|
74
|
+
sandbox: sandbox,
|
|
40
75
|
onSuccess: function () {
|
|
41
76
|
var newNamespace = window[NAMESPACE];
|
|
42
|
-
if (newNamespace) {
|
|
77
|
+
if (newNamespace && namespaceMatchesVersion(newNamespace, version)) {
|
|
43
78
|
resolve(newNamespace);
|
|
79
|
+
return;
|
|
44
80
|
}
|
|
45
|
-
|
|
46
|
-
|
|
81
|
+
if (newNamespace) {
|
|
82
|
+
delete window[NAMESPACE];
|
|
47
83
|
}
|
|
84
|
+
reject(new Error('Guesty Tokenization is not available'));
|
|
48
85
|
},
|
|
49
86
|
onError: function () {
|
|
50
87
|
reject(new Error("The script ".concat(scriptUrl, " failed to load")));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var n="guestyTokenization",o=function(o){var
|
|
1
|
+
var n="guestyTokenization",e=function(n){return"handle3DSChallenge"in n},o=function(n,o){return!(!n||"object"!=typeof n)&&("v3"===o?e(n):!e(n))},t=function(e){var t,r;if(void 0===e&&(e={}),"undefined"==typeof window)return Promise.resolve(null);var i=null!==(t=e.version)&&void 0!==t?t:"v1",a=null!==(r=e.sandbox)&&void 0!==r&&r,u="https://pay.guesty.com/tokenization/".concat(i,"/init.js"),c=function(n,e){void 0===e&&(e=!1);for(var o=document.querySelectorAll('script[src="'.concat(n,'"]')),t=0;t<o.length;t+=1){var r=o.item(t);if(r&&"sandbox"===r.getAttribute("data-env")===e)return r}return null}(u,a),d=window[n];return c&&d&&o(d,i)?Promise.resolve(d):(c&&c.remove(),function(e){var t=window[n];t&&!o(t,e)&&delete window[n]}(i),new Promise((function(e,t){!function(n){var e=n.url,o=n.sandbox,t=n.onSuccess,r=n.onError,i=document.createElement("script");i.src=e,i.async=!0,i.onerror=r,i.onload=t,o&&i.setAttribute("data-env","sandbox"),document.head.insertBefore(i,document.head.firstElementChild)}({url:u,sandbox:a,onSuccess:function(){var r=window[n];r&&o(r,i)?e(r):(r&&delete window[n],t(new Error("Guesty Tokenization is not available")))},onError:function(){t(new Error("The script ".concat(u," failed to load")))}})})))};export{t as loadScript};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadScript.d.ts","sourceRoot":"","sources":["../../src/loadScript.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"loadScript.d.ts","sourceRoot":"","sources":["../../src/loadScript.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAE7C,eAAO,MAAM,UAAU,aAAa,iBAAiB,qBAiDpD,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
type TokenizationVersion = 'v1' | 'v2' | 'v3';
|
|
2
|
+
export declare const namespaceMatchesVersion: (namespace: unknown, version: TokenizationVersion) => boolean;
|
|
3
|
+
export declare const clearMismatchedNamespace: (version: TokenizationVersion) => void;
|
|
4
|
+
export {};
|
|
5
|
+
//# sourceMappingURL=namespaceVersion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"namespaceVersion.d.ts","sourceRoot":"","sources":["../../src/namespaceVersion.ts"],"names":[],"mappings":"AAEA,KAAK,mBAAmB,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAK9C,eAAO,MAAM,uBAAuB,cACvB,OAAO,WACT,mBAAmB,KAC3B,OAUF,CAAC;AAEF,eAAO,MAAM,wBAAwB,YAAa,mBAAmB,SASpE,CAAC"}
|
package/lib/esm/src/utils.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB,QAAS,MAAM,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB,QAAS,MAAM,sCAkB5C,CAAC;AAEF,MAAM,WAAW,0BAA0B;IACzC,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,eAAO,MAAM,mBAAmB,0CAK7B,0BAA0B,SAY5B,CAAC"}
|
package/package.json
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -20,15 +20,52 @@ export interface GuestyTokenizationStyles {
|
|
|
20
20
|
borderRadius?: number;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
export interface GuestyTokenizationV3Styles {
|
|
24
|
+
fontFamily?: string;
|
|
25
|
+
fontSizeBase?: number;
|
|
26
|
+
fontSizeMd?: number;
|
|
27
|
+
fontSizeLg?: number;
|
|
28
|
+
fontWeightRegular?: string | number;
|
|
29
|
+
fontWeightBold?: string | number;
|
|
30
|
+
borderRadius?: number;
|
|
31
|
+
inputHeight?: number;
|
|
32
|
+
inputPadding?: number;
|
|
33
|
+
colorText?: string;
|
|
34
|
+
colorTextError?: string;
|
|
35
|
+
colorPlaceholder?: string;
|
|
36
|
+
colorBorder?: string;
|
|
37
|
+
colorBorderFocus?: string;
|
|
38
|
+
colorFormBackground?: string;
|
|
39
|
+
colorInputBackground?: string;
|
|
40
|
+
// Explicitly unsupported in v3.
|
|
41
|
+
mobileBreakpoint?: never;
|
|
42
|
+
colorBorderError?: never;
|
|
43
|
+
colorBorderHover?: never;
|
|
44
|
+
colorBackground?: never;
|
|
45
|
+
colorBackgroundError?: never;
|
|
46
|
+
colorBackgroundDisabled?: never;
|
|
47
|
+
}
|
|
48
|
+
|
|
23
49
|
type Section = 'cardholderName' | 'paymentDetails' | 'billingAddress';
|
|
24
50
|
type TCardholderNameInput = 'firstName' | 'lastName' | 'cardHolderId';
|
|
25
51
|
type TBillingAddressInput = 'street' | 'city' | 'state' | 'zipCode' | 'country';
|
|
26
|
-
type TPaymentDetailsInput =
|
|
52
|
+
type TPaymentDetailsInput =
|
|
53
|
+
| 'nameOnCard'
|
|
54
|
+
| 'cardNumber'
|
|
55
|
+
| 'expirationDate'
|
|
56
|
+
| 'csc';
|
|
57
|
+
type TBankDetailsInput =
|
|
58
|
+
| 'accountHolderName'
|
|
59
|
+
| 'routingNumber'
|
|
60
|
+
| 'accountNumber'
|
|
61
|
+
| 'accountType'
|
|
62
|
+
| 'entityType';
|
|
27
63
|
|
|
28
64
|
type TInput =
|
|
29
65
|
| TCardholderNameInput
|
|
30
66
|
| TBillingAddressInput
|
|
31
|
-
| TPaymentDetailsInput
|
|
67
|
+
| TPaymentDetailsInput
|
|
68
|
+
| TBankDetailsInput;
|
|
32
69
|
|
|
33
70
|
export interface GuestyTokenizationV1RenderOptions {
|
|
34
71
|
containerId: string;
|
|
@@ -76,30 +113,168 @@ export interface GuestyTokenizationV2RenderOptions {
|
|
|
76
113
|
showPciCompliantLink?: boolean;
|
|
77
114
|
}
|
|
78
115
|
|
|
116
|
+
interface GuestyTokenizationV3BaseRenderOptions {
|
|
117
|
+
containerId: string;
|
|
118
|
+
providerId: string;
|
|
119
|
+
onStatusChange?: (status: boolean) => void;
|
|
120
|
+
styles?: GuestyTokenizationV3Styles;
|
|
121
|
+
lang?: string;
|
|
122
|
+
initialValues?: never;
|
|
123
|
+
inputsConfig?: {
|
|
124
|
+
[key in TInput]?: {
|
|
125
|
+
label?: string;
|
|
126
|
+
placeholder?: string;
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
showReuseCheckbox?: boolean;
|
|
130
|
+
showAddressToggle?: boolean;
|
|
131
|
+
showNameToggle?: boolean;
|
|
132
|
+
addressToggleLabel?: string;
|
|
133
|
+
nameToggleLabel?: string;
|
|
134
|
+
showSupportedCards?: boolean;
|
|
135
|
+
showPciCompliantLink?: boolean;
|
|
136
|
+
paymentMethod?: never;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
interface GuestyTokenizationV3CountryOption {
|
|
140
|
+
value: string;
|
|
141
|
+
label: string;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
interface GuestyTokenizationV3SharedInitialValues {
|
|
145
|
+
street?: string;
|
|
146
|
+
city?: string;
|
|
147
|
+
state?: string;
|
|
148
|
+
zipCode?: string;
|
|
149
|
+
country?: GuestyTokenizationV3CountryOption;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export interface GuestyTokenizationV3CardInitialValues
|
|
153
|
+
extends GuestyTokenizationV3SharedInitialValues {
|
|
154
|
+
nameOnCard?: string;
|
|
155
|
+
cardHolderId?: string;
|
|
156
|
+
cardNumber?: string;
|
|
157
|
+
expirationDate?: string;
|
|
158
|
+
csc?: string;
|
|
159
|
+
accountHolderName?: never;
|
|
160
|
+
routingNumber?: never;
|
|
161
|
+
accountNumber?: never;
|
|
162
|
+
accountType?: never;
|
|
163
|
+
entityType?: never;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export interface GuestyTokenizationV3AchInitialValues
|
|
167
|
+
extends GuestyTokenizationV3SharedInitialValues {
|
|
168
|
+
accountHolderName?: string;
|
|
169
|
+
routingNumber?: string;
|
|
170
|
+
accountNumber?: string;
|
|
171
|
+
accountType?: '1' | '2';
|
|
172
|
+
entityType?: '0' | '1';
|
|
173
|
+
nameOnCard?: never;
|
|
174
|
+
cardHolderId?: never;
|
|
175
|
+
cardNumber?: never;
|
|
176
|
+
expirationDate?: never;
|
|
177
|
+
csc?: never;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export interface GuestyTokenizationV3CardRenderOptions
|
|
181
|
+
extends GuestyTokenizationV3BaseRenderOptions {
|
|
182
|
+
paymentMethod?: 'card';
|
|
183
|
+
initialValues?: GuestyTokenizationV3CardInitialValues;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export interface GuestyTokenizationV3AchRenderOptions
|
|
187
|
+
extends GuestyTokenizationV3BaseRenderOptions {
|
|
188
|
+
paymentMethod: 'ach';
|
|
189
|
+
initialValues?: GuestyTokenizationV3AchInitialValues;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export type GuestyTokenizationV3RenderOptions =
|
|
193
|
+
| GuestyTokenizationV3CardRenderOptions
|
|
194
|
+
| GuestyTokenizationV3AchRenderOptions;
|
|
195
|
+
|
|
79
196
|
export interface GuestyTokenizationV2ApiV2SubmitPayload {
|
|
80
197
|
amount: number;
|
|
81
198
|
currency: string;
|
|
82
199
|
apiVersion: 'v2';
|
|
83
200
|
}
|
|
84
201
|
|
|
85
|
-
|
|
202
|
+
type ReservationOrQuote =
|
|
203
|
+
| {
|
|
204
|
+
reservationId: string;
|
|
205
|
+
quoteId?: never;
|
|
206
|
+
guest?: never;
|
|
207
|
+
}
|
|
208
|
+
| {
|
|
209
|
+
quoteId: string;
|
|
210
|
+
guest: {
|
|
211
|
+
firstName: string;
|
|
212
|
+
lastName: string;
|
|
213
|
+
email?: string;
|
|
214
|
+
phone?: string;
|
|
215
|
+
};
|
|
216
|
+
reservationId?: never;
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
export type GuestyTokenizationV2ApiV3SubmitPayload = {
|
|
86
220
|
listingId: string;
|
|
87
|
-
quoteId: string;
|
|
88
221
|
amount: number;
|
|
89
222
|
currency: string;
|
|
90
|
-
guest: {
|
|
91
|
-
firstName: string;
|
|
92
|
-
lastName: string;
|
|
93
|
-
email?: string;
|
|
94
|
-
phone?: string;
|
|
95
|
-
};
|
|
96
223
|
apiVersion?: 'v3';
|
|
97
|
-
}
|
|
224
|
+
} & ReservationOrQuote;
|
|
98
225
|
|
|
99
226
|
export type GuestyTokenizationV2SubmitPayload =
|
|
100
227
|
| GuestyTokenizationV2ApiV2SubmitPayload
|
|
101
228
|
| GuestyTokenizationV2ApiV3SubmitPayload;
|
|
102
229
|
|
|
230
|
+
export interface GuestyTokenizationV3SubmitGuest {
|
|
231
|
+
firstName: string;
|
|
232
|
+
lastName: string;
|
|
233
|
+
email?: string;
|
|
234
|
+
phone?: string;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
interface GuestyTokenizationV3SubmitPayloadBase {
|
|
238
|
+
amount: number;
|
|
239
|
+
currency: string;
|
|
240
|
+
method?: 'verify' | 'verify_no_3ds';
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
export interface GuestyTokenizationV3LegacySubmitPayload
|
|
244
|
+
extends GuestyTokenizationV3SubmitPayloadBase {
|
|
245
|
+
apiVersion: 'v2';
|
|
246
|
+
listingId?: never;
|
|
247
|
+
reservationId?: never;
|
|
248
|
+
quoteId?: never;
|
|
249
|
+
guest?: never;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
export interface GuestyTokenizationV3InstantChargeSubmitPayload
|
|
253
|
+
extends GuestyTokenizationV3SubmitPayloadBase {
|
|
254
|
+
listingId: string;
|
|
255
|
+
reservationId: string;
|
|
256
|
+
quoteId?: never;
|
|
257
|
+
guest?: never;
|
|
258
|
+
apiVersion?: 'v3';
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
export interface GuestyTokenizationV3QuoteSubmitPayload
|
|
262
|
+
extends GuestyTokenizationV3SubmitPayloadBase {
|
|
263
|
+
listingId: string;
|
|
264
|
+
quoteId: string;
|
|
265
|
+
guest: GuestyTokenizationV3SubmitGuest;
|
|
266
|
+
reservationId?: never;
|
|
267
|
+
apiVersion?: 'v3';
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
export type GuestyTokenizationV3CardSubmitPayload =
|
|
271
|
+
| GuestyTokenizationV3LegacySubmitPayload
|
|
272
|
+
| GuestyTokenizationV3InstantChargeSubmitPayload
|
|
273
|
+
| GuestyTokenizationV3QuoteSubmitPayload;
|
|
274
|
+
|
|
275
|
+
export type GuestyTokenizationV3SubmitPayload =
|
|
276
|
+
GuestyTokenizationV3CardSubmitPayload;
|
|
277
|
+
|
|
103
278
|
export interface PaymentMethod {
|
|
104
279
|
_id: string;
|
|
105
280
|
}
|
|
@@ -120,27 +295,54 @@ export interface GuestyTokenizationV2Namespace {
|
|
|
120
295
|
validate: () => void;
|
|
121
296
|
}
|
|
122
297
|
|
|
298
|
+
export interface GuestyTokenizationHandle3DSChallengeOptions {
|
|
299
|
+
/** Opaque challenge payload returned by the Guesty backend. */
|
|
300
|
+
threeDSChallenge: Record<string, unknown>;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
export interface GuestyTokenizationV3Namespace {
|
|
304
|
+
render: (options: GuestyTokenizationV3RenderOptions) => Promise<void>;
|
|
305
|
+
destroy: () => Promise<void>;
|
|
306
|
+
submit: () => Promise<PaymentMethod>;
|
|
307
|
+
submit: (
|
|
308
|
+
payload: GuestyTokenizationV3SubmitPayload
|
|
309
|
+
) => Promise<PaymentMethod>;
|
|
310
|
+
validate: () => void;
|
|
311
|
+
handle3DSChallenge: (
|
|
312
|
+
options: GuestyTokenizationHandle3DSChallengeOptions
|
|
313
|
+
) => Promise<Record<string, unknown>>;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
export interface LoadScriptOptions {
|
|
317
|
+
sandbox?: boolean;
|
|
318
|
+
version?: 'v1' | 'v2' | 'v3';
|
|
319
|
+
}
|
|
320
|
+
|
|
123
321
|
type NamespaceBasedOnVersion<T extends LoadScriptOptions['version']> =
|
|
124
322
|
T extends 'v1'
|
|
125
323
|
? GuestyTokenizationV1Namespace
|
|
126
324
|
: T extends 'v2'
|
|
127
325
|
? GuestyTokenizationV2Namespace
|
|
128
|
-
:
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
sandbox?: boolean;
|
|
132
|
-
version?: 'v1' | 'v2';
|
|
133
|
-
}
|
|
326
|
+
: T extends 'v3'
|
|
327
|
+
? GuestyTokenizationV3Namespace
|
|
328
|
+
: never;
|
|
134
329
|
|
|
135
330
|
export function loadScript(
|
|
136
331
|
options?: LoadScriptOptions
|
|
137
|
-
): Promise<
|
|
332
|
+
): Promise<GuestyTokenizationV1Namespace | null>;
|
|
333
|
+
export function loadScript<T extends 'v1' | 'v2' | 'v3'>(
|
|
334
|
+
options: LoadScriptOptions & { version: T }
|
|
335
|
+
): Promise<NamespaceBasedOnVersion<T> | null>;
|
|
336
|
+
export function loadScript<T extends LoadScriptOptions['version']>(
|
|
337
|
+
options?: LoadScriptOptions & { version?: T }
|
|
338
|
+
): Promise<NamespaceBasedOnVersion<T> | GuestyTokenizationV1Namespace | null>;
|
|
138
339
|
|
|
139
340
|
declare global {
|
|
140
341
|
interface Window {
|
|
141
342
|
guestyTokenization?:
|
|
142
343
|
| GuestyTokenizationV1Namespace
|
|
143
344
|
| GuestyTokenizationV2Namespace
|
|
345
|
+
| GuestyTokenizationV3Namespace
|
|
144
346
|
| null;
|
|
145
347
|
}
|
|
146
348
|
}
|