# Path: src/cybersource/constants.py
# DECISION_ACCEPT = "ACCEPT"
# 
# DECISION_REVIEW = "REVIEW"
# 
# DECISION_DECLINE = "DECLINE"
# 
# DECISION_ERROR = "ERROR"


from cryptography.fernet import InvalidToken
from django.conf import settings
from django.db import models
from django.contrib.postgres.fields import HStoreField
from django.utils.translation import gettext_lazy as _
from django.utils import timezone
from oscar.core.compat import AUTH_USER_MODEL
from oscar.models.fields import NullCharField
from fernet_fields import EncryptedTextField
from .constants import (
    DECISION_ACCEPT,
    DECISION_REVIEW,
    DECISION_DECLINE,
    DECISION_ERROR,
)
import dateutil.parser
import logging

    # Timestamps
    date_modified = models.DateTimeField(_("Date Modified"), auto_now=True)
    date_created = models.DateTimeField(_("Date Received"), auto_now_add=True)

    class Meta:
        verbose_name = _("CyberSource Reply")
        verbose_name_plural = _("CyberSource Replies")
        ordering = ("date_created",)

    def __str__(self):
        return _("CyberSource Reply %(created)s") % dict(created=self.date_created)

    @property
    def signed_date_time(self):
        try:
            return dateutil.parser.parse(self.data["signed_date_time"])
        except (AttributeError, ValueError, KeyError):
            return self.date_created

    def get_decision(self):
        # Accept
        if self.reason_code in (100,):
            return DECISION_ACCEPT

        # Review
        if self.reason_code in (201, 480):
            return DECISION_REVIEW

        # Rejections

# Path: src/cybersource/constants.py
# DECISION_ACCEPT = "ACCEPT"
# 
# DECISION_REVIEW = "REVIEW"
# 
# DECISION_DECLINE = "DECLINE"
# 
# DECISION_ERROR = "ERROR"


# Path: src/cybersource/models.py
from cryptography.fernet import InvalidToken
from django.conf import settings
from django.db import models
from django.contrib.postgres.fields import HStoreField
from django.utils.translation import gettext_lazy as _
from django.utils import timezone
from oscar.core.compat import AUTH_USER_MODEL
from oscar.models.fields import NullCharField
from fernet_fields import EncryptedTextField
from .constants import (
    DECISION_ACCEPT,
    DECISION_REVIEW,
    DECISION_DECLINE,
    DECISION_ERROR,
)
import dateutil.parser
import logging


    # Timestamps
    date_modified = models.DateTimeField(_("Date Modified"), auto_now=True)
    date_created = models.DateTimeField(_("Date Received"), auto_now_add=True)

    class Meta:
        verbose_name = _("CyberSource Reply")
        verbose_name_plural = _("CyberSource Replies")
        ordering = ("date_created",)

    def __str__(self):
        return _("CyberSource Reply %(created)s") % dict(created=self.date_created)

    @property
    def signed_date_time(self):
        try:
            return dateutil.parser.parse(self.data["signed_date_time"])
        except (AttributeError, ValueError, KeyError):
            return self.date_created

    def get_decision(self):
        # Accept
        if self.reason_code in (100,):
            return DECISION_ACCEPT

        # Review
        if self.reason_code in (201, 480):
            return DECISION_REVIEW

        # Rejections

        if self.reason_code in (