@akinon/next 1.117.0-rc.0 → 1.117.0-rc.2
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
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @akinon/next
|
|
2
2
|
|
|
3
|
+
## 1.117.0-rc.2
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 591e345e: ZERO-3855: Enhance credit card payment handling in checkout middlewares
|
|
8
|
+
|
|
9
|
+
## 1.117.0-rc.1
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- 36143125: ZERO-3987: Add barcode scanner functionality with modal and button
|
|
14
|
+
|
|
3
15
|
## 1.117.0-rc.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { NextRequest, NextResponse } from 'next/server';
|
|
2
|
+
import Settings from 'settings';
|
|
3
|
+
|
|
4
|
+
export async function GET(request: NextRequest) {
|
|
5
|
+
try {
|
|
6
|
+
const { searchParams } = new URL(request.url);
|
|
7
|
+
const barcode = searchParams.get('search_text');
|
|
8
|
+
|
|
9
|
+
if (!barcode) {
|
|
10
|
+
return NextResponse.json(
|
|
11
|
+
{ error: 'Missing search_text parameter (barcode)' },
|
|
12
|
+
{ status: 400 }
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if (Settings.commerceUrl === 'default') {
|
|
17
|
+
return NextResponse.json(
|
|
18
|
+
{ error: 'Commerce URL is not configured' },
|
|
19
|
+
{ status: 500 }
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const queryParams = new URLSearchParams();
|
|
24
|
+
queryParams.append('search_text', barcode);
|
|
25
|
+
|
|
26
|
+
searchParams.forEach((value, key) => {
|
|
27
|
+
if (key !== 'search_text') {
|
|
28
|
+
queryParams.append(key, value);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const apiUrl = `${Settings.commerceUrl}/list/?${queryParams.toString()}`;
|
|
33
|
+
|
|
34
|
+
const headers: Record<string, string> = {
|
|
35
|
+
Accept: 'application/json',
|
|
36
|
+
'Content-Type': 'application/json'
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const response = await fetch(apiUrl, {
|
|
40
|
+
method: 'GET',
|
|
41
|
+
headers
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
if (!response.ok) {
|
|
45
|
+
return NextResponse.json(
|
|
46
|
+
{ error: `API request failed with status: ${response.status}` },
|
|
47
|
+
{ status: response.status }
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const data = await response.json();
|
|
52
|
+
return NextResponse.json(data);
|
|
53
|
+
} catch (error) {
|
|
54
|
+
return NextResponse.json(
|
|
55
|
+
{ error: (error as Error).message },
|
|
56
|
+
{ status: 500 }
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -55,6 +55,7 @@ export enum Component {
|
|
|
55
55
|
SavedCard = 'SavedCardOption',
|
|
56
56
|
VirtualTryOnPlugin = 'VirtualTryOnPlugin',
|
|
57
57
|
BasketVirtualTryOn = 'BasketVirtualTryOn',
|
|
58
|
+
BarcodeScannerPlugin = 'BarcodeScannerPlugin',
|
|
58
59
|
IyzicoSavedCard = 'IyzicoSavedCardOption',
|
|
59
60
|
Hepsipay = 'Hepsipay',
|
|
60
61
|
FlowPayment = 'FlowPayment',
|
|
@@ -116,7 +117,7 @@ const PluginComponents = new Map([
|
|
|
116
117
|
[Plugin.FlowPayment, [Component.FlowPayment]],
|
|
117
118
|
[
|
|
118
119
|
Plugin.VirtualTryOn,
|
|
119
|
-
[Component.VirtualTryOnPlugin, Component.BasketVirtualTryOn]
|
|
120
|
+
[Component.VirtualTryOnPlugin, Component.BasketVirtualTryOn, Component.BarcodeScannerPlugin]
|
|
120
121
|
],
|
|
121
122
|
[Plugin.Hepsipay, [Component.Hepsipay]],
|
|
122
123
|
[Plugin.MasterpassRest, [Component.MasterpassRest]],
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akinon/next",
|
|
3
3
|
"description": "Core package for Project Zero Next",
|
|
4
|
-
"version": "1.117.0-rc.
|
|
4
|
+
"version": "1.117.0-rc.2",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"bin": {
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"set-cookie-parser": "2.6.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@akinon/eslint-plugin-projectzero": "1.117.0-rc.
|
|
38
|
+
"@akinon/eslint-plugin-projectzero": "1.117.0-rc.2",
|
|
39
39
|
"@babel/core": "7.26.10",
|
|
40
40
|
"@babel/preset-env": "7.26.9",
|
|
41
41
|
"@babel/preset-typescript": "7.27.0",
|
|
@@ -204,15 +204,25 @@ export const contextListMiddleware: Middleware = ({
|
|
|
204
204
|
(ctx) => ctx.page_name === 'DeliveryOptionSelectionPage'
|
|
205
205
|
)
|
|
206
206
|
) {
|
|
207
|
+
const isCreditCardPayment =
|
|
208
|
+
preOrder?.payment_option?.payment_type === 'credit_card' ||
|
|
209
|
+
preOrder?.payment_option?.payment_type === 'masterpass';
|
|
210
|
+
|
|
207
211
|
if (context.page_context.card_type) {
|
|
208
212
|
dispatch(setCardType(context.page_context.card_type));
|
|
213
|
+
} else if (isCreditCardPayment) {
|
|
214
|
+
dispatch(setCardType(null));
|
|
209
215
|
}
|
|
210
216
|
|
|
211
217
|
if (
|
|
212
218
|
context.page_context.installments &&
|
|
213
219
|
preOrder?.payment_option?.payment_type !== 'masterpass_rest'
|
|
214
220
|
) {
|
|
215
|
-
|
|
221
|
+
if (!isCreditCardPayment || context.page_context.card_type) {
|
|
222
|
+
dispatch(
|
|
223
|
+
setInstallmentOptions(context.page_context.installments)
|
|
224
|
+
);
|
|
225
|
+
}
|
|
216
226
|
}
|
|
217
227
|
}
|
|
218
228
|
|
|
@@ -14,9 +14,17 @@ export const installmentOptionMiddleware: Middleware = ({
|
|
|
14
14
|
return result;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
const { installmentOptions } = getState().checkout;
|
|
17
|
+
const { installmentOptions, cardType } = getState().checkout;
|
|
18
18
|
const { endpoints: apiEndpoints } = checkoutApi;
|
|
19
19
|
|
|
20
|
+
const isCreditCardPayment =
|
|
21
|
+
preOrder?.payment_option?.payment_type === 'credit_card' ||
|
|
22
|
+
preOrder?.payment_option?.payment_type === 'masterpass';
|
|
23
|
+
|
|
24
|
+
if (isCreditCardPayment && !cardType) {
|
|
25
|
+
return result;
|
|
26
|
+
}
|
|
27
|
+
|
|
20
28
|
if (
|
|
21
29
|
!preOrder?.installment &&
|
|
22
30
|
preOrder?.payment_option?.payment_type !== 'saved_card' &&
|