vona-module-test-pay 5.0.7 → 5.0.9

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/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/.metadata/index.ts"],"sourcesContent":[null],"names":["ScopeModuleTestPay","BeanScopeBase","__decorate","Scope","__z_BeanInfo","module"],"mappings":";;;;AAMO,IAAMA,kBAAkB,GAAxB,MAAMA,kBAAmB,SAAQC,aAAa,CAAA;AAAxCD,kBAAkB,GAAAE,UAAA,CAAA,CAD9BC,KAAK,EAAE,EAAAC,QAAA,CAAA;EAAAC,MAAA,EAAA;AAAA,CAAA,CAAA,CACK,EAAAL,kBAAkB,CAAyB;AAsBxD;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../src/.metadata/index.ts"],"sourcesContent":[null],"names":["ScopeModuleTestPay","BeanScopeBase","__decorate","Scope","__z_BeanInfo","module"],"mappings":";;;;AAMO,IAAMA,kBAAkB,GAAxB,MAAMA,kBAAmB,SAAQC,aAAa,CAAA;AAAxCD,kBAAkB,GAAAE,UAAA,CAAA,CAD9BC,KAAK,EAAE,EAAAC,QAAA,CAAA;EAAAC,MAAA,EAAA;AAAA,CAAA,CAAA,CACK,EAAAL,kBAAkB,CAAyB;AAsBxD;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vona-module-test-pay",
3
- "version": "5.0.7",
3
+ "version": "5.0.9",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "Vona Module"
@@ -30,9 +30,9 @@
30
30
  "postpack": "clean-package restore"
31
31
  },
32
32
  "dependencies": {
33
- "vona-module-a-pay": "5.0.8",
34
- "vona-module-pay-mock": "5.0.8",
35
- "vona-module-pay-stripe": "5.0.8"
33
+ "vona-module-a-pay": "5.0.10",
34
+ "vona-module-pay-mock": "5.0.10",
35
+ "vona-module-pay-stripe": "5.0.10"
36
36
  },
37
37
  "title": "test-pay",
38
38
  "vonaModule": {
@@ -52,5 +52,5 @@
52
52
  }
53
53
  }
54
54
  },
55
- "gitHead": "ad6f4a6afb4c6f0ba968b84152fcf888b0450e3e"
55
+ "gitHead": "8d575dd958be6aa16daa249bdbdb024d20d0789d"
56
56
  }
@@ -0,0 +1,66 @@
1
+ import type { IMetaOptionsIndex } from 'vona-module-a-index';
2
+
3
+ import assert from 'node:assert/strict';
4
+ import { describe, it } from 'node:test';
5
+ import { appResource } from 'vona';
6
+ import { app } from 'vona-mock';
7
+
8
+ const expectedIndexes = {
9
+ payPaymentSession: [
10
+ 'businessReference',
11
+ 'providerCorrelationReference',
12
+ 'state+expiresAt',
13
+ 'providerPaymentId',
14
+ 'providerOrderId',
15
+ 'providerCaptureId',
16
+ ],
17
+ payProviderOperation: [
18
+ 'paymentSessionId+kind',
19
+ 'refundOperationId',
20
+ 'nextAttemptAt+state',
21
+ 'claimExpiresAt+state',
22
+ 'idempotencyKey',
23
+ ],
24
+ payProviderOperationRecoveryAudit: [
25
+ 'providerOperationId+actionIdempotencyKey',
26
+ 'occurredAt+providerOperationId',
27
+ ],
28
+ payRefundOperation: [
29
+ 'paymentSessionId',
30
+ 'providerCorrelationReference',
31
+ 'providerRefundId',
32
+ 'state',
33
+ ],
34
+ payWebhookInbox: ['providerName+clientName', 'providerEventId', 'paymentSessionId', 'state'],
35
+ payPaymentAudit: 'paymentSessionId',
36
+ payOutboxEvent: ['refundOperationId', 'nextAttemptAt+state', 'claimExpiresAt+state'],
37
+ };
38
+
39
+ describe('paymentIndexes.test.ts', { concurrency: false }, () => {
40
+ it('registers every payment index without overwriting table keys', () => {
41
+ const options = appResource.getBean('a-pay.meta.index')?.options as IMetaOptionsIndex;
42
+ assert.ok(options);
43
+ assert.deepEqual(options.indexes, expectedIndexes);
44
+ });
45
+
46
+ it('creates the refund and recovery lookup indexes', async () => {
47
+ await app.bean.executor.mockCtx(async () => {
48
+ const db = app.bean.database.current;
49
+ for (const table of [
50
+ 'payRefundOperation',
51
+ 'payProviderOperation',
52
+ 'payProviderOperationRecoveryAudit',
53
+ ]) {
54
+ const indexes = await db.dialect.fetchIndexes(db.connection.schema, table);
55
+ const names = new Set(indexes.map(index => index.indexName));
56
+ for (const field of expectedIndexes[table]) {
57
+ const firstColumn = field.split('+')[0];
58
+ assert.ok(
59
+ names.has(`idx_${table}_${firstColumn}`),
60
+ `${table}: ${field}; indexes: ${[...names]}`,
61
+ );
62
+ }
63
+ }
64
+ });
65
+ });
66
+ });
@@ -287,24 +287,28 @@ async function createCheckout(suffix: string, providerCandidateKey = 'paypal'):
287
287
  async function callbackToken(sessionId: number, purpose: 'return' | 'cancel') {
288
288
  const session = await app.scope('a-pay').model.paymentSession.getById(sessionId);
289
289
  assert.ok(session);
290
- return (await app.scope('a-pay').service.paymentCallback.createUrls(session))[
290
+ const callbackUrl = (await app.scope('a-pay').service.paymentCallback.createUrls(session))[
291
291
  purpose === 'return' ? 'returnUrl' : 'cancelUrl'
292
292
  ];
293
+ const port = app.meta.env.SERVER_LISTEN_PORT;
294
+ const fallbackOrigin = `http://${port ? `localhost:${port}` : 'localhost'}`;
295
+ const url = new URL(callbackUrl);
296
+ assert.equal(url.origin, fallbackOrigin);
297
+ assert.equal(url.pathname, `/api/pay/payment-callback/${purpose}`);
298
+ assert.ok(url.searchParams.get('state'));
299
+ return callbackUrl;
293
300
  }
294
301
 
295
302
  describe('paypalLifecycle.test.ts', { concurrency: false, sequential: true }, () => {
296
303
  const releases: Array<() => void> = [];
297
- let originalServe: { protocol?: string; host?: string };
298
304
 
299
305
  before(async () => {
300
- for (const scene of ['a-commerce', 'a-pay']) releases.push(await acquireTestLock(scene));
301
- originalServe = { ...app.config.server.serve };
302
- (app.config.server.serve as any).protocol = 'http';
303
- (app.config.server.serve as any).host = 'localhost';
306
+ for (const scene of ['a-commerce', 'a-pay']) {
307
+ releases.push(await acquireTestLock(scene));
308
+ }
304
309
  });
305
310
 
306
311
  after(() => {
307
- Object.assign(app.config.server.serve, originalServe);
308
312
  for (const release of releases.reverse()) release();
309
313
  });
310
314
 
@@ -262,7 +262,15 @@ async function createCheckout(suffix: string): Promise<IFixture> {
262
262
  async function callbackToken(sessionId: number) {
263
263
  const session = await app.scope('a-pay').model.paymentSession.getById(sessionId);
264
264
  assert.ok(session);
265
- return (await app.scope('a-pay').service.paymentCallback.createUrls(session)).returnUrl;
265
+ const callbackUrl = (await app.scope('a-pay').service.paymentCallback.createUrls(session))
266
+ .returnUrl;
267
+ const port = app.meta.env.SERVER_LISTEN_PORT;
268
+ const fallbackOrigin = `http://${port ? `localhost:${port}` : 'localhost'}`;
269
+ const url = new URL(callbackUrl);
270
+ assert.equal(url.origin, fallbackOrigin);
271
+ assert.equal(url.pathname, '/api/pay/payment-callback/return');
272
+ assert.ok(url.searchParams.get('state'));
273
+ return callbackUrl;
266
274
  }
267
275
 
268
276
  async function consumeReturnCallback(sessionId: number, gateway: ReturnType<typeof createGateway>) {
@@ -291,17 +299,14 @@ async function dispatchPaymentOutcome(paymentSessionId: number) {
291
299
 
292
300
  describe('stripeLifecycle.test.ts', { concurrency: false, sequential: true }, () => {
293
301
  const releases: Array<() => void> = [];
294
- let originalServe: { protocol?: string; host?: string };
295
302
 
296
303
  before(async () => {
297
- for (const scene of ['a-commerce', 'a-pay']) releases.push(await acquireTestLock(scene));
298
- originalServe = { ...app.config.server.serve };
299
- (app.config.server.serve as any).protocol = 'http';
300
- (app.config.server.serve as any).host = 'localhost';
304
+ for (const scene of ['a-commerce', 'a-pay']) {
305
+ releases.push(await acquireTestLock(scene));
306
+ }
301
307
  });
302
308
 
303
309
  after(() => {
304
- Object.assign(app.config.server.serve, originalServe);
305
310
  for (const release of releases.reverse()) release();
306
311
  });
307
312