@lancom/shared 0.0.420 → 0.0.421
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/components/checkout/order/order-payment-information/order-payment-information.vue +1 -0
- package/components/common/payment/payment_card/pinpayment/pinpayment.scss +10 -1
- package/components/common/payment/payment_card/pinpayment/pinpayment.vue +57 -33
- package/package.json +1 -1
- package/plugins/vue-recaptcha.js +40 -12
|
@@ -10,6 +10,15 @@
|
|
|
10
10
|
background-color: #F4F4F4;
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
|
+
&__error {
|
|
14
|
+
font-weight: bold;
|
|
15
|
+
font-size: 14px;
|
|
16
|
+
padding: 18px 10px;
|
|
17
|
+
text-align: center;
|
|
18
|
+
color: $white;
|
|
19
|
+
background: #EA3434;
|
|
20
|
+
margin-top: 20px;
|
|
21
|
+
}
|
|
13
22
|
&__field-container {
|
|
14
23
|
width: 100%;
|
|
15
24
|
}
|
|
@@ -50,4 +59,4 @@
|
|
|
50
59
|
}
|
|
51
60
|
}
|
|
52
61
|
}
|
|
53
|
-
}
|
|
62
|
+
}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="Payment__wrapper">
|
|
3
|
-
<div
|
|
3
|
+
<div
|
|
4
|
+
v-if="pinpaymentsError"
|
|
5
|
+
class="Payment__error">
|
|
6
|
+
{{ pinpaymentsError }}
|
|
7
|
+
</div>
|
|
8
|
+
<div v-else-if="(hasSpinner && processing) || loading">
|
|
4
9
|
<spinner />
|
|
5
10
|
</div>
|
|
6
11
|
<div
|
|
@@ -86,7 +91,6 @@
|
|
|
86
91
|
</template>
|
|
87
92
|
|
|
88
93
|
<script>
|
|
89
|
-
let timer = null;
|
|
90
94
|
let pinpaymentStartLoaded = false;
|
|
91
95
|
|
|
92
96
|
export default {
|
|
@@ -108,26 +112,20 @@ export default {
|
|
|
108
112
|
return {
|
|
109
113
|
processing: false,
|
|
110
114
|
loading: false,
|
|
115
|
+
waitPinpaymentTimer: null,
|
|
116
|
+
pinpaymentsError: null,
|
|
111
117
|
fields: null
|
|
112
118
|
};
|
|
113
119
|
},
|
|
114
120
|
async mounted() {
|
|
115
121
|
this.loading = true;
|
|
116
|
-
|
|
117
122
|
await this.loadPinpayments();
|
|
118
|
-
|
|
119
123
|
if (window.HostedFields) {
|
|
120
124
|
await this.initHostedPayment();
|
|
121
|
-
} else {
|
|
122
|
-
window.addEventListener('load', async () => {
|
|
123
|
-
if (!this.fields) {
|
|
124
|
-
await this.initHostedPayment();
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
125
|
}
|
|
128
126
|
},
|
|
129
127
|
destroyed() {
|
|
130
|
-
clearInterval(
|
|
128
|
+
clearInterval(this.waitPinpaymentTimer);
|
|
131
129
|
},
|
|
132
130
|
methods: {
|
|
133
131
|
initHostedPayment() {
|
|
@@ -207,30 +205,56 @@ export default {
|
|
|
207
205
|
},
|
|
208
206
|
async loadPinpayments() {
|
|
209
207
|
if (process.browser) {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
} else {
|
|
224
|
-
let repeated = 0;
|
|
225
|
-
timer = setInterval(() => {
|
|
226
|
-
if (!!window.HostedFields || repeated++ > 40) {
|
|
227
|
-
clearInterval(timer);
|
|
228
|
-
resolve();
|
|
229
|
-
}
|
|
230
|
-
}, 500);
|
|
208
|
+
if (pinpaymentStartLoaded) {
|
|
209
|
+
await this.waitUntilLoadedPinpayment();
|
|
210
|
+
}
|
|
211
|
+
if (!window.HostedField) {
|
|
212
|
+
pinpaymentStartLoaded = true;
|
|
213
|
+
for (let index = 0; index < 10; index++) {
|
|
214
|
+
try {
|
|
215
|
+
await this.loadPinpaymentsJs();
|
|
216
|
+
break;
|
|
217
|
+
} catch (e) {
|
|
218
|
+
console.log('loadPinpayments:error ', e);
|
|
219
|
+
await new Promise(resolve => setTimeout(resolve, 500));
|
|
220
|
+
}
|
|
231
221
|
}
|
|
232
|
-
}
|
|
222
|
+
}
|
|
223
|
+
if (!window.HostedFields) {
|
|
224
|
+
this.pinpaymentsError = '"Credit Card" payment temporarily not available';
|
|
225
|
+
}
|
|
233
226
|
}
|
|
227
|
+
},
|
|
228
|
+
waitUntilLoadedPinpayment() {
|
|
229
|
+
return new Promise((resolve, reject) => {
|
|
230
|
+
let repeated = 0;
|
|
231
|
+
this.waitPinpaymentTimer = setInterval(() => {
|
|
232
|
+
if (!!window.HostedFields || repeated++ > 10) {
|
|
233
|
+
clearInterval(this.waitPinpaymentTimer);
|
|
234
|
+
resolve();
|
|
235
|
+
}
|
|
236
|
+
}, 500);
|
|
237
|
+
});
|
|
238
|
+
},
|
|
239
|
+
loadPinpaymentsJs() {
|
|
240
|
+
return (new Promise((resolve, reject) => {
|
|
241
|
+
const domElement = document.createElement('script');
|
|
242
|
+
domElement.type = 'text/javascript';
|
|
243
|
+
domElement.setAttribute('src', 'https://cdn.pinpayments.com/pin.hosted_fields.v1.js');
|
|
244
|
+
domElement.onload = () => {
|
|
245
|
+
setTimeout(() => {
|
|
246
|
+
if (window.HostedFields) {
|
|
247
|
+
resolve();
|
|
248
|
+
} else {
|
|
249
|
+
reject(new Error('Failed to Load JS'));
|
|
250
|
+
}
|
|
251
|
+
}, 500);
|
|
252
|
+
};
|
|
253
|
+
domElement.onerror = () => {
|
|
254
|
+
reject(new Error('Failed to Load JS'));
|
|
255
|
+
};
|
|
256
|
+
document.body.appendChild(domElement);
|
|
257
|
+
}));
|
|
234
258
|
}
|
|
235
259
|
}
|
|
236
260
|
};
|
package/package.json
CHANGED
package/plugins/vue-recaptcha.js
CHANGED
|
@@ -1,29 +1,57 @@
|
|
|
1
1
|
import Vue from 'vue';
|
|
2
2
|
|
|
3
|
-
let
|
|
3
|
+
let recaptchaStartLoaded = false;
|
|
4
4
|
|
|
5
5
|
export default () => {
|
|
6
6
|
Vue.mixin({
|
|
7
|
+
data() {
|
|
8
|
+
return {
|
|
9
|
+
waitRecaptchaTimer: null,
|
|
10
|
+
recaptchaError: null
|
|
11
|
+
};
|
|
12
|
+
},
|
|
7
13
|
methods: {
|
|
8
14
|
async getRecaptcha(name) {
|
|
9
15
|
await this.preloadReCaptcha();
|
|
10
16
|
return process.env.IS_LOCAL === 'true' || await this.$recaptcha(name);
|
|
11
17
|
},
|
|
12
18
|
async preloadReCaptcha() {
|
|
19
|
+
if (recaptchaStartLoaded) {
|
|
20
|
+
await this.waitUntilLoadedRecaptcha();
|
|
21
|
+
}
|
|
22
|
+
|
|
13
23
|
if (!this.$recaptcha) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
+
recaptchaStartLoaded = true;
|
|
25
|
+
for (let index = 0; index < 10; index++) {
|
|
26
|
+
try {
|
|
27
|
+
await this.loadRecaptchaJs();
|
|
28
|
+
break;
|
|
29
|
+
} catch (e) {
|
|
30
|
+
console.log('loadRecaptcha:error ', e);
|
|
31
|
+
await new Promise(resolve => setTimeout(resolve, 500));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
24
34
|
}
|
|
35
|
+
|
|
36
|
+
await this.$recaptchaLoaded();
|
|
37
|
+
|
|
38
|
+
if (!this.$recaptcha) {
|
|
39
|
+
this.recaptchaError = 'Recaptcha temporarily not available';
|
|
40
|
+
}
|
|
41
|
+
console.log('loadRecaptcha:result ', !!this.$recaptcha);
|
|
42
|
+
},
|
|
43
|
+
waitUntilLoadedRecaptcha() {
|
|
44
|
+
return new Promise((resolve, reject) => {
|
|
45
|
+
let repeated = 0;
|
|
46
|
+
this.waitRecaptchaTimer = setInterval(() => {
|
|
47
|
+
if (!!this.$recaptcha || repeated++ > 10) {
|
|
48
|
+
clearInterval(this.waitRecaptchaTimer);
|
|
49
|
+
resolve();
|
|
50
|
+
}
|
|
51
|
+
}, 500);
|
|
52
|
+
});
|
|
25
53
|
},
|
|
26
|
-
async
|
|
54
|
+
async loadRecaptchaJs() {
|
|
27
55
|
const { VueReCaptcha } = await import('vue-recaptcha-v3');
|
|
28
56
|
Vue.use(VueReCaptcha, {
|
|
29
57
|
siteKey: process.env.RECAPTCHA_KEY,
|