@healnow/payments-ui 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/lib/payments/card.js +15 -6
- package/package.json +6 -6
- package/src/payments/card.js +17 -8
package/lib/payments/card.js
CHANGED
|
@@ -32,7 +32,14 @@ var Card = (_mounted = /*#__PURE__*/new WeakMap(), _messenger = /*#__PURE__*/new
|
|
|
32
32
|
_classPrivateFieldInitSpec(this, _tokenResolve, null);
|
|
33
33
|
_classPrivateFieldInitSpec(this, _tokenReject, null);
|
|
34
34
|
_classPrivateFieldInitSpec(this, _errorHandler, null);
|
|
35
|
-
_classPrivateFieldSet(_messenger, this, new _channelMessenger["default"](
|
|
35
|
+
_classPrivateFieldSet(_messenger, this, new _channelMessenger["default"]({
|
|
36
|
+
timeout: 300,
|
|
37
|
+
connection: {
|
|
38
|
+
retries: 100,
|
|
39
|
+
delay: 300
|
|
40
|
+
}
|
|
41
|
+
}));
|
|
42
|
+
_classPrivateFieldGet(_messenger, this).peerSupportsAck = true;
|
|
36
43
|
_classPrivateFieldSet(_baseUrl, this, baseUrl);
|
|
37
44
|
_classPrivateFieldSet(_clientKey, this, clientKey);
|
|
38
45
|
_classPrivateFieldGet(_messenger, this).onMessage(_assertClassBrand(_Class_brand, this, _onMessage).bind(this));
|
|
@@ -46,7 +53,9 @@ var Card = (_mounted = /*#__PURE__*/new WeakMap(), _messenger = /*#__PURE__*/new
|
|
|
46
53
|
key: "tokenize",
|
|
47
54
|
value: function tokenize() {
|
|
48
55
|
var _this = this;
|
|
49
|
-
if (_classPrivateFieldGet(_tokenResolve, this))
|
|
56
|
+
if (_classPrivateFieldGet(_tokenResolve, this)) {
|
|
57
|
+
return Promise.reject(new Error('Card is already being tokenized'));
|
|
58
|
+
}
|
|
50
59
|
return new Promise(function (resolve, reject) {
|
|
51
60
|
_classPrivateFieldGet(_messenger, _this).send({
|
|
52
61
|
type: 'tokenize'
|
|
@@ -68,12 +77,12 @@ var Card = (_mounted = /*#__PURE__*/new WeakMap(), _messenger = /*#__PURE__*/new
|
|
|
68
77
|
target.appendChild(iframe);
|
|
69
78
|
_classPrivateFieldSet(_mounted, _this2, true);
|
|
70
79
|
iframe.addEventListener('load', function () {
|
|
71
|
-
|
|
72
|
-
_classPrivateFieldGet(_messenger, _this2).
|
|
80
|
+
_classPrivateFieldGet(_messenger, _this2).connect(iframe).then(function () {
|
|
81
|
+
_classPrivateFieldGet(_messenger, _this2).send({
|
|
73
82
|
type: 'init',
|
|
74
83
|
key: _classPrivateFieldGet(_clientKey, _this2)
|
|
75
|
-
}).then(resolve)["catch"](reject)
|
|
76
|
-
}
|
|
84
|
+
}).then(resolve)["catch"](reject);
|
|
85
|
+
})["catch"](reject);
|
|
77
86
|
});
|
|
78
87
|
});
|
|
79
88
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@healnow/payments-ui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/payments.js",
|
|
6
6
|
"scripts": {
|
|
@@ -16,15 +16,15 @@
|
|
|
16
16
|
"author": "Mladen Ilic <mladen@healnow.io>",
|
|
17
17
|
"license": "ISC",
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@mladenilic/channel-messenger": "^1.
|
|
19
|
+
"@mladenilic/channel-messenger": "^2.1.1",
|
|
20
20
|
"lodash.merge": "^4.6.2"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@babel/cli": "^7.28.
|
|
24
|
-
"@babel/core": "^7.28.
|
|
25
|
-
"@babel/preset-env": "^7.28.
|
|
23
|
+
"@babel/cli": "^7.28.3",
|
|
24
|
+
"@babel/core": "^7.28.5",
|
|
25
|
+
"@babel/preset-env": "^7.28.5",
|
|
26
26
|
"babel-loader": "^10.0.0",
|
|
27
|
-
"webpack": "^5.
|
|
27
|
+
"webpack": "^5.104.1",
|
|
28
28
|
"webpack-cli": "^6.0.1",
|
|
29
29
|
"webpack-dev-server": "^5.2.2"
|
|
30
30
|
}
|
package/src/payments/card.js
CHANGED
|
@@ -10,7 +10,16 @@ const Card = class {
|
|
|
10
10
|
#errorHandler = null;
|
|
11
11
|
|
|
12
12
|
constructor(baseUrl = '', clientKey = '') {
|
|
13
|
-
this.#messenger = new ChannelMessenger(
|
|
13
|
+
this.#messenger = new ChannelMessenger({
|
|
14
|
+
timeout: 300,
|
|
15
|
+
connection: {
|
|
16
|
+
retries: 100,
|
|
17
|
+
delay: 300
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
this.#messenger.peerSupportsAck = true;
|
|
22
|
+
|
|
14
23
|
this.#baseUrl = baseUrl;
|
|
15
24
|
this.#clientKey = clientKey;
|
|
16
25
|
|
|
@@ -22,7 +31,9 @@ const Card = class {
|
|
|
22
31
|
}
|
|
23
32
|
|
|
24
33
|
tokenize() {
|
|
25
|
-
if (this.#tokenResolve)
|
|
34
|
+
if (this.#tokenResolve) {
|
|
35
|
+
return Promise.reject(new Error('Card is already being tokenized'));
|
|
36
|
+
}
|
|
26
37
|
|
|
27
38
|
return new Promise((resolve, reject) => {
|
|
28
39
|
this.#messenger.send({ type: 'tokenize' }).catch(reject);
|
|
@@ -45,12 +56,10 @@ const Card = class {
|
|
|
45
56
|
this.#mounted = true;
|
|
46
57
|
|
|
47
58
|
iframe.addEventListener('load', () => {
|
|
48
|
-
|
|
49
|
-
this.#messenger.
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
).catch(reject)
|
|
53
|
-
}, 300);
|
|
59
|
+
this.#messenger.connect(iframe).then(() => {
|
|
60
|
+
this.#messenger.send({ type: 'init', key: this.#clientKey })
|
|
61
|
+
.then(resolve).catch(reject)
|
|
62
|
+
}).catch(reject);
|
|
54
63
|
});
|
|
55
64
|
});
|
|
56
65
|
}
|