@akinon/pz-tamara-extension 1.126.24-v1-rc.21 → 1.126.24
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 -6
- package/package.json +1 -1
- package/src/pages/TamaraPaymentGateway.tsx +7 -35
- package/src/utils/index.ts +0 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
# @akinon/pz-tamara-extension
|
|
2
2
|
|
|
3
|
-
## 1.126.24
|
|
4
|
-
|
|
5
|
-
### Patch Changes
|
|
6
|
-
|
|
7
|
-
- 560e209d: ZERO-4523: send is_premium_customer as null in Tamara risk_assessment
|
|
8
|
-
- 560e209d: ZERO-4523: add risk_assessment to Tamara session payload
|
|
3
|
+
## 1.126.24
|
|
9
4
|
|
|
10
5
|
## 1.126.23
|
|
11
6
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import settings from 'settings';
|
|
3
|
-
import { URLS } from '@akinon/next/data/urls';
|
|
4
3
|
import { cookies } from 'next/headers';
|
|
5
4
|
import FormComponent from '../components/FormComponent';
|
|
6
5
|
import {
|
|
@@ -8,8 +7,7 @@ import {
|
|
|
8
7
|
generateHash,
|
|
9
8
|
getRandomString,
|
|
10
9
|
formatDecimal,
|
|
11
|
-
getQuantizeFormat
|
|
12
|
-
formatDateDDMMYYYY
|
|
10
|
+
getQuantizeFormat
|
|
13
11
|
} from '../utils';
|
|
14
12
|
import { TamaraPaymentGatewayProps } from '../types';
|
|
15
13
|
|
|
@@ -39,14 +37,10 @@ export const TamaraPaymentGateway = async ({
|
|
|
39
37
|
'Accept-Language': language
|
|
40
38
|
};
|
|
41
39
|
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
),
|
|
47
|
-
fetchData(URLS.user.currentUser, requestHeaders),
|
|
48
|
-
fetchData(`${URLS.account.order}?status=550&limit=9999`, requestHeaders)
|
|
49
|
-
]);
|
|
40
|
+
const preOrder = await fetchData(
|
|
41
|
+
`${settings.commerceUrl}/orders/checkout/?page=OrderNotePage`,
|
|
42
|
+
requestHeaders
|
|
43
|
+
);
|
|
50
44
|
|
|
51
45
|
const salt = getRandomString(10);
|
|
52
46
|
const hash = generateHash(salt, sessionId, hashKey);
|
|
@@ -112,15 +106,6 @@ export const TamaraPaymentGateway = async ({
|
|
|
112
106
|
};
|
|
113
107
|
});
|
|
114
108
|
|
|
115
|
-
const tamaraSlug = preOrder?.pre_order?.payment_option?.slug;
|
|
116
|
-
const tamaraOrders = (orders?.results ?? []).filter(
|
|
117
|
-
(order: any) => order?.payment_option_slug === tamaraSlug
|
|
118
|
-
);
|
|
119
|
-
const tamaraPaidDates = tamaraOrders
|
|
120
|
-
.map((order: any) => order?.created_date)
|
|
121
|
-
.filter(Boolean)
|
|
122
|
-
.sort();
|
|
123
|
-
|
|
124
109
|
const context = {
|
|
125
110
|
hash,
|
|
126
111
|
salt,
|
|
@@ -148,24 +133,11 @@ export const TamaraPaymentGateway = async ({
|
|
|
148
133
|
line1: preOrder.pre_order.shipping_address.line,
|
|
149
134
|
phone_number: preOrder.pre_order.shipping_address.phone_number,
|
|
150
135
|
region: preOrder.pre_order.shipping_address.township.name
|
|
151
|
-
},
|
|
152
|
-
risk_assessment: {
|
|
153
|
-
is_premium_customer: null,
|
|
154
|
-
account_creation_date: formatDateDDMMYYYY(userProfile?.date_joined),
|
|
155
|
-
total_order_count: tamaraOrders.length,
|
|
156
|
-
date_first_paid: formatDateDDMMYYYY(tamaraPaidDates[0]),
|
|
157
|
-
date_last_paid: formatDateDDMMYYYY(
|
|
158
|
-
tamaraPaidDates[tamaraPaidDates.length - 1]
|
|
159
|
-
)
|
|
160
136
|
}
|
|
161
137
|
};
|
|
162
138
|
|
|
163
|
-
const DefaultContainer = ({ children }
|
|
164
|
-
|
|
165
|
-
);
|
|
166
|
-
const RenderContainer: (props: {
|
|
167
|
-
children?: React.ReactNode;
|
|
168
|
-
}) => React.ReactNode =
|
|
139
|
+
const DefaultContainer = ({ children }) => <>{children}</>;
|
|
140
|
+
const RenderContainer =
|
|
169
141
|
renderer?.paymentGateway?.renderContainer || DefaultContainer;
|
|
170
142
|
|
|
171
143
|
return (
|
package/src/utils/index.ts
CHANGED
|
@@ -60,14 +60,3 @@ export const getQuantizeFormat = (priceAsString: string): number => {
|
|
|
60
60
|
|
|
61
61
|
return Math.pow(10, -decimalPlaces);
|
|
62
62
|
};
|
|
63
|
-
|
|
64
|
-
export const formatDateDDMMYYYY = (
|
|
65
|
-
value?: string | null
|
|
66
|
-
): string | null => {
|
|
67
|
-
if (!value) return null;
|
|
68
|
-
const date = new Date(value);
|
|
69
|
-
if (Number.isNaN(date.getTime())) return null;
|
|
70
|
-
const day = String(date.getDate()).padStart(2, '0');
|
|
71
|
-
const month = String(date.getMonth() + 1).padStart(2, '0');
|
|
72
|
-
return `${day}-${month}-${date.getFullYear()}`;
|
|
73
|
-
};
|