@akinon/next 1.112.0-snapshot-ZERO-3792-20251124084303 → 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-20251124084303
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,57 +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(
135
- referenceUrl
136
- )}`;
137
- const clientIP = getClientIP(request);
138
- const locale = getLocaleFromRequest(request);
139
-
140
- const headersToSend = {
141
- Accept: 'application/json',
142
- ...(locale && { 'Accept-Language': locale }),
143
- ...(request.headers.get('authorization') && {
144
- Authorization: request.headers.get('authorization')!
145
- }),
146
- ...(clientIP && {
147
- 'X-Forwarded-For': clientIP
148
- })
149
- };
150
-
151
- const response = await fetch(externalUrl, {
152
- method: 'GET',
153
- headers: headersToSend
154
- });
155
-
156
- let responseData: any;
157
- const responseText = await response.text();
158
-
159
- try {
160
- responseData = responseText ? JSON.parse(responseText) : {};
161
- } catch (parseError) {
162
- return NextResponse.json(
163
- { error: 'Invalid JSON response from job status API' },
164
- { status: 500 }
165
- );
166
- }
167
-
168
- return NextResponse.json(responseData, {
169
- status: response.status,
170
- headers: {
171
- 'Access-Control-Allow-Origin': '*',
172
- 'Access-Control-Allow-Methods': 'GET, POST, PUT, OPTIONS',
173
- 'Access-Control-Allow-Headers': 'Content-Type, Accept, Authorization'
174
- }
175
- });
176
125
  }
177
126
 
178
127
  return NextResponse.json(
@@ -192,32 +141,13 @@ export async function POST(request: NextRequest) {
192
141
  const body = await request.json();
193
142
 
194
143
  let externalUrl: string;
195
- let httpMethod = 'POST';
196
-
197
144
  if (endpoint === 'feedback') {
198
- if (!body.url || typeof body.url !== 'string' || !body.url.trim()) {
199
- return NextResponse.json(
200
- { status: 'error', message: 'URL is required for feedback' },
201
- { status: 400 }
202
- );
203
- }
204
- if (typeof body.feedback !== 'boolean') {
205
- return NextResponse.json(
206
- { status: 'error', message: 'Feedback must be a boolean value' },
207
- { status: 400 }
208
- );
209
- }
210
145
  externalUrl = `${VIRTUAL_TRY_ON_API_URL}/api/v1/feedback`;
211
- httpMethod = 'PUT';
212
- } else if (endpoint === 'async-multiple-try-on') {
213
- externalUrl = `${VIRTUAL_TRY_ON_API_URL}/api/async/v1/multiple-virtual-try-on`;
214
146
  } else {
215
- return NextResponse.json(
216
- { error: 'Invalid endpoint specified' },
217
- { status: 400 }
218
- );
147
+ externalUrl = `${VIRTUAL_TRY_ON_API_URL}/api/v1/virtual-try-on`;
219
148
  }
220
149
 
150
+ const httpMethod = endpoint === 'feedback' ? 'PUT' : 'POST';
221
151
  const clientIP = getClientIP(request);
222
152
  const locale = getLocaleFromRequest(request);
223
153
 
@@ -233,18 +163,13 @@ export async function POST(request: NextRequest) {
233
163
  })
234
164
  };
235
165
 
236
- const fetchOptions: RequestInit = {
166
+ const response = await fetch(externalUrl, {
237
167
  method: httpMethod,
238
- headers: headersToSend
239
- };
240
-
241
- if (httpMethod !== 'GET') {
242
- fetchOptions.body = JSON.stringify(body);
243
- }
244
-
245
- const response = await fetch(externalUrl, fetchOptions);
168
+ headers: headersToSend,
169
+ body: JSON.stringify(body)
170
+ });
246
171
 
247
- let responseData: Record<string, any>;
172
+ let responseData: any;
248
173
  const responseText = await response.text();
249
174
 
250
175
  if (endpoint === 'feedback') {
@@ -348,7 +273,7 @@ export async function PUT(request: NextRequest) {
348
273
  body: JSON.stringify(body)
349
274
  });
350
275
 
351
- const responseData = response?.json() || {};
276
+ const responseData = await response.json();
352
277
 
353
278
  return NextResponse.json(responseData, {
354
279
  status: response.status,
@@ -362,8 +287,7 @@ export async function PUT(request: NextRequest) {
362
287
  return NextResponse.json(
363
288
  {
364
289
  status: 'error',
365
- message: 'Internal server error occurred during feedback submission',
366
- error: (error as Error).message
290
+ message: 'Internal server error occurred during feedback submission'
367
291
  },
368
292
  { status: 500 }
369
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-20251124084303",
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-20251124084303",
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' &&