Skip to content

Commit

Permalink
feat(incoming-payment): error log
Browse files Browse the repository at this point in the history
  • Loading branch information
golobitch committed Aug 14, 2024
1 parent ea46b1e commit f39d329
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ describe('Incoming Payment Service', (): void => {
expect(approvedIncomingPayment.approvedAt).toBeDefined()
expect(!approvedIncomingPayment.cancelledAt).toBeTruthy()
expect(approvedIncomingPayment.cancelledAt).toBeFalsy()
})
})

describe('cancelIncomingPayment', (): void => {
Expand Down
15 changes: 14 additions & 1 deletion packages/backend/src/open_payments/payment/incoming/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,22 @@ async function createIncomingPayment(
timeoutMs: deps.config.incomingPaymentCreatedPollTimeout
})

if (response) return response
if (response?.cancelledAt) {
deps.logger.error(
{ cancelledAt: response.cancelledAt.toISOString() },
'Incoming payment was cancelled'
)
return IncomingPaymentError.ActionNotPerformed
}

if (response?.approvedAt) return response
return IncomingPaymentError.ActionNotPerformed
} catch (err) {
const errorMessage = 'Got error / timeout while polling incoming payment'
deps.logger.error(
{ errorMessage: err instanceof Error && err.message },
errorMessage
)
return IncomingPaymentError.ActionNotPerformed
}
}
Expand Down

0 comments on commit f39d329

Please sign in to comment.