Skip to content

Commit 6a457f4

Browse files
authored
feat(backend): additional webhook events for outgoing payments (#3651)
* feat(backend): add additional webhook events for outgoing payments * feat(backend): update webhook recipients logic * chore(backend): extract funded and cancelled events into a new type * chore(backend): move IncomingPaymentInitiationReason to separate file * chore(backend): simplify webhook recipients logic
1 parent 3be9ecf commit 6a457f4

File tree

28 files changed

+892
-261
lines changed

28 files changed

+892
-261
lines changed

localenv/mock-account-servicing-entity/generated/graphql.ts

Lines changed: 15 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/**
2+
* @param { import("knex").Knex } knex
3+
* @returns { Promise<void> }
4+
*/
5+
exports.up = async function (knex) {
6+
const hasColumn = await knex.schema.hasColumn(
7+
'outgoingPaymentCardDetails',
8+
'requestId'
9+
)
10+
if (!hasColumn) {
11+
await knex.schema.alterTable(
12+
'outgoingPaymentCardDetails',
13+
function (table) {
14+
table.string('requestId').notNullable()
15+
}
16+
)
17+
}
18+
}
19+
20+
/**
21+
* @param { import("knex").Knex } knex
22+
* @returns { Promise<void> }
23+
*/
24+
exports.down = async function (knex) {
25+
const hasColumn = await knex.schema.hasColumn(
26+
'outgoingPaymentCardDetails',
27+
'requestId'
28+
)
29+
if (hasColumn) {
30+
await knex.schema.alterTable(
31+
'outgoingPaymentCardDetails',
32+
function (table) {
33+
table.dropColumn('requestId')
34+
}
35+
)
36+
}
37+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* @param { import("knex").Knex } knex
3+
* @returns { Promise<void> }
4+
*/
5+
exports.up = function (knex) {
6+
return knex.schema
7+
.alterTable('outgoingPayments', function (table) {
8+
table.enum('initiatedBy', ['CARD', 'OPEN_PAYMENTS', 'ADMIN'])
9+
})
10+
.then(() => {
11+
return Promise.all([
12+
knex.raw(
13+
`UPDATE "outgoingPayments" SET "initiatedBy" = 'OPEN_PAYMENTS' WHERE "grantId" IS NOT NULL`
14+
),
15+
knex.raw(
16+
`UPDATE "outgoingPayments" SET "initiatedBy" = 'ADMIN' WHERE "grantId" IS NULL`
17+
)
18+
])
19+
})
20+
.then(() => {
21+
return knex.raw(
22+
`ALTER TABLE "outgoingPayments" ALTER COLUMN "initiatedBy" SET NOT NULL`
23+
)
24+
})
25+
}
26+
27+
/**
28+
* @param { import("knex").Knex } knex
29+
* @returns { Promise<void> }
30+
*/
31+
exports.down = function (knex) {
32+
return knex.schema.alterTable('outgoingPayments', function (table) {
33+
table.dropColumn('initiatedBy')
34+
})
35+
}

packages/backend/src/asset/model.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ export class Asset extends BaseModel implements LiquidityAccount {
5151
balance
5252
},
5353
tenantId: this.tenantId,
54-
webhooks: finalizeWebhookRecipients([this.tenantId], config)
54+
webhooks: finalizeWebhookRecipients(
55+
{ tenantIds: [this.tenantId] },
56+
config
57+
)
5558
})
5659
}
5760
}

packages/backend/src/config/app.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,8 @@ export const Config = {
205205
),
206206
cardServiceUrl: optional(envString, 'CARD_SERVICE_URL'),
207207
posServiceUrl: optional(envString, 'POS_SERVICE_URL'),
208-
posWebhookServiceUrl: optional(envString, 'POS_WEBHOOK_SERVICE_URL')
208+
posWebhookServiceUrl: optional(envString, 'POS_WEBHOOK_SERVICE_URL'),
209+
cardWebhookUrl: optional(envString, 'CARD_WEBHOOK_SERVICE_URL')
209210
}
210211

211212
// eslint-disable-next-line @typescript-eslint/no-explicit-any

packages/backend/src/graphql/generated/graphql.schema.json

Lines changed: 80 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/backend/src/graphql/generated/graphql.ts

Lines changed: 15 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)