payment-kit 1.22.21 → 1.22.23
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.
|
@@ -282,30 +282,59 @@ 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: '',
|
|
309
|
+
setup_future_usage: 'on_session',
|
|
300
310
|
metadata: formatMetadata(metadata || {}),
|
|
301
|
-
}
|
|
311
|
+
};
|
|
302
312
|
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
}
|
|
313
|
+
// Only set customer_id if it's a valid non-empty string
|
|
314
|
+
if (finalCustomerId) {
|
|
315
|
+
createData.customer_id = finalCustomerId;
|
|
316
|
+
}
|
|
307
317
|
|
|
308
|
-
|
|
318
|
+
try {
|
|
319
|
+
const newPaymentIntent = await PaymentIntent.create(createData);
|
|
320
|
+
|
|
321
|
+
logger.info('Created new payment intent for refund', {
|
|
322
|
+
paymentIntentId: newPaymentIntent.id,
|
|
323
|
+
refundAmount: amount,
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
return newPaymentIntent.id;
|
|
327
|
+
} catch (error: any) {
|
|
328
|
+
logger.error('Failed to create payment intent for refund', {
|
|
329
|
+
error,
|
|
330
|
+
createData: {
|
|
331
|
+
...createData,
|
|
332
|
+
customer_id: createData.customer_id || 'null',
|
|
333
|
+
customer_id_length: createData.customer_id?.length || 0,
|
|
334
|
+
},
|
|
335
|
+
});
|
|
336
|
+
throw error;
|
|
337
|
+
}
|
|
309
338
|
}
|
|
310
339
|
|
|
311
340
|
// Returns transaction hash and payment details
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { DataTypes } from 'sequelize';
|
|
2
|
+
|
|
3
|
+
import logger from '../../libs/logger';
|
|
4
|
+
import { Migration } from '../migrate';
|
|
5
|
+
|
|
6
|
+
export const up: Migration = async ({ context }) => {
|
|
7
|
+
// Check if column already allows null
|
|
8
|
+
const [results] = await context.sequelize.query('PRAGMA table_info(payment_intents)');
|
|
9
|
+
const columnInfo = (results as any[]).find((col: any) => col.name === 'setup_future_usage');
|
|
10
|
+
|
|
11
|
+
// If column doesn't exist or already allows null (notnull = 0), skip migration
|
|
12
|
+
if (!columnInfo || columnInfo.notnull === 0) {
|
|
13
|
+
logger.info('setup_future_usage already allows null, skipping migration');
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Change setup_future_usage column to allow null
|
|
18
|
+
await context.changeColumn('payment_intents', 'setup_future_usage', {
|
|
19
|
+
type: DataTypes.ENUM('on_session', 'off_session'),
|
|
20
|
+
allowNull: true,
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const down: Migration = async () => {};
|
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.23",
|
|
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.23",
|
|
61
|
+
"@blocklet/payment-react": "1.22.23",
|
|
62
|
+
"@blocklet/payment-vendor": "1.22.23",
|
|
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.23",
|
|
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": "e00ac48d6a560d32ff437314cf62f0b865c7a837"
|
|
180
180
|
}
|