vona-module-test-pay 5.0.9 → 5.0.10
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/package.json +2 -2
- package/test/payMock.test.ts +1 -1
- package/test/paypalLifecycle.test.ts +39 -35
- package/test/stripeLifecycle.test.ts +33 -26
- package/test/webhook.test.ts +3 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vona-module-test-pay",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.10",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Vona Module"
|
|
@@ -52,5 +52,5 @@
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "ac1ffe7f3effb85c5d4896bb26c2c4e8751aa089"
|
|
56
56
|
}
|
package/test/payMock.test.ts
CHANGED
|
@@ -38,7 +38,7 @@ async function cleanup(fixture: IFixture) {
|
|
|
38
38
|
await app.bean.passport.signout();
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
describe('payMock.test.ts', { concurrency: false
|
|
41
|
+
describe('payMock.test.ts', { concurrency: false }, () => {
|
|
42
42
|
let releaseTestLock: (() => void) | undefined;
|
|
43
43
|
|
|
44
44
|
before(async () => {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { TableIdentity } from 'table-identity';
|
|
2
|
+
|
|
1
3
|
import { ApiError } from '@cabloy/paypal-server-sdk';
|
|
2
4
|
import assert from 'node:assert';
|
|
3
5
|
import { randomUUID } from 'node:crypto';
|
|
@@ -5,17 +7,17 @@ import { after, before, describe, it } from 'node:test';
|
|
|
5
7
|
import { acquireTestLock, app } from 'vona-mock';
|
|
6
8
|
|
|
7
9
|
interface IFixture {
|
|
8
|
-
categoryId?:
|
|
9
|
-
productId?:
|
|
10
|
-
skuId?:
|
|
11
|
-
balanceId?:
|
|
12
|
-
addressId?:
|
|
13
|
-
cartId?:
|
|
14
|
-
userId?:
|
|
10
|
+
categoryId?: TableIdentity;
|
|
11
|
+
productId?: TableIdentity;
|
|
12
|
+
skuId?: TableIdentity;
|
|
13
|
+
balanceId?: TableIdentity;
|
|
14
|
+
addressId?: TableIdentity;
|
|
15
|
+
cartId?: TableIdentity;
|
|
16
|
+
userId?: TableIdentity;
|
|
15
17
|
customerName?: string;
|
|
16
|
-
orderId?:
|
|
17
|
-
paymentAttemptId?:
|
|
18
|
-
paymentSessionId?:
|
|
18
|
+
orderId?: TableIdentity;
|
|
19
|
+
paymentAttemptId?: TableIdentity;
|
|
20
|
+
paymentSessionId?: TableIdentity;
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
interface IGatewayState {
|
|
@@ -237,6 +239,7 @@ async function createCheckout(suffix: string, providerCandidateKey = 'paypal'):
|
|
|
237
239
|
lifecycle: 'active',
|
|
238
240
|
},
|
|
239
241
|
});
|
|
242
|
+
assert.ok(fixture.skuId !== undefined);
|
|
240
243
|
fixture.balanceId = (
|
|
241
244
|
await app.scope('commerce-trade').service.stockBalance.adjustStock({
|
|
242
245
|
skuId: fixture.skuId,
|
|
@@ -244,11 +247,11 @@ async function createCheckout(suffix: string, providerCandidateKey = 'paypal'):
|
|
|
244
247
|
reason: 'PayPal lifecycle fixture',
|
|
245
248
|
correlationId: `paypal-stock-${suffix}`,
|
|
246
249
|
})
|
|
247
|
-
).id
|
|
250
|
+
).id;
|
|
248
251
|
await app.bean.passport.signout();
|
|
249
252
|
fixture.customerName = `paypal-customer-${suffix}`;
|
|
250
253
|
const customer = await app.bean.user.register({ name: fixture.customerName }, true);
|
|
251
|
-
fixture.userId = customer.id
|
|
254
|
+
fixture.userId = customer.id;
|
|
252
255
|
await app.bean.passport.signinMock(fixture.customerName as any);
|
|
253
256
|
const userId = app.bean.passport.currentUser!.id;
|
|
254
257
|
fixture.addressId = await app.bean.executor.performAction(
|
|
@@ -267,24 +270,25 @@ async function createCheckout(suffix: string, providerCandidateKey = 'paypal'):
|
|
|
267
270
|
},
|
|
268
271
|
);
|
|
269
272
|
const cart = await app.scope('commerce-trade').model.cart.insert({ userId });
|
|
270
|
-
fixture.cartId = cart.id
|
|
273
|
+
fixture.cartId = cart.id;
|
|
271
274
|
await app.scope('commerce-trade').model.cartItem.insert({
|
|
272
275
|
cartId: cart.id,
|
|
273
276
|
skuId: fixture.skuId,
|
|
274
277
|
quantity: 1,
|
|
275
278
|
});
|
|
279
|
+
assert.ok(fixture.addressId !== undefined);
|
|
276
280
|
const checkout = await app.scope('commerce-trade').service.order.checkout({
|
|
277
281
|
addressId: fixture.addressId,
|
|
278
282
|
correlationId: `paypal-checkout-${suffix}`,
|
|
279
283
|
providerCandidateKey,
|
|
280
284
|
});
|
|
281
|
-
fixture.orderId = checkout.orderId
|
|
282
|
-
fixture.paymentAttemptId = checkout.paymentAttemptId
|
|
283
|
-
fixture.paymentSessionId = checkout.paymentSessionId
|
|
285
|
+
fixture.orderId = checkout.orderId;
|
|
286
|
+
fixture.paymentAttemptId = checkout.paymentAttemptId;
|
|
287
|
+
fixture.paymentSessionId = checkout.paymentSessionId;
|
|
284
288
|
return fixture;
|
|
285
289
|
}
|
|
286
290
|
|
|
287
|
-
async function callbackToken(sessionId:
|
|
291
|
+
async function callbackToken(sessionId: TableIdentity, purpose: 'return' | 'cancel') {
|
|
288
292
|
const session = await app.scope('a-pay').model.paymentSession.getById(sessionId);
|
|
289
293
|
assert.ok(session);
|
|
290
294
|
const callbackUrl = (await app.scope('a-pay').service.paymentCallback.createUrls(session))[
|
|
@@ -299,7 +303,7 @@ async function callbackToken(sessionId: number, purpose: 'return' | 'cancel') {
|
|
|
299
303
|
return callbackUrl;
|
|
300
304
|
}
|
|
301
305
|
|
|
302
|
-
describe('paypalLifecycle.test.ts', { concurrency: false
|
|
306
|
+
describe('paypalLifecycle.test.ts', { concurrency: false }, () => {
|
|
303
307
|
const releases: Array<() => void> = [];
|
|
304
308
|
|
|
305
309
|
before(async () => {
|
|
@@ -363,7 +367,7 @@ describe('paypalLifecycle.test.ts', { concurrency: false, sequential: true }, ()
|
|
|
363
367
|
assert.notEqual(started.providerCorrelationReference, String(started.id));
|
|
364
368
|
assert.notEqual(started.providerInvoiceReference, String(fixture.paymentAttemptId));
|
|
365
369
|
|
|
366
|
-
const returnUrl = await callbackToken(started.id
|
|
370
|
+
const returnUrl = await callbackToken(started.id, 'return');
|
|
367
371
|
const returnState = new URL(returnUrl).searchParams.get('state');
|
|
368
372
|
assert.ok(returnState);
|
|
369
373
|
const callback = await pay.service.paymentCallback.consume('return', returnState);
|
|
@@ -421,9 +425,9 @@ describe('paypalLifecycle.test.ts', { concurrency: false, sequential: true }, ()
|
|
|
421
425
|
Object.assign(fixture, await createCheckout(randomUUID().slice(0, 12)), {});
|
|
422
426
|
const pay = app.scope('a-pay');
|
|
423
427
|
const started = await pay.service.paymentSession.start(fixture.paymentSessionId!);
|
|
424
|
-
const returnState = new URL(
|
|
425
|
-
|
|
426
|
-
)
|
|
428
|
+
const returnState = new URL(await callbackToken(started.id, 'return')).searchParams.get(
|
|
429
|
+
'state',
|
|
430
|
+
);
|
|
427
431
|
assert.ok(returnState);
|
|
428
432
|
await assert.rejects(
|
|
429
433
|
app.bean.executor.performAction('get', '/pay/payment-callback/return', {
|
|
@@ -494,9 +498,9 @@ describe('paypalLifecycle.test.ts', { concurrency: false, sequential: true }, ()
|
|
|
494
498
|
Object.assign(fixture, await createCheckout(randomUUID().slice(0, 12)), {});
|
|
495
499
|
const pay = app.scope('a-pay');
|
|
496
500
|
const started = await pay.service.paymentSession.start(fixture.paymentSessionId!);
|
|
497
|
-
const returnState = new URL(
|
|
498
|
-
|
|
499
|
-
)
|
|
501
|
+
const returnState = new URL(await callbackToken(started.id, 'return')).searchParams.get(
|
|
502
|
+
'state',
|
|
503
|
+
);
|
|
500
504
|
assert.ok(returnState);
|
|
501
505
|
await assert.rejects(
|
|
502
506
|
app.bean.executor.performAction('get', '/pay/payment-callback/return', {
|
|
@@ -578,13 +582,13 @@ describe('paypalLifecycle.test.ts', { concurrency: false, sequential: true }, ()
|
|
|
578
582
|
supplementary_data: { related_ids: { order_id: state.orderId } },
|
|
579
583
|
},
|
|
580
584
|
});
|
|
581
|
-
const verified = await
|
|
585
|
+
const verified = await app.bean.payProvider.get('pay-paypal:paypal').verifyWebhook(
|
|
582
586
|
{
|
|
583
587
|
rawBody,
|
|
584
588
|
body: JSON.parse(rawBody),
|
|
585
589
|
headers: { 'paypal-transmission-id': 'transmission-test' },
|
|
586
590
|
},
|
|
587
|
-
|
|
591
|
+
app.bean.payProvider.getOptions('pay-paypal:paypal', 'default'),
|
|
588
592
|
);
|
|
589
593
|
await pay.service.webhook.receive({
|
|
590
594
|
providerName: 'pay-paypal:paypal',
|
|
@@ -637,7 +641,7 @@ describe('paypalLifecycle.test.ts', { concurrency: false, sequential: true }, ()
|
|
|
637
641
|
assert.ok(session);
|
|
638
642
|
const started = await pay.service.paymentSession.start(session.id);
|
|
639
643
|
state.orderStatus = 'VOIDED';
|
|
640
|
-
const cancelUrl = await callbackToken(started.id
|
|
644
|
+
const cancelUrl = await callbackToken(started.id, 'cancel');
|
|
641
645
|
const cancelState = new URL(cancelUrl).searchParams.get('state');
|
|
642
646
|
assert.ok(cancelState);
|
|
643
647
|
await assert.rejects(
|
|
@@ -703,7 +707,7 @@ describe('paypalLifecycle.test.ts', { concurrency: false, sequential: true }, ()
|
|
|
703
707
|
const session = await pay.model.paymentSession.getById(fixture.paymentSessionId!);
|
|
704
708
|
assert.ok(session);
|
|
705
709
|
const started = await pay.service.paymentSession.start(session.id);
|
|
706
|
-
const cancelUrl = await callbackToken(started.id
|
|
710
|
+
const cancelUrl = await callbackToken(started.id, 'cancel');
|
|
707
711
|
const cancelState = new URL(cancelUrl).searchParams.get('state');
|
|
708
712
|
assert.ok(cancelState);
|
|
709
713
|
await assert.rejects(
|
|
@@ -764,9 +768,9 @@ describe('paypalLifecycle.test.ts', { concurrency: false, sequential: true }, ()
|
|
|
764
768
|
Object.assign(fixture, await createCheckout(randomUUID().slice(0, 12)), {});
|
|
765
769
|
const pay = app.scope('a-pay');
|
|
766
770
|
const started = await pay.service.paymentSession.start(fixture.paymentSessionId!);
|
|
767
|
-
const cancelState = new URL(
|
|
768
|
-
|
|
769
|
-
)
|
|
771
|
+
const cancelState = new URL(await callbackToken(started.id, 'cancel')).searchParams.get(
|
|
772
|
+
'state',
|
|
773
|
+
);
|
|
770
774
|
assert.ok(cancelState);
|
|
771
775
|
await assert.rejects(
|
|
772
776
|
app.bean.executor.performAction('get', '/pay/payment-callback/cancel', {
|
|
@@ -822,7 +826,7 @@ describe('paypalLifecycle.test.ts', { concurrency: false, sequential: true }, ()
|
|
|
822
826
|
const session = await pay.model.paymentSession.getById(fixture.paymentSessionId!);
|
|
823
827
|
assert.ok(session);
|
|
824
828
|
const started = await pay.service.paymentSession.start(session.id);
|
|
825
|
-
const returnUrl = await callbackToken(started.id
|
|
829
|
+
const returnUrl = await callbackToken(started.id, 'return');
|
|
826
830
|
const token = new URL(returnUrl).searchParams.get('state');
|
|
827
831
|
assert.ok(token);
|
|
828
832
|
const unsafeState = await app.bean.jwt.get('oauthstate').sign(
|
|
@@ -1099,13 +1103,13 @@ describe('paypalLifecycle.test.ts', { concurrency: false, sequential: true }, ()
|
|
|
1099
1103
|
supplementary_data: { related_ids: { capture_id: state.captureId } },
|
|
1100
1104
|
},
|
|
1101
1105
|
});
|
|
1102
|
-
const verified = await
|
|
1106
|
+
const verified = await app.bean.payProvider.get('pay-paypal:paypal').verifyWebhook(
|
|
1103
1107
|
{
|
|
1104
1108
|
rawBody,
|
|
1105
1109
|
body: JSON.parse(rawBody),
|
|
1106
1110
|
headers: { 'paypal-transmission-id': 'webhook-refunded-test' },
|
|
1107
1111
|
},
|
|
1108
|
-
|
|
1112
|
+
app.bean.payProvider.getOptions('pay-paypal:paypal', 'default'),
|
|
1109
1113
|
);
|
|
1110
1114
|
assert.equal(verified.refundOperationId, executed.refundOperationId);
|
|
1111
1115
|
await pay.service.webhook.receive({
|
|
@@ -1,20 +1,22 @@
|
|
|
1
|
+
import type { TableIdentity } from 'table-identity';
|
|
2
|
+
|
|
1
3
|
import assert from 'node:assert';
|
|
2
4
|
import { randomUUID } from 'node:crypto';
|
|
3
5
|
import { after, before, describe, it } from 'node:test';
|
|
4
6
|
import { acquireTestLock, app } from 'vona-mock';
|
|
5
7
|
|
|
6
8
|
interface IFixture {
|
|
7
|
-
categoryId?:
|
|
8
|
-
productId?:
|
|
9
|
-
skuId?:
|
|
10
|
-
balanceId?:
|
|
11
|
-
addressId?:
|
|
12
|
-
cartId?:
|
|
13
|
-
userId?:
|
|
9
|
+
categoryId?: TableIdentity;
|
|
10
|
+
productId?: TableIdentity;
|
|
11
|
+
skuId?: TableIdentity;
|
|
12
|
+
balanceId?: TableIdentity;
|
|
13
|
+
addressId?: TableIdentity;
|
|
14
|
+
cartId?: TableIdentity;
|
|
15
|
+
userId?: TableIdentity;
|
|
14
16
|
customerName?: string;
|
|
15
|
-
orderId?:
|
|
16
|
-
paymentAttemptId?:
|
|
17
|
-
paymentSessionId?:
|
|
17
|
+
orderId?: TableIdentity;
|
|
18
|
+
paymentAttemptId?: TableIdentity;
|
|
19
|
+
paymentSessionId?: TableIdentity;
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
interface IGatewayState {
|
|
@@ -212,6 +214,7 @@ async function createCheckout(suffix: string): Promise<IFixture> {
|
|
|
212
214
|
lifecycle: 'active',
|
|
213
215
|
},
|
|
214
216
|
});
|
|
217
|
+
assert.ok(fixture.skuId !== undefined);
|
|
215
218
|
fixture.balanceId = (
|
|
216
219
|
await app.scope('commerce-trade').service.stockBalance.adjustStock({
|
|
217
220
|
skuId: fixture.skuId,
|
|
@@ -219,11 +222,11 @@ async function createCheckout(suffix: string): Promise<IFixture> {
|
|
|
219
222
|
reason: 'Stripe lifecycle fixture',
|
|
220
223
|
correlationId: `stripe-stock-${suffix}`,
|
|
221
224
|
})
|
|
222
|
-
).id
|
|
225
|
+
).id;
|
|
223
226
|
await app.bean.passport.signout();
|
|
224
227
|
fixture.customerName = `stripe-customer-${suffix}`;
|
|
225
228
|
const customer = await app.bean.user.register({ name: fixture.customerName }, true);
|
|
226
|
-
fixture.userId = customer.id
|
|
229
|
+
fixture.userId = customer.id;
|
|
227
230
|
await app.bean.passport.signinMock(fixture.customerName as any);
|
|
228
231
|
const userId = app.bean.passport.currentUser!.id;
|
|
229
232
|
fixture.addressId = await app.bean.executor.performAction(
|
|
@@ -242,24 +245,25 @@ async function createCheckout(suffix: string): Promise<IFixture> {
|
|
|
242
245
|
},
|
|
243
246
|
);
|
|
244
247
|
const cart = await app.scope('commerce-trade').model.cart.insert({ userId });
|
|
245
|
-
fixture.cartId = cart.id
|
|
248
|
+
fixture.cartId = cart.id;
|
|
246
249
|
await app.scope('commerce-trade').model.cartItem.insert({
|
|
247
250
|
cartId: cart.id,
|
|
248
251
|
skuId: fixture.skuId,
|
|
249
252
|
quantity: 1,
|
|
250
253
|
});
|
|
254
|
+
assert.ok(fixture.addressId !== undefined);
|
|
251
255
|
const checkout = await app.scope('commerce-trade').service.order.checkout({
|
|
252
256
|
addressId: fixture.addressId,
|
|
253
257
|
correlationId: `stripe-checkout-${suffix}`,
|
|
254
258
|
providerCandidateKey: 'stripe',
|
|
255
259
|
});
|
|
256
|
-
fixture.orderId = checkout.orderId
|
|
257
|
-
fixture.paymentAttemptId = checkout.paymentAttemptId
|
|
258
|
-
fixture.paymentSessionId = checkout.paymentSessionId
|
|
260
|
+
fixture.orderId = checkout.orderId;
|
|
261
|
+
fixture.paymentAttemptId = checkout.paymentAttemptId;
|
|
262
|
+
fixture.paymentSessionId = checkout.paymentSessionId;
|
|
259
263
|
return fixture;
|
|
260
264
|
}
|
|
261
265
|
|
|
262
|
-
async function callbackToken(sessionId:
|
|
266
|
+
async function callbackToken(sessionId: TableIdentity) {
|
|
263
267
|
const session = await app.scope('a-pay').model.paymentSession.getById(sessionId);
|
|
264
268
|
assert.ok(session);
|
|
265
269
|
const callbackUrl = (await app.scope('a-pay').service.paymentCallback.createUrls(session))
|
|
@@ -273,7 +277,10 @@ async function callbackToken(sessionId: number) {
|
|
|
273
277
|
return callbackUrl;
|
|
274
278
|
}
|
|
275
279
|
|
|
276
|
-
async function consumeReturnCallback(
|
|
280
|
+
async function consumeReturnCallback(
|
|
281
|
+
sessionId: TableIdentity,
|
|
282
|
+
gateway: ReturnType<typeof createGateway>,
|
|
283
|
+
) {
|
|
277
284
|
const state = new URL(await callbackToken(sessionId)).searchParams.get('state');
|
|
278
285
|
assert.ok(state);
|
|
279
286
|
await assert.rejects(
|
|
@@ -285,7 +292,7 @@ async function consumeReturnCallback(sessionId: number, gateway: ReturnType<type
|
|
|
285
292
|
);
|
|
286
293
|
}
|
|
287
294
|
|
|
288
|
-
async function dispatchPaymentOutcome(paymentSessionId:
|
|
295
|
+
async function dispatchPaymentOutcome(paymentSessionId: TableIdentity) {
|
|
289
296
|
const pay = app.scope('a-pay');
|
|
290
297
|
const outbox = await pay.model.outboxEvent.get({
|
|
291
298
|
paymentSessionId,
|
|
@@ -297,7 +304,7 @@ async function dispatchPaymentOutcome(paymentSessionId: number) {
|
|
|
297
304
|
return outbox;
|
|
298
305
|
}
|
|
299
306
|
|
|
300
|
-
describe('stripeLifecycle.test.ts', { concurrency: false
|
|
307
|
+
describe('stripeLifecycle.test.ts', { concurrency: false }, () => {
|
|
301
308
|
const releases: Array<() => void> = [];
|
|
302
309
|
|
|
303
310
|
before(async () => {
|
|
@@ -352,8 +359,8 @@ describe('stripeLifecycle.test.ts', { concurrency: false, sequential: true }, ()
|
|
|
352
359
|
providerInvoiceReference: started.providerInvoiceReference,
|
|
353
360
|
});
|
|
354
361
|
assert.equal(started.providerOrderId, state.checkoutSessionId);
|
|
355
|
-
await consumeReturnCallback(started.id
|
|
356
|
-
const outbox = await dispatchPaymentOutcome(started.id
|
|
362
|
+
await consumeReturnCallback(started.id, gateway);
|
|
363
|
+
const outbox = await dispatchPaymentOutcome(started.id);
|
|
357
364
|
const order = await app.scope('commerce-trade').model.order.getById(fixture.orderId!);
|
|
358
365
|
const attempt = await app
|
|
359
366
|
.scope('commerce-payment')
|
|
@@ -429,13 +436,13 @@ describe('stripeLifecycle.test.ts', { concurrency: false, sequential: true }, ()
|
|
|
429
436
|
const rawBody = JSON.stringify({
|
|
430
437
|
id: `stripe-webhook-${started.id}`,
|
|
431
438
|
});
|
|
432
|
-
const verified = await
|
|
439
|
+
const verified = await app.bean.payProvider.get('pay-stripe:stripe').verifyWebhook(
|
|
433
440
|
{
|
|
434
441
|
rawBody,
|
|
435
442
|
body: JSON.parse(rawBody),
|
|
436
443
|
headers: { 'stripe-signature': 'stripe-signature-test' },
|
|
437
444
|
},
|
|
438
|
-
|
|
445
|
+
app.bean.payProvider.getOptions('pay-stripe:stripe', 'default'),
|
|
439
446
|
);
|
|
440
447
|
await pay.service.webhook.receive({
|
|
441
448
|
providerName: 'pay-stripe:stripe',
|
|
@@ -506,7 +513,7 @@ describe('stripeLifecycle.test.ts', { concurrency: false, sequential: true }, ()
|
|
|
506
513
|
Object.assign(fixture, await createCheckout(randomUUID().slice(0, 12)));
|
|
507
514
|
const pay = app.scope('a-pay');
|
|
508
515
|
const started = await pay.service.paymentSession.start(fixture.paymentSessionId!);
|
|
509
|
-
await consumeReturnCallback(started.id
|
|
516
|
+
await consumeReturnCallback(started.id, gateway);
|
|
510
517
|
const operation = await pay.model.providerOperation.get({
|
|
511
518
|
paymentSessionId: started.id,
|
|
512
519
|
kind: 'confirm',
|
|
@@ -530,7 +537,7 @@ describe('stripeLifecycle.test.ts', { concurrency: false, sequential: true }, ()
|
|
|
530
537
|
});
|
|
531
538
|
assert.equal(await pay.service.providerOperation.queueDue(), 1);
|
|
532
539
|
assert.equal((await pay.model.paymentSession.getById(started.id))?.state, 'succeeded');
|
|
533
|
-
await dispatchPaymentOutcome(started.id
|
|
540
|
+
await dispatchPaymentOutcome(started.id);
|
|
534
541
|
assert.equal(
|
|
535
542
|
(await app.scope('commerce-trade').model.order.getById(fixture.orderId!))?.state,
|
|
536
543
|
'paid',
|
package/test/webhook.test.ts
CHANGED
|
@@ -84,8 +84,8 @@ function createCommand(rawBody: string, paymentSessionId: number) {
|
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
function sign(rawBody: string, clientName: 'default' | 'secondary' = 'default') {
|
|
87
|
-
const options = app.bean.payProvider.
|
|
88
|
-
assert.
|
|
87
|
+
const options = app.bean.payProvider.resolveByName('pay-mock:mock', clientName).clientOptions;
|
|
88
|
+
assert.ok(typeof options.secretWebhook === 'string');
|
|
89
89
|
return createHmac('sha256', options.secretWebhook).update(rawBody).digest('hex');
|
|
90
90
|
}
|
|
91
91
|
|
|
@@ -104,7 +104,7 @@ async function countFacts(paymentSessionId: number) {
|
|
|
104
104
|
return { inboxes, audits, outbox };
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
describe('webhook.test.ts', { concurrency: false
|
|
107
|
+
describe('webhook.test.ts', { concurrency: false }, () => {
|
|
108
108
|
let releaseTestLock: (() => void) | undefined;
|
|
109
109
|
|
|
110
110
|
before(async () => {
|