# Path: src/oscarapicheckout/settings.py
# ORDER_STATUS_AUTHORIZED = overridable("ORDER_STATUS_AUTHORIZED", "Authorized")
# 
# ORDER_STATUS_PAYMENT_DECLINED = overridable(
#     "ORDER_STATUS_PAYMENT_DECLINED", "Payment Declined"
# )
# 
# Path: src/oscarapicheckout/signals.py

# 
# Path: src/oscarapicheckout/states.py
# COMPLETE = "Complete"
# 
# DECLINED = "Declined"
# 
# CONSUMED = "Consumed"
# 
# class Complete(SourceBoundPaymentStatus):
#     status = COMPLETE
# 
# class Declined(SourceBoundPaymentStatus):
#     status = DECLINED
# 
# class Consumed(SourceBoundPaymentStatus):
#     status = CONSUMED


from decimal import Decimal
from django.db.models import F
from django.utils.translation import gettext_lazy as _
from oscar.core.loading import get_class, get_model
from oscarapi.basket import operations
from .settings import ORDER_STATUS_AUTHORIZED, ORDER_STATUS_PAYMENT_DECLINED
from .signals import order_payment_declined, order_payment_authorized
from .states import COMPLETE, DECLINED, CONSUMED, Complete, Declined, Consumed
import pickle
import base64
        voucher = voucher_application.voucher

        parent = getattr(voucher, "parent", None)
        if parent:
            parent.num_orders = F("num_orders") - 1
            parent.save(update_children=False)

        voucher.num_orders = F("num_orders") - 1
        voucher.save()

    # Delete some related objects
    order.discounts.all().delete()
    order.line_prices.all().delete()
    voucher_applications.delete()

    # Thaw the basket and put it back into the request.session so that it can be retried
    order.basket.thaw()
    operations.store_basket_in_session(order.basket, request.session)

    # Send a signal
    order_payment_declined.send(sender=order, order=order, request=request)


def _update_order_status(order, request):
    states = list_payment_method_states(request)

    declined = [s for k, s in states.items() if s.status == DECLINED]
    if len(declined) > 0:
        _set_order_payment_declined(order, request)


# Path: src/oscarapicheckout/settings.py
# ORDER_STATUS_AUTHORIZED = overridable("ORDER_STATUS_AUTHORIZED", "Authorized")
# 
# ORDER_STATUS_PAYMENT_DECLINED = overridable(
#     "ORDER_STATUS_PAYMENT_DECLINED", "Payment Declined"
# )
# 
# Path: src/oscarapicheckout/signals.py

# 
# Path: src/oscarapicheckout/states.py
# COMPLETE = "Complete"
# 
# DECLINED = "Declined"
# 
# CONSUMED = "Consumed"
# 
# class Complete(SourceBoundPaymentStatus):
#     status = COMPLETE
# 
# class Declined(SourceBoundPaymentStatus):
#     status = DECLINED
# 
# class Consumed(SourceBoundPaymentStatus):
#     status = CONSUMED


# Path: src/oscarapicheckout/utils.py
from decimal import Decimal
from django.db.models import F
from django.utils.translation import gettext_lazy as _
from oscar.core.loading import get_class, get_model
from oscarapi.basket import operations
from .settings import ORDER_STATUS_AUTHORIZED, ORDER_STATUS_PAYMENT_DECLINED
from .signals import order_payment_declined, order_payment_authorized
from .states import COMPLETE, DECLINED, CONSUMED, Complete, Declined, Consumed
import pickle
import base64

        voucher = voucher_application.voucher

        parent = getattr(voucher, "parent", None)
        if parent:
            parent.num_orders = F("num_orders") - 1
            parent.save(update_children=False)

        voucher.num_orders = F("num_orders") - 1
        voucher.save()

    # Delete some related objects
    order.discounts.all().delete()
    order.line_prices.all().delete()
    voucher_applications.delete()

    # Thaw the basket and put it back into the request.session so that it can be retried
    order.basket.thaw()
    operations.store_basket_in_session(order.basket, request.session)

    # Send a signal
    order_payment_declined.send(sender=order, order=order, request=request)


def _update_order_status(order, request):
    states = list_payment_method_states(request)

    declined = [s for k, s in states.items() if s.status == DECLINED]
    if len(declined) > 0:
        _set_order_payment_declined(order, request)


    not_complete = [s for k, s in states.items() if s.status != COMPLETE]