@guestyorg/tokenization-js 1.0.4 → 1.1.1
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/README.md +1 -0
- package/lib/cjs/guesty-tokenization-js.js +6 -4
- package/lib/cjs/guesty-tokenization-js.min.js +1 -1
- package/lib/cjs/src/constants.d.ts +0 -1
- package/lib/cjs/src/constants.d.ts.map +1 -1
- package/lib/cjs/src/loadScript.d.ts.map +1 -1
- package/lib/esm/guesty-tokenization-js.js +6 -4
- package/lib/esm/guesty-tokenization-js.min.js +1 -1
- package/lib/esm/src/constants.d.ts +0 -1
- package/lib/esm/src/constants.d.ts.map +1 -1
- package/lib/esm/src/loadScript.d.ts.map +1 -1
- package/package.json +1 -1
- package/types/index.d.ts +83 -7
package/README.md
CHANGED
|
@@ -17,14 +17,16 @@ var injectScriptElement = function (_a) {
|
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
var NAMESPACE = 'guestyTokenization';
|
|
20
|
-
var SCRIPT_URL = 'https://pay.guesty.com/tokenization/v1/init.js';
|
|
21
20
|
|
|
22
21
|
var loadScript = function (options) {
|
|
22
|
+
var _a;
|
|
23
23
|
if (options === void 0) { options = {}; }
|
|
24
24
|
if (typeof window === 'undefined') {
|
|
25
25
|
return Promise.resolve(null);
|
|
26
26
|
}
|
|
27
|
-
var
|
|
27
|
+
var version = (_a = options.version) !== null && _a !== void 0 ? _a : 'v1';
|
|
28
|
+
var scriptUrl = "https://pay.guesty.com/tokenization/".concat(version, "/init.js");
|
|
29
|
+
var existingScript = findScriptElement(scriptUrl);
|
|
28
30
|
var existingNamespace = window[NAMESPACE];
|
|
29
31
|
if (existingScript) {
|
|
30
32
|
if (existingNamespace) {
|
|
@@ -35,7 +37,7 @@ var loadScript = function (options) {
|
|
|
35
37
|
return new Promise(function (resolve, reject) {
|
|
36
38
|
var _a;
|
|
37
39
|
injectScriptElement({
|
|
38
|
-
url:
|
|
40
|
+
url: scriptUrl,
|
|
39
41
|
sandbox: (_a = options.sandbox) !== null && _a !== void 0 ? _a : false,
|
|
40
42
|
onSuccess: function () {
|
|
41
43
|
var newNamespace = window[NAMESPACE];
|
|
@@ -47,7 +49,7 @@ var loadScript = function (options) {
|
|
|
47
49
|
}
|
|
48
50
|
},
|
|
49
51
|
onError: function () {
|
|
50
|
-
reject(new Error("The script ".concat(
|
|
52
|
+
reject(new Error("The script ".concat(scriptUrl, " failed to load")));
|
|
51
53
|
},
|
|
52
54
|
});
|
|
53
55
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var o="guestyTokenization";exports.loadScript=function(n){var e;if(void 0===n&&(n={}),"undefined"==typeof window)return Promise.resolve(null);var r,t=null!==(e=n.version)&&void 0!==e?e:"v1",i="https://pay.guesty.com/tokenization/".concat(t,"/init.js"),s=(r=i,document.querySelector('script[src="'.concat(r,'"]'))),a=window[o];if(s){if(a)return Promise.resolve(a);s.remove()}return new Promise((function(e,r){var t;!function(o){var n=o.url,e=o.sandbox,r=o.onSuccess,t=o.onError,i=document.createElement("script");i.src=n,i.async=!0,i.onerror=t,i.onload=r,e&&i.setAttribute("data-env","sandbox"),document.head.insertBefore(i,document.head.firstElementChild)}({url:i,sandbox:null!==(t=n.sandbox)&&void 0!==t&&t,onSuccess:function(){var n=window[o];n?e(n):r(new Error("Guesty Tokenization is not available"))},onError:function(){r(new Error("The script ".concat(i," failed to load")))}})}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,uBAAuB,CAAC
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,uBAAuB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadScript.d.ts","sourceRoot":"","sources":["../../src/loadScript.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAE7C,eAAO,MAAM,UAAU,aAAa,iBAAiB,
|
|
1
|
+
{"version":3,"file":"loadScript.d.ts","sourceRoot":"","sources":["../../src/loadScript.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAE7C,eAAO,MAAM,UAAU,aAAa,iBAAiB,qBAmCpD,CAAC"}
|
|
@@ -15,14 +15,16 @@ var injectScriptElement = function (_a) {
|
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
var NAMESPACE = 'guestyTokenization';
|
|
18
|
-
var SCRIPT_URL = 'https://pay.guesty.com/tokenization/v1/init.js';
|
|
19
18
|
|
|
20
19
|
var loadScript = function (options) {
|
|
20
|
+
var _a;
|
|
21
21
|
if (options === void 0) { options = {}; }
|
|
22
22
|
if (typeof window === 'undefined') {
|
|
23
23
|
return Promise.resolve(null);
|
|
24
24
|
}
|
|
25
|
-
var
|
|
25
|
+
var version = (_a = options.version) !== null && _a !== void 0 ? _a : 'v1';
|
|
26
|
+
var scriptUrl = "https://pay.guesty.com/tokenization/".concat(version, "/init.js");
|
|
27
|
+
var existingScript = findScriptElement(scriptUrl);
|
|
26
28
|
var existingNamespace = window[NAMESPACE];
|
|
27
29
|
if (existingScript) {
|
|
28
30
|
if (existingNamespace) {
|
|
@@ -33,7 +35,7 @@ var loadScript = function (options) {
|
|
|
33
35
|
return new Promise(function (resolve, reject) {
|
|
34
36
|
var _a;
|
|
35
37
|
injectScriptElement({
|
|
36
|
-
url:
|
|
38
|
+
url: scriptUrl,
|
|
37
39
|
sandbox: (_a = options.sandbox) !== null && _a !== void 0 ? _a : false,
|
|
38
40
|
onSuccess: function () {
|
|
39
41
|
var newNamespace = window[NAMESPACE];
|
|
@@ -45,7 +47,7 @@ var loadScript = function (options) {
|
|
|
45
47
|
}
|
|
46
48
|
},
|
|
47
49
|
onError: function () {
|
|
48
|
-
reject(new Error("The script ".concat(
|
|
50
|
+
reject(new Error("The script ".concat(scriptUrl, " failed to load")));
|
|
49
51
|
},
|
|
50
52
|
});
|
|
51
53
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var n="guestyTokenization",o=function(o){var e;if(void 0===o&&(o={}),"undefined"==typeof window)return Promise.resolve(null);var r,t=null!==(e=o.version)&&void 0!==e?e:"v1",i="https://pay.guesty.com/tokenization/".concat(t,"/init.js"),a=(r=i,document.querySelector('script[src="'.concat(r,'"]'))),s=window[n];if(a){if(s)return Promise.resolve(s);a.remove()}return new Promise((function(e,r){var t;!function(n){var o=n.url,e=n.sandbox,r=n.onSuccess,t=n.onError,i=document.createElement("script");i.src=o,i.async=!0,i.onerror=t,i.onload=r,e&&i.setAttribute("data-env","sandbox"),document.head.insertBefore(i,document.head.firstElementChild)}({url:i,sandbox:null!==(t=o.sandbox)&&void 0!==t&&t,onSuccess:function(){var o=window[n];o?e(o):r(new Error("Guesty Tokenization is not available"))},onError:function(){r(new Error("The script ".concat(i," failed to load")))}})}))};export{o as loadScript};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,uBAAuB,CAAC
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,uBAAuB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadScript.d.ts","sourceRoot":"","sources":["../../src/loadScript.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAE7C,eAAO,MAAM,UAAU,aAAa,iBAAiB,
|
|
1
|
+
{"version":3,"file":"loadScript.d.ts","sourceRoot":"","sources":["../../src/loadScript.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAE7C,eAAO,MAAM,UAAU,aAAa,iBAAiB,qBAmCpD,CAAC"}
|
package/package.json
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -30,7 +30,7 @@ type TInput =
|
|
|
30
30
|
| TBillingAddressInput
|
|
31
31
|
| TPaymentDetailsInput;
|
|
32
32
|
|
|
33
|
-
export interface
|
|
33
|
+
export interface GuestyTokenizationV1RenderOptions {
|
|
34
34
|
containerId: string;
|
|
35
35
|
providerId: string;
|
|
36
36
|
amount: number;
|
|
@@ -54,27 +54,103 @@ export interface GuestyTokenizationRenderOptions {
|
|
|
54
54
|
};
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
export interface GuestyTokenizationV2RenderOptions {
|
|
58
|
+
containerId: string;
|
|
59
|
+
providerId: string;
|
|
60
|
+
onStatusChange?: (status: boolean) => void;
|
|
61
|
+
styles?: GuestyTokenizationStyles;
|
|
62
|
+
lang?: string;
|
|
63
|
+
initialValues?: {
|
|
64
|
+
firstName?: string;
|
|
65
|
+
lastName?: string;
|
|
66
|
+
street?: string;
|
|
67
|
+
city?: string;
|
|
68
|
+
state?: string;
|
|
69
|
+
zipCode?: string;
|
|
70
|
+
country?: string;
|
|
71
|
+
};
|
|
72
|
+
showInitialValuesToggle?: boolean;
|
|
73
|
+
initialValuesToggleLabel?: string;
|
|
74
|
+
sections?: Section[];
|
|
75
|
+
showSupportedCards?: boolean;
|
|
76
|
+
showPciCompliantLink?: boolean;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export interface GuestyTokenizationV2ApiV2SubmitPayload {
|
|
80
|
+
amount: number;
|
|
81
|
+
currency: string;
|
|
82
|
+
apiVersion: 'v2';
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
type ReservationOrQuote =
|
|
86
|
+
| {
|
|
87
|
+
reservationId: string;
|
|
88
|
+
quoteId?: never;
|
|
89
|
+
guest?: never;
|
|
90
|
+
}
|
|
91
|
+
| {
|
|
92
|
+
quoteId: string;
|
|
93
|
+
guest: {
|
|
94
|
+
firstName: string;
|
|
95
|
+
lastName: string;
|
|
96
|
+
email?: string;
|
|
97
|
+
phone?: string;
|
|
98
|
+
};
|
|
99
|
+
reservationId?: never;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
export type GuestyTokenizationV2ApiV3SubmitPayload = {
|
|
103
|
+
listingId: string;
|
|
104
|
+
amount: number;
|
|
105
|
+
currency: string;
|
|
106
|
+
apiVersion?: 'v3';
|
|
107
|
+
} & ReservationOrQuote;
|
|
108
|
+
|
|
109
|
+
export type GuestyTokenizationV2SubmitPayload =
|
|
110
|
+
| GuestyTokenizationV2ApiV2SubmitPayload
|
|
111
|
+
| GuestyTokenizationV2ApiV3SubmitPayload;
|
|
112
|
+
|
|
57
113
|
export interface PaymentMethod {
|
|
58
114
|
_id: string;
|
|
59
115
|
}
|
|
60
116
|
|
|
61
|
-
export interface
|
|
62
|
-
render: (options:
|
|
117
|
+
export interface GuestyTokenizationV1Namespace {
|
|
118
|
+
render: (options: GuestyTokenizationV1RenderOptions) => Promise<void>;
|
|
63
119
|
destroy: () => Promise<void>;
|
|
64
120
|
submit: () => Promise<PaymentMethod>;
|
|
65
121
|
validate: () => void;
|
|
66
122
|
}
|
|
67
123
|
|
|
124
|
+
export interface GuestyTokenizationV2Namespace {
|
|
125
|
+
render: (options: GuestyTokenizationV2RenderOptions) => Promise<void>;
|
|
126
|
+
destroy: () => Promise<void>;
|
|
127
|
+
submit: (
|
|
128
|
+
payload: GuestyTokenizationV2SubmitPayload
|
|
129
|
+
) => Promise<PaymentMethod>;
|
|
130
|
+
validate: () => void;
|
|
131
|
+
}
|
|
132
|
+
|
|
68
133
|
export interface LoadScriptOptions {
|
|
69
134
|
sandbox?: boolean;
|
|
135
|
+
version?: 'v1' | 'v2';
|
|
70
136
|
}
|
|
71
137
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
138
|
+
type NamespaceBasedOnVersion<T extends LoadScriptOptions['version']> =
|
|
139
|
+
T extends 'v1'
|
|
140
|
+
? GuestyTokenizationV1Namespace
|
|
141
|
+
: T extends 'v2'
|
|
142
|
+
? GuestyTokenizationV2Namespace
|
|
143
|
+
: never;
|
|
144
|
+
|
|
145
|
+
export function loadScript<T extends LoadScriptOptions['version']>(
|
|
146
|
+
options?: LoadScriptOptions & { version: T }
|
|
147
|
+
): Promise<NamespaceBasedOnVersion<T> | null>;
|
|
75
148
|
|
|
76
149
|
declare global {
|
|
77
150
|
interface Window {
|
|
78
|
-
guestyTokenization?:
|
|
151
|
+
guestyTokenization?:
|
|
152
|
+
| GuestyTokenizationV1Namespace
|
|
153
|
+
| GuestyTokenizationV2Namespace
|
|
154
|
+
| null;
|
|
79
155
|
}
|
|
80
156
|
}
|