payment-kit 1.22.21 → 1.22.22
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/api/src/routes/refunds.ts +37 -9
- package/blocklet.yml +1 -1
- package/package.json +6 -6
|
@@ -282,30 +282,58 @@ async function resolveOrCreatePaymentIntent(
|
|
|
282
282
|
return '';
|
|
283
283
|
}
|
|
284
284
|
|
|
285
|
-
|
|
285
|
+
// Validate and normalize customer_id - must be non-empty string if provided
|
|
286
|
+
let finalCustomerId: string | undefined;
|
|
287
|
+
if (customerId && customerId.trim().length > 0) {
|
|
288
|
+
finalCustomerId = customerId.trim();
|
|
289
|
+
} else if (customerId && customerId.trim().length === 0) {
|
|
290
|
+
logger.warn('Invalid customer_id: empty string, will not set customer_id', {
|
|
291
|
+
customerId,
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
const createData: any = {
|
|
286
296
|
livemode,
|
|
287
297
|
amount,
|
|
288
298
|
amount_received: amount,
|
|
289
299
|
amount_capturable: '0',
|
|
290
300
|
currency_id: finalCurrencyId,
|
|
291
|
-
customer_id: customerId,
|
|
292
301
|
payment_method_id: finalPaymentMethodId,
|
|
293
302
|
description: description || `Refund to ${destination}`,
|
|
294
303
|
status: 'succeeded',
|
|
295
304
|
capture_method: 'automatic',
|
|
296
305
|
confirmation_method: 'automatic',
|
|
297
306
|
payment_method_types: [chainType],
|
|
298
|
-
statement_descriptor:
|
|
307
|
+
statement_descriptor: '',
|
|
299
308
|
statement_descriptor_suffix: '',
|
|
300
309
|
metadata: formatMetadata(metadata || {}),
|
|
301
|
-
}
|
|
310
|
+
};
|
|
302
311
|
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
}
|
|
312
|
+
// Only set customer_id if it's a valid non-empty string
|
|
313
|
+
if (finalCustomerId) {
|
|
314
|
+
createData.customer_id = finalCustomerId;
|
|
315
|
+
}
|
|
307
316
|
|
|
308
|
-
|
|
317
|
+
try {
|
|
318
|
+
const newPaymentIntent = await PaymentIntent.create(createData);
|
|
319
|
+
|
|
320
|
+
logger.info('Created new payment intent for refund', {
|
|
321
|
+
paymentIntentId: newPaymentIntent.id,
|
|
322
|
+
refundAmount: amount,
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
return newPaymentIntent.id;
|
|
326
|
+
} catch (error: any) {
|
|
327
|
+
logger.error('Failed to create payment intent for refund', {
|
|
328
|
+
error,
|
|
329
|
+
createData: {
|
|
330
|
+
...createData,
|
|
331
|
+
customer_id: createData.customer_id || 'null',
|
|
332
|
+
customer_id_length: createData.customer_id?.length || 0,
|
|
333
|
+
},
|
|
334
|
+
});
|
|
335
|
+
throw error;
|
|
336
|
+
}
|
|
309
337
|
}
|
|
310
338
|
|
|
311
339
|
// Returns transaction hash and payment details
|
package/blocklet.yml
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "payment-kit",
|
|
3
|
-
"version": "1.22.
|
|
3
|
+
"version": "1.22.22",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "blocklet dev --open",
|
|
6
6
|
"lint": "tsc --noEmit && eslint src api/src --ext .mjs,.js,.jsx,.ts,.tsx",
|
|
@@ -57,9 +57,9 @@
|
|
|
57
57
|
"@blocklet/error": "^0.3.3",
|
|
58
58
|
"@blocklet/js-sdk": "^1.17.3-beta-20251119-102907-28b69b76",
|
|
59
59
|
"@blocklet/logger": "^1.17.3-beta-20251119-102907-28b69b76",
|
|
60
|
-
"@blocklet/payment-broker-client": "1.22.
|
|
61
|
-
"@blocklet/payment-react": "1.22.
|
|
62
|
-
"@blocklet/payment-vendor": "1.22.
|
|
60
|
+
"@blocklet/payment-broker-client": "1.22.22",
|
|
61
|
+
"@blocklet/payment-react": "1.22.22",
|
|
62
|
+
"@blocklet/payment-vendor": "1.22.22",
|
|
63
63
|
"@blocklet/sdk": "^1.17.3-beta-20251119-102907-28b69b76",
|
|
64
64
|
"@blocklet/ui-react": "^3.2.7",
|
|
65
65
|
"@blocklet/uploader": "^0.3.11",
|
|
@@ -129,7 +129,7 @@
|
|
|
129
129
|
"devDependencies": {
|
|
130
130
|
"@abtnode/types": "^1.17.3-beta-20251119-102907-28b69b76",
|
|
131
131
|
"@arcblock/eslint-config-ts": "^0.3.3",
|
|
132
|
-
"@blocklet/payment-types": "1.22.
|
|
132
|
+
"@blocklet/payment-types": "1.22.22",
|
|
133
133
|
"@types/cookie-parser": "^1.4.9",
|
|
134
134
|
"@types/cors": "^2.8.19",
|
|
135
135
|
"@types/debug": "^4.1.12",
|
|
@@ -176,5 +176,5 @@
|
|
|
176
176
|
"parser": "typescript"
|
|
177
177
|
}
|
|
178
178
|
},
|
|
179
|
-
"gitHead": "
|
|
179
|
+
"gitHead": "4324caf5e314593d0a56b4893f503932ae83d8ae"
|
|
180
180
|
}
|