@everymatrix/cashier-method-details 1.27.5 → 1.27.7
Sign up to get free protection for your applications and to get access to all the features.
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@everymatrix/cashier-method-details",
|
3
|
-
"version": "1.27.
|
3
|
+
"version": "1.27.7",
|
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": "3f35682fb79fe589569c214127888b75fb556be4"
|
39
39
|
}
|
@@ -12,12 +12,11 @@
|
|
12
12
|
import '@everymatrix/cashier-notifications'
|
13
13
|
|
14
14
|
import type {PaymentMethod} from "./CashierMethodDetails.types";
|
15
|
-
import {number} from "svelte-i18n";
|
16
15
|
export class PaymentMethodDetails {
|
17
16
|
name: string;
|
18
17
|
label: string;
|
19
18
|
description: string;
|
20
|
-
type:
|
19
|
+
type: string;
|
21
20
|
defaultValue: any;
|
22
21
|
format: string;
|
23
22
|
placeholder: string;
|
@@ -85,7 +84,19 @@
|
|
85
84
|
}
|
86
85
|
}
|
87
86
|
|
88
|
-
|
87
|
+
enum TxnType {
|
88
|
+
Deposit='Deposit',
|
89
|
+
Withdraw='Withdraw'
|
90
|
+
}
|
91
|
+
|
92
|
+
const VISIBLE_FIELD_TYPES: string[] = 'Text,Number,Money,Boolean,Lookup,Date,Time,DateTime,Password,Label,Link,QRCode'.split(',');
|
93
|
+
|
94
|
+
enum RedirectionModeStringEnum {
|
95
|
+
Default = 'Default',
|
96
|
+
RedirectWithRetry = 'Redirect'
|
97
|
+
}
|
98
|
+
|
99
|
+
enum FieldTypes {
|
89
100
|
Unknown ='Unknown',
|
90
101
|
Text ='Text',
|
91
102
|
Boolean ='Boolean',
|
@@ -119,18 +130,6 @@
|
|
119
130
|
export let clientstyling:string = '';
|
120
131
|
export let clientstylingurl:string = ''
|
121
132
|
|
122
|
-
export enum TxnType {
|
123
|
-
Deposit='Deposit',
|
124
|
-
Withdraw='Withdraw'
|
125
|
-
}
|
126
|
-
|
127
|
-
const VISIBLE_FIELD_TYPES: string[] =
|
128
|
-
'Text,Number,Money,Boolean,Lookup,Date,Time,DateTime,Password,Label,Link,QRCode'.split(',');
|
129
|
-
export enum RedirectionModeStringEnum {
|
130
|
-
Default = 'Default',
|
131
|
-
RedirectWithRetry = 'Redirect'
|
132
|
-
}
|
133
|
-
|
134
133
|
let xPaymentSessionToken: string;
|
135
134
|
let selectedPaymentMethod: PaymentMethod = {} as PaymentMethod;
|
136
135
|
let fields: PaymentMethodDetails[] = [];
|
@@ -165,6 +164,7 @@
|
|
165
164
|
let fieldValidation = {};
|
166
165
|
let openLookupTop = false;
|
167
166
|
let maxLookupHeight: number;
|
167
|
+
let editedAmount: number;
|
168
168
|
|
169
169
|
$: endpoint && session && selectedpaymentmethodname && currency && getPaymentDetails();
|
170
170
|
$: clientstyling && customStylingContainer && setClientStyling();
|
@@ -231,7 +231,10 @@
|
|
231
231
|
showError = {};
|
232
232
|
prepareFields = {};
|
233
233
|
fieldValidation = {};
|
234
|
-
|
234
|
+
editedAmount = amount;
|
235
|
+
if (!selectedPaymentMethod.HideAmountField) {
|
236
|
+
validateAmount();
|
237
|
+
}
|
235
238
|
fields = selectedPaymentMethod.Fields && selectedPaymentMethod.Fields.map(field => new PaymentMethodDetails(field));
|
236
239
|
fields.forEach(field => { validateField(field) })
|
237
240
|
hideMethodsList();
|
@@ -322,7 +325,7 @@
|
|
322
325
|
"XPaymentSessionToken": xPaymentSessionToken,
|
323
326
|
"Transaction": {
|
324
327
|
"PaymentMethod": selectedPaymentMethod.Name,
|
325
|
-
"Amount":
|
328
|
+
"Amount": editedAmount,
|
326
329
|
"Currency": currency,
|
327
330
|
"CustomFields": prepareFields
|
328
331
|
},
|
@@ -433,14 +436,14 @@
|
|
433
436
|
}
|
434
437
|
|
435
438
|
const emptyAmountError = ():string => {
|
436
|
-
if (!
|
439
|
+
if (!editedAmount) {
|
437
440
|
return $_('errorEmptyField')
|
438
441
|
}
|
439
442
|
return ''
|
440
443
|
}
|
441
444
|
|
442
445
|
const minAmountError = () => {
|
443
|
-
if (selectedPaymentMethod.DisplayCurrency.MinAmountLimit >
|
446
|
+
if (selectedPaymentMethod.DisplayCurrency.MinAmountLimit > editedAmount) {
|
444
447
|
return $_('minAmountError', {
|
445
448
|
values: {
|
446
449
|
amount: formatter.format(selectedPaymentMethod.DisplayCurrency.MinAmountLimit),
|
@@ -452,7 +455,7 @@
|
|
452
455
|
}
|
453
456
|
|
454
457
|
const maxAmountError = () => {
|
455
|
-
if (selectedPaymentMethod.DisplayCurrency.MaxAmountLimit <
|
458
|
+
if (selectedPaymentMethod.DisplayCurrency.MaxAmountLimit < editedAmount) {
|
456
459
|
return $_('maxAmountError', {
|
457
460
|
values: {
|
458
461
|
amount: formatter.format(selectedPaymentMethod.DisplayCurrency.MaxAmountLimit),
|
@@ -464,7 +467,7 @@
|
|
464
467
|
}
|
465
468
|
|
466
469
|
const amountMultiplierError = () => {
|
467
|
-
if (selectedPaymentMethod.AmountMultiplier && (
|
470
|
+
if (selectedPaymentMethod.AmountMultiplier && (editedAmount % selectedPaymentMethod.AmountMultiplier !== 0)) {
|
468
471
|
return $_('amountMultiplierError', {
|
469
472
|
values: {
|
470
473
|
multiplier: selectedPaymentMethod.AmountMultiplier
|
@@ -482,7 +485,7 @@
|
|
482
485
|
}
|
483
486
|
|
484
487
|
const amountDecimalError = ():string => {
|
485
|
-
if (Number(
|
488
|
+
if (Number(editedAmount).toFixed(2) != +editedAmount) {
|
486
489
|
return $_('amountDecimalError')
|
487
490
|
}
|
488
491
|
return ''
|
@@ -496,7 +499,7 @@
|
|
496
499
|
}
|
497
500
|
|
498
501
|
const emptyFieldError = (field, value):string => {
|
499
|
-
if (field.isRequired && (!value || !value.toString().trim())) {
|
502
|
+
if (typeof value !== 'boolean' && field.isRequired && (!value || !value.toString().trim())) {
|
500
503
|
return $_('errorEmptyField')
|
501
504
|
}
|
502
505
|
return ''
|
@@ -526,11 +529,11 @@
|
|
526
529
|
{#if selectedPaymentMethod?.Name}
|
527
530
|
<div class="MethodsDetails">
|
528
531
|
{#if !showReceiptPage}
|
529
|
-
<form on:submit|preventDefault={prepareTxn}>
|
532
|
+
<form on:submit|preventDefault={prepareTxn} novalidate>
|
530
533
|
<div class="FieldWrapper">
|
531
534
|
<div class="FormLogo">
|
532
535
|
<div class="SelectedLogoWrapper">
|
533
|
-
<img src={selectedPaymentMethod.Logos[0].LogoUrl} alt={selectedPaymentMethod.Label} />
|
536
|
+
<img src={selectedPaymentMethod.Logos[0] && selectedPaymentMethod.Logos[0].LogoUrl} alt={selectedPaymentMethod.Label} />
|
534
537
|
</div>
|
535
538
|
<div class="SelectedLogoDescription">
|
536
539
|
{selectedPaymentMethod.Label}
|
@@ -552,7 +555,7 @@
|
|
552
555
|
</span>
|
553
556
|
{#if selectedPaymentMethod.IsAmountConfigurable}
|
554
557
|
<input type="number"
|
555
|
-
bind:value={
|
558
|
+
bind:value={editedAmount}
|
556
559
|
on:input={() => validateAmount()}
|
557
560
|
on:blur={() => {showError['amount'] = true; validateAmount()}}
|
558
561
|
placeholder="{$_('amountPlaceholder')}"
|
@@ -625,7 +628,7 @@
|
|
625
628
|
on:change="{() => { showError[field.name] = true; validateField(field) }}"
|
626
629
|
>
|
627
630
|
<span class="Checkmark"></span>
|
628
|
-
<span class="Description">{@html field.descriptionWithLink}</span>
|
631
|
+
<span class="Description" class:Required={field.isRequired}>{@html field.descriptionWithLink}</span>
|
629
632
|
</div>
|
630
633
|
{:else if field.type === FieldTypes.QRCode}
|
631
634
|
<div class="QRCode" on:click={() => {openUrlInNewTab(field.description)}}>
|
@@ -649,7 +652,9 @@
|
|
649
652
|
<path fill-rule="evenodd" clip-rule="evenodd" d="M7.51564 0.574496C6.49714 0.733152 5.5928 1.46162 5.21164 2.43037C5.01714 2.92471 4.98674 3.24368 4.98671 4.78987L4.98668 5.99306L4.55336 6.00671C4.20693 6.01762 4.08258 6.03221 3.93336 6.07946C3.43136 6.23846 3.00318 6.58293 2.73943 7.04C2.70133 7.106 2.63639 7.256 2.59508 7.37334L2.52002 7.58665V13.9067L2.59268 14.12C2.6993 14.4331 2.83849 14.6518 3.09336 14.9067C3.34821 15.1615 3.56693 15.3007 3.88002 15.4073L4.09336 15.48H11.9067L12.12 15.4073C12.4331 15.3007 12.6518 15.1615 12.9067 14.9067C13.1616 14.6518 13.3007 14.4331 13.4074 14.12L13.48 13.9067V7.58665L13.405 7.37334C13.1846 6.74712 12.6999 6.27875 12.0667 6.08C11.9191 6.03371 11.7891 6.0184 11.4467 6.00696L11.0134 5.99253L11.0133 4.78959C11.0133 4.128 11.0008 3.45465 10.9855 3.29334C10.9257 2.66268 10.7188 2.13556 10.3497 1.67368C9.66549 0.817589 8.6023 0.405214 7.51564 0.574496ZM8.46436 1.58665C9.01596 1.7035 9.52999 2.11659 9.79758 2.65809C9.98521 3.03771 9.98202 3.00646 9.99305 4.58L10.003 6H5.99702L6.00699 4.58C6.01802 3.00646 6.01483 3.03771 6.20246 2.65809C6.31793 2.42446 6.43799 2.26065 6.61818 2.09103C6.89043 1.83468 7.21371 1.65496 7.52352 1.58775C7.74977 1.53865 8.23518 1.53809 8.46436 1.58665ZM11.9201 7.0955C12.0975 7.17871 12.2992 7.37412 12.3874 7.54806C12.4231 7.61846 12.465 7.75796 12.4805 7.85803C12.4993 7.97978 12.5061 8.97962 12.501 10.88L12.4934 13.72L12.4082 13.8997C12.26 14.2127 12.0016 14.419 11.6821 14.4796C11.4864 14.5167 4.51364 14.5167 4.31793 14.4796C3.99843 14.419 3.74008 14.2127 3.59183 13.8997L3.50668 13.72L3.49905 10.88C3.49393 8.97728 3.50074 7.97987 3.51964 7.85778C3.57627 7.49218 3.79218 7.21543 4.12918 7.0765L4.28002 7.01431L8.02668 7.0205L11.7734 7.02665L11.9201 7.0955Z" fill="white"/>
|
650
653
|
</svg>
|
651
654
|
{$_(`${type.toLowerCase()}.makeTxnButton`)}
|
652
|
-
|
655
|
+
{#if !selectedPaymentMethod.HideAmountField}
|
656
|
+
<span class="ButtonAmount">{formatter.format(editedAmount ?? 0)} {currency}</span>
|
657
|
+
{/if}
|
653
658
|
</button>
|
654
659
|
{:else}
|
655
660
|
<button class="PrimaryButton">
|
@@ -703,7 +708,8 @@
|
|
703
708
|
{/if}
|
704
709
|
{#if showConfirmModal}
|
705
710
|
<cashier-confirm-modal>
|
706
|
-
<span slot="text">{$_(`${type.toLowerCase()}.confirmText
|
711
|
+
<span slot="text">{$_(`${type.toLowerCase()}.confirmText`,
|
712
|
+
{ values: !selectedPaymentMethod.HideAmountField ? { amount: formatter.format(editedAmount ?? 0), currency } : {amount: '', currency: ''}})}</span>
|
707
713
|
<div slot="confirm">{$_(`${type.toLowerCase()}.confirmButton`)}</div>
|
708
714
|
</cashier-confirm-modal>
|
709
715
|
{/if}
|
@@ -793,6 +799,7 @@
|
|
793
799
|
font-size: var(--emw--font-size-x-small, 12px);
|
794
800
|
margin: 10px 0 5px;
|
795
801
|
line-height: var(--emw--font-size-x-small, 12px);
|
802
|
+
white-space: pre-line;
|
796
803
|
}
|
797
804
|
.RedirectionNotification {
|
798
805
|
height: 100%;
|
@@ -871,6 +878,9 @@
|
|
871
878
|
margin: 0;
|
872
879
|
padding: 0;
|
873
880
|
}
|
881
|
+
&.Invalid:has(.Checkbox) {
|
882
|
+
border: 1px solid var(--emw--color-error, #FE0101);
|
883
|
+
}
|
874
884
|
}
|
875
885
|
.Alert {
|
876
886
|
display: none;
|
@@ -945,12 +955,16 @@
|
|
945
955
|
align-items: center;
|
946
956
|
justify-content: center;
|
947
957
|
gap: 5px;
|
958
|
+
&:has(.ButtonSpinner),
|
959
|
+
&:has(.ButtonSpinner):hover,
|
960
|
+
&:active {
|
961
|
+
background: var(--emw--color-active, #5C950F);
|
962
|
+
}
|
948
963
|
.ButtonAmount {
|
949
964
|
font-weight: 600;
|
950
965
|
}
|
951
966
|
.ButtonSpinner {
|
952
967
|
animation: loading-spinner 1s linear infinite;
|
953
|
-
background: var(--emw--color-active, #5C950F);
|
954
968
|
}
|
955
969
|
&[disabled] {
|
956
970
|
background: var(--emw--color-disabled, #99999980);
|
@@ -960,9 +974,6 @@
|
|
960
974
|
&:hover {
|
961
975
|
background: var(--emw--color-hover, #71B11B);
|
962
976
|
}
|
963
|
-
&:active {
|
964
|
-
background: var(--emw--color-active, #5C950F);
|
965
|
-
}
|
966
977
|
}
|
967
978
|
.QRCode {
|
968
979
|
width: 250px;
|
@@ -12,8 +12,8 @@ export interface PaymentMethod {
|
|
12
12
|
AmountMultiplier: number;
|
13
13
|
RedirectionMode: Number;
|
14
14
|
DisplayCurrency: PaymentMethodCurrencyConfig;
|
15
|
-
Currencies:
|
16
|
-
Fields:
|
15
|
+
Currencies: PaymentMethodCurrencyConfig[];
|
16
|
+
Fields: PaymentMethodDetails[];
|
17
17
|
Account: any;
|
18
18
|
Logos: any;
|
19
19
|
PredefinedAmounts: number[];
|
@@ -32,7 +32,7 @@ export interface PaymentMethodCurrencyConfig {
|
|
32
32
|
Name: string;
|
33
33
|
Label: string;
|
34
34
|
Description: string;
|
35
|
-
Amounts:
|
35
|
+
Amounts: number[];
|
36
36
|
MinAmountLimit: number;
|
37
37
|
MaxAmountLimit: number;
|
38
38
|
}
|
@@ -61,31 +61,3 @@ export interface PaymentMethodDetails {
|
|
61
61
|
UseCopyButton: boolean;
|
62
62
|
InputMask: string[];
|
63
63
|
}
|
64
|
-
|
65
|
-
export const FIELD_TYPES = {
|
66
|
-
0: 'Unknown',
|
67
|
-
1: 'Text',
|
68
|
-
2: 'Boolean',
|
69
|
-
3: 'Number',
|
70
|
-
4: 'Money',
|
71
|
-
5: 'DateTime',
|
72
|
-
6: 'Lookup',
|
73
|
-
7: 'IpAddress',
|
74
|
-
8: 'Date',
|
75
|
-
9: 'Time',
|
76
|
-
10: 'LookupCollection',
|
77
|
-
11: 'Hidden',
|
78
|
-
12: 'Label',
|
79
|
-
13: 'Password',
|
80
|
-
14: 'Link',
|
81
|
-
15: 'Image',
|
82
|
-
19: 'Html',
|
83
|
-
20: 'QRCode'
|
84
|
-
};
|
85
|
-
export const VISIBLE_FIELD_TYPES: string[] =
|
86
|
-
'Text,Number,Money,Boolean,Lookup,Date,Time,DateTime,Password,Label,Link,QRCode'.split(',');
|
87
|
-
|
88
|
-
export enum RedirectionModeStringEnum {
|
89
|
-
Default = 'Default',
|
90
|
-
RedirectWithRetry = 'Redirect'
|
91
|
-
}
|
package/src/translations.js
CHANGED
@@ -21,12 +21,12 @@ export const TRANSLATIONS = {
|
|
21
21
|
"invalidFieldError": "{field} is invalid",
|
22
22
|
"deposit": {
|
23
23
|
"makeTxnButton": "DEPOSIT",
|
24
|
-
"confirmText": "
|
24
|
+
"confirmText": "You\'re going to deposit {amount} {currency} to your account",
|
25
25
|
"confirmButton": "Ok",
|
26
26
|
},
|
27
27
|
"withdraw": {
|
28
28
|
"makeTxnButton": "WITHDRAW",
|
29
|
-
"confirmText": "
|
29
|
+
"confirmText": "You\'re going to withdraw {amount} {currency} from your account",
|
30
30
|
"confirmButton": "Ok",
|
31
31
|
}
|
32
32
|
}
|