Skip to content

Commit

Permalink
Fix crash when check-invoice is called when there is no invoice
Browse files Browse the repository at this point in the history
During test and development of website improvements I noticed that
calling the endpoint to check-invoice when there is no invoice or
checkout object would cause a crash.

This commit fixes this

Testing: Performing hot-reloading of checkout page in the same
preconditions that triggered the bug. Also, reran automated tests to
ensure there are no regressions

Signed-off-by: Daniel D’Aquino <[email protected]>
  • Loading branch information
danieldaquino committed Mar 2, 2024
1 parent 680031a commit 951c46d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/invoicing.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class PurpleInvoiceManager {
// Checks the status of the invoice associated with the given checkout object directly with the LN node, and handles successful payments.
async check_checkout_object_invoice(checkout_id) {
const checkout_object = await this.get_checkout_object(checkout_id)
if (checkout_object.invoice) {
if (checkout_object?.invoice) {
checkout_object.invoice.paid = await this.check_invoice_is_paid(checkout_object.invoice.label)
if (checkout_object.invoice.paid) {
this.handle_successful_payment(checkout_object.invoice.bolt11)
Expand Down

0 comments on commit 951c46d

Please sign in to comment.