@akinon/next 1.112.0-snapshot-ZERO-3792-20251121121755 → 1.112.0-snapshot-ZERO-3855-20251124131245

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,10 +1,10 @@
1
1
  # @akinon/next
2
2
 
3
- ## 1.112.0-snapshot-ZERO-3792-20251121121755
3
+ ## 1.112.0-snapshot-ZERO-3855-20251124131245
4
4
 
5
5
  ### Minor Changes
6
6
 
7
- - 888fdec: ZERO-3792: Virtual Try On new features are implemented and also basket support implemented.
7
+ - 591e345: ZERO-3855: Enhance credit card payment handling in checkout middlewares
8
8
 
9
9
  ## 1.111.0
10
10
 
@@ -122,55 +122,6 @@ export async function GET(request: NextRequest) {
122
122
  'X-Virtual-Try-On-Cache-Status': 'MISS'
123
123
  }
124
124
  });
125
- } else if (endpoint === 'job-status') {
126
- const referenceUrl = searchParams.get('reference_url');
127
- if (!referenceUrl) {
128
- return NextResponse.json(
129
- { error: 'reference_url is required' },
130
- { status: 400 }
131
- );
132
- }
133
-
134
- const externalUrl = `${VIRTUAL_TRY_ON_API_URL}/api/async/v1/job-status?reference_url=${encodeURIComponent(referenceUrl)}`;
135
- const clientIP = getClientIP(request);
136
- const locale = getLocaleFromRequest(request);
137
-
138
- const headersToSend = {
139
- Accept: 'application/json',
140
- ...(locale && { 'Accept-Language': locale }),
141
- ...(request.headers.get('authorization') && {
142
- Authorization: request.headers.get('authorization')!
143
- }),
144
- ...(clientIP && {
145
- 'X-Forwarded-For': clientIP
146
- })
147
- };
148
-
149
- const response = await fetch(externalUrl, {
150
- method: 'GET',
151
- headers: headersToSend
152
- });
153
-
154
- let responseData: any;
155
- const responseText = await response.text();
156
-
157
- try {
158
- responseData = responseText ? JSON.parse(responseText) : {};
159
- } catch (parseError) {
160
- return NextResponse.json(
161
- { error: 'Invalid JSON response from job status API' },
162
- { status: 500 }
163
- );
164
- }
165
-
166
- return NextResponse.json(responseData, {
167
- status: response.status,
168
- headers: {
169
- 'Access-Control-Allow-Origin': '*',
170
- 'Access-Control-Allow-Methods': 'GET, POST, PUT, OPTIONS',
171
- 'Access-Control-Allow-Headers': 'Content-Type, Accept, Authorization'
172
- }
173
- });
174
125
  }
175
126
 
176
127
  return NextResponse.json(
@@ -190,32 +141,13 @@ export async function POST(request: NextRequest) {
190
141
  const body = await request.json();
191
142
 
192
143
  let externalUrl: string;
193
- let httpMethod = 'POST';
194
-
195
144
  if (endpoint === 'feedback') {
196
- if (!body.url || typeof body.url !== 'string' || !body.url.trim()) {
197
- return NextResponse.json(
198
- { status: 'error', message: 'URL is required for feedback' },
199
- { status: 400 }
200
- );
201
- }
202
- if (typeof body.feedback !== 'boolean') {
203
- return NextResponse.json(
204
- { status: 'error', message: 'Feedback must be a boolean value' },
205
- { status: 400 }
206
- );
207
- }
208
145
  externalUrl = `${VIRTUAL_TRY_ON_API_URL}/api/v1/feedback`;
209
- httpMethod = 'PUT';
210
- } else if (endpoint === 'async-multiple-try-on') {
211
- externalUrl = `${VIRTUAL_TRY_ON_API_URL}/api/async/v1/multiple-virtual-try-on`;
212
146
  } else {
213
- return NextResponse.json(
214
- { error: 'Invalid endpoint specified' },
215
- { status: 400 }
216
- );
147
+ externalUrl = `${VIRTUAL_TRY_ON_API_URL}/api/v1/virtual-try-on`;
217
148
  }
218
149
 
150
+ const httpMethod = endpoint === 'feedback' ? 'PUT' : 'POST';
219
151
  const clientIP = getClientIP(request);
220
152
  const locale = getLocaleFromRequest(request);
221
153
 
@@ -231,18 +163,13 @@ export async function POST(request: NextRequest) {
231
163
  })
232
164
  };
233
165
 
234
- const fetchOptions: RequestInit = {
166
+ const response = await fetch(externalUrl, {
235
167
  method: httpMethod,
236
- headers: headersToSend
237
- };
238
-
239
- if (httpMethod !== 'GET') {
240
- fetchOptions.body = JSON.stringify(body);
241
- }
242
-
243
- const response = await fetch(externalUrl, fetchOptions);
168
+ headers: headersToSend,
169
+ body: JSON.stringify(body)
170
+ });
244
171
 
245
- let responseData: Record<string, any>;
172
+ let responseData: any;
246
173
  const responseText = await response.text();
247
174
 
248
175
  if (endpoint === 'feedback') {
@@ -346,7 +273,7 @@ export async function PUT(request: NextRequest) {
346
273
  body: JSON.stringify(body)
347
274
  });
348
275
 
349
- const responseData = response?.json() || {};
276
+ const responseData = await response.json();
350
277
 
351
278
  return NextResponse.json(responseData, {
352
279
  status: response.status,
@@ -360,8 +287,7 @@ export async function PUT(request: NextRequest) {
360
287
  return NextResponse.json(
361
288
  {
362
289
  status: 'error',
363
- message: 'Internal server error occurred during feedback submission',
364
- error: (error as Error).message
290
+ message: 'Internal server error occurred during feedback submission'
365
291
  },
366
292
  { status: 500 }
367
293
  );
@@ -51,7 +51,6 @@ export enum Component {
51
51
  MultiBasket = 'MultiBasket',
52
52
  SavedCard = 'SavedCardOption',
53
53
  VirtualTryOnPlugin = 'VirtualTryOnPlugin',
54
- BasketVirtualTryOn = 'BasketVirtualTryOn',
55
54
  IyzicoSavedCard = 'IyzicoSavedCardOption',
56
55
  Hepsipay = 'Hepsipay',
57
56
  FlowPayment = 'FlowPayment',
@@ -91,11 +90,7 @@ const PluginComponents = new Map([
91
90
  [Plugin.SavedCard, [Component.SavedCard, Component.IyzicoSavedCard]],
92
91
  [Plugin.SavedCard, [Component.SavedCard]],
93
92
  [Plugin.FlowPayment, [Component.FlowPayment]],
94
- [
95
- Plugin.VirtualTryOn,
96
- [Component.VirtualTryOnPlugin, Component.BasketVirtualTryOn]
97
- ],
98
- [Plugin.Hepsipay, [Component.Hepsipay]],
93
+ [Plugin.VirtualTryOn, [Component.VirtualTryOnPlugin]],
99
94
  [Plugin.Hepsipay, [Component.Hepsipay]],
100
95
  [Plugin.MasterpassRest, [Component.MasterpassRest]]
101
96
  ]);
@@ -109,10 +104,10 @@ const getPlugin = (component: Component) => {
109
104
  };
110
105
 
111
106
  export default function PluginModule({
112
- component,
113
- props,
114
- children
115
- }: {
107
+ component,
108
+ props,
109
+ children
110
+ }: {
116
111
  component: Component;
117
112
  props?: any;
118
113
  children?: React.ReactNode;
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.112.0-snapshot-ZERO-3792-20251121121755",
4
+ "version": "1.112.0-snapshot-ZERO-3855-20251124131245",
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.112.0-snapshot-ZERO-3792-20251121121755",
38
+ "@akinon/eslint-plugin-projectzero": "1.112.0-snapshot-ZERO-3855-20251124131245",
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
- dispatch(setInstallmentOptions(context.page_context.installments));
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' &&