Skip to content

Commit 42ae225

Browse files
fix: align amountPaid and test missing OPENNODE_API_KEY
1 parent 5cc207c commit 42ae225

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

src/controllers/callbacks/opennode-callback-controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ export class OpenNodeCallbackController implements IController {
120120
id: updatedInvoice.id,
121121
pubkey: updatedInvoice.pubkey,
122122
status: updatedInvoice.status,
123-
amountPaid: updatedInvoice.amountRequested,
123+
amountPaid: updatedInvoice.amountPaid,
124124
confirmedAt: updatedInvoice.confirmedAt,
125125
})
126126
await this.paymentsService.sendInvoiceUpdateNotification(updatedInvoice)

test/unit/controllers/callbacks/opennode-callback-controller.spec.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,22 @@ describe('OpenNodeCallbackController', () => {
114114
expect(updateInvoiceStatusStub).not.to.have.been.called
115115
})
116116

117+
it('returns internal server error when OPENNODE_API_KEY is missing', async () => {
118+
delete process.env.OPENNODE_API_KEY
119+
request.body = {
120+
hashed_order: 'some-hash',
121+
id: 'invoice-id',
122+
status: 'paid',
123+
}
124+
125+
await controller.handleRequest(request, response)
126+
127+
expect(statusStub).to.have.been.calledOnceWithExactly(500)
128+
expect(setHeaderStub).to.have.been.calledOnceWithExactly('content-type', 'text/plain; charset=utf8')
129+
expect(sendStub).to.have.been.calledOnceWithExactly('Internal Server Error')
130+
expect(updateInvoiceStatusStub).not.to.have.been.called
131+
})
132+
117133
it('rejects callbacks with mismatched hashed_order', async () => {
118134
request.body = {
119135
hashed_order: 'invalid',

0 commit comments

Comments
 (0)