@adonis-agora/payments 0.20.0 → 0.21.0
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/CHANGELOG.md +21 -0
- package/dist/assets/spa/assets/{index-DBJQRh8m.js → index-DsNg6yNC.js} +4 -4
- package/dist/assets/spa/assets/index-DsNg6yNC.js.map +1 -0
- package/dist/assets/spa/index.html +1 -1
- package/dist/providers/payments_provider.d.ts +5 -2
- package/dist/providers/payments_provider.d.ts.map +1 -1
- package/dist/providers/payments_provider.js +32 -0
- package/dist/providers/payments_provider.js.map +1 -1
- package/dist/src/billing/billing_store.d.ts +13 -9
- package/dist/src/billing/billing_store.d.ts.map +1 -1
- package/dist/src/billing/billing_store.js.map +1 -1
- package/dist/src/billing/lucid_billing_store.d.ts +2 -2
- package/dist/src/billing/lucid_billing_store.d.ts.map +1 -1
- package/dist/src/billing/lucid_billing_store.js +114 -31
- package/dist/src/billing/lucid_billing_store.js.map +1 -1
- package/dist/src/billing/mixins/json_column.d.ts +14 -0
- package/dist/src/billing/mixins/json_column.d.ts.map +1 -0
- package/dist/src/billing/mixins/json_column.js +36 -0
- package/dist/src/billing/mixins/json_column.js.map +1 -0
- package/dist/src/billing/mixins/with_audit_event.d.ts +5 -0
- package/dist/src/billing/mixins/with_audit_event.d.ts.map +1 -1
- package/dist/src/billing/mixins/with_audit_event.js +7 -1
- package/dist/src/billing/mixins/with_audit_event.js.map +1 -1
- package/dist/src/billing/mixins/with_customer.d.ts +5 -0
- package/dist/src/billing/mixins/with_customer.d.ts.map +1 -1
- package/dist/src/billing/mixins/with_customer.js +7 -1
- package/dist/src/billing/mixins/with_customer.js.map +1 -1
- package/dist/src/billing/mixins/with_dispute.d.ts +5 -0
- package/dist/src/billing/mixins/with_dispute.d.ts.map +1 -1
- package/dist/src/billing/mixins/with_dispute.js +7 -1
- package/dist/src/billing/mixins/with_dispute.js.map +1 -1
- package/dist/src/billing/mixins/with_payment.d.ts +5 -0
- package/dist/src/billing/mixins/with_payment.d.ts.map +1 -1
- package/dist/src/billing/mixins/with_payment.js +8 -2
- package/dist/src/billing/mixins/with_payment.js.map +1 -1
- package/dist/src/billing/mixins/with_subscription.d.ts +5 -0
- package/dist/src/billing/mixins/with_subscription.d.ts.map +1 -1
- package/dist/src/billing/mixins/with_subscription.js +8 -2
- package/dist/src/billing/mixins/with_subscription.js.map +1 -1
- package/dist/src/billing/mixins/with_usage_event.d.ts +5 -0
- package/dist/src/billing/mixins/with_usage_event.d.ts.map +1 -1
- package/dist/src/billing/mixins/with_usage_event.js +7 -1
- package/dist/src/billing/mixins/with_usage_event.js.map +1 -1
- package/dist/src/billing/mixins/with_webhook_event.d.ts +11 -0
- package/dist/src/billing/mixins/with_webhook_event.d.ts.map +1 -1
- package/dist/src/billing/mixins/with_webhook_event.js +11 -2
- package/dist/src/billing/mixins/with_webhook_event.js.map +1 -1
- package/dist/src/billing/schema.d.ts.map +1 -1
- package/dist/src/billing/schema.js +49 -5
- package/dist/src/billing/schema.js.map +1 -1
- package/dist/src/billing/webhook_dispatcher.d.ts +5 -1
- package/dist/src/billing/webhook_dispatcher.d.ts.map +1 -1
- package/dist/src/billing/webhook_dispatcher.js +2 -1
- package/dist/src/billing/webhook_dispatcher.js.map +1 -1
- package/dist/src/dashboard/handlers.d.ts +5 -9
- package/dist/src/dashboard/handlers.d.ts.map +1 -1
- package/dist/src/dashboard/handlers.js +25 -55
- package/dist/src/dashboard/handlers.js.map +1 -1
- package/dist/src/driver.d.ts +12 -0
- package/dist/src/driver.d.ts.map +1 -1
- package/dist/src/drivers/mercadopago.d.ts +6 -0
- package/dist/src/drivers/mercadopago.d.ts.map +1 -1
- package/dist/src/drivers/mercadopago.js +23 -1
- package/dist/src/drivers/mercadopago.js.map +1 -1
- package/dist/src/drivers/mollie.d.ts +7 -0
- package/dist/src/drivers/mollie.d.ts.map +1 -1
- package/dist/src/drivers/mollie.js +22 -0
- package/dist/src/drivers/mollie.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/package_origin.d.ts +7 -0
- package/dist/src/package_origin.d.ts.map +1 -0
- package/dist/src/package_origin.js +7 -0
- package/dist/src/package_origin.js.map +1 -0
- package/dist/src/testing/in_memory_billing_store.d.ts +8 -6
- package/dist/src/testing/in_memory_billing_store.d.ts.map +1 -1
- package/dist/src/testing/in_memory_billing_store.js +15 -5
- package/dist/src/testing/in_memory_billing_store.js.map +1 -1
- package/dist/src/webhook_security.d.ts.map +1 -1
- package/dist/src/webhook_security.js +26 -5
- package/dist/src/webhook_security.js.map +1 -1
- package/package.json +6 -5
- package/dist/assets/spa/assets/index-DBJQRh8m.js.map +0 -1
|
@@ -6,12 +6,18 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
6
6
|
};
|
|
7
7
|
import { randomUUID } from 'node:crypto';
|
|
8
8
|
import { BaseModel, beforeCreate, column } from '@adonisjs/lucid/orm';
|
|
9
|
+
import { jsonColumn } from './json_column.js';
|
|
9
10
|
/**
|
|
10
11
|
* The Lucid model backing the `billing_usage_events` table — a metered subscription's
|
|
11
12
|
* consumption ledger. One row per usage event (e.g. an API call, a stored GB, a message);
|
|
12
13
|
* the billing layer aggregates them per meter for a period to bill usage-based plans.
|
|
13
14
|
*/
|
|
14
15
|
export class BillingUsageEvent extends BaseModel {
|
|
16
|
+
/**
|
|
17
|
+
* The hook below assigns the id, so Lucid must not overwrite it with what the INSERT reports.
|
|
18
|
+
* On SQLite that is the numeric rowid, and every later `where id = ?` would miss the row.
|
|
19
|
+
*/
|
|
20
|
+
static selfAssignPrimaryKey = true;
|
|
15
21
|
/**
|
|
16
22
|
* The `id` column is a `uuid` with no database-side default (see the published
|
|
17
23
|
* migration), so nothing but this hook fills it. Generating it here rather than in the
|
|
@@ -45,7 +51,7 @@ __decorate([
|
|
|
45
51
|
column()
|
|
46
52
|
], BillingUsageEvent.prototype, "quantity", void 0);
|
|
47
53
|
__decorate([
|
|
48
|
-
column({ serializeAs: null })
|
|
54
|
+
column({ ...jsonColumn, serializeAs: null })
|
|
49
55
|
], BillingUsageEvent.prototype, "metadata", void 0);
|
|
50
56
|
__decorate([
|
|
51
57
|
column.dateTime({ autoCreate: true })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"with_usage_event.js","sourceRoot":"","sources":["../../../../src/billing/mixins/with_usage_event.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"with_usage_event.js","sourceRoot":"","sources":["../../../../src/billing/mixins/with_usage_event.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAEtE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C;;;;GAIG;AACH,MAAM,OAAO,iBAAkB,SAAQ,SAAS;IAC9C;;;OAGG;IACH,MAAM,CAAU,oBAAoB,GAAG,IAAI,CAAC;IAE5C;;;;;OAKG;IAEI,AAAP,MAAM,CAAC,UAAU,CAAC,GAAsB;QACtC,IAAI,CAAC,GAAG,CAAC,EAAE;YAAE,GAAG,CAAC,EAAE,GAAG,UAAU,EAAE,CAAC;IACrC,CAAC;CAyCF;AAtCS;IADP,MAAM,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;6CACT;AAIX;IADP,MAAM,EAAE;yDAC6B;AAI9B;IADP,MAAM,EAAE;qDACyB;AAQ1B;IADP,MAAM,EAAE;oDACwB;AAIzB;IADP,MAAM,EAAE;kDACsB;AAIvB;IADP,MAAM,EAAE;gDACa;AAId;IADP,MAAM,EAAE;mDACgB;AAGjB;IADP,MAAM,CAAC,EAAE,GAAG,UAAU,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;mDACH;AAGlC;IADP,MAAM,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;qDACT;AAGrB;IADP,MAAM,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;oDAC5B;AA1CrB;IADN,YAAY,EAAE;yCAGd"}
|
|
@@ -6,6 +6,11 @@ import type { DateTime } from 'luxon';
|
|
|
6
6
|
* webhook is never processed twice.
|
|
7
7
|
*/
|
|
8
8
|
export declare class BillingWebhookEvent extends BaseModel {
|
|
9
|
+
/**
|
|
10
|
+
* The hook below assigns the id, so Lucid must not overwrite it with what the INSERT reports.
|
|
11
|
+
* On SQLite that is the numeric rowid, and every later `where id = ?` would miss the row.
|
|
12
|
+
*/
|
|
13
|
+
static selfAssignPrimaryKey: boolean;
|
|
9
14
|
/**
|
|
10
15
|
* The `id` column is a `uuid` with no database-side default (see the published
|
|
11
16
|
* migration), so nothing but this hook fills it. Generating it here rather than in the
|
|
@@ -31,6 +36,12 @@ export declare class BillingWebhookEvent extends BaseModel {
|
|
|
31
36
|
* retry says so rather than replaying half an event.
|
|
32
37
|
*/
|
|
33
38
|
normalized: Record<string, unknown> | null;
|
|
39
|
+
/**
|
|
40
|
+
* The payment this delivery is about — the normalized event's `gatewayId` on a `payment.*`
|
|
41
|
+
* event, `''` on any other. `null` on rows recorded before the column existed, and on a
|
|
42
|
+
* `payment.*` event that normalized no id.
|
|
43
|
+
*/
|
|
44
|
+
paymentGatewayId: string | null;
|
|
34
45
|
/** Error message when processing failed. */
|
|
35
46
|
error: string | null;
|
|
36
47
|
createdAt: DateTime;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"with_webhook_event.d.ts","sourceRoot":"","sources":["../../../../src/billing/mixins/with_webhook_event.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAwB,MAAM,qBAAqB,CAAC;AACtE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"with_webhook_event.d.ts","sourceRoot":"","sources":["../../../../src/billing/mixins/with_webhook_event.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAwB,MAAM,qBAAqB,CAAC;AACtE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAGtC;;;;GAIG;AACH,qBAAa,mBAAoB,SAAQ,SAAS;IAChD;;;OAGG;IACH,OAAgB,oBAAoB,UAAQ;IAE5C;;;;;OAKG;IAEH,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,mBAAmB,GAAG,IAAI,CAEhD;IAGO,EAAE,EAAE,MAAM,CAAC;IAEnB,8CAA8C;IAEtC,cAAc,EAAE,MAAM,CAAC;IAGvB,QAAQ,EAAE,MAAM,CAAC;IAGjB,IAAI,EAAE,MAAM,CAAC;IAGb,MAAM,EAAE,UAAU,GAAG,WAAW,GAAG,QAAQ,CAAC;IAG5C,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAEzC;;;;;;;;;OASG;IAEK,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAEnD;;;;OAIG;IAEK,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAExC,4CAA4C;IAEpC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAGrB,SAAS,EAAE,QAAQ,CAAC;IAGpB,SAAS,EAAE,QAAQ,CAAC;CAC7B"}
|
|
@@ -6,12 +6,18 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
6
6
|
};
|
|
7
7
|
import { randomUUID } from 'node:crypto';
|
|
8
8
|
import { BaseModel, beforeCreate, column } from '@adonisjs/lucid/orm';
|
|
9
|
+
import { jsonColumn } from './json_column.js';
|
|
9
10
|
/**
|
|
10
11
|
* The Lucid model backing the `billing_webhook_events` table — the idempotency ledger.
|
|
11
12
|
* Every webhook event is recorded here (keyed by gateway event id) so a re-delivered
|
|
12
13
|
* webhook is never processed twice.
|
|
13
14
|
*/
|
|
14
15
|
export class BillingWebhookEvent extends BaseModel {
|
|
16
|
+
/**
|
|
17
|
+
* The hook below assigns the id, so Lucid must not overwrite it with what the INSERT reports.
|
|
18
|
+
* On SQLite that is the numeric rowid, and every later `where id = ?` would miss the row.
|
|
19
|
+
*/
|
|
20
|
+
static selfAssignPrimaryKey = true;
|
|
15
21
|
/**
|
|
16
22
|
* The `id` column is a `uuid` with no database-side default (see the published
|
|
17
23
|
* migration), so nothing but this hook fills it. Generating it here rather than in the
|
|
@@ -39,11 +45,14 @@ __decorate([
|
|
|
39
45
|
column()
|
|
40
46
|
], BillingWebhookEvent.prototype, "status", void 0);
|
|
41
47
|
__decorate([
|
|
42
|
-
column({ serializeAs: null })
|
|
48
|
+
column({ ...jsonColumn, serializeAs: null })
|
|
43
49
|
], BillingWebhookEvent.prototype, "payload", void 0);
|
|
44
50
|
__decorate([
|
|
45
|
-
column({ serializeAs: null })
|
|
51
|
+
column({ ...jsonColumn, serializeAs: null })
|
|
46
52
|
], BillingWebhookEvent.prototype, "normalized", void 0);
|
|
53
|
+
__decorate([
|
|
54
|
+
column({ serializeAs: null })
|
|
55
|
+
], BillingWebhookEvent.prototype, "paymentGatewayId", void 0);
|
|
47
56
|
__decorate([
|
|
48
57
|
column({ serializeAs: null })
|
|
49
58
|
], BillingWebhookEvent.prototype, "error", void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"with_webhook_event.js","sourceRoot":"","sources":["../../../../src/billing/mixins/with_webhook_event.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file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2CAGd"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/billing/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,+CAA+C;AAC/C,MAAM,MAAM,kBAAkB,GAAG,SAAS,OAAO,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE9E;;;;;;;;;;GAUG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACxE;AAED;;;;;;GAMG;AACH,MAAM,WAAW,aAAc,SAAQ,gBAAgB;IACrD,OAAO,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC5B,UAAU,CAAC,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG;QAAE,OAAO,CAAC,EAAE;YAAE,IAAI,CAAC,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,CAAC;CAC7D;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,YACzB,mBAAmB,EACnB,uBAAuB,EACvB,kBAAkB,EAClB,wBAAwB,EACxB,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,CACd,CAAC;AAEX,oEAAoE;AACpE,wBAAgB,aAAa,CAAC,EAAE,EAAE,aAAa,GAAG,MAAM,GAAG,SAAS,CAQnE;
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/billing/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,+CAA+C;AAC/C,MAAM,MAAM,kBAAkB,GAAG,SAAS,OAAO,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE9E;;;;;;;;;;GAUG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACxE;AAED;;;;;;GAMG;AACH,MAAM,WAAW,aAAc,SAAQ,gBAAgB;IACrD,OAAO,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC5B,UAAU,CAAC,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG;QAAE,OAAO,CAAC,EAAE;YAAE,IAAI,CAAC,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,CAAC;CAC7D;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,YACzB,mBAAmB,EACnB,uBAAuB,EACvB,kBAAkB,EAClB,wBAAwB,EACxB,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,CACd,CAAC;AAEX,oEAAoE;AACpE,wBAAgB,aAAa,CAAC,EAAE,EAAE,aAAa,GAAG,MAAM,GAAG,SAAS,CAQnE;AA6GD;;;;;;;;;;;;GAYG;AACH,wBAAsB,mBAAmB,CAAC,EAAE,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAuX1E;AAaD;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAKxE;AAED;;;;;;;;GAQG;AACH,wBAAsB,iBAAiB,CAAC,EAAE,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAKxE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,qBAAqB,CAAC,EAAE,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAU5E"}
|
|
@@ -86,6 +86,25 @@ async function createIndex(db, dialect, name, table, columns) {
|
|
|
86
86
|
throw error;
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
|
+
/**
|
|
90
|
+
* Drop a secondary index, idempotently. Same split as {@link createIndex}: MySQL has no
|
|
91
|
+
* `DROP INDEX IF EXISTS`, so there the statement is attempted and a missing-index error is
|
|
92
|
+
* swallowed. Any other failure still throws.
|
|
93
|
+
*/
|
|
94
|
+
async function dropIndex(db, dialect, name, table) {
|
|
95
|
+
if (!isMysql(dialect)) {
|
|
96
|
+
await db.rawQuery(`DROP INDEX IF EXISTS ${name}`);
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
try {
|
|
100
|
+
await db.rawQuery(`DROP INDEX ${name} ON ${table}`);
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
104
|
+
if (!/check that (column\/key|it) exists|can't drop/i.test(message))
|
|
105
|
+
throw error;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
89
108
|
/**
|
|
90
109
|
* Add a column that was introduced AFTER its table shipped, idempotently.
|
|
91
110
|
*
|
|
@@ -181,6 +200,7 @@ export async function createBillingTables(db) {
|
|
|
181
200
|
status VARCHAR(255),
|
|
182
201
|
payload ${t.json},
|
|
183
202
|
normalized ${t.json},
|
|
203
|
+
payment_gateway_id VARCHAR(255),
|
|
184
204
|
error TEXT,
|
|
185
205
|
created_at ${t.timestamp} NOT NULL,
|
|
186
206
|
updated_at ${t.timestamp} NOT NULL
|
|
@@ -298,6 +318,11 @@ export async function createBillingTables(db) {
|
|
|
298
318
|
// Nullable: an app that meters per subscription or per customer never sets them.
|
|
299
319
|
await addColumn(db, dialect, 'billing_usage_events', 'scope_type', 'VARCHAR(255)');
|
|
300
320
|
await addColumn(db, dialect, 'billing_usage_events', 'scope_id', 'VARCHAR(255)');
|
|
321
|
+
// 0.21.0 — the payment a ledger row is about, copied from the normalized event's `gatewayId`
|
|
322
|
+
// when the row is recorded, so a payment's timeline is an indexed equality instead of a
|
|
323
|
+
// substring scan over every stored payload. `''` on a row about something else; `NULL` on rows
|
|
324
|
+
// recorded before the column existed, which the timeline still finds by substring.
|
|
325
|
+
await addColumn(db, dialect, 'billing_webhook_events', 'payment_gateway_id', 'VARCHAR(255)');
|
|
301
326
|
// ── Indexes ───────────────────────────────────────────────────────────────────────────
|
|
302
327
|
//
|
|
303
328
|
// Last, and that is load-bearing twice over. Every table above has to exist, and so does
|
|
@@ -316,11 +341,30 @@ export async function createBillingTables(db) {
|
|
|
316
341
|
// (the health check) and "what has anyone done to THIS payment" (the timeline).
|
|
317
342
|
await createIndex(db, dialect, 'billing_audit_events_action_idx', 'billing_audit_events', 'action, created_at');
|
|
318
343
|
await createIndex(db, dialect, 'billing_audit_events_subject_idx', 'billing_audit_events', 'subject_type, subject_id');
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
//
|
|
322
|
-
//
|
|
323
|
-
await createIndex(db, dialect, '
|
|
344
|
+
// The usage reads: "how much of this meter, in this window" per subscription, customer or
|
|
345
|
+
// scope. `recorded_at` closes each index so the window is a range scan rather than a read of
|
|
346
|
+
// every row the owner ever recorded — `usage().remaining()` runs this before each metered
|
|
347
|
+
// call. The scope index needs the 0.18.0 ALTERs above on an older install.
|
|
348
|
+
await createIndex(db, dialect, 'billing_usage_subscription_meter_recorded_idx', 'billing_usage_events', 'subscription_id, meter, recorded_at');
|
|
349
|
+
await createIndex(db, dialect, 'billing_usage_customer_meter_recorded_idx', 'billing_usage_events', 'customer_id, meter, recorded_at');
|
|
350
|
+
await createIndex(db, dialect, 'billing_usage_scope_meter_recorded_idx', 'billing_usage_events', 'scope_type, scope_id, meter, recorded_at');
|
|
351
|
+
// The overview's read: every meter, one window, no owner.
|
|
352
|
+
await createIndex(db, dialect, 'billing_usage_recorded_meter_idx', 'billing_usage_events', 'recorded_at, meter');
|
|
353
|
+
// Each of these is a leading prefix of an index above, so it only costs writes.
|
|
354
|
+
await dropIndex(db, dialect, 'billing_usage_subscription_meter_idx', 'billing_usage_events');
|
|
355
|
+
await dropIndex(db, dialect, 'billing_usage_customer_meter_idx', 'billing_usage_events');
|
|
356
|
+
await dropIndex(db, dialect, 'billing_usage_scope_meter_idx', 'billing_usage_events');
|
|
357
|
+
// A payment's timeline, newest first. Also serves the `IS NULL` read over rows recorded
|
|
358
|
+
// before the column existed.
|
|
359
|
+
await createIndex(db, dialect, 'billing_webhook_events_payment_idx', 'billing_webhook_events', 'payment_gateway_id, created_at');
|
|
360
|
+
// What the console polls: newest-first pages with and without a status filter, the status
|
|
361
|
+
// counts over a creation window, and revenue over a settlement window.
|
|
362
|
+
await createIndex(db, dialect, 'billing_payments_status_created_idx', 'billing_payments', 'status, created_at');
|
|
363
|
+
await createIndex(db, dialect, 'billing_payments_created_idx', 'billing_payments', 'created_at');
|
|
364
|
+
await createIndex(db, dialect, 'billing_payments_status_paid_idx', 'billing_payments', 'status, paid_at');
|
|
365
|
+
await createIndex(db, dialect, 'billing_webhook_events_status_created_idx', 'billing_webhook_events', 'status, created_at');
|
|
366
|
+
await createIndex(db, dialect, 'billing_webhook_events_created_idx', 'billing_webhook_events', 'created_at');
|
|
367
|
+
await createIndex(db, dialect, 'billing_subscriptions_status_created_idx', 'billing_subscriptions', 'status, created_at');
|
|
324
368
|
// The renewal runner's working set: every tick asks "which managed subscriptions are due".
|
|
325
369
|
// Unindexed, that is a full scan of every subscription ever created, on a schedule.
|
|
326
370
|
await createIndex(db, dialect, 'billing_subscriptions_due_idx', 'billing_subscriptions', 'managed, status, next_charge_at');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/billing/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAgCH;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,mBAAmB;IACnB,uBAAuB;IACvB,kBAAkB;IAClB,wBAAwB;IACxB,kBAAkB;IAClB,sBAAsB;IACtB,sBAAsB;CACd,CAAC;AAEX,oEAAoE;AACpE,MAAM,UAAU,aAAa,CAAC,EAAiB;IAC7C,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC;QAChC,IAAI,OA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AC,OAAO,EAAE,EAAE,CAAC;QAClD,uFAAuF;QACvF,uFAAuF;QACvF,IAAI,CAAC;YACH,MAAM,EAAE,CAAC,QAAQ,CAAC,eAAe,KAAK,EAAE,CAAC,CAAC;QAC5C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC;gBAAE,MAAM,KAAK,CAAC;QAC/C,CAAC;IACH,CAAC;AACH,CAAC;AAED,wFAAwF;AACxF,SAAS,mBAAmB,CAAC,KAAc;IACzC,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACvE,OAAO,CACL,+EAA+E,CAAC,IAAI,CAAC,OAAO,CAAC;QAC7F,wDAAwD;QACvD,KAA2B,EAAE,IAAI,KAAK,OAAO;QAC7C,KAA4B,EAAE,KAAK,KAAK,IAAI,CAC9C,CAAC;AACJ,CAAC"}
|
|
@@ -59,7 +59,11 @@ export interface WebhookDispatcherOptions {
|
|
|
59
59
|
* — which is exactly what `'auto'` selects — that was every webhook, forever.
|
|
60
60
|
*/
|
|
61
61
|
export interface DurableEngineLike {
|
|
62
|
-
register(name: string, version: string, fn: (ctx: unknown, input: never) => Promise<void
|
|
62
|
+
register(name: string, version: string, fn: (ctx: unknown, input: never) => Promise<void>,
|
|
63
|
+
/** `origin` stamps every run with this package's name (durable >= 0.36; older engines ignore it). */
|
|
64
|
+
opts?: {
|
|
65
|
+
origin?: string;
|
|
66
|
+
}): void;
|
|
63
67
|
start(name: string, input: unknown, runId: string): Promise<unknown>;
|
|
64
68
|
}
|
|
65
69
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhook_dispatcher.d.ts","sourceRoot":"","sources":["../../../src/billing/webhook_dispatcher.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"webhook_dispatcher.d.ts","sourceRo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wB,MAAM,CAAC;AAE5C,iEAAiE;AACjE,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,YAAY,CAAC;IACpB,KAAK,EAAE,KAAK,CAAC;CACd;AAED;;;;;;GAMG;AACH,MAAM,WAAW,qBAAqB;IACpC,4CAA4C;IAC5C,KAAK,EAAE,MAAM,CAAC;IACd,yEAAyE;IACzE,UAAU,EAAE,MAAM,CAAC;IACnB,yEAAyE;IACzE,QAAQ,EAAE,sBAAsB,EAAE,CAAC;CACpC;AAED;;;;;GAKG;AACH,qBAAa,iBAAiB;;IAqB5B,YAAY,OAAO,EAAE,wBAAwB,EAQ5C;IAED;;;OAGG;IACG,QAAQ,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAG/D;IAED;;;;;;;;;;;;;;;;;;;;;OAqBG;IACG,WAAW,CAAC,MAAM,EAAE,YAAY,GAAG,YAAY,EAAE,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAiBvF;IA8BD,mDAAmD;IACnD,IAAI,IAAI,IAAI,mBAAmB,CAE9B;IA+GD;;;;;;;;;;;;;;;;;;;;OAoBG;IACG,aAAa,CAAC,OAAO,GAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAkBvE;CACF"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { PACKAGE_ORIGIN } from '../package_origin.js';
|
|
2
3
|
/**
|
|
3
4
|
* The durable workflow's identity. Stable and explicit: the engine registry is keyed by
|
|
4
5
|
* name, an in-flight run records the name+version it started on, and a name that changed
|
|
@@ -179,7 +180,7 @@ export class WebhookDispatcher {
|
|
|
179
180
|
engine.register(WEBHOOK_WORKFLOW_NAME, WEBHOOK_WORKFLOW_VERSION, async (_ctx, input) => {
|
|
180
181
|
this.#accepted = Math.max(0, this.#accepted - 1);
|
|
181
182
|
await this.#track(processor.process(input.event));
|
|
182
|
-
});
|
|
183
|
+
}, { origin: PACKAGE_ORIGIN });
|
|
183
184
|
this.#registered = true;
|
|
184
185
|
}
|
|
185
186
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhook_dispatcher.js","sourceRoot":"","sources":["../../../src/billing/webhook_dispatcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"webhook_dispatcher.js","sourceRoot":"","sources":["../../../src/billing/webhook_dispatcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AA2EtD;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,kBAAkB,CAAC;AACxD,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,CAAC;AAwB5C;;;;;GAKG;AACH,MAAM,OAAO,iBAAiB;IAC5B,UAAU,CAAmB;IAC7B,KAAK,CAAsB;IAC3B,YAAY,CAAS;IACrB,YAAY,CAAS;IACrB,WAAW,CAAS;IACpB,OAAO,CAAgC;IACvC,WAAW,GAAG,KAAK,CAAC;IACpB,eAAe,GAAG,KAAK,CAAC;IACxB,iBAAiB,CAAuC;IACxD,cAAc,CAAiD;IAC/D;;;;;;OAMG;IACH,SAAS,GAAG,CAAC,CAAC;IACd,SAAS,GAAG,IAAI,GAAG,EAAoB,CAAC;IAExC,YAAY,OAAiC;QAC3C,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,SAAS,CAAC;QACpC,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,IAAI,IAAI,MAAM,CAAC;QACpC,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;QAC9C,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,OAA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AAO,CAAC,MAAe;IAC9B,OAAO,MAAM,YAAY,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;AACtE,CAAC"}
|
|
@@ -107,12 +107,8 @@ export declare const SUBSCRIPTION_STATUSES: readonly ['past_due', 'paused', 'inc
|
|
|
107
107
|
* is about to lapse. Everything else can wait until tomorrow. */
|
|
108
108
|
export declare const SUBSCRIPTION_DEFAULT_STATUS = "past_due";
|
|
109
109
|
/**
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
* `BillingListQuery` filters on `status` only, so `?provider=` is applied here, over pages read
|
|
113
|
-
* from the store. That is bounded work by construction — but it has to be bounded VISIBLY: a
|
|
114
|
-
* silent "no Asaas payments" that really means "none in the last thousand rows" is the kind of
|
|
115
|
-
* wrong answer an operator acts on. `page.truncated` says which one they are looking at.
|
|
110
|
+
* @deprecated Nothing reads this. Every list applies `?provider=` in the store, so no page
|
|
111
|
+
* scans beyond the rows it returns and `meta.truncated` is always `false`.
|
|
116
112
|
*/
|
|
117
113
|
export declare const PROVIDER_SCAN_CAP = 1000;
|
|
118
114
|
/**
|
|
@@ -176,9 +172,9 @@ export declare function payments(deps: Deps, req: ApiRequest): Promise<ApiRespon
|
|
|
176
172
|
* - the row's CURRENT state, including `refundedAmount` and the app's own reference;
|
|
177
173
|
* - the app-side OWNER, through `billing_customers`;
|
|
178
174
|
* - every DISPUTE filed against it — that table does carry a real link (`payment_gateway_id`);
|
|
179
|
-
* - the LEDGER rows
|
|
180
|
-
*
|
|
181
|
-
* mentions the id. `events.matchedBy`
|
|
175
|
+
* - the LEDGER rows recorded for it, newest first — matched on the payment id each row keeps.
|
|
176
|
+
* Rows recorded before that column existed are matched by payload substring instead, which can
|
|
177
|
+
* include a delivery that merely mentions the id. `events.matchedBy` names the method.
|
|
182
178
|
* - the AUDIT rows naming it — who refunded it, from this console, and when.
|
|
183
179
|
*
|
|
184
180
|
* The stored payload is still never returned. The timeline says an event ARRIVED and what type it
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../../src/dashboard/handlers.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,YAAY,EAKlB,MAAM,6BAA6B,CAAC;AACrC,OAAO,
|
|
1
|
+
{"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../../src/dashboard/handlers.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,YAAY,EAKlB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,yBAAyB,EAAwB,MAAM,0BAA0B,CAAC;AAC3F,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAG/D;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,kDAAkD;AAClD,MAAM,WAAW,IAAI;IACnB,KAAK,EAAE,YAAY,CAAC;IACpB,gGAAgG;IAChG,QAAQ,EAAE,MAAM,CAAC;IACjB,8EAA8E;IAC9E,GAAG,CAAC,EAAE,MAAM,IAAI,CAAC;IACjB;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC;IACpC;;;;;;;;OAQG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;;;;OAOG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;CACrD;AAED,iEAAiE;AACjE,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,qFAAqF;IACrF,kBAAkB,EAAE,OAAO,CAAC;CAC7B;AAED,gEAAgE;AAChE,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,YAAY,CAAC;IACrB,aAAa,EAAE,YAAY,CAAC;CAC7B;AAED,uDAAuD;AACvD,MAAM,WAAW,UAAU;IACzB,oDAAoD;I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,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,WAAW,CAAC,CA8EtF;AAiCD;;;;;;;;;GASG;AACH,wBAAsB,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,WAAW,CAAC,CAwFrF;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,WAAW,CAAC,CAiDzF;AA6CD,qGAAqG;AACrG,OAAO,EAAE,yBAAyB,EAAE,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { billingHealth } from '../billing/billing_health.js';
|
|
2
2
|
import { billingOverview } from '../billing/billing_overview.js';
|
|
3
3
|
import { AUDIT_ACTIONS, OPEN_DISPUTE_STATUSES, } from '../billing/billing_store.js';
|
|
4
|
-
import { BILLING_LIST_DEFAULT_SIZE,
|
|
4
|
+
import { BILLING_LIST_DEFAULT_SIZE, clampPage, clampSize } from '../billing/list_query.js';
|
|
5
5
|
import { resolvePeriod } from './period.js';
|
|
6
6
|
/** A `200 OK` JSON response. Exported so sibling handlers share one convention. */
|
|
7
7
|
export const ok = (body) => ({ status: 200, body });
|
|
@@ -67,12 +67,8 @@ export const SUBSCRIPTION_DEFAULT_STATUS = 'past_due';
|
|
|
67
67
|
* yet, and a `refunded`/`canceled` one has none left to take. */
|
|
68
68
|
const REFUNDABLE_STATUS = 'paid';
|
|
69
69
|
/**
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
* `BillingListQuery` filters on `status` only, so `?provider=` is applied here, over pages read
|
|
73
|
-
* from the store. That is bounded work by construction — but it has to be bounded VISIBLY: a
|
|
74
|
-
* silent "no Asaas payments" that really means "none in the last thousand rows" is the kind of
|
|
75
|
-
* wrong answer an operator acts on. `page.truncated` says which one they are looking at.
|
|
70
|
+
* @deprecated Nothing reads this. Every list applies `?provider=` in the store, so no page
|
|
71
|
+
* scans beyond the rows it returns and `meta.truncated` is always `false`.
|
|
76
72
|
*/
|
|
77
73
|
export const PROVIDER_SCAN_CAP = 1000;
|
|
78
74
|
/** How far back `GET /providers` looks to learn which gateways this install actually uses. */
|
|
@@ -117,44 +113,12 @@ function iso(value) {
|
|
|
117
113
|
return value === null ? null : value.toISOString();
|
|
118
114
|
}
|
|
119
115
|
/**
|
|
120
|
-
* Read one page,
|
|
121
|
-
*
|
|
122
|
-
* With no `provider` this is a single store call and `truncated` is always `false`. With one, it
|
|
123
|
-
* walks the store in store-sized chunks, keeping matches, until it has filled the requested page,
|
|
124
|
-
* run out of rows, or hit {@link PROVIDER_SCAN_CAP}.
|
|
116
|
+
* Read one page. Every filter, `provider` included, is a column the store applies, so the page
|
|
117
|
+
* is complete by construction: `scanned` is the rows returned and `truncated` is always `false`.
|
|
125
118
|
*/
|
|
126
|
-
async function pageBy(fetch, paging
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
return { rows, scanned: rows.length, truncated: false };
|
|
130
|
-
}
|
|
131
|
-
// The scan walks the table in MAX-SIZE pages of its own — the requested page is a window over
|
|
132
|
-
// the matches, not over the rows, so the two page numbers are unrelated and the row offset of
|
|
133
|
-
// the window is computed here rather than asked of the store.
|
|
134
|
-
const skip = (paging.page - 1) * paging.size;
|
|
135
|
-
const wanted = skip + paging.size;
|
|
136
|
-
const matched = [];
|
|
137
|
-
let scanned = 0;
|
|
138
|
-
let scanPage = 1;
|
|
139
|
-
let exhausted = false;
|
|
140
|
-
while (matched.length < wanted && scanned < PROVIDER_SCAN_CAP && !exhausted) {
|
|
141
|
-
const rows = await fetch(BILLING_LIST_MAX_SIZE, scanPage);
|
|
142
|
-
scanned += rows.length;
|
|
143
|
-
scanPage += 1;
|
|
144
|
-
if (rows.length < BILLING_LIST_MAX_SIZE)
|
|
145
|
-
exhausted = true;
|
|
146
|
-
for (const row of rows) {
|
|
147
|
-
if (row.provider === provider)
|
|
148
|
-
matched.push(row);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
return {
|
|
152
|
-
rows: matched.slice(skip, wanted),
|
|
153
|
-
scanned,
|
|
154
|
-
// Only a scan that stopped SHORT is truncated. Filling the page or reaching the end of the
|
|
155
|
-
// table are both complete answers.
|
|
156
|
-
truncated: !exhausted && matched.length < wanted,
|
|
157
|
-
};
|
|
119
|
+
async function pageBy(fetch, paging) {
|
|
120
|
+
const rows = await fetch(paging.size, paging.page);
|
|
121
|
+
return { rows, scanned: rows.length, truncated: false };
|
|
158
122
|
}
|
|
159
123
|
/** The `meta` envelope every list endpoint echoes back, in the same `{ page, size }` terms the
|
|
160
124
|
* request used. `meta` is Lucid's own spelling for it (`.paginate()` answers `{ meta, data }`),
|
|
@@ -394,12 +358,13 @@ export async function payments(deps, req) {
|
|
|
394
358
|
const paging = pageOf(req);
|
|
395
359
|
const filtered = await pageBy((size, page) => deps.store.listPayments({
|
|
396
360
|
...(status !== undefined ? { status } : {}),
|
|
361
|
+
...(provider !== undefined ? { provider } : {}),
|
|
397
362
|
...(reference !== undefined ? { externalReference: reference } : {}),
|
|
398
363
|
...(gatewayId !== undefined ? { gatewayId } : {}),
|
|
399
364
|
...(customerId !== undefined ? { customerId } : {}),
|
|
400
365
|
size,
|
|
401
366
|
page,
|
|
402
|
-
}), paging
|
|
367
|
+
}), paging);
|
|
403
368
|
const owners = await ownersFor(deps.store, filtered.rows);
|
|
404
369
|
return ok({
|
|
405
370
|
payments: filtered.rows.map((row) => paymentJson(row, (row.customerId && owners.get(row.customerId)) || null, deps.capabilities)),
|
|
@@ -425,9 +390,9 @@ export async function payments(deps, req) {
|
|
|
425
390
|
* - the row's CURRENT state, including `refundedAmount` and the app's own reference;
|
|
426
391
|
* - the app-side OWNER, through `billing_customers`;
|
|
427
392
|
* - every DISPUTE filed against it — that table does carry a real link (`payment_gateway_id`);
|
|
428
|
-
* - the LEDGER rows
|
|
429
|
-
*
|
|
430
|
-
* mentions the id. `events.matchedBy`
|
|
393
|
+
* - the LEDGER rows recorded for it, newest first — matched on the payment id each row keeps.
|
|
394
|
+
* Rows recorded before that column existed are matched by payload substring instead, which can
|
|
395
|
+
* include a delivery that merely mentions the id. `events.matchedBy` names the method.
|
|
431
396
|
* - the AUDIT rows naming it — who refunded it, from this console, and when.
|
|
432
397
|
*
|
|
433
398
|
* The stored payload is still never returned. The timeline says an event ARRIVED and what type it
|
|
@@ -447,7 +412,7 @@ export async function paymentDetail(deps, req) {
|
|
|
447
412
|
}
|
|
448
413
|
const [owners, disputeRows, eventRows, auditRows] = await Promise.all([
|
|
449
414
|
ownersFor(deps.store, [row]),
|
|
450
|
-
deps.store.listDisputes({ size: PAYMENT_TIMELINE_LIMIT }),
|
|
415
|
+
deps.store.listDisputes({ paymentGatewayId: gatewayId, size: PAYMENT_TIMELINE_LIMIT }),
|
|
451
416
|
deps.store.listWebhookEventsForPayment(gatewayId, { size: PAYMENT_TIMELINE_LIMIT }),
|
|
452
417
|
deps.store.listAuditEvents({
|
|
453
418
|
subjectType: 'payment',
|
|
@@ -457,14 +422,13 @@ export async function paymentDetail(deps, req) {
|
|
|
457
422
|
]);
|
|
458
423
|
return ok({
|
|
459
424
|
payment: paymentJson(row, (row.customerId && owners.get(row.customerId)) || null, deps.capabilities),
|
|
460
|
-
// Filtered here
|
|
461
|
-
//
|
|
462
|
-
// this long on one install is itself the emergency.
|
|
425
|
+
// Filtered again here for a custom store that predates the `paymentGatewayId` filter: it
|
|
426
|
+
// returns every payment's disputes, and only this one's belong on the page.
|
|
463
427
|
disputes: disputeRows.filter((d) => d.paymentGatewayId === gatewayId).map(disputeJson),
|
|
464
428
|
events: {
|
|
465
429
|
rows: eventRows.map(webhookEventJson),
|
|
466
430
|
/** How the rows were found — see the note on `listWebhookEventsForPayment`. */
|
|
467
|
-
matchedBy: '
|
|
431
|
+
matchedBy: 'payment-gateway-id',
|
|
468
432
|
},
|
|
469
433
|
audit: auditRows.map(auditJson),
|
|
470
434
|
currency: deps.currency,
|
|
@@ -487,7 +451,12 @@ export async function subscriptions(deps, req) {
|
|
|
487
451
|
const status = filterQuery(req.query.status);
|
|
488
452
|
const provider = filterQuery(req.query.provider);
|
|
489
453
|
const paging = pageOf(req);
|
|
490
|
-
const filtered = await pageBy((size, page) => deps.store.listSubscriptions({
|
|
454
|
+
const filtered = await pageBy((size, page) => deps.store.listSubscriptions({
|
|
455
|
+
...(status !== undefined ? { status } : {}),
|
|
456
|
+
...(provider !== undefined ? { provider } : {}),
|
|
457
|
+
size,
|
|
458
|
+
page,
|
|
459
|
+
}), paging);
|
|
491
460
|
// The one number that makes the filter tabs worth reading: how many are past due IN TOTAL, not
|
|
492
461
|
// just on this page. Cheap — a single count — and it is the figure that decides the operator's
|
|
493
462
|
// morning.
|
|
@@ -549,10 +518,11 @@ export async function webhookEvents(deps, req) {
|
|
|
549
518
|
const paging = pageOf(req);
|
|
550
519
|
const filtered = await pageBy((size, page) => deps.store.listWebhookEvents({
|
|
551
520
|
...(status !== undefined ? { status } : {}),
|
|
521
|
+
...(provider !== undefined ? { provider } : {}),
|
|
552
522
|
...(type !== undefined ? { type } : {}),
|
|
553
523
|
size,
|
|
554
524
|
page,
|
|
555
|
-
}), paging
|
|
525
|
+
}), paging);
|
|
556
526
|
return ok({
|
|
557
527
|
events: filtered.rows.map(webhookEventJson),
|
|
558
528
|
meta: listMeta(paging, filtered),
|