@akinon/next 1.119.0-rc.2 → 1.119.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/CHANGELOG.md +1 -58
- package/bin/pz-generate-routes.js +1 -10
- package/components/plugin-module.tsx +2 -2
- package/data/client/account.ts +1 -12
- package/data/client/checkout.ts +70 -100
- package/data/urls.ts +1 -5
- package/lib/cache-handler.mjs +2 -8
- package/lib/cache.ts +3 -8
- package/middlewares/complete-gpay.ts +5 -6
- package/middlewares/complete-masterpass.ts +5 -6
- package/middlewares/complete-wallet.ts +5 -6
- package/middlewares/default.ts +19 -62
- package/middlewares/index.ts +1 -3
- package/middlewares/masterpass-rest-callback.ts +8 -13
- package/middlewares/redirection-payment.ts +5 -6
- package/middlewares/saved-card-redirection.ts +5 -6
- package/middlewares/three-d-redirection.ts +5 -6
- package/middlewares/wallet-complete-redirection.ts +5 -6
- package/package.json +2 -2
- package/plugins.d.ts +0 -10
- package/plugins.js +0 -1
- package/redux/middlewares/checkout.ts +1 -11
- package/redux/middlewares/pre-order/installment-option.ts +1 -9
- package/types/index.ts +0 -6
- package/utils/index.ts +1 -21
- package/utils/mobile-3d-iframe.ts +2 -8
- package/utils/redirection-iframe.ts +2 -8
- package/with-pz-config.js +4 -1
- package/api/barcode-search.ts +0 -59
- package/middlewares/bfcache-headers.ts +0 -18
- package/utils/get-checkout-path.ts +0 -3
package/lib/cache-handler.mjs
CHANGED
|
@@ -364,17 +364,11 @@ CacheHandler.onCreation(async () => {
|
|
|
364
364
|
};
|
|
365
365
|
}
|
|
366
366
|
|
|
367
|
-
const
|
|
367
|
+
const redisHandler = createRedisHandler({
|
|
368
368
|
client,
|
|
369
369
|
timeoutMs: CACHE_CONFIG.redis.timeoutMs,
|
|
370
370
|
keyExpirationStrategy: 'EXPIREAT'
|
|
371
|
-
};
|
|
372
|
-
|
|
373
|
-
if (process.env.CACHE_PASSWORD) {
|
|
374
|
-
redisOptions.password = process.env.CACHE_PASSWORD;
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
const redisHandler = createRedisHandler(redisOptions);
|
|
371
|
+
});
|
|
378
372
|
|
|
379
373
|
const localHandler = createLruHandler(CACHE_CONFIG.lru);
|
|
380
374
|
|
package/lib/cache.ts
CHANGED
|
@@ -155,14 +155,9 @@ export class Cache {
|
|
|
155
155
|
process.env.CACHE_PORT
|
|
156
156
|
}/${process.env.CACHE_BUCKET ?? '0'}`;
|
|
157
157
|
|
|
158
|
-
const
|
|
159
|
-
url: redisUrl
|
|
160
|
-
|
|
161
|
-
password: process.env.CACHE_PASSWORD
|
|
162
|
-
})
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
const client: RedisClientType = createClient(options);
|
|
158
|
+
const client: RedisClientType = createClient({
|
|
159
|
+
url: redisUrl
|
|
160
|
+
});
|
|
166
161
|
|
|
167
162
|
client.on('error', (error) => {
|
|
168
163
|
logger.error('Redis client error', { redisUrl, error });
|
|
@@ -4,7 +4,6 @@ import { Buffer } from 'buffer';
|
|
|
4
4
|
import logger from '../utils/log';
|
|
5
5
|
import { getUrlPathWithLocale } from '../utils/localization';
|
|
6
6
|
import { PzNextRequest } from '.';
|
|
7
|
-
import { getCheckoutPath } from '../utils';
|
|
8
7
|
|
|
9
8
|
const streamToString = async (stream: ReadableStream<Uint8Array> | null) => {
|
|
10
9
|
if (stream) {
|
|
@@ -41,8 +40,7 @@ const withCompleteGpay =
|
|
|
41
40
|
return middleware(req, event);
|
|
42
41
|
}
|
|
43
42
|
|
|
44
|
-
const
|
|
45
|
-
const requestUrl = `${Settings.commerceUrl}${getCheckoutPath(isPostCheckout)}${url.search}`;
|
|
43
|
+
const requestUrl = `${Settings.commerceUrl}/orders/checkout/${url.search}`;
|
|
46
44
|
const requestHeaders = {
|
|
47
45
|
'X-Requested-With': 'XMLHttpRequest',
|
|
48
46
|
'Content-Type': 'application/x-www-form-urlencoded',
|
|
@@ -110,9 +108,10 @@ const withCompleteGpay =
|
|
|
110
108
|
});
|
|
111
109
|
|
|
112
110
|
// Add error cookie
|
|
113
|
-
errorResponse.
|
|
114
|
-
|
|
115
|
-
|
|
111
|
+
errorResponse.headers.append(
|
|
112
|
+
'Set-Cookie',
|
|
113
|
+
`pz-pos-error=${JSON.stringify(errors)}; path=/;`
|
|
114
|
+
);
|
|
116
115
|
|
|
117
116
|
return errorResponse;
|
|
118
117
|
}
|
|
@@ -5,7 +5,6 @@ import logger from '../utils/log';
|
|
|
5
5
|
import { getUrlPathWithLocale } from '../utils/localization';
|
|
6
6
|
import { PzNextRequest } from '.';
|
|
7
7
|
import { ServerVariables } from '../utils/server-variables';
|
|
8
|
-
import { getCheckoutPath } from '../utils';
|
|
9
8
|
|
|
10
9
|
const streamToString = async (stream: ReadableStream<Uint8Array> | null) => {
|
|
11
10
|
if (stream) {
|
|
@@ -42,8 +41,7 @@ const withCompleteMasterpass =
|
|
|
42
41
|
return middleware(req, event);
|
|
43
42
|
}
|
|
44
43
|
|
|
45
|
-
const
|
|
46
|
-
const requestUrl = `${Settings.commerceUrl}${getCheckoutPath(isPostCheckout)}${url.search}`;
|
|
44
|
+
const requestUrl = `${Settings.commerceUrl}/orders/checkout/${url.search}`;
|
|
47
45
|
const requestHeaders = {
|
|
48
46
|
'X-Requested-With': 'XMLHttpRequest',
|
|
49
47
|
'Content-Type': 'application/x-www-form-urlencoded',
|
|
@@ -111,9 +109,10 @@ const withCompleteMasterpass =
|
|
|
111
109
|
});
|
|
112
110
|
|
|
113
111
|
// Add error cookie
|
|
114
|
-
errorResponse.
|
|
115
|
-
|
|
116
|
-
|
|
112
|
+
errorResponse.headers.append(
|
|
113
|
+
'Set-Cookie',
|
|
114
|
+
`pz-pos-error=${JSON.stringify(errors)}; path=/;`
|
|
115
|
+
);
|
|
117
116
|
|
|
118
117
|
return errorResponse;
|
|
119
118
|
}
|
|
@@ -4,7 +4,6 @@ import { Buffer } from 'buffer';
|
|
|
4
4
|
import logger from '../utils/log';
|
|
5
5
|
import { getUrlPathWithLocale } from '../utils/localization';
|
|
6
6
|
import { PzNextRequest } from '.';
|
|
7
|
-
import { getCheckoutPath } from '../utils';
|
|
8
7
|
|
|
9
8
|
const streamToString = async (stream: ReadableStream<Uint8Array> | null) => {
|
|
10
9
|
if (stream) {
|
|
@@ -40,8 +39,7 @@ const withCompleteWallet =
|
|
|
40
39
|
return middleware(req, event);
|
|
41
40
|
}
|
|
42
41
|
|
|
43
|
-
const
|
|
44
|
-
const requestUrl = `${Settings.commerceUrl}${getCheckoutPath(isPostCheckout)}${url.search}`;
|
|
42
|
+
const requestUrl = `${Settings.commerceUrl}/orders/checkout/${url.search}`;
|
|
45
43
|
const requestHeaders = {
|
|
46
44
|
'X-Requested-With': 'XMLHttpRequest',
|
|
47
45
|
'Content-Type': 'application/x-www-form-urlencoded',
|
|
@@ -107,9 +105,10 @@ const withCompleteWallet =
|
|
|
107
105
|
});
|
|
108
106
|
|
|
109
107
|
// Add error cookie
|
|
110
|
-
errorResponse.
|
|
111
|
-
|
|
112
|
-
|
|
108
|
+
errorResponse.headers.append(
|
|
109
|
+
'Set-Cookie',
|
|
110
|
+
`pz-pos-error=${JSON.stringify(errors)}; path=/;`
|
|
111
|
+
);
|
|
113
112
|
|
|
114
113
|
return errorResponse;
|
|
115
114
|
}
|
package/middlewares/default.ts
CHANGED
|
@@ -14,8 +14,7 @@ import {
|
|
|
14
14
|
withUrlRedirection,
|
|
15
15
|
withCompleteWallet,
|
|
16
16
|
withWalletCompleteRedirection,
|
|
17
|
-
withMasterpassRestCallback
|
|
18
|
-
withBfcacheHeaders
|
|
17
|
+
withMasterpassRestCallback
|
|
19
18
|
} from '.';
|
|
20
19
|
import { urlLocaleMatcherRegex } from '../utils';
|
|
21
20
|
import withCurrency from './currency';
|
|
@@ -26,8 +25,6 @@ import { getUrlPathWithLocale } from '../utils/localization';
|
|
|
26
25
|
import getRootHostname from '../utils/get-root-hostname';
|
|
27
26
|
import { LocaleUrlStrategy } from '../localization';
|
|
28
27
|
|
|
29
|
-
const POST_CHECKOUT_COOKIE_MAX_AGE_MS = 1000 * 60 * 30; // 30 minutes
|
|
30
|
-
|
|
31
28
|
const withPzDefault =
|
|
32
29
|
(middleware: NextMiddleware) =>
|
|
33
30
|
async (req: PzNextRequest, event: NextFetchEvent) => {
|
|
@@ -104,7 +101,6 @@ const withPzDefault =
|
|
|
104
101
|
if (
|
|
105
102
|
req.nextUrl.pathname.includes('/orders/hooks/') ||
|
|
106
103
|
req.nextUrl.pathname.includes('/orders/checkout-with-token/') ||
|
|
107
|
-
req.nextUrl.pathname.includes('/orders/post-checkout-redirect/') ||
|
|
108
104
|
req.nextUrl.pathname.includes('/hooks/cash_register/complete/') ||
|
|
109
105
|
req.nextUrl.pathname.includes('/hooks/cash_register/pre_order/')
|
|
110
106
|
) {
|
|
@@ -132,13 +128,8 @@ const withPzDefault =
|
|
|
132
128
|
}
|
|
133
129
|
|
|
134
130
|
if (req.nextUrl.pathname.startsWith('/orders/redirection/')) {
|
|
135
|
-
const queryString = searchParams.toString();
|
|
136
131
|
return NextResponse.rewrite(
|
|
137
|
-
new URL(
|
|
138
|
-
`${encodeURI(Settings.commerceUrl)}/orders/redirection/${
|
|
139
|
-
queryString ? `?${queryString}` : ''
|
|
140
|
-
}`
|
|
141
|
-
)
|
|
132
|
+
new URL(`${encodeURI(Settings.commerceUrl)}/orders/redirection/`)
|
|
142
133
|
);
|
|
143
134
|
}
|
|
144
135
|
|
|
@@ -156,35 +147,21 @@ const withPzDefault =
|
|
|
156
147
|
);
|
|
157
148
|
}
|
|
158
149
|
|
|
159
|
-
// If commerce redirects to /orders/checkout/
|
|
160
|
-
const isPostCheckout = !!req.nextUrl.pathname.match(
|
|
161
|
-
new RegExp('^/orders/post-checkout/$')
|
|
162
|
-
);
|
|
163
|
-
const checkoutLocalePath = getUrlPathWithLocale(
|
|
164
|
-
'/orders/checkout/',
|
|
165
|
-
req.cookies.get('pz-locale')?.value
|
|
166
|
-
);
|
|
150
|
+
// If commerce redirects to /orders/checkout/ without locale
|
|
167
151
|
if (
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
152
|
+
req.nextUrl.pathname.match(new RegExp('^/orders/checkout/$')) &&
|
|
153
|
+
req.nextUrl.searchParams.size === 0 &&
|
|
154
|
+
getUrlPathWithLocale(
|
|
155
|
+
'/orders/checkout/',
|
|
156
|
+
req.cookies.get('pz-locale')?.value
|
|
157
|
+
) !== req.nextUrl.pathname
|
|
172
158
|
) {
|
|
173
|
-
const
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
)
|
|
177
|
-
|
|
178
|
-
if (isPostCheckout) {
|
|
179
|
-
response.cookies.set('pz-post-checkout-flow', 'true', {
|
|
180
|
-
path: '/',
|
|
181
|
-
sameSite: 'none',
|
|
182
|
-
secure: true,
|
|
183
|
-
expires: new Date(Date.now() + POST_CHECKOUT_COOKIE_MAX_AGE_MS)
|
|
184
|
-
});
|
|
185
|
-
}
|
|
159
|
+
const redirectUrlWithLocale = `${url.origin}${getUrlPathWithLocale(
|
|
160
|
+
'/orders/checkout/',
|
|
161
|
+
req.cookies.get('pz-locale')?.value
|
|
162
|
+
)}`;
|
|
186
163
|
|
|
187
|
-
return
|
|
164
|
+
return NextResponse.redirect(redirectUrlWithLocale, 303);
|
|
188
165
|
}
|
|
189
166
|
|
|
190
167
|
// Dynamically handle any payment gateway without specifying names
|
|
@@ -256,11 +233,10 @@ const withPzDefault =
|
|
|
256
233
|
withCompleteWallet(
|
|
257
234
|
withWalletCompleteRedirection(
|
|
258
235
|
withMasterpassRestCallback(
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
) => {
|
|
236
|
+
async (
|
|
237
|
+
req: PzNextRequest,
|
|
238
|
+
event: NextFetchEvent
|
|
239
|
+
) => {
|
|
264
240
|
let middlewareResult: NextResponse | void =
|
|
265
241
|
NextResponse.next();
|
|
266
242
|
|
|
@@ -444,25 +420,6 @@ const withPzDefault =
|
|
|
444
420
|
);
|
|
445
421
|
}
|
|
446
422
|
|
|
447
|
-
if (
|
|
448
|
-
req.cookies.get(
|
|
449
|
-
'pz-post-checkout-flow'
|
|
450
|
-
)
|
|
451
|
-
) {
|
|
452
|
-
if (
|
|
453
|
-
pathnameWithoutLocale.startsWith(
|
|
454
|
-
'/orders/completed/'
|
|
455
|
-
) ||
|
|
456
|
-
pathnameWithoutLocale.startsWith(
|
|
457
|
-
'/basket'
|
|
458
|
-
)
|
|
459
|
-
) {
|
|
460
|
-
middlewareResult.cookies.delete(
|
|
461
|
-
'pz-post-checkout-flow'
|
|
462
|
-
);
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
|
|
466
423
|
if (process.env.ACC_APP_VERSION) {
|
|
467
424
|
middlewareResult.headers.set(
|
|
468
425
|
'acc-app-version',
|
|
@@ -500,7 +457,7 @@ const withPzDefault =
|
|
|
500
457
|
}
|
|
501
458
|
|
|
502
459
|
return middlewareResult;
|
|
503
|
-
}
|
|
460
|
+
}
|
|
504
461
|
)
|
|
505
462
|
)
|
|
506
463
|
)
|
package/middlewares/index.ts
CHANGED
|
@@ -12,7 +12,6 @@ import withSavedCardRedirection from './saved-card-redirection';
|
|
|
12
12
|
import withCompleteWallet from './complete-wallet';
|
|
13
13
|
import withWalletCompleteRedirection from './wallet-complete-redirection';
|
|
14
14
|
import withMasterpassRestCallback from './masterpass-rest-callback';
|
|
15
|
-
import withBfcacheHeaders from './bfcache-headers';
|
|
16
15
|
import { NextRequest } from 'next/server';
|
|
17
16
|
|
|
18
17
|
export {
|
|
@@ -29,8 +28,7 @@ export {
|
|
|
29
28
|
withSavedCardRedirection,
|
|
30
29
|
withCompleteWallet,
|
|
31
30
|
withWalletCompleteRedirection,
|
|
32
|
-
withMasterpassRestCallback
|
|
33
|
-
withBfcacheHeaders
|
|
31
|
+
withMasterpassRestCallback
|
|
34
32
|
};
|
|
35
33
|
|
|
36
34
|
export interface PzNextRequest extends NextRequest {
|
|
@@ -3,7 +3,6 @@ import Settings from 'settings';
|
|
|
3
3
|
import logger from '../utils/log';
|
|
4
4
|
import { getUrlPathWithLocale } from '../utils/localization';
|
|
5
5
|
import { PzNextRequest } from '.';
|
|
6
|
-
import { getCheckoutPath } from '../utils';
|
|
7
6
|
|
|
8
7
|
const withMasterpassRestCallback =
|
|
9
8
|
(middleware: NextMiddleware) =>
|
|
@@ -20,9 +19,7 @@ const withMasterpassRestCallback =
|
|
|
20
19
|
}
|
|
21
20
|
|
|
22
21
|
try {
|
|
23
|
-
const
|
|
24
|
-
const requestUrl = new URL(getCheckoutPath(isPostCheckout), Settings.commerceUrl);
|
|
25
|
-
|
|
22
|
+
const requestUrl = new URL('/orders/checkout/', Settings.commerceUrl);
|
|
26
23
|
url.searchParams.forEach((value, key) => {
|
|
27
24
|
requestUrl.searchParams.set(key, value);
|
|
28
25
|
});
|
|
@@ -59,20 +56,18 @@ const withMasterpassRestCallback =
|
|
|
59
56
|
ip
|
|
60
57
|
});
|
|
61
58
|
|
|
62
|
-
|
|
59
|
+
return NextResponse.redirect(
|
|
63
60
|
`${url.origin}${getUrlPathWithLocale(
|
|
64
61
|
'/orders/checkout/',
|
|
65
62
|
req.cookies.get('pz-locale')?.value
|
|
66
63
|
)}`,
|
|
67
|
-
|
|
64
|
+
{
|
|
65
|
+
status: 303,
|
|
66
|
+
headers: {
|
|
67
|
+
'Set-Cookie': `pz-pos-error=${encodeURIComponent(JSON.stringify(errors))}; path=/;`
|
|
68
|
+
}
|
|
69
|
+
}
|
|
68
70
|
);
|
|
69
|
-
|
|
70
|
-
// Add error cookie
|
|
71
|
-
errorResponse.cookies.set('pz-pos-error', JSON.stringify(errors), {
|
|
72
|
-
path: '/'
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
return errorResponse;
|
|
76
71
|
}
|
|
77
72
|
|
|
78
73
|
const redirectUrl =
|
|
@@ -4,7 +4,6 @@ import Settings from 'settings';
|
|
|
4
4
|
import logger from '../utils/log';
|
|
5
5
|
import { PzNextRequest } from '.';
|
|
6
6
|
import { getUrlPathWithLocale } from '../utils/localization';
|
|
7
|
-
import { getCheckoutPath } from '../utils';
|
|
8
7
|
|
|
9
8
|
const streamToString = async (stream: ReadableStream<Uint8Array> | null) => {
|
|
10
9
|
if (stream) {
|
|
@@ -42,8 +41,7 @@ const withRedirectionPayment =
|
|
|
42
41
|
return middleware(req, event);
|
|
43
42
|
}
|
|
44
43
|
|
|
45
|
-
const
|
|
46
|
-
const requestUrl = `${Settings.commerceUrl}${getCheckoutPath(isPostCheckout)}${url.search}`;
|
|
44
|
+
const requestUrl = `${Settings.commerceUrl}/orders/checkout/${url.search}`;
|
|
47
45
|
const requestHeaders = {
|
|
48
46
|
'X-Requested-With': 'XMLHttpRequest',
|
|
49
47
|
'Content-Type': 'application/x-www-form-urlencoded',
|
|
@@ -111,9 +109,10 @@ const withRedirectionPayment =
|
|
|
111
109
|
});
|
|
112
110
|
|
|
113
111
|
// Add error cookie
|
|
114
|
-
errorResponse.
|
|
115
|
-
|
|
116
|
-
|
|
112
|
+
errorResponse.headers.append(
|
|
113
|
+
'Set-Cookie',
|
|
114
|
+
`pz-pos-error=${JSON.stringify(errors)}; path=/;`
|
|
115
|
+
);
|
|
117
116
|
|
|
118
117
|
return errorResponse;
|
|
119
118
|
}
|
|
@@ -5,7 +5,6 @@ import logger from '../utils/log';
|
|
|
5
5
|
import { getUrlPathWithLocale } from '../utils/localization';
|
|
6
6
|
import { PzNextRequest } from '.';
|
|
7
7
|
import { ServerVariables } from '../utils/server-variables';
|
|
8
|
-
import { getCheckoutPath } from '../utils';
|
|
9
8
|
|
|
10
9
|
const streamToString = async (stream: ReadableStream<Uint8Array> | null) => {
|
|
11
10
|
if (stream) {
|
|
@@ -42,8 +41,7 @@ const withSavedCardRedirection =
|
|
|
42
41
|
return middleware(req, event);
|
|
43
42
|
}
|
|
44
43
|
|
|
45
|
-
const
|
|
46
|
-
const requestUrl = `${Settings.commerceUrl}${getCheckoutPath(isPostCheckout)}${url.search}`;
|
|
44
|
+
const requestUrl = `${Settings.commerceUrl}/orders/checkout/${url.search}`;
|
|
47
45
|
const requestHeaders = {
|
|
48
46
|
'X-Requested-With': 'XMLHttpRequest',
|
|
49
47
|
'Content-Type': 'application/x-www-form-urlencoded',
|
|
@@ -111,9 +109,10 @@ const withSavedCardRedirection =
|
|
|
111
109
|
});
|
|
112
110
|
|
|
113
111
|
// Add error cookie
|
|
114
|
-
errorResponse.
|
|
115
|
-
|
|
116
|
-
|
|
112
|
+
errorResponse.headers.append(
|
|
113
|
+
'Set-Cookie',
|
|
114
|
+
`pz-pos-error=${JSON.stringify(errors)}; path=/;`
|
|
115
|
+
);
|
|
117
116
|
|
|
118
117
|
return errorResponse;
|
|
119
118
|
}
|
|
@@ -4,7 +4,6 @@ import { Buffer } from 'buffer';
|
|
|
4
4
|
import logger from '../utils/log';
|
|
5
5
|
import { getUrlPathWithLocale } from '../utils/localization';
|
|
6
6
|
import { PzNextRequest } from '.';
|
|
7
|
-
import { getCheckoutPath } from '../utils';
|
|
8
7
|
|
|
9
8
|
const streamToString = async (stream: ReadableStream<Uint8Array> | null) => {
|
|
10
9
|
if (stream) {
|
|
@@ -41,8 +40,7 @@ const withThreeDRedirection =
|
|
|
41
40
|
return middleware(req, event);
|
|
42
41
|
}
|
|
43
42
|
|
|
44
|
-
const
|
|
45
|
-
const requestUrl = `${Settings.commerceUrl}${getCheckoutPath(isPostCheckout)}${url.search}`;
|
|
43
|
+
const requestUrl = `${Settings.commerceUrl}/orders/checkout/${url.search}`;
|
|
46
44
|
const requestHeaders = {
|
|
47
45
|
'X-Requested-With': 'XMLHttpRequest',
|
|
48
46
|
'Content-Type': 'application/x-www-form-urlencoded',
|
|
@@ -110,9 +108,10 @@ const withThreeDRedirection =
|
|
|
110
108
|
});
|
|
111
109
|
|
|
112
110
|
// Add error cookie
|
|
113
|
-
errorResponse.
|
|
114
|
-
|
|
115
|
-
|
|
111
|
+
errorResponse.headers.append(
|
|
112
|
+
'Set-Cookie',
|
|
113
|
+
`pz-pos-error=${JSON.stringify(errors)}; path=/;`
|
|
114
|
+
);
|
|
116
115
|
|
|
117
116
|
return errorResponse;
|
|
118
117
|
}
|
|
@@ -4,7 +4,6 @@ import { Buffer } from 'buffer';
|
|
|
4
4
|
import logger from '../utils/log';
|
|
5
5
|
import { getUrlPathWithLocale } from '../utils/localization';
|
|
6
6
|
import { PzNextRequest } from '.';
|
|
7
|
-
import { getCheckoutPath } from '../utils';
|
|
8
7
|
|
|
9
8
|
const streamToString = async (stream: ReadableStream<Uint8Array> | null) => {
|
|
10
9
|
if (stream) {
|
|
@@ -40,8 +39,7 @@ const withWalletCompleteRedirection =
|
|
|
40
39
|
return middleware(req, event);
|
|
41
40
|
}
|
|
42
41
|
|
|
43
|
-
const
|
|
44
|
-
const requestUrl = `${Settings.commerceUrl}${getCheckoutPath(isPostCheckout)}${url.search}`;
|
|
42
|
+
const requestUrl = `${Settings.commerceUrl}/orders/checkout/${url.search}`;
|
|
45
43
|
const requestHeaders = {
|
|
46
44
|
'X-Requested-With': 'XMLHttpRequest',
|
|
47
45
|
'Content-Type': 'application/x-www-form-urlencoded',
|
|
@@ -131,9 +129,10 @@ const withWalletCompleteRedirection =
|
|
|
131
129
|
});
|
|
132
130
|
|
|
133
131
|
// Add error cookie
|
|
134
|
-
errorResponse.
|
|
135
|
-
|
|
136
|
-
|
|
132
|
+
errorResponse.headers.append(
|
|
133
|
+
'Set-Cookie',
|
|
134
|
+
`pz-pos-error=${JSON.stringify(errors)}; path=/;`
|
|
135
|
+
);
|
|
137
136
|
|
|
138
137
|
return errorResponse;
|
|
139
138
|
}
|
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.119.0
|
|
4
|
+
"version": "1.119.0",
|
|
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.119.0
|
|
38
|
+
"@akinon/eslint-plugin-projectzero": "1.119.0",
|
|
39
39
|
"@babel/core": "7.26.10",
|
|
40
40
|
"@babel/preset-env": "7.26.9",
|
|
41
41
|
"@babel/preset-typescript": "7.27.0",
|
package/plugins.d.ts
CHANGED
|
@@ -37,16 +37,6 @@ declare module '@akinon/pz-cybersource-uc/src/redux/middleware' {
|
|
|
37
37
|
export default middleware as any;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
declare module '@akinon/pz-apple-pay' {}
|
|
41
|
-
|
|
42
|
-
declare module '@akinon/pz-similar-products' {
|
|
43
|
-
export const SimilarProductsModal: any;
|
|
44
|
-
export const SimilarProductsFilterSidebar: any;
|
|
45
|
-
export const SimilarProductsResultsGrid: any;
|
|
46
|
-
export const SimilarProductsPlugin: any;
|
|
47
|
-
export const SimilarProductsButtonPlugin: any;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
40
|
declare module '@akinon/pz-cybersource-uc/src/redux/reducer' {
|
|
51
41
|
export default reducer as any;
|
|
52
42
|
}
|
package/plugins.js
CHANGED
|
@@ -204,25 +204,15 @@ 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
|
-
|
|
211
207
|
if (context.page_context.card_type) {
|
|
212
208
|
dispatch(setCardType(context.page_context.card_type));
|
|
213
|
-
} else if (isCreditCardPayment) {
|
|
214
|
-
dispatch(setCardType(null));
|
|
215
209
|
}
|
|
216
210
|
|
|
217
211
|
if (
|
|
218
212
|
context.page_context.installments &&
|
|
219
213
|
preOrder?.payment_option?.payment_type !== 'masterpass_rest'
|
|
220
214
|
) {
|
|
221
|
-
|
|
222
|
-
dispatch(
|
|
223
|
-
setInstallmentOptions(context.page_context.installments)
|
|
224
|
-
);
|
|
225
|
-
}
|
|
215
|
+
dispatch(setInstallmentOptions(context.page_context.installments));
|
|
226
216
|
}
|
|
227
217
|
}
|
|
228
218
|
|
|
@@ -14,17 +14,9 @@ export const installmentOptionMiddleware: Middleware = ({
|
|
|
14
14
|
return result;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
const { installmentOptions
|
|
17
|
+
const { installmentOptions } = 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
|
-
|
|
28
20
|
if (
|
|
29
21
|
!preOrder?.installment &&
|
|
30
22
|
preOrder?.payment_option?.payment_type !== 'saved_card' &&
|
package/types/index.ts
CHANGED
|
@@ -83,12 +83,6 @@ export interface Settings {
|
|
|
83
83
|
};
|
|
84
84
|
usePrettyUrlRoute?: boolean;
|
|
85
85
|
commerceUrl: string;
|
|
86
|
-
/**
|
|
87
|
-
* This option allows you to track Sentry events on the client side, in addition to server and edge environments.
|
|
88
|
-
*
|
|
89
|
-
* It overrides process.env.NEXT_PUBLIC_SENTRY_DSN and process.env.SENTRY_DSN.
|
|
90
|
-
*/
|
|
91
|
-
sentryDsn?: string;
|
|
92
86
|
redis: {
|
|
93
87
|
defaultExpirationTime: number;
|
|
94
88
|
};
|
package/utils/index.ts
CHANGED
|
@@ -7,7 +7,6 @@ export * from './get-currency';
|
|
|
7
7
|
export * from './menu-generator';
|
|
8
8
|
export * from './generate-commerce-search-params';
|
|
9
9
|
export * from './get-currency-label';
|
|
10
|
-
export * from './get-checkout-path';
|
|
11
10
|
|
|
12
11
|
export function getCookie(name: string) {
|
|
13
12
|
if (typeof document === 'undefined') {
|
|
@@ -195,9 +194,7 @@ export const urlLocaleMatcherRegex = new RegExp(
|
|
|
195
194
|
|
|
196
195
|
export const getPosError = () => {
|
|
197
196
|
const cookieValue = getCookie('pz-pos-error');
|
|
198
|
-
const error = JSON.parse(
|
|
199
|
-
cookieValue ? decodeURIComponent(cookieValue) : '{}'
|
|
200
|
-
);
|
|
197
|
+
const error = JSON.parse(cookieValue ? decodeURIComponent(cookieValue) : '{}');
|
|
201
198
|
|
|
202
199
|
// delete 'pz-pos-error' cookie when refreshing or closing page
|
|
203
200
|
window.addEventListener('beforeunload', () => {
|
|
@@ -207,23 +204,6 @@ export const getPosError = () => {
|
|
|
207
204
|
return error;
|
|
208
205
|
};
|
|
209
206
|
|
|
210
|
-
export const checkPaymentWillRedirect = (response: {
|
|
211
|
-
context_list?: Array<{
|
|
212
|
-
page_name: string;
|
|
213
|
-
page_context?: { context_data?: { redirect_url?: string } };
|
|
214
|
-
}>;
|
|
215
|
-
redirect_url?: string;
|
|
216
|
-
errors?: unknown;
|
|
217
|
-
}): boolean => {
|
|
218
|
-
if (!response) return false;
|
|
219
|
-
|
|
220
|
-
const hasThankYouPage = response.context_list?.some(
|
|
221
|
-
(c) => c.page_name === 'ThankYouPage'
|
|
222
|
-
);
|
|
223
|
-
|
|
224
|
-
return Boolean(hasThankYouPage || response.redirect_url);
|
|
225
|
-
};
|
|
226
|
-
|
|
227
207
|
export const urlSchemes = [
|
|
228
208
|
'http',
|
|
229
209
|
'tel:',
|
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
const iframeURLChange = (iframe, callback) => {
|
|
2
2
|
iframe.addEventListener('load', () => {
|
|
3
3
|
setTimeout(() => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const iframeLocation = iframe.contentWindow.location;
|
|
7
|
-
|
|
8
|
-
callback(iframeLocation);
|
|
9
|
-
}
|
|
10
|
-
} catch (error) {
|
|
11
|
-
// Expected: browser blocks cross-origin iframe access for security
|
|
4
|
+
if (iframe?.contentWindow?.location) {
|
|
5
|
+
callback(iframe.contentWindow.location);
|
|
12
6
|
}
|
|
13
7
|
}, 0);
|
|
14
8
|
});
|
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
const iframeURLChange = (iframe, callback) => {
|
|
2
2
|
iframe.addEventListener('load', () => {
|
|
3
3
|
setTimeout(() => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const iframeLocation = iframe.contentWindow.location;
|
|
7
|
-
|
|
8
|
-
callback(iframeLocation);
|
|
9
|
-
}
|
|
10
|
-
} catch (error) {
|
|
11
|
-
// Expected: browser blocks cross-origin iframe access for security
|
|
4
|
+
if (iframe?.contentWindow?.location) {
|
|
5
|
+
callback(iframe.contentWindow.location);
|
|
12
6
|
}
|
|
13
7
|
}, 0);
|
|
14
8
|
});
|