def sanity_check(self):
        try:
            self.order = Order.objects.from_request(self.request)
            
        except Order.DoesNotExist:
            url = urlresolvers.reverse('satchmo_checkout-step1')
            self.invalidate(HttpResponseRedirect(url))
            return False

        try:
            self.cart = Cart.objects.from_request(self.request)
            if self.cart.numItems == 0 and not self.order.is_partially_paid:
                template = self.lookup_template('EMPTY_CART')
                self.invalidate(render_to_response(template,
                                                   context_instance=RequestContext(self.request)))
                return False
                
        except Cart.DoesNotExist:
            template = self.lookup_template('EMPTY_CART')
            self.invalidate(render_to_response(template,
                                               context_instance=RequestContext(self.request)))
            return False

        # Check if the order is still valid
        if not self.order.validate(self.request):
            context = RequestContext(self.request, 
                {'message': _('Your order is no longer valid.')})
            self.invalidate(render_to_response(self.templates['404'],
                                               context_instance=context))

        self.valid = True
        signals.confirm_sanity_check.send(self, controller=self)
        return True
Ensure we have a valid cart and order.
dataset/ETHPy150Open dokterbob/satchmo/satchmo/apps/payment/views/confirm.py/ConfirmController.sanity_check