From c53d8b2c26e5e3e2884e128ed4eaf69b95bf336f Mon Sep 17 00:00:00 2001 From: Magnus Hagander Date: Mon, 27 Nov 2023 15:12:36 +0100 Subject: [PATCH] Don't attempt to return users to non-existant transfer When a registration transfer invoice is completed, if they payment confirmation notification hits before the user clicks onwards, we can't find the transfer record because it's been removed. In this case, just redirect the user back to the invoice so they get something other than a crash. --- postgresqleu/confreg/invoicehandler.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/postgresqleu/confreg/invoicehandler.py b/postgresqleu/confreg/invoicehandler.py index 033a5bd58..9a07a60a4 100644 --- a/postgresqleu/confreg/invoicehandler.py +++ b/postgresqleu/confreg/invoicehandler.py @@ -333,7 +333,10 @@ def get_return_url(self, invoice): try: pending = RegistrationTransferPending.objects.get(pk=invoice.processorid) except RegistrationTransferPending.DoesNotExist: - raise Exception("Could not find pending transfer: %s!" % invoice.processorid) + # We can't find the transfer - that could be because it's successfully completed, + # at which point the reservation may be canceled. So in this case, we just redirect + # the user back to their invoice, because we have to send them somewhere. + return "{}/invoices/{}/".format(settings.SITEBASE, invoice.recipient_secret) return "{}/events/{}/".format(settings.SITEBASE, pending.conference.urlname)