'Method to "retire" orders that have gone through to the payment service
but have (erroneously) not had their statuses updated.
This method only works on orders that satisfy the following conditions:
1) the order status is either "cart" or "paying" (otherwise we raise
an InvalidStatusToRetire error)
2) the order\'s order item\'s statuses match the order\'s status (otherwise
we throw an UnexpectedOrderItemStatus error)'

def retire(self):

    if (self.status in ORDER_STATUS_MAP.values()):
        return
    if (self.status not in ORDER_STATUS_MAP.keys()):
        raise InvalidStatusToRetire("order    status    {order_status}    is    not    'paying'    or    'cart'".format(order_status=self.status))
    for item in self.orderitem_set.all():
        if (item.status != self.status):
            raise UnexpectedOrderItemStatus('order_item    status    is    different    from    order    status')
    self.status = ORDER_STATUS_MAP[self.status]
    self.save()
    for item in self.orderitem_set.all():
        item.retire()
