# 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
    pickled = base64.standard_b64decode(base64ed)
    obj = pickle.loads(pickled)
    return obj


def _update_payment_method_state(request, method_key, state):
    states = request.session.get(CHECKOUT_PAYMENT_STEPS, {})
    states[method_key] = _session_pickle(state)
    request.session[CHECKOUT_PAYMENT_STEPS] = states
    request.session.modified = True


def _set_order_authorized(order, request):
    # Set the order status
    order.set_status(ORDER_STATUS_AUTHORIZED)

    # Mark the basket as submitted
    order.basket.submit()

    # Update the owner of the basket to match the order
    if order.user != order.basket.owner:
        order.basket.owner = order.user
        order.basket.save()

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


def _set_order_payment_declined(order, request):
    # Set the order status

# 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

    pickled = base64.standard_b64decode(base64ed)
    obj = pickle.loads(pickled)
    return obj


def _update_payment_method_state(request, method_key, state):
    states = request.session.get(CHECKOUT_PAYMENT_STEPS, {})
    states[method_key] = _session_pickle(state)
    request.session[CHECKOUT_PAYMENT_STEPS] = states
    request.session.modified = True


def _set_order_authorized(order, request):
    # Set the order status
    order.set_status(ORDER_STATUS_AUTHORIZED)

    # Mark the basket as submitted
    order.basket.submit()

    # Update the owner of the basket to match the order
    if order.user != order.basket.owner:
        order.basket.owner = order.user
        order.basket.save()

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


def _set_order_payment_declined(order, request):
    # Set the order status

    order.set_status(ORDER_STATUS_PAYMENT_DECLINED)