@akinon/next 1.118.0-rc.4 → 1.118.0-rc.6

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,14 @@
1
1
  # @akinon/next
2
2
 
3
+ ## 1.118.0-rc.6
4
+
5
+ ## 1.118.0-rc.5
6
+
7
+ ### Minor Changes
8
+
9
+ - aef81c5d: ZERO-4034: Refactor checkout API to use dynamic store imports for improved performance
10
+ - 49c82e1a: ZERO-4047: Remove Sentry configuration from default Next.js config
11
+
3
12
  ## 1.118.0-rc.4
4
13
 
5
14
  ### Minor Changes
@@ -20,7 +20,7 @@ import {
20
20
  import { buildClientRequestUrl } from '../../utils';
21
21
  import { api } from './api';
22
22
  import { checkout } from '../urls';
23
- import { AppDispatch, AppStore, store } from 'redux/store';
23
+ import type { AppDispatch, AppStore } from 'redux/store';
24
24
  import settings from 'settings';
25
25
  import { showMobile3dIframe } from '../../utils/mobile-3d-iframe';
26
26
  import {
@@ -33,6 +33,11 @@ import {
33
33
  buildPurchaseForm
34
34
  } from '@akinon/pz-masterpass/src/utils';
35
35
 
36
+ const getStore = async (): Promise<AppStore> => {
37
+ const { store } = await import('redux/store');
38
+ return store;
39
+ };
40
+
36
41
  interface CheckoutResponse {
37
42
  pre_order?: PreOrder;
38
43
  errors: {
@@ -231,25 +236,32 @@ export const checkoutApi = api.injectEndpoints({
231
236
  CheckoutResponse,
232
237
  CompleteCreditCardParams
233
238
  >({
234
- query: ({
235
- card_holder,
236
- card_cvv,
237
- card_number,
238
- card_month,
239
- card_year,
240
- use_three_d = true,
241
- save = undefined
242
- }) => {
239
+ async queryFn(
240
+ {
241
+ card_holder,
242
+ card_cvv,
243
+ card_number,
244
+ card_month,
245
+ card_year,
246
+ use_three_d = true,
247
+ save = undefined
248
+ },
249
+ _queryApi,
250
+ _extraOptions,
251
+ baseQuery
252
+ ) {
253
+ const reduxStore = await getStore();
243
254
  const paymentOption =
244
- store.getState().checkout?.preOrder?.payment_option;
255
+ reduxStore.getState().checkout?.preOrder?.payment_option;
245
256
 
246
257
  if (paymentOption?.payment_type === 'masterpass') {
247
- return {
258
+ const result = await baseQuery({
248
259
  url: buildClientRequestUrl(checkout.getMasterpassOrderNo, {
249
260
  useFormData: true
250
261
  }),
251
262
  method: 'POST'
252
- };
263
+ });
264
+ return result as { data: CheckoutResponse } | { error: any };
253
265
  }
254
266
 
255
267
  const body: Record<string, string> = {
@@ -266,18 +278,19 @@ export const checkoutApi = api.injectEndpoints({
266
278
  body.save = save ? '1' : '0';
267
279
  }
268
280
 
269
- return {
281
+ const result = await baseQuery({
270
282
  url: buildClientRequestUrl(checkout.completeCreditCardPayment, {
271
283
  useFormData: true
272
284
  }),
273
285
  method: 'POST',
274
286
  body
275
- };
287
+ });
288
+ return result as { data: CheckoutResponse } | { error: any };
276
289
  },
277
290
  async onQueryStarted(args, { dispatch, queryFulfilled }) {
278
291
  dispatch(setPaymentStepBusy(true));
279
292
  const { data } = await queryFulfilled;
280
- const reduxStore = (await import('redux/store')).store;
293
+ const reduxStore = await getStore();
281
294
  const completePaymentContext = data?.context_list?.find(
282
295
  (context) => context?.page_name === 'MasterpassCompletePage'
283
296
  );
@@ -522,15 +535,16 @@ export const checkoutApi = api.injectEndpoints({
522
535
  }
523
536
  }),
524
537
  setBinNumber: build.mutation<CheckoutResponse, string>({
525
- query: (binNumber: string) => {
538
+ async queryFn(binNumber, _queryApi, _extraOptions, baseQuery) {
539
+ const reduxStore = await getStore();
526
540
  const paymentOption =
527
- store.getState().checkout?.preOrder?.payment_option;
541
+ reduxStore.getState().checkout?.preOrder?.payment_option;
528
542
  const binNumberUrl =
529
543
  paymentOption?.payment_type === 'masterpass'
530
544
  ? checkout.setMasterpassBinNumber
531
545
  : checkout.setBinNumber;
532
546
 
533
- return {
547
+ const result = await baseQuery({
534
548
  url: buildClientRequestUrl(binNumberUrl, {
535
549
  useFormData: true
536
550
  }),
@@ -538,7 +552,8 @@ export const checkoutApi = api.injectEndpoints({
538
552
  body: {
539
553
  bin_number: binNumber
540
554
  }
541
- };
555
+ });
556
+ return result as { data: CheckoutResponse } | { error: any };
542
557
  },
543
558
  async onQueryStarted(arg, { dispatch, queryFulfilled }) {
544
559
  dispatch(setPaymentStepBusy(true));
@@ -548,14 +563,16 @@ export const checkoutApi = api.injectEndpoints({
548
563
  }
549
564
  }),
550
565
  setInstallmentOption: build.mutation<CheckoutResponse, number>({
551
- query: (pk: number) => {
566
+ async queryFn(pk, _queryApi, _extraOptions, baseQuery) {
567
+ const reduxStore = await getStore();
552
568
  const paymentOption =
553
- store.getState().checkout?.preOrder?.payment_option;
569
+ reduxStore.getState().checkout?.preOrder?.payment_option;
554
570
  const installmentOption =
555
571
  paymentOption?.payment_type === 'masterpass'
556
572
  ? checkout.setMasterPassInstallmentOption
557
573
  : checkout.setInstallmentOption;
558
- return {
574
+
575
+ const result = await baseQuery({
559
576
  url: buildClientRequestUrl(installmentOption, {
560
577
  useFormData: true
561
578
  }),
@@ -563,7 +580,8 @@ export const checkoutApi = api.injectEndpoints({
563
580
  body: {
564
581
  installment: String(pk)
565
582
  }
566
- };
583
+ });
584
+ return result as { data: CheckoutResponse } | { error: any };
567
585
  },
568
586
  async onQueryStarted(arg, { dispatch, queryFulfilled }) {
569
587
  dispatch(setPaymentStepBusy(true));
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.118.0-rc.4",
4
+ "version": "1.118.0-rc.6",
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.118.0-rc.4",
38
+ "@akinon/eslint-plugin-projectzero": "1.118.0-rc.6",
39
39
  "@babel/core": "7.26.10",
40
40
  "@babel/preset-env": "7.26.9",
41
41
  "@babel/preset-typescript": "7.27.0",
package/utils/index.ts CHANGED
@@ -204,6 +204,23 @@ export const getPosError = () => {
204
204
  return error;
205
205
  };
206
206
 
207
+ export const checkPaymentWillRedirect = (response: {
208
+ context_list?: Array<{
209
+ page_name: string;
210
+ page_context?: { context_data?: { redirect_url?: string } };
211
+ }>;
212
+ redirect_url?: string;
213
+ errors?: unknown;
214
+ }): boolean => {
215
+ if (!response) return false;
216
+
217
+ const hasThankYouPage = response.context_list?.some(
218
+ (c) => c.page_name === 'ThankYouPage'
219
+ );
220
+
221
+ return Boolean(hasThankYouPage || response.redirect_url);
222
+ };
223
+
207
224
  export const urlSchemes = [
208
225
  'http',
209
226
  'tel:',
package/with-pz-config.js CHANGED
@@ -65,10 +65,7 @@ const defaultConfig = {
65
65
  translations: false
66
66
  };
67
67
  return config;
68
- },
69
- sentry: {
70
- hideSourceMaps: true
71
- } // TODO: This section will be reviewed again in the Sentry 8 update.
68
+ }
72
69
  };
73
70
 
74
71
  const withPzConfig = (