@everymatrix/cashier-methods-list 1.34.2 → 1.35.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@everymatrix/cashier-methods-list",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.35.0",
|
|
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": "cad27ef6706d0e17f1eda3810fee31f1ec373fa9"
|
|
39
39
|
}
|
|
@@ -30,6 +30,13 @@
|
|
|
30
30
|
let showMethodsList: boolean = true;
|
|
31
31
|
let formatter = new Intl.NumberFormat(local, {minimumFractionDigits: 2 });
|
|
32
32
|
let errorMessage = '';
|
|
33
|
+
let errorResponseCode: string;
|
|
34
|
+
|
|
35
|
+
enum ResponseCode {
|
|
36
|
+
PlayerSessionIsNotValid = 'PlayerSessionIsNotValid',
|
|
37
|
+
Success = 'Success',
|
|
38
|
+
JwtTokenError = 'JwtTokenError'
|
|
39
|
+
}
|
|
33
40
|
|
|
34
41
|
$: endpoint && session && customerid && getMetaData();
|
|
35
42
|
$: lang && setActiveLanguage();
|
|
@@ -79,14 +86,44 @@
|
|
|
79
86
|
errorMessage = data.error;
|
|
80
87
|
return;
|
|
81
88
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
89
|
+
|
|
90
|
+
if (data.ResponseCode === ResponseCode.PlayerSessionIsNotValid) {
|
|
91
|
+
errorResponseCode = data.ResponseCode;
|
|
92
|
+
setErrorResponseCode();
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (data.ResponseCode === ResponseCode.JwtTokenError) {
|
|
97
|
+
errorResponseCode = data.ResponseCode;
|
|
98
|
+
setErrorResponseCode();
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (data.ResponseCode !== ResponseCode.Success) {
|
|
103
|
+
errorResponseCode = data.ResponseCode;
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
paymentMethods = data.PaymentMethods?.Ordering ? payMethOrderedList(data) : payMethUnorderedList(data);
|
|
86
108
|
methodsButtonToggleText = (numberofmethodsshown && +numberofmethodsshown > 0 && paymentMethods.length > +numberofmethodsshown) ? $_('showAll') : '';
|
|
87
109
|
paymentMethodsToShow = methodsButtonToggleText ? paymentMethods.slice(0, +numberofmethodsshown) : paymentMethods;
|
|
88
110
|
})
|
|
89
111
|
}
|
|
112
|
+
const payMethOrderedList = (data: any) => {
|
|
113
|
+
const payMeths = [];
|
|
114
|
+
data.PaymentMethods.Ordering.DefaultPaymentMethodsOrder.forEach(Name => {
|
|
115
|
+
const payMethData: any = data.PaymentMethods.PaymentMethods.find(item => item.Name === Name);
|
|
116
|
+
if(payMethData) payMeths.push({...payMethData, LogoUrl: payMethData.Logos && payMethData.Logos.length && payMethData.Logos[0].LogoUrl ? `https:${payMethData.Logos[0].LogoUrl}` : ''});
|
|
117
|
+
})
|
|
118
|
+
return payMeths;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const payMethUnorderedList = (data: any) => {
|
|
122
|
+
return data.PaymentMethods.PaymentMethods.map((payMeth) => ({
|
|
123
|
+
...payMeth,
|
|
124
|
+
LogoUrl: payMeth.Logos && payMeth.Logos.length && payMeth.Logos[0].LogoUrl ? `https:${payMeth.Logos[0].LogoUrl}` : ''
|
|
125
|
+
}));
|
|
126
|
+
}
|
|
90
127
|
|
|
91
128
|
const selectPayMeth = (payMeth: PaymentMethod): void => {
|
|
92
129
|
selectedPaymentMethod = payMeth.Name;
|
|
@@ -98,6 +135,10 @@
|
|
|
98
135
|
}));
|
|
99
136
|
}
|
|
100
137
|
|
|
138
|
+
const setErrorResponseCode = () => {
|
|
139
|
+
window.postMessage({type: 'ErrorResponseCode', errorResponseCode}, window.location.href);
|
|
140
|
+
}
|
|
141
|
+
|
|
101
142
|
const showAllMethodsToggle = () => {
|
|
102
143
|
paymentMethodsToShow == paymentMethods ? showLessMethods() : showAllMethods()
|
|
103
144
|
}
|