@everymatrix/cashier-method-details 1.43.2 → 1.43.4
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/CHANGELOG.md +1 -0
- package/dist/cashier-method-details.js +203 -196
- package/dist/cashier-method-details.js.map +1 -1
- package/package.json +2 -2
- package/src/CashierMethodDetails.svelte +126 -81
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@everymatrix/cashier-method-details",
|
3
|
-
"version": "1.43.
|
3
|
+
"version": "1.43.4",
|
4
4
|
"main": "index.js",
|
5
5
|
"svelte": "src/index.ts",
|
6
6
|
"scripts": {
|
@@ -35,5 +35,5 @@
|
|
35
35
|
"publishConfig": {
|
36
36
|
"access": "public"
|
37
37
|
},
|
38
|
-
"gitHead": "
|
38
|
+
"gitHead": "8464c47cb49b4ffa1c9debfac3a7dfc3097cf57a"
|
39
39
|
}
|
@@ -120,7 +120,8 @@
|
|
120
120
|
enum ResponseCode {
|
121
121
|
PlayerSessionIsNotValid = 'PlayerSessionIsNotValid',
|
122
122
|
Success = 'Success',
|
123
|
-
JwtTokenError = 'JwtTokenError'
|
123
|
+
JwtTokenError = 'JwtTokenError',
|
124
|
+
Maintenance = 'Maintenance'
|
124
125
|
}
|
125
126
|
|
126
127
|
const VISIBLE_FIELD_TYPES: string[] = 'Text,Number,Money,Boolean,Lookup,Date,Time,DateTime,Password,Label,Link,QRCode'.split(',');
|
@@ -218,13 +219,11 @@
|
|
218
219
|
let selectedPaymentMethod: PaymentMethod = {} as PaymentMethod;
|
219
220
|
let fields: PaymentMethodDetails[] = [];
|
220
221
|
let prepareFields = {};
|
221
|
-
let
|
222
|
-
let
|
223
|
-
let displayNone:boolean = false;
|
224
|
-
let customStylingContainer:HTMLElement;
|
222
|
+
let displayNone: boolean = false;
|
223
|
+
let customStylingContainer: HTMLElement;
|
225
224
|
let prepareRequest;
|
226
|
-
let showConfirmModal:boolean = false;
|
227
|
-
let showReceiptPage:boolean = false;
|
225
|
+
let showConfirmModal: boolean = false;
|
226
|
+
let showReceiptPage: boolean = false;
|
228
227
|
let redirectUrl: string;
|
229
228
|
let windowRedirect: Window;
|
230
229
|
let showRedirectNotification: boolean;
|
@@ -239,9 +238,7 @@
|
|
239
238
|
let qrCodeScriptSrc: string = 'https://cdn.rawgit.com/davidshimjs/qrcodejs/gh-pages/qrcode.min.js';
|
240
239
|
let blankPageTarget: string = '_blank';
|
241
240
|
let externalLink: string = '';
|
242
|
-
let mobileView:boolean = false;
|
243
|
-
let userAgent:string = window.navigator.userAgent;
|
244
|
-
let mediaQuery = window.matchMedia('(max-width: 750px)');
|
241
|
+
let mobileView: boolean = false;
|
245
242
|
let innerWidth: number;
|
246
243
|
let formatter = new Intl.NumberFormat(local, {minimumFractionDigits: 2 });
|
247
244
|
let amountError = '';
|
@@ -254,8 +251,10 @@
|
|
254
251
|
let isDisabled: boolean;
|
255
252
|
let showErrorModal = false;
|
256
253
|
let transactionId = '';
|
257
|
-
let showSpinner: boolean =
|
258
|
-
|
254
|
+
let showSpinner: boolean = false;
|
255
|
+
let abortController = new AbortController();
|
256
|
+
|
257
|
+
$: endpoint && session && selectedpaymentmethodname && currency && initMethod();
|
259
258
|
$: clientstyling && customStylingContainer && setClientStyling();
|
260
259
|
$: clientstylingurl && customStylingContainer && setClientStylingURL();
|
261
260
|
$: lang && setActiveLanguage();
|
@@ -264,8 +263,7 @@
|
|
264
263
|
$: fields.length && qrCodeContainer.length && generateQr();
|
265
264
|
$: fields.length && flatpickrEl.length && createDatePicker();
|
266
265
|
|
267
|
-
|
268
|
-
const reinitMethod = () => {
|
266
|
+
const initMethod = () => {
|
269
267
|
if (flatpickrEl.length) {
|
270
268
|
flatpickrEl.forEach(el => {
|
271
269
|
if (!el) {
|
@@ -308,6 +306,12 @@
|
|
308
306
|
})
|
309
307
|
}
|
310
308
|
|
309
|
+
const reinitMethod = (e) => {
|
310
|
+
if (abortController?.signal?.aborted && selectedpaymentmethodname === e.detail.Name) {
|
311
|
+
initMethod()
|
312
|
+
}
|
313
|
+
}
|
314
|
+
|
311
315
|
const createDatePicker = () => {
|
312
316
|
const dateOptions = {
|
313
317
|
[FieldTypes.Time]: {
|
@@ -347,9 +351,11 @@
|
|
347
351
|
})
|
348
352
|
});
|
349
353
|
}
|
354
|
+
|
350
355
|
const setActiveLanguage = ():void => {
|
351
356
|
setLocale(lang);
|
352
357
|
}
|
358
|
+
|
353
359
|
const setTranslationUrl = () => {
|
354
360
|
let url:string = translationurl;
|
355
361
|
if (url) {
|
@@ -370,6 +376,10 @@
|
|
370
376
|
});
|
371
377
|
|
372
378
|
const getPaymentDetails = () => {
|
379
|
+
abortPaymentFetch();
|
380
|
+
abortController = new AbortController();
|
381
|
+
const signal = abortController.signal;
|
382
|
+
showSpinner = true;
|
373
383
|
const url:URL = new URL(`${endpoint}/v1/player/${customerid}/payment/GetPaymentMethod`);
|
374
384
|
const headers = new Headers();
|
375
385
|
headers.append("accept", "application/json");
|
@@ -386,46 +396,53 @@
|
|
386
396
|
})
|
387
397
|
}
|
388
398
|
fetch(url, requestParams).then(res => res.json()).then(data => {
|
389
|
-
if (
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
399
|
+
if (!signal.aborted) {
|
400
|
+
if (data.error) {
|
401
|
+
window.postMessage({type: 'ShowSessionError', error: data.error}, window.location.href)
|
402
|
+
return;
|
403
|
+
}
|
404
|
+
if (data.ResponseCode === ResponseCode.PlayerSessionIsNotValid
|
405
|
+
|| data.ResponseCode === ResponseCode.Maintenance
|
406
|
+
|| data.ResponseCode === ResponseCode.JwtTokenError) {
|
407
|
+
errorResponseCode = data.ResponseCode;
|
408
|
+
setErrorResponseCode();
|
409
|
+
return;
|
410
|
+
}
|
411
|
+
if (data.ResponseCode !== ResponseCode.Success) {
|
412
|
+
errorResponseCode = data.ResponseCode;
|
413
|
+
return;
|
414
|
+
}
|
415
|
+
xPaymentSessionToken = data.XPaymentSessionToken;
|
416
|
+
selectedPaymentMethod = data.PaymentMethod;
|
417
|
+
editedAmount = Number(amount);
|
418
|
+
if (!selectedPaymentMethod.HideAmountField) {
|
419
|
+
validateAmount();
|
420
|
+
} else {
|
421
|
+
amountError = '';
|
422
|
+
}
|
423
|
+
fields = selectedPaymentMethod.Fields && selectedPaymentMethod.Fields.map(field => new PaymentMethodDetails(field));
|
424
|
+
fields.forEach(field => {
|
425
|
+
if (field?.defaultValue) {
|
426
|
+
prepareFields[field.name] = field.defaultValue;
|
427
|
+
}
|
428
|
+
validateField(field);
|
429
|
+
})
|
430
|
+
setConfirmModalInfo();
|
395
431
|
setErrorResponseCode();
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
return;
|
432
|
+
hideMethodsList();
|
433
|
+
window.postMessage({
|
434
|
+
type: 'StartSessionCountdown',
|
435
|
+
xPaymentSessionToken,
|
436
|
+
selectedPaymentMethodName: selectedpaymentmethodname
|
437
|
+
}, window.location.href);
|
403
438
|
}
|
439
|
+
}).finally(() => { showSpinner = signal.aborted })
|
440
|
+
}
|
404
441
|
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
xPaymentSessionToken = data.XPaymentSessionToken;
|
410
|
-
selectedPaymentMethod = data.PaymentMethod;
|
411
|
-
editedAmount = Number(amount);
|
412
|
-
if (!selectedPaymentMethod.HideAmountField) {
|
413
|
-
validateAmount();
|
414
|
-
} else {
|
415
|
-
amountError = '';
|
416
|
-
}
|
417
|
-
fields = selectedPaymentMethod.Fields && selectedPaymentMethod.Fields.map(field => new PaymentMethodDetails(field));
|
418
|
-
fields.forEach(field => {
|
419
|
-
if (field?.defaultValue) {
|
420
|
-
prepareFields[field.name] = field.defaultValue;
|
421
|
-
}
|
422
|
-
validateField(field);
|
423
|
-
})
|
424
|
-
setConfirmModalInfo();
|
425
|
-
setErrorResponseCode();
|
426
|
-
hideMethodsList();
|
427
|
-
window.postMessage({ type: 'StartSessionCountdown', xPaymentSessionToken, selectedPaymentMethodName: selectedpaymentmethodname }, window.location.href);
|
428
|
-
}).finally(() => showSpinner = false)
|
442
|
+
const abortPaymentFetch = ():void => {
|
443
|
+
if (abortController) {
|
444
|
+
abortController.abort();
|
445
|
+
}
|
429
446
|
}
|
430
447
|
|
431
448
|
const setClientStyling = ():void => {
|
@@ -471,6 +488,7 @@
|
|
471
488
|
window.addEventListener('confirmModal', confirmTxn, false);
|
472
489
|
window.addEventListener('closeIframe', closeIframe, false);
|
473
490
|
window.addEventListener('notificationButtonClick', retryRedirect, false);
|
491
|
+
window.addEventListener('selectPayMeth', reinitMethod, false)
|
474
492
|
document.addEventListener('click',closeAllLookups);
|
475
493
|
window.addEventListener('message', messageHandler, false);
|
476
494
|
dayjs.extend(customParseFormat);
|
@@ -480,6 +498,7 @@
|
|
480
498
|
window.removeEventListener('confirmModal', confirmTxn);
|
481
499
|
window.removeEventListener('closeIframe', closeIframe);
|
482
500
|
window.removeEventListener('notificationButtonClick', retryRedirect);
|
501
|
+
window.removeEventListener('selectPayMeth', reinitMethod, false)
|
483
502
|
window.removeEventListener('message', messageHandler);
|
484
503
|
}
|
485
504
|
});
|
@@ -546,23 +565,17 @@
|
|
546
565
|
postMessage({type: 'ShowSessionError', error: data.error}, window.location.href)
|
547
566
|
return;
|
548
567
|
}
|
549
|
-
if (data.ResponseCode === ResponseCode.PlayerSessionIsNotValid) {
|
550
|
-
errorResponseCode = data.ResponseCode
|
551
|
-
setErrorResponseCode();
|
552
|
-
return;
|
553
|
-
}
|
554
|
-
|
555
|
-
if (data.ResponseCode === ResponseCode.JwtTokenError) {
|
556
|
-
errorResponseCode = data.ResponseCode
|
557
|
-
setErrorResponseCode();
|
558
|
-
return;
|
559
|
-
}
|
560
|
-
|
561
568
|
if (data.ResponseCode !== ResponseCode.Success) {
|
562
569
|
errorResponseCode = data.ResponseCode
|
563
570
|
isProcessingTxn = false;
|
564
571
|
toggleDisableActionOnPage();
|
565
|
-
|
572
|
+
if (data.ResponseCode === ResponseCode.PlayerSessionIsNotValid
|
573
|
+
|| data.ResponseCode === ResponseCode.Maintenance
|
574
|
+
|| data.ResponseCode === ResponseCode.JwtTokenError) {
|
575
|
+
setErrorResponseCode();
|
576
|
+
} else {
|
577
|
+
showModal()
|
578
|
+
}
|
566
579
|
return;
|
567
580
|
}
|
568
581
|
xPaymentSessionToken = data.XPaymentSessionToken;
|
@@ -577,16 +590,20 @@
|
|
577
590
|
const setErrorResponseCode = () => {
|
578
591
|
window.postMessage({type: 'ErrorResponseCode', errorResponseCode}, window.location.href);
|
579
592
|
}
|
593
|
+
|
580
594
|
const setConfirmModalInfo = () => {
|
581
595
|
window.postMessage({type:'ShowConfirmModal', showConfirmModal, editedAmount, hideAmountField: selectedPaymentMethod.HideAmountField}, window.location.href);
|
582
596
|
}
|
597
|
+
|
583
598
|
const setRedirectInfo = () => {
|
584
599
|
window.postMessage({type: 'RedirectInfo', redirectMode, redirectUrl}, window.location.href);
|
585
600
|
}
|
601
|
+
|
586
602
|
const showModal = () => {
|
587
603
|
showErrorModal = true;
|
588
604
|
window.postMessage({ type: 'ShowCashierModal', modalErrorMessage: errorResponseCode}, window.location.href)
|
589
605
|
}
|
606
|
+
|
590
607
|
const backToMethodList = () => {
|
591
608
|
dispatchEvent(new CustomEvent('backToMethodList', {
|
592
609
|
bubbles: true,
|
@@ -601,6 +618,9 @@
|
|
601
618
|
}
|
602
619
|
|
603
620
|
const hidePaymentDetails = () => {
|
621
|
+
if (showSpinner) {
|
622
|
+
abortPaymentFetch()
|
623
|
+
}
|
604
624
|
dispatchEvent(new CustomEvent('hidePaymentDetails', {
|
605
625
|
detail: { hideMethodDetails: mobileView },
|
606
626
|
bubbles: true,
|
@@ -617,14 +637,17 @@
|
|
617
637
|
composed: true
|
618
638
|
}));
|
619
639
|
}
|
640
|
+
|
620
641
|
const closeIframe = () => {
|
621
642
|
redirectUrl = null;
|
622
643
|
showReceiptPage = true;
|
623
644
|
setRedirectInfo();
|
624
645
|
}
|
646
|
+
|
625
647
|
const closeModal = () => {
|
626
648
|
showConfirmModal = false;
|
627
649
|
}
|
650
|
+
|
628
651
|
const confirmTxn = () => {
|
629
652
|
isProcessingTxn = true;
|
630
653
|
const url:URL = new URL(`${endpoint}/v1/player/${customerid}/payment/GetPaymentConfirm`);
|
@@ -642,23 +665,17 @@
|
|
642
665
|
})
|
643
666
|
}
|
644
667
|
fetch(url, requestParams).then((res) => res.json()).then(data => {
|
645
|
-
if(data.ResponseCode === ResponseCode.PlayerSessionIsNotValid) {
|
646
|
-
errorResponseCode = data.ResponseCode
|
647
|
-
setErrorResponseCode();
|
648
|
-
return;
|
649
|
-
}
|
650
|
-
|
651
|
-
if(data.ResponseCode === ResponseCode.JwtTokenError) {
|
652
|
-
errorResponseCode = data.ResponseCode
|
653
|
-
setErrorResponseCode();
|
654
|
-
return;
|
655
|
-
}
|
656
|
-
|
657
668
|
if (data.ResponseCode !== ResponseCode.Success) {
|
658
|
-
errorResponseCode = data.ResponseCode
|
669
|
+
errorResponseCode = data.ResponseCode
|
659
670
|
isProcessingTxn = false;
|
660
671
|
toggleDisableActionOnPage();
|
661
|
-
|
672
|
+
if (data.ResponseCode === ResponseCode.PlayerSessionIsNotValid
|
673
|
+
|| data.ResponseCode === ResponseCode.Maintenance
|
674
|
+
|| data.ResponseCode === ResponseCode.JwtTokenError) {
|
675
|
+
setErrorResponseCode();
|
676
|
+
} else {
|
677
|
+
showModal()
|
678
|
+
}
|
662
679
|
return;
|
663
680
|
}
|
664
681
|
xPaymentSessionToken = data.XPaymentSessionToken;
|
@@ -807,6 +824,12 @@
|
|
807
824
|
return ''
|
808
825
|
}
|
809
826
|
|
827
|
+
const keydownHandler = (event: KeyboardEvent) => {
|
828
|
+
const invalidKeys = ['+','-','e','E'];
|
829
|
+
if (invalidKeys.includes(event.key)) {
|
830
|
+
event.preventDefault();
|
831
|
+
}
|
832
|
+
}
|
810
833
|
const validateAmount = () => {
|
811
834
|
amountError = emptyAmountError() || minAmountError() ||
|
812
835
|
maxAmountError() || amountMultiplierError() ||
|
@@ -879,6 +902,7 @@
|
|
879
902
|
<input type="number"
|
880
903
|
bind:value={editedAmount}
|
881
904
|
on:input={() => validateAmount()}
|
905
|
+
on:keydown={(event) => keydownHandler(event)}
|
882
906
|
on:blur={() => {showError['amount'] = true; validateAmount()}}
|
883
907
|
placeholder="{$_('amountPlaceholder')}"
|
884
908
|
>
|
@@ -1048,7 +1072,7 @@
|
|
1048
1072
|
hidebuttons="{`${!mobileView}`}"
|
1049
1073
|
errorcode={errorResponseCode}
|
1050
1074
|
>
|
1051
|
-
<
|
1075
|
+
<button slot="button" class="CashierErrorButton" on:click={backToMethodList}>{$_('backToMethodList')}</button>
|
1052
1076
|
</cashier-error>
|
1053
1077
|
{/if}
|
1054
1078
|
</div>
|
@@ -1333,6 +1357,27 @@
|
|
1333
1357
|
background: var(--mmw--color-main-button-hover, #71B11B);
|
1334
1358
|
}
|
1335
1359
|
}
|
1360
|
+
.CashierErrorButton {
|
1361
|
+
width: 100%;
|
1362
|
+
height: 36px;
|
1363
|
+
color: var(--emw--color-white, #FFF);
|
1364
|
+
text-align: center;
|
1365
|
+
cursor: pointer;
|
1366
|
+
font-size: var(--emw--font-size-x-small, 12px);
|
1367
|
+
font-style: normal;
|
1368
|
+
font-weight: var(--emw--font-weight-semibold, 500);
|
1369
|
+
font-family: inherit;
|
1370
|
+
line-height: 36px;
|
1371
|
+
border: none;
|
1372
|
+
border-radius: var(--emw--border-radius-medium, 4px);
|
1373
|
+
background: var(--emw--color-primary, #7EC51E);
|
1374
|
+
&:hover {
|
1375
|
+
background: var(--mmw--color-main-button-hover, #71B11B);
|
1376
|
+
}
|
1377
|
+
&:active {
|
1378
|
+
background: var(--mmw--color-main-button-active, #5C950F);
|
1379
|
+
}
|
1380
|
+
}
|
1336
1381
|
.QRCode {
|
1337
1382
|
width: 250px;
|
1338
1383
|
margin: auto;
|
@@ -1393,7 +1438,7 @@
|
|
1393
1438
|
display: block;
|
1394
1439
|
}
|
1395
1440
|
}
|
1396
|
-
}
|
1441
|
+
}
|
1397
1442
|
.DateInput {
|
1398
1443
|
position: relative;
|
1399
1444
|
.MobileDateInput {
|
@@ -1449,7 +1494,7 @@
|
|
1449
1494
|
position: absolute;
|
1450
1495
|
left: 0;
|
1451
1496
|
right: 0;
|
1452
|
-
z-index:
|
1497
|
+
z-index: 3;
|
1453
1498
|
background-color: var(--emw--color-white, #fff);
|
1454
1499
|
border: 1px solid var(--mmw--color-grey-105, #E8E9EB);
|
1455
1500
|
border-radius: var(--emw--border-radius-medium, 4px);
|