Skip to content

Commit 7002c47

Browse files
authored
feat(backend): add custom webhook URL for POS (#3628)
* feat(backend): add custom webhook URL for POS * fix(backend): remove fallback webhook URL for POS
1 parent a99c9af commit 7002c47

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

packages/backend/src/config/app.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,8 @@ export const Config = {
204204
false
205205
),
206206
cardServiceUrl: optional(envString, 'CARD_SERVICE_URL'),
207-
posServiceUrl: optional(envString, 'POS_SERVICE_URL')
207+
posServiceUrl: optional(envString, 'POS_SERVICE_URL'),
208+
posWebhookServiceUrl: optional(envString, 'POS_WEBHOOK_SERVICE_URL')
208209
}
209210

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

packages/backend/src/open_payments/payment/incoming/service.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -896,7 +896,7 @@ describe('Incoming Payment Service', (): void => {
896896
'Creates webhook event for POS service if card payment',
897897
withConfigOverride(
898898
() => config,
899-
{ posServiceUrl: faker.internet.url() },
899+
{ posWebhookServiceUrl: faker.internet.url() },
900900
async (): Promise<void> => {
901901
await expect(
902902
IncomingPaymentEvent.query(knex).where({

packages/backend/src/webhook/service.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ describe('Webhook Service', (): void => {
699699
'adds webhooks for POS service if event was for a card payment',
700700
withConfigOverride(
701701
() => config,
702-
{ posServiceUrl: faker.internet.url() },
702+
{ posWebhookServiceUrl: faker.internet.url() },
703703
async (): Promise<void> => {
704704
const tenantId = crypto.randomUUID()
705705
expect(

packages/backend/src/webhook/service.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ async function processNextWebhook(
168168

169169
if (webhook.metadata?.sendToPosService) {
170170
await sendWebhook(deps, webhook, {
171-
webhookUrl: `${deps.config.posServiceUrl}/webhook`
171+
webhookUrl: deps.config.posWebhookServiceUrl
172172
})
173173
} else {
174174
const settings = await deps_.tenantSettingService.get({
@@ -316,7 +316,7 @@ export function finalizeWebhookRecipients(
316316

317317
if (
318318
initiationReason === IncomingPaymentInitiationReason.Card &&
319-
config.posServiceUrl
319+
config.posWebhookServiceUrl
320320
) {
321321
recipients = recipients.concat([
322322
{
@@ -328,7 +328,7 @@ export function finalizeWebhookRecipients(
328328
])
329329
} else if (
330330
initiationReason === IncomingPaymentInitiationReason.Card &&
331-
!config.posServiceUrl
331+
!config.posWebhookServiceUrl
332332
) {
333333
logger?.warn('Could not create webhook recipient for point of sale service')
334334
}

0 commit comments

Comments
 (0)