Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/backend/src/config/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,8 @@ export const Config = {
false
),
cardServiceUrl: optional(envString, 'CARD_SERVICE_URL'),
posServiceUrl: optional(envString, 'POS_SERVICE_URL')
posServiceUrl: optional(envString, 'POS_SERVICE_URL'),
posWebhookServiceUrl: optional(envString, 'POS_WEBHOOK_SERVICE_URL')
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,7 @@ describe('Incoming Payment Service', (): void => {
'Creates webhook event for POS service if card payment',
withConfigOverride(
() => config,
{ posServiceUrl: faker.internet.url() },
{ posWebhookServiceUrl: faker.internet.url() },
async (): Promise<void> => {
await expect(
IncomingPaymentEvent.query(knex).where({
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/webhook/service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ describe('Webhook Service', (): void => {
'adds webhooks for POS service if event was for a card payment',
withConfigOverride(
() => config,
{ posServiceUrl: faker.internet.url() },
{ posWebhookServiceUrl: faker.internet.url() },
async (): Promise<void> => {
const tenantId = crypto.randomUUID()
expect(
Expand Down
9 changes: 7 additions & 2 deletions packages/backend/src/webhook/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,11 @@ async function processNextWebhook(

if (webhook.metadata?.sendToPosService) {
await sendWebhook(deps, webhook, {
webhookUrl: `${deps.config.posServiceUrl}/webhook`
webhookUrl:
deps.config.posWebhookServiceUrl ??
(deps.config.posServiceUrl
? `${deps.config.posServiceUrl}/webhook`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say, we can remove the fallback URL even. Might cause unexpected issues

: undefined)
})
} else {
const settings = await deps_.tenantSettingService.get({
Expand Down Expand Up @@ -316,7 +320,7 @@ export function finalizeWebhookRecipients(

if (
initiationReason === IncomingPaymentInitiationReason.Card &&
config.posServiceUrl
(config.posWebhookServiceUrl || config.posServiceUrl)
) {
recipients = recipients.concat([
{
Expand All @@ -328,6 +332,7 @@ export function finalizeWebhookRecipients(
])
} else if (
initiationReason === IncomingPaymentInitiationReason.Card &&
!config.posWebhookServiceUrl &&
!config.posServiceUrl
) {
logger?.warn('Could not create webhook recipient for point of sale service')
Expand Down
Loading