Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 5 additions & 0 deletions .changeset/callback-check-payments-enabled.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"nostream": patch
---

fix: check payments.enabled in callback route middleware
2 changes: 1 addition & 1 deletion src/routes/callbacks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const router: Router = Router()
const requireProcessor = (name: string) =>
(_req: Request, res: Response, next: NextFunction) => {
const settings = createSettings()
if (settings.payments?.processor !== name) {
if (!settings.payments?.enabled || settings.payments.processor !== name) {
res.status(403).send('Forbidden')
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,17 @@ Given('OpenNode callback processing is enabled', function () {
...settings,
payments: {
...(settings?.payments ?? {}),
enabled: true,
processor: 'opennode',
},
paymentsProcessors: {
...(settings?.paymentsProcessors ?? {}),
opennode: {
...(settings?.paymentsProcessors?.opennode ?? {}),
baseURL: 'api.opennode.com',
callbackBaseURL: 'http://localhost:18808/callbacks/opennode',
},
},
}

process.env.OPENNODE_API_KEY = OPENNODE_TEST_API_KEY
Expand Down
2 changes: 1 addition & 1 deletion test/unit/routes/callbacks.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('callbacks router', () => {
receivedBody = undefined

createSettingsStub = Sinon.stub(settingsFactory, 'createSettings').returns({
payments: { processor: 'opennode' },
payments: { enabled: true, processor: 'opennode' },
} as any)

createOpenNodeCallbackControllerStub = Sinon.stub(openNodeControllerFactory, 'createOpenNodeCallbackController').returns({
Expand Down
Loading