loop over invoices to check if they expired

This commit is contained in:
Thomas Steen Rasmussen 2017-06-20 00:13:37 +02:00
parent 3010033b75
commit cc874cdbb8

View file

@ -536,15 +536,16 @@ class CoinifyRedirectView(LoginRequiredMixin, EnsureUserOwnsOrderMixin, EnsureUn
order = self.get_object() order = self.get_object()
# check if we already have a coinifyinvoice for this order # check if we already have a coinifyinvoice for this order
if hasattr(order, 'coinifyapiinvoice'): if order.coinify_api_invoices.exists():
# we already have a coinifyinvoice for this order, check if it expired coinifyinvoice = None
if order.coinifyapiinvoice.expired: for tempinvoice in order.coinify_api_invoices.all():
# this coinifyinvoice expired, we need a new one # we already have a coinifyinvoice for this order, check if it expired
logger.warning("coinifyinvoice id %s expired" % order.coinifyapiinvoice.invoicejson['id']) if not coinifyinvoice.expired:
order.coinifyapiinvoice = None coinifyinvoice = tempinvoice
break
# create a new coinify invoice if needed # create a new coinify invoice if needed
if not hasattr(order, 'coinifyapiinvoice'): if not coinifyinvoice:
coinifyinvoice = create_coinify_invoice(order, request) coinifyinvoice = create_coinify_invoice(order, request)
if not coinifyinvoice: if not coinifyinvoice:
messages.error(request, "There was a problem with the payment provider. Please try again later") messages.error(request, "There was a problem with the payment provider. Please try again later")