payment-kit 1.20.6 → 1.20.7
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/crons/index.ts +1 -1
- package/api/src/index.ts +2 -2
- package/api/src/libs/{vendor-adapter-factory.ts → vendor/adapters/factory.ts} +20 -2
- package/api/src/libs/{adapters → vendor/adapters}/launcher-adapter.ts +11 -9
- package/api/src/libs/{vendor-adapter.ts → vendor/adapters/types.ts} +1 -19
- package/api/src/libs/{vendor-fulfillment.ts → vendor/fulfillment.ts} +15 -19
- package/api/src/queues/vendor/{vendor-commission.ts → commission.ts} +10 -10
- package/api/src/queues/vendor/{vendor-fulfillment-coordinator.ts → fulfillment-coordinator.ts} +3 -5
- package/api/src/queues/vendor/{vendor-fulfillment.ts → fulfillment.ts} +3 -2
- package/api/src/queues/vendor/{vendor-status-check.ts → status-check.ts} +3 -4
- package/api/src/routes/checkout-sessions.ts +10 -1
- package/api/src/routes/vendor.ts +2 -1
- package/blocklet.yml +1 -1
- package/doc/vendor_fulfillment_system.md +1 -3
- package/package.json +5 -5
package/api/src/crons/index.ts
CHANGED
|
@@ -24,7 +24,7 @@ import logger from '../libs/logger';
|
|
|
24
24
|
import { startCreditConsumeQueue } from '../queues/credit-consume';
|
|
25
25
|
import { startDepositVaultQueue } from '../queues/payment';
|
|
26
26
|
import { startSubscriptionQueue } from '../queues/subscription';
|
|
27
|
-
import { startVendorStatusCheckSchedule } from '../queues/vendor/
|
|
27
|
+
import { startVendorStatusCheckSchedule } from '../queues/vendor/status-check';
|
|
28
28
|
import { CheckoutSession } from '../store/models';
|
|
29
29
|
import { createMeteringSubscriptionDetection } from './metering-subscription-detection';
|
|
30
30
|
import { createPaymentStat } from './payment-stat';
|
package/api/src/index.ts
CHANGED
|
@@ -34,8 +34,8 @@ import { startPayoutQueue } from './queues/payout';
|
|
|
34
34
|
import { startRefundQueue } from './queues/refund';
|
|
35
35
|
import { startUploadBillingInfoListener } from './queues/space';
|
|
36
36
|
import { startSubscriptionQueue } from './queues/subscription';
|
|
37
|
-
import { startVendorCommissionQueue } from './queues/vendor/
|
|
38
|
-
import { startVendorFulfillmentQueue } from './queues/vendor/
|
|
37
|
+
import { startVendorCommissionQueue } from './queues/vendor/commission';
|
|
38
|
+
import { startVendorFulfillmentQueue } from './queues/vendor/fulfillment';
|
|
39
39
|
import routes from './routes';
|
|
40
40
|
import autoRechargeAuthorizationHandlers from './routes/connect/auto-recharge-auth';
|
|
41
41
|
import changePaymentHandlers from './routes/connect/change-payment';
|
|
@@ -1,5 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { LauncherAdapter } from './
|
|
1
|
+
import { BN } from '@ocap/util';
|
|
2
|
+
import { LauncherAdapter } from './launcher-adapter';
|
|
3
|
+
import { VendorAdapter, VendorConfig } from './types';
|
|
4
|
+
|
|
5
|
+
export function calculateVendorCommission(
|
|
6
|
+
totalAmount: string,
|
|
7
|
+
commissionRate: number,
|
|
8
|
+
commissionType: 'percentage' | 'fixed_amount',
|
|
9
|
+
itemAmount?: string
|
|
10
|
+
): string {
|
|
11
|
+
const amount = itemAmount || totalAmount || '0';
|
|
12
|
+
|
|
13
|
+
if (commissionType === 'percentage') {
|
|
14
|
+
return new BN(amount)
|
|
15
|
+
.mul(new BN(commissionRate || 0))
|
|
16
|
+
.div(new BN(100))
|
|
17
|
+
.toString();
|
|
18
|
+
}
|
|
19
|
+
return new BN(commissionRate).toString();
|
|
20
|
+
}
|
|
3
21
|
|
|
4
22
|
export class VendorAdapterFactory {
|
|
5
23
|
static create(vendorConfig: string | VendorConfig): VendorAdapter {
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { VendorAuth } from '@blocklet/payment-vendor';
|
|
2
2
|
|
|
3
|
+
import { ProductVendor } from '../../../store/models';
|
|
4
|
+
import logger from '../../logger';
|
|
5
|
+
import { api } from '../../util';
|
|
3
6
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
7
|
+
CheckOrderStatusParams,
|
|
8
|
+
CheckOrderStatusResult,
|
|
6
9
|
FulfillOrderParams,
|
|
7
10
|
FulfillOrderResult,
|
|
8
11
|
ReturnRequestParams,
|
|
9
12
|
ReturnRequestResult,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
} from '
|
|
13
|
-
import logger from '../logger';
|
|
14
|
-
import { ProductVendor } from '../../store/models';
|
|
15
|
-
import { api } from '../util';
|
|
13
|
+
VendorAdapter,
|
|
14
|
+
VendorConfig,
|
|
15
|
+
} from './types';
|
|
16
16
|
|
|
17
17
|
export class LauncherAdapter implements VendorAdapter {
|
|
18
18
|
private vendorConfig: VendorConfig | null = null;
|
|
@@ -40,6 +40,7 @@ export class LauncherAdapter implements VendorAdapter {
|
|
|
40
40
|
|
|
41
41
|
async fulfillOrder(params: FulfillOrderParams): Promise<FulfillOrderResult> {
|
|
42
42
|
logger.info('Creating launcher order via real API', {
|
|
43
|
+
checkoutSessionId: params.checkoutSessionId,
|
|
43
44
|
productCode: params.productCode,
|
|
44
45
|
customerId: params.customerId,
|
|
45
46
|
description: params.description,
|
|
@@ -50,6 +51,7 @@ export class LauncherAdapter implements VendorAdapter {
|
|
|
50
51
|
try {
|
|
51
52
|
const launcherApiUrl = vendorConfig.app_url;
|
|
52
53
|
const orderData = {
|
|
54
|
+
checkoutSessionId: params.checkoutSessionId,
|
|
53
55
|
description: params.description,
|
|
54
56
|
userInfo: params.userInfo,
|
|
55
57
|
deliveryParams: params.deliveryParams,
|
|
@@ -119,7 +121,7 @@ export class LauncherAdapter implements VendorAdapter {
|
|
|
119
121
|
}
|
|
120
122
|
|
|
121
123
|
async requestReturn(params: ReturnRequestParams): Promise<ReturnRequestResult> {
|
|
122
|
-
logger.
|
|
124
|
+
logger.info('Requesting return for Launcher order', {
|
|
123
125
|
orderId: params.orderId,
|
|
124
126
|
reason: params.reason,
|
|
125
127
|
});
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { BN } from '@ocap/util';
|
|
2
|
-
|
|
3
1
|
export interface VendorConfig {
|
|
4
2
|
id: string;
|
|
5
3
|
vendor_key: string;
|
|
@@ -15,6 +13,7 @@ export interface VendorConfig {
|
|
|
15
13
|
}
|
|
16
14
|
|
|
17
15
|
export interface FulfillOrderParams {
|
|
16
|
+
checkoutSessionId: string;
|
|
18
17
|
productCode: string;
|
|
19
18
|
customerId: string;
|
|
20
19
|
quantity: number;
|
|
@@ -90,20 +89,3 @@ export interface VendorAdapter {
|
|
|
90
89
|
requestReturn(params: ReturnRequestParams): Promise<ReturnRequestResult>;
|
|
91
90
|
checkOrderStatus(params: CheckOrderStatusParams): Promise<CheckOrderStatusResult>;
|
|
92
91
|
}
|
|
93
|
-
|
|
94
|
-
export function calculateVendorCommission(
|
|
95
|
-
totalAmount: string,
|
|
96
|
-
commissionRate: number,
|
|
97
|
-
commissionType: 'percentage' | 'fixed_amount',
|
|
98
|
-
itemAmount?: string
|
|
99
|
-
): string {
|
|
100
|
-
const amount = itemAmount || totalAmount || '0';
|
|
101
|
-
|
|
102
|
-
if (commissionType === 'percentage') {
|
|
103
|
-
return new BN(amount)
|
|
104
|
-
.mul(new BN(commissionRate || 0))
|
|
105
|
-
.div(new BN(100))
|
|
106
|
-
.toString();
|
|
107
|
-
}
|
|
108
|
-
return new BN(commissionRate).toString();
|
|
109
|
-
}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { BN } from '@ocap/util';
|
|
2
|
-
import { CheckoutSession } from '
|
|
3
|
-
import { Product } from '
|
|
4
|
-
import { ProductVendor } from '
|
|
5
|
-
import { Payout } from '
|
|
6
|
-
import { PaymentIntent } from '
|
|
7
|
-
import { Price } from '
|
|
8
|
-
import { VendorAdapterFactory } from './
|
|
9
|
-
import {
|
|
10
|
-
import logger from '
|
|
11
|
-
import { Customer } from '../store/models';
|
|
2
|
+
import { CheckoutSession } from '../../store/models/checkout-session';
|
|
3
|
+
import { Product } from '../../store/models/product';
|
|
4
|
+
import { ProductVendor } from '../../store/models/product-vendor';
|
|
5
|
+
import { Payout } from '../../store/models/payout';
|
|
6
|
+
import { PaymentIntent } from '../../store/models/payment-intent';
|
|
7
|
+
import { Price } from '../../store/models/price';
|
|
8
|
+
import { calculateVendorCommission, VendorAdapterFactory } from './adapters/factory';
|
|
9
|
+
import { Customer } from '../../store/models';
|
|
10
|
+
import logger from '../logger';
|
|
12
11
|
|
|
13
12
|
export interface VendorFulfillmentResult {
|
|
14
13
|
vendorId: string;
|
|
@@ -40,6 +39,7 @@ export class VendorFulfillmentService {
|
|
|
40
39
|
// Execute single vendor fulfillment (public interface for coordinator system)
|
|
41
40
|
static async fulfillSingleVendorOrder(
|
|
42
41
|
orderInfo: {
|
|
42
|
+
checkoutSessionId: string;
|
|
43
43
|
amount_total: string;
|
|
44
44
|
customer_id: string;
|
|
45
45
|
payment_intent_id: string | null;
|
|
@@ -55,7 +55,7 @@ export class VendorFulfillmentService {
|
|
|
55
55
|
throw new Error(`Vendor not found: ${vendorConfig.vendor_id}`);
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
const adapter =
|
|
58
|
+
const adapter = this.getVendorAdapter(vendor.vendor_key);
|
|
59
59
|
|
|
60
60
|
// Calculate commission amount
|
|
61
61
|
const commissionRate = vendorConfig.commission_rate || vendor.default_commission_rate;
|
|
@@ -70,6 +70,7 @@ export class VendorFulfillmentService {
|
|
|
70
70
|
const userEmail = (await Customer.findByPk(orderInfo.customer_id))?.email || '';
|
|
71
71
|
|
|
72
72
|
const fulfillmentResult = await adapter.fulfillOrder({
|
|
73
|
+
checkoutSessionId: orderInfo.checkoutSessionId,
|
|
73
74
|
productCode: vendorConfig.vendor_id,
|
|
74
75
|
customerId: orderInfo.customer_id || '',
|
|
75
76
|
quantity: 1,
|
|
@@ -302,17 +303,12 @@ export class VendorFulfillmentService {
|
|
|
302
303
|
}
|
|
303
304
|
}
|
|
304
305
|
|
|
305
|
-
static
|
|
306
|
+
static getVendorAdapter(vendorKey: string) {
|
|
306
307
|
try {
|
|
307
|
-
|
|
308
|
-
if (!vendor) {
|
|
309
|
-
throw new Error(`Vendor not found: ${vendorId}`);
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
return VendorAdapterFactory.create(vendor.vendor_key);
|
|
308
|
+
return VendorAdapterFactory.create(vendorKey);
|
|
313
309
|
} catch (error: any) {
|
|
314
310
|
logger.error('Failed to get vendor adapter', {
|
|
315
|
-
|
|
311
|
+
vendorKey,
|
|
316
312
|
error: error.message,
|
|
317
313
|
});
|
|
318
314
|
throw error;
|
|
@@ -6,7 +6,7 @@ import { PaymentIntent } from '../../store/models/payment-intent';
|
|
|
6
6
|
import { Product } from '../../store/models/product';
|
|
7
7
|
import { Price } from '../../store/models/price';
|
|
8
8
|
import { depositVaultQueue } from '../payment';
|
|
9
|
-
import { startVendorFulfillment, triggerCoordinatorCheck } from './
|
|
9
|
+
import { startVendorFulfillment, triggerCommissionProcess, triggerCoordinatorCheck } from './fulfillment-coordinator';
|
|
10
10
|
|
|
11
11
|
type VendorCommissionJob = {
|
|
12
12
|
paymentIntentId: string;
|
|
@@ -97,20 +97,12 @@ export const handleVendorCommission = async (job: VendorCommissionJob) => {
|
|
|
97
97
|
// Find CheckoutSession through PaymentIntent
|
|
98
98
|
checkoutSession = await CheckoutSession.findByPaymentIntentId(paymentIntent.id);
|
|
99
99
|
if (!checkoutSession) {
|
|
100
|
-
logger.warn('CheckoutSession not found for PaymentIntent, proceeding with direct deposit vault transfer', {
|
|
101
|
-
paymentIntentId: paymentIntent.id,
|
|
102
|
-
});
|
|
103
100
|
await executeDirectDepositVault(paymentIntent);
|
|
104
101
|
return;
|
|
105
102
|
}
|
|
106
103
|
|
|
107
104
|
const hasVendorConfig = await checkIfPaymentIntentHasVendors(paymentIntent, checkoutSession);
|
|
108
105
|
if (!hasVendorConfig) {
|
|
109
|
-
logger.info('No vendor configuration found , proceeding with direct deposit vault transfer', {
|
|
110
|
-
paymentIntentId: paymentIntent.id,
|
|
111
|
-
currencyId: paymentIntent.currency_id,
|
|
112
|
-
});
|
|
113
|
-
|
|
114
106
|
await executeDirectDepositVault(paymentIntent);
|
|
115
107
|
return;
|
|
116
108
|
}
|
|
@@ -119,6 +111,14 @@ export const handleVendorCommission = async (job: VendorCommissionJob) => {
|
|
|
119
111
|
paymentIntentId: paymentIntent.id,
|
|
120
112
|
});
|
|
121
113
|
|
|
114
|
+
if (checkoutSession.fulfillment_status === 'completed') {
|
|
115
|
+
logger.info('CheckoutSession already completed, directly trigger commission process', {
|
|
116
|
+
checkoutSessionId: checkoutSession.id,
|
|
117
|
+
});
|
|
118
|
+
await triggerCommissionProcess(checkoutSession.id, paymentIntent.id);
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
122
|
await startVendorFulfillment(checkoutSession.id, paymentIntent.id);
|
|
123
123
|
} catch (error: any) {
|
|
124
124
|
logger.error('Vendor commission decision failed, fallback to direct deposit vault', {
|
|
@@ -135,7 +135,7 @@ export const handleVendorCommission = async (job: VendorCommissionJob) => {
|
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
try {
|
|
138
|
-
|
|
138
|
+
triggerCoordinatorCheck(checkoutSession.id, job.paymentIntentId, 'vendor_commission_decision_failed');
|
|
139
139
|
} catch (err: any) {
|
|
140
140
|
logger.error('Failed to trigger coordinator check[handleVendorCommission]', { error: err.message });
|
|
141
141
|
}
|
package/api/src/queues/vendor/{vendor-fulfillment-coordinator.ts → fulfillment-coordinator.ts}
RENAMED
|
@@ -2,7 +2,7 @@ import { events } from '../../libs/event';
|
|
|
2
2
|
import { getLock } from '../../libs/lock';
|
|
3
3
|
import logger from '../../libs/logger';
|
|
4
4
|
import createQueue from '../../libs/queue';
|
|
5
|
-
import { VendorFulfillmentService } from '../../libs/vendor
|
|
5
|
+
import { VendorFulfillmentService } from '../../libs/vendor/fulfillment';
|
|
6
6
|
import { CheckoutSession } from '../../store/models/checkout-session';
|
|
7
7
|
import { PaymentIntent } from '../../store/models/payment-intent';
|
|
8
8
|
import { Price } from '../../store/models/price';
|
|
@@ -394,7 +394,7 @@ export function triggerCoordinatorCheck(checkoutSessionId: string, paymentIntent
|
|
|
394
394
|
});
|
|
395
395
|
}
|
|
396
396
|
|
|
397
|
-
async function triggerCommissionProcess(checkoutSessionId: string, paymentIntentId: string): Promise<void> {
|
|
397
|
+
export async function triggerCommissionProcess(checkoutSessionId: string, paymentIntentId: string): Promise<void> {
|
|
398
398
|
logger.info('Triggering commission process', {
|
|
399
399
|
checkoutSessionId,
|
|
400
400
|
paymentIntentId,
|
|
@@ -481,8 +481,6 @@ export async function initiateFullRefund(paymentIntentId: string, reason: string
|
|
|
481
481
|
amount: refund.amount,
|
|
482
482
|
reason,
|
|
483
483
|
});
|
|
484
|
-
|
|
485
|
-
events.emit('refund.created', refund);
|
|
486
484
|
} catch (error: any) {
|
|
487
485
|
logger.error('Failed to create full refund', {
|
|
488
486
|
paymentIntentId,
|
|
@@ -575,7 +573,7 @@ async function requestReturnFromSingleVendor(
|
|
|
575
573
|
});
|
|
576
574
|
|
|
577
575
|
try {
|
|
578
|
-
const vendorAdapter =
|
|
576
|
+
const vendorAdapter = VendorFulfillmentService.getVendorAdapter(vendor.vendor_key);
|
|
579
577
|
if (!vendorAdapter) {
|
|
580
578
|
throw new Error(`No adapter found for vendor: ${vendor.vendor_id}`);
|
|
581
579
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { events } from '../../libs/event';
|
|
2
2
|
import logger from '../../libs/logger';
|
|
3
3
|
import createQueue from '../../libs/queue';
|
|
4
|
-
import { VendorFulfillmentService } from '../../libs/vendor
|
|
4
|
+
import { VendorFulfillmentService } from '../../libs/vendor/fulfillment';
|
|
5
5
|
import { CheckoutSession } from '../../store/models/checkout-session';
|
|
6
|
-
import { updateVendorFulfillmentStatus } from './
|
|
6
|
+
import { updateVendorFulfillmentStatus } from './fulfillment-coordinator';
|
|
7
7
|
|
|
8
8
|
type VendorFulfillmentJob = {
|
|
9
9
|
checkoutSessionId: string;
|
|
@@ -28,6 +28,7 @@ export const handleVendorFulfillment = async (job: VendorFulfillmentJob) => {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
const orderInfo = {
|
|
31
|
+
checkoutSessionId,
|
|
31
32
|
amount_total: checkoutSession.amount_total,
|
|
32
33
|
customer_id: checkoutSession.customer_id || '',
|
|
33
34
|
payment_intent_id: checkoutSession.payment_intent_id || '',
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { joinURL } from 'ufo';
|
|
2
2
|
import createQueue from '../../libs/queue';
|
|
3
3
|
import { getBlockletJson } from '../../libs/util';
|
|
4
|
-
import { VendorAdapterFactory } from '../../libs/vendor-adapter-factory';
|
|
5
4
|
import { CheckoutSession } from '../../store/models/checkout-session';
|
|
6
5
|
import { ProductVendor } from '../../store/models';
|
|
7
|
-
import { fulfillmentCoordinatorQueue } from './
|
|
6
|
+
import { fulfillmentCoordinatorQueue } from './fulfillment-coordinator';
|
|
8
7
|
import logger from '../../libs/logger';
|
|
9
8
|
import { vendorTimeoutMinutes } from '../../libs/env';
|
|
9
|
+
import { VendorFulfillmentService } from '../../libs/vendor/fulfillment';
|
|
10
10
|
|
|
11
11
|
export const startVendorStatusCheckSchedule = async () => {
|
|
12
12
|
const checkoutSessions = await CheckoutSession.findAll({
|
|
@@ -109,8 +109,7 @@ export const handleVendorStatusCheck = async (job: VendorStatusCheckJob) => {
|
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
|
|
113
|
-
const adapter = await VendorAdapterFactory.create(vendor.vendor_key);
|
|
112
|
+
const adapter = VendorFulfillmentService.getVendorAdapter(vendor.vendor_key);
|
|
114
113
|
const result = await adapter.checkOrderStatus({ appUrl: vendor.app_url });
|
|
115
114
|
|
|
116
115
|
if (result.status === 'completed') {
|
|
@@ -94,6 +94,7 @@ import { CHARGE_SUPPORTED_CHAIN_TYPES } from '../libs/constants';
|
|
|
94
94
|
import { blocklet } from '../libs/auth';
|
|
95
95
|
import { addSubscriptionJob } from '../queues/subscription';
|
|
96
96
|
import { updateDataConcurrency } from '../libs/env';
|
|
97
|
+
import { formatToShortUrl } from '../libs/url';
|
|
97
98
|
|
|
98
99
|
const router = Router();
|
|
99
100
|
|
|
@@ -824,7 +825,7 @@ router.post('/', authLogin, async (req, res) => {
|
|
|
824
825
|
});
|
|
825
826
|
|
|
826
827
|
export async function startCheckoutSessionFromPaymentLink(id: string, req: Request, res: Response) {
|
|
827
|
-
const { metadata } = req.body;
|
|
828
|
+
const { metadata, needShortUrl = false } = req.body;
|
|
828
829
|
try {
|
|
829
830
|
const link = await PaymentLink.findByPk(id);
|
|
830
831
|
if (!link) {
|
|
@@ -980,7 +981,15 @@ export async function startCheckoutSessionFromPaymentLink(id: string, req: Reque
|
|
|
980
981
|
doc.line_items = await Price.expand(updatedItems, { upsell: true });
|
|
981
982
|
}
|
|
982
983
|
|
|
984
|
+
let paymentUrl = getUrl(`/checkout/pay/${doc.id}`);
|
|
985
|
+
if (needShortUrl) {
|
|
986
|
+
const validUntil = dayjs().add(20, 'minutes').format('YYYY-MM-DDTHH:mm:ss+00:00');
|
|
987
|
+
const maxVisits = 5;
|
|
988
|
+
paymentUrl = await formatToShortUrl({ url: paymentUrl, validUntil, maxVisits });
|
|
989
|
+
}
|
|
990
|
+
|
|
983
991
|
res.json({
|
|
992
|
+
paymentUrl,
|
|
984
993
|
checkoutSession: doc.toJSON(),
|
|
985
994
|
paymentMethods: await getPaymentMethods(doc),
|
|
986
995
|
paymentLink: link,
|
package/api/src/routes/vendor.ts
CHANGED
|
@@ -3,7 +3,7 @@ import Joi from 'joi';
|
|
|
3
3
|
|
|
4
4
|
import { joinURL } from 'ufo';
|
|
5
5
|
import { VendorAuth } from '@blocklet/payment-vendor';
|
|
6
|
-
import { VendorFulfillmentService } from '../libs/vendor
|
|
6
|
+
import { VendorFulfillmentService } from '../libs/vendor/fulfillment';
|
|
7
7
|
import logger from '../libs/logger';
|
|
8
8
|
import { ProductVendor } from '../store/models/product-vendor';
|
|
9
9
|
import { wallet } from '../libs/auth';
|
|
@@ -364,6 +364,7 @@ async function testVendorFulfillment(req: any, res: any) {
|
|
|
364
364
|
});
|
|
365
365
|
|
|
366
366
|
const orderInfo = {
|
|
367
|
+
checkoutSessionId: testCheckoutSession.id,
|
|
367
368
|
amount_total: testCheckoutSession.amount_total.toString(),
|
|
368
369
|
customer_id: testCheckoutSession.customer_id,
|
|
369
370
|
payment_intent_id: testCheckoutSession.payment_intent_id,
|
package/blocklet.yml
CHANGED
|
@@ -745,8 +745,6 @@ async function initiateFullRefund(
|
|
|
745
745
|
// ... 其他字段
|
|
746
746
|
});
|
|
747
747
|
|
|
748
|
-
// 触发退款队列处理
|
|
749
|
-
events.emit('refund.created', refund);
|
|
750
748
|
} catch (error) {
|
|
751
749
|
logger.error('Failed to create full refund', { error: error.message });
|
|
752
750
|
}
|
|
@@ -792,7 +790,7 @@ async function requestReturnFromSingleVendor(
|
|
|
792
790
|
): Promise<void> {
|
|
793
791
|
try {
|
|
794
792
|
// 1. 获取供应商适配器
|
|
795
|
-
const vendorAdapter =
|
|
793
|
+
const vendorAdapter = VendorFulfillmentService.getVendorAdapter(vendor.vendor_key);
|
|
796
794
|
|
|
797
795
|
// 2. 调用供应商的退货请求方法
|
|
798
796
|
const returnResult = await vendorAdapter.requestReturn({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "payment-kit",
|
|
3
|
-
"version": "1.20.
|
|
3
|
+
"version": "1.20.7",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "blocklet dev --open",
|
|
6
6
|
"lint": "tsc --noEmit && eslint src api/src --ext .mjs,.js,.jsx,.ts,.tsx",
|
|
@@ -55,8 +55,8 @@
|
|
|
55
55
|
"@blocklet/error": "^0.2.5",
|
|
56
56
|
"@blocklet/js-sdk": "^1.16.52-beta-20250908-085420-224a58fa",
|
|
57
57
|
"@blocklet/logger": "^1.16.52-beta-20250908-085420-224a58fa",
|
|
58
|
-
"@blocklet/payment-react": "1.20.
|
|
59
|
-
"@blocklet/payment-vendor": "1.20.
|
|
58
|
+
"@blocklet/payment-react": "1.20.7",
|
|
59
|
+
"@blocklet/payment-vendor": "1.20.7",
|
|
60
60
|
"@blocklet/sdk": "^1.16.52-beta-20250908-085420-224a58fa",
|
|
61
61
|
"@blocklet/ui-react": "^3.1.37",
|
|
62
62
|
"@blocklet/uploader": "^0.2.10",
|
|
@@ -125,7 +125,7 @@
|
|
|
125
125
|
"devDependencies": {
|
|
126
126
|
"@abtnode/types": "^1.16.52-beta-20250908-085420-224a58fa",
|
|
127
127
|
"@arcblock/eslint-config-ts": "^0.3.3",
|
|
128
|
-
"@blocklet/payment-types": "1.20.
|
|
128
|
+
"@blocklet/payment-types": "1.20.7",
|
|
129
129
|
"@types/cookie-parser": "^1.4.9",
|
|
130
130
|
"@types/cors": "^2.8.19",
|
|
131
131
|
"@types/debug": "^4.1.12",
|
|
@@ -172,5 +172,5 @@
|
|
|
172
172
|
"parser": "typescript"
|
|
173
173
|
}
|
|
174
174
|
},
|
|
175
|
-
"gitHead": "
|
|
175
|
+
"gitHead": "4ceda9d8cf6413d3c28514d774eb653ba5145f1b"
|
|
176
176
|
}
|