@everymatrix/cashier-method-details 1.29.4 → 1.29.6
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 +2 -0
- package/dist/cashier-method-details.js +147 -143
- package/dist/cashier-method-details.js.map +1 -1
- package/package.json +2 -2
- package/src/CashierMethodDetails.svelte +73 -61
- package/src/translations.js +0 -11
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@everymatrix/cashier-method-details",
|
3
|
-
"version": "1.29.
|
3
|
+
"version": "1.29.6",
|
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": "a67714e03295f6cdb76990ce33c8baeec7819b9f"
|
39
39
|
}
|
@@ -17,8 +17,6 @@
|
|
17
17
|
import FlatpickrLanguages from "flatpickr/dist/l10n";
|
18
18
|
import dayjs from 'dayjs';
|
19
19
|
import customParseFormat from 'dayjs/plugin/customParseFormat';
|
20
|
-
import isSameOrBefore from 'dayjs/plugin/isSameOrBefore';
|
21
|
-
import isSameOrAfter from 'dayjs/plugin/isSameOrAfter';
|
22
20
|
import type {PaymentMethod} from "./CashierMethodDetails.types";
|
23
21
|
export class PaymentMethodDetails {
|
24
22
|
name: string;
|
@@ -164,7 +162,7 @@
|
|
164
162
|
export let translationurl: string;
|
165
163
|
export let customerid: string;
|
166
164
|
export let currency: string;
|
167
|
-
export let amount:
|
165
|
+
export let amount: string;
|
168
166
|
export let assetsurl: string;
|
169
167
|
export let type: string = TxnType.Deposit;
|
170
168
|
export let selectedpaymentmethodname: string;
|
@@ -209,6 +207,7 @@
|
|
209
207
|
let editedAmount: number;
|
210
208
|
let errorResponseCode: string;
|
211
209
|
let isDisabled: boolean;
|
210
|
+
let showErrorModal = false;
|
212
211
|
|
213
212
|
$: endpoint && session && selectedpaymentmethodname && currency && reinitMethod();
|
214
213
|
$: clientstyling && customStylingContainer && setClientStyling();
|
@@ -238,7 +237,9 @@
|
|
238
237
|
fieldValidation = {};
|
239
238
|
qrCodeContainer = [];
|
240
239
|
selectedPaymentMethod = null;
|
241
|
-
errorResponseCode = ''
|
240
|
+
errorResponseCode = '';
|
241
|
+
showErrorModal = false;
|
242
|
+
setErrorResponseCode();
|
242
243
|
getPaymentDetails();
|
243
244
|
}
|
244
245
|
|
@@ -341,11 +342,12 @@
|
|
341
342
|
}
|
342
343
|
if (data.ResponseCode !== 'Success') {
|
343
344
|
errorResponseCode = data.ResponseCode;
|
345
|
+
setErrorResponseCode();
|
344
346
|
return;
|
345
347
|
}
|
346
348
|
xPaymentSessionToken = data.XPaymentSessionToken;
|
347
349
|
selectedPaymentMethod = data.PaymentMethod;
|
348
|
-
editedAmount = amount;
|
350
|
+
editedAmount = Number(amount);
|
349
351
|
if (!selectedPaymentMethod.HideAmountField) {
|
350
352
|
validateAmount();
|
351
353
|
}
|
@@ -356,6 +358,8 @@
|
|
356
358
|
}
|
357
359
|
validateField(field);
|
358
360
|
})
|
361
|
+
setConfirmModalInfo();
|
362
|
+
setErrorResponseCode();
|
359
363
|
hideMethodsList();
|
360
364
|
})
|
361
365
|
}
|
@@ -386,6 +390,13 @@
|
|
386
390
|
mobileView = isMobile(userAgent) || mediaQuery.matches
|
387
391
|
}
|
388
392
|
|
393
|
+
const messageHandler = (e:any) => {
|
394
|
+
if (e.data.type == 'ErrorResponseCode') {
|
395
|
+
errorResponseCode = e.data.errorResponseCode;
|
396
|
+
showReceiptPage = e.data.showReceiptPage;
|
397
|
+
}
|
398
|
+
}
|
399
|
+
|
389
400
|
onMount(() => {
|
390
401
|
window.addEventListener('closeModal', closeModal, false);
|
391
402
|
window.addEventListener('confirmModal', confirmTxn, false);
|
@@ -393,9 +404,8 @@
|
|
393
404
|
window.addEventListener('notificationButtonClick', retryRedirect, false);
|
394
405
|
window.addEventListener('closeCashierReceiptPage', closeReceiptPage, false);
|
395
406
|
document.addEventListener('click',closeAllLookups);
|
407
|
+
window.addEventListener('message', messageHandler, false);
|
396
408
|
dayjs.extend(customParseFormat);
|
397
|
-
dayjs.extend(isSameOrBefore);
|
398
|
-
dayjs.extend(isSameOrAfter);
|
399
409
|
|
400
410
|
return () => {
|
401
411
|
window.removeEventListener('closeModal', closeModal);
|
@@ -403,6 +413,7 @@
|
|
403
413
|
window.removeEventListener('closeIframe', closeIframe);
|
404
414
|
window.removeEventListener('notificationButtonClick', retryRedirect);
|
405
415
|
window.removeEventListener('closeCashierReceiptPage', closeReceiptPage);
|
416
|
+
window.removeEventListener('message', messageHandler);
|
406
417
|
}
|
407
418
|
});
|
408
419
|
|
@@ -470,6 +481,7 @@
|
|
470
481
|
if (data.ResponseCode !== 'Success') {
|
471
482
|
errorResponseCode = data.ResponseCode
|
472
483
|
isProcessingTxn = false;
|
484
|
+
setErrorResponseCode();
|
473
485
|
toggleDisableActionOnPage();
|
474
486
|
showModal()
|
475
487
|
return;
|
@@ -477,18 +489,24 @@
|
|
477
489
|
xPaymentSessionToken = data.XPaymentSessionToken;
|
478
490
|
isProcessingTxn = false;
|
479
491
|
showConfirmModal = true;
|
492
|
+
setConfirmModalInfo();
|
480
493
|
toggleDisableActionOnPage();
|
481
494
|
})
|
482
495
|
}
|
483
496
|
|
497
|
+
const setErrorResponseCode = () => {
|
498
|
+
window.postMessage({type: 'ErrorResponseCode', errorResponseCode});
|
499
|
+
}
|
500
|
+
const setConfirmModalInfo = () => {
|
501
|
+
window.postMessage({type:'ShowConfirmModal', showConfirmModal, editedAmount});
|
502
|
+
}
|
503
|
+
const setRedirectInfo = () => {
|
504
|
+
window.postMessage({type: 'RedirectInfo', redirectMode, redirectUrl});
|
505
|
+
}
|
484
506
|
const showModal = () => {
|
507
|
+
showErrorModal = true;
|
485
508
|
window.postMessage({ type: 'ShowCashierModal' }, window.location.href)
|
486
509
|
}
|
487
|
-
|
488
|
-
const hideModal = () => {
|
489
|
-
window.postMessage({ type: 'HideCashierModal' }, window.location.href)
|
490
|
-
}
|
491
|
-
|
492
510
|
const backToMethodList = () => {
|
493
511
|
dispatchEvent(new CustomEvent('backToMethodList', {
|
494
512
|
bubbles: true,
|
@@ -522,6 +540,7 @@
|
|
522
540
|
const closeIframe = () => {
|
523
541
|
redirectUrl = null;
|
524
542
|
showReceiptPage = true;
|
543
|
+
setRedirectInfo();
|
525
544
|
}
|
526
545
|
const closeModal = () => {
|
527
546
|
showConfirmModal = false;
|
@@ -545,6 +564,7 @@
|
|
545
564
|
if (data.ResponseCode !== 'Success') {
|
546
565
|
errorResponseCode = data.ResponseCode;
|
547
566
|
isProcessingTxn = false;
|
567
|
+
toggleDisableActionOnPage();
|
548
568
|
showModal();
|
549
569
|
return;
|
550
570
|
}
|
@@ -553,6 +573,7 @@
|
|
553
573
|
redirectMode = redirectModeMap.get(data.RedirectionMode);
|
554
574
|
isProcessingTxn = false;
|
555
575
|
toggleDisableActionOnPage();
|
576
|
+
setRedirectInfo();
|
556
577
|
if (!redirectUrl) {
|
557
578
|
showReceiptPage = true;
|
558
579
|
}
|
@@ -569,6 +590,7 @@
|
|
569
590
|
windowRedirect = window.open(redirectUrl, '_blank');
|
570
591
|
showRedirectNotification = true;
|
571
592
|
showRetryNotification = false;
|
593
|
+
setRedirectInfo();
|
572
594
|
}
|
573
595
|
|
574
596
|
const closeReceiptPage = () => {
|
@@ -702,7 +724,7 @@
|
|
702
724
|
const inputValue = dayjs(value, format);
|
703
725
|
const maxValue = dayjs(field.maxValue, format);
|
704
726
|
const minValue = dayjs(field.minValue, format);
|
705
|
-
if (inputValue.
|
727
|
+
if (inputValue.isBefore(minValue) || inputValue.isAfter(maxValue)) {
|
706
728
|
fieldValidation[field.name] = $_('invalidFieldError',{ values: { field: field.label }})
|
707
729
|
return;
|
708
730
|
}
|
@@ -727,7 +749,7 @@
|
|
727
749
|
<div class="CashierMethodDetails" bind:this={customStylingContainer}>
|
728
750
|
{#if selectedPaymentMethod?.Name}
|
729
751
|
<div class="MethodsDetails">
|
730
|
-
{#if !showReceiptPage}
|
752
|
+
{#if !showReceiptPage && !errorResponseCode || (errorResponseCode && showErrorModal)}
|
731
753
|
<form on:submit|preventDefault={prepareTxn} novalidate>
|
732
754
|
<div class="FieldWrapper">
|
733
755
|
<div class="FormLogo">
|
@@ -793,7 +815,8 @@
|
|
793
815
|
on:input="{() => { validateField(field) }}"
|
794
816
|
on:blur="{() => { showError[field.name] = true; validateField(field) }}">
|
795
817
|
{:else if field.type === FieldTypes.Time || field.type === FieldTypes.Date || field.type === FieldTypes.DateTime}
|
796
|
-
|
818
|
+
<div class="DateInput">
|
819
|
+
<input class="DateTimePicker" type="text" bind:value={ prepareFields[field.name] } pattern={field.format}
|
797
820
|
data-field={JSON.stringify(field)}
|
798
821
|
placeholder={field.placeholder}
|
799
822
|
on:input={() => { showError[field.name] = true; dateTimeValidation(field) }}
|
@@ -801,6 +824,10 @@
|
|
801
824
|
on:blur={() => { showError[field.name] = true; dateTimeValidation(field) }}
|
802
825
|
bind:this={flatpickrEl[flatpickrEl.length]}
|
803
826
|
>
|
827
|
+
{#if isMobile(userAgent)}
|
828
|
+
<div class="MobileDateInput">{prepareFields[field.name]}</div>
|
829
|
+
{/if}
|
830
|
+
</div>
|
804
831
|
{:else if field.type === FieldTypes.Number || field.type === FieldTypes.Money}
|
805
832
|
<input type="number" placeholder="{field.placeholder}" bind:value={prepareFields[field.name]}
|
806
833
|
on:input="{() => { validateField(field) }}"
|
@@ -903,7 +930,7 @@
|
|
903
930
|
</div>
|
904
931
|
{/if}
|
905
932
|
</div>
|
906
|
-
{
|
933
|
+
{#if errorResponseCode && !showErrorModal}
|
907
934
|
<cashier-error
|
908
935
|
{assetsurl}
|
909
936
|
{translationurl}
|
@@ -915,33 +942,7 @@
|
|
915
942
|
<div slot="button" class="ModalButton" on:click={backToMethodList}>{$_('backToMethodList')}</div>
|
916
943
|
</cashier-error>
|
917
944
|
{/if}
|
918
|
-
{#if redirectUrl && redirectMode === RedirectionModeStringEnum.Default}
|
919
|
-
<div class="IframeRedirect">
|
920
|
-
<cashier-iframe-redirect
|
921
|
-
lang="{lang}"
|
922
|
-
translationurl="{translationurl}"
|
923
|
-
iframeurl="{redirectUrl}"
|
924
|
-
></cashier-iframe-redirect>
|
925
|
-
</div>
|
926
945
|
{/if}
|
927
|
-
{#if showConfirmModal}
|
928
|
-
<cashier-confirm-modal>
|
929
|
-
<span slot="text">{$_(`${type.toLowerCase()}.confirmText`,
|
930
|
-
{ values: !selectedPaymentMethod.HideAmountField ? { amount: formatter.format(editedAmount ?? 0), currency } : {amount: '', currency: ''}})}</span>
|
931
|
-
<div slot="confirm">{$_(`${type.toLowerCase()}.confirmButton`)}</div>
|
932
|
-
</cashier-confirm-modal>
|
933
|
-
{/if}
|
934
|
-
<cashier-modal>
|
935
|
-
<cashier-error
|
936
|
-
{assetsurl}
|
937
|
-
{translationurl}
|
938
|
-
{clientstylingurl}
|
939
|
-
{clientstyling}
|
940
|
-
errorcode={errorResponseCode}
|
941
|
-
>
|
942
|
-
<div slot="button" class="ModalButton" on:click={hideModal}>{$_('closeModal')}</div>
|
943
|
-
</cashier-error>
|
944
|
-
</cashier-modal>
|
945
946
|
</div>
|
946
947
|
|
947
948
|
|
@@ -976,12 +977,16 @@
|
|
976
977
|
margin: 0;
|
977
978
|
}
|
978
979
|
|
980
|
+
input::-webkit-date-and-time-value {
|
981
|
+
visibility: hidden;
|
982
|
+
}
|
983
|
+
|
979
984
|
input[type=number] {
|
980
985
|
-moz-appearance: textfield;
|
981
986
|
}
|
982
987
|
.CashierMethodDetails {
|
983
988
|
width: 100%;
|
984
|
-
height:
|
989
|
+
height: inherit;
|
985
990
|
container-name: method-details;
|
986
991
|
container-type: inline-size;
|
987
992
|
}
|
@@ -1083,22 +1088,6 @@
|
|
1083
1088
|
text-transform: none;
|
1084
1089
|
}
|
1085
1090
|
}
|
1086
|
-
cashier-iframe-redirect {
|
1087
|
-
height: inherit;
|
1088
|
-
width: inherit;
|
1089
|
-
}
|
1090
|
-
.IframeRedirect {
|
1091
|
-
display: flex;
|
1092
|
-
position: absolute;
|
1093
|
-
align-items: center;
|
1094
|
-
justify-content: center;
|
1095
|
-
width: 100%;
|
1096
|
-
height: 100%;
|
1097
|
-
z-index: 100;
|
1098
|
-
top: 0;
|
1099
|
-
left: 0;
|
1100
|
-
background-color: var(--emw--color-white, #FFF);
|
1101
|
-
}
|
1102
1091
|
.FieldWrapper, label{
|
1103
1092
|
display: flex;
|
1104
1093
|
flex-direction: column ;
|
@@ -1279,6 +1268,19 @@
|
|
1279
1268
|
display: block;
|
1280
1269
|
}
|
1281
1270
|
}
|
1271
|
+
}
|
1272
|
+
.DateInput {
|
1273
|
+
position: relative;
|
1274
|
+
}
|
1275
|
+
.MobileDateInput {
|
1276
|
+
position: absolute;
|
1277
|
+
top: 50%;
|
1278
|
+
transform: translateY(-50%);
|
1279
|
+
left: 15px;
|
1280
|
+
}
|
1281
|
+
.DateTimePicker {
|
1282
|
+
width: -webkit-fill-available;
|
1283
|
+
width: -moz-available;
|
1282
1284
|
}
|
1283
1285
|
.CustomSelect {
|
1284
1286
|
width: 100%;
|
@@ -1341,11 +1343,21 @@
|
|
1341
1343
|
text-overflow: ellipsis;
|
1342
1344
|
}
|
1343
1345
|
|
1344
|
-
label, input, .Description, .FormLogo .ChangePaymeth {
|
1346
|
+
label, input, .Description, .FormLogo .ChangePaymeth, .OptionList div {
|
1345
1347
|
font-size: var(--emw--font-size-x-small, 12px);
|
1346
1348
|
}
|
1347
1349
|
.SelectedMethodDescription, .AmountLimits {
|
1348
1350
|
font-size: var(--emw--font-size-2x-small, 10px);
|
1349
1351
|
}
|
1350
|
-
|
1352
|
+
|
1353
|
+
.DateTimePicker {
|
1354
|
+
-webkit-appearance: none;
|
1355
|
+
-moz-appearance: none;
|
1356
|
+
font-size: inherit;
|
1357
|
+
background: none;
|
1358
|
+
width: -webkit-fill-available;
|
1359
|
+
font-size: 0;
|
1360
|
+
width: -moz-available;
|
1361
|
+
}
|
1362
|
+
}
|
1351
1363
|
</style>
|
package/src/translations.js
CHANGED
@@ -19,17 +19,6 @@ export const TRANSLATIONS = {
|
|
19
19
|
"amountIntError": "Amount should be integer value",
|
20
20
|
"amountDecimalError": "Amount should have 2 or less digits after decimal point",
|
21
21
|
"invalidFieldError": "{field} is invalid",
|
22
|
-
"closeModal": "CLOSE",
|
23
22
|
"backToMethodList": "BACK TO PAYMENT METHODS",
|
24
|
-
"deposit": {
|
25
|
-
"makeTxnButton": "DEPOSIT",
|
26
|
-
"confirmText": "You're going to deposit {amount} {currency} to your account",
|
27
|
-
"confirmButton": "Ok"
|
28
|
-
},
|
29
|
-
"withdraw": {
|
30
|
-
"makeTxnButton": "WITHDRAW",
|
31
|
-
"confirmText": "You're going to withdraw {amount} {currency} from your account",
|
32
|
-
"confirmButton": "Ok"
|
33
|
-
}
|
34
23
|
}
|
35
24
|
}
|