# Path: src/cybersource/constants.py
# DECISION_REVIEW = "REVIEW"
# 
# DECISION_ACCEPT = "ACCEPT"


from unittest import skipUnless, mock
from decimal import Decimal as D
from django.conf import settings
from django.core import mail
from django.urls import reverse
from django.utils import timezone
from django.utils.crypto import get_random_string
from oscar.core.loading import get_model
from oscar.test import factories
from rest_framework import status
from rest_framework.test import APITestCase
from cybersource.models import CyberSourceReply
from ..constants import DECISION_REVIEW, DECISION_ACCEPT
from . import factories as cs_factories
import datetime
import uuid
DO_SOAP = settings.CYBERSOURCE_SOAP_KEY and settings.CYBERSOURCE_MERCHANT_ID


# Mock cybersource.methods.Bluefin.log_soap_response with this
def mock_log_soap_response(request, order, response):
    # convert Mock object to dict, as the real method converts a sudsobject to dict
    response = {
        "decision": response.decision,
        "merchantReferenceCode": response.merchantReferenceCode,
    }

    response["req_reference_number"] = response.get("merchantReferenceCode", "")

    log = CyberSourceReply(
        user=request.user if request.user.is_authenticated else None,
        order=order,
        reply_type=CyberSourceReply.REPLY_TYPE_SA,
        data=response,
        auth_avs_code=response.get("auth_avs_code"),
        auth_code=response.get("auth_code"),
        auth_response=response.get("auth_response"),
        auth_trans_ref_no=response.get("auth_trans_ref_no"),
        decision=response.get("decision"),
        message=response.get("message"),
        reason_code=response.get("reason_code"),
        req_bill_to_address_postal_code=response.get("req_bill_to_address_postal_code"),
        req_bill_to_forename=response.get("req_bill_to_forename"),
        req_bill_to_surname=response.get("req_bill_to_surname"),
        req_card_expiry_date=response.get("req_card_expiry_date"),
        req_reference_number=response.get("req_reference_number"),

# Path: src/cybersource/constants.py
# DECISION_REVIEW = "REVIEW"
# 
# DECISION_ACCEPT = "ACCEPT"


# Path: src/cybersource/tests/test_checkout.py
from unittest import skipUnless, mock
from decimal import Decimal as D
from django.conf import settings
from django.core import mail
from django.urls import reverse
from django.utils import timezone
from django.utils.crypto import get_random_string
from oscar.core.loading import get_model
from oscar.test import factories
from rest_framework import status
from rest_framework.test import APITestCase
from cybersource.models import CyberSourceReply
from ..constants import DECISION_REVIEW, DECISION_ACCEPT
from . import factories as cs_factories
import datetime
import uuid

DO_SOAP = settings.CYBERSOURCE_SOAP_KEY and settings.CYBERSOURCE_MERCHANT_ID


# Mock cybersource.methods.Bluefin.log_soap_response with this
def mock_log_soap_response(request, order, response):
    # convert Mock object to dict, as the real method converts a sudsobject to dict
    response = {
        "decision": response.decision,
        "merchantReferenceCode": response.merchantReferenceCode,
    }

    response["req_reference_number"] = response.get("merchantReferenceCode", "")

    log = CyberSourceReply(
        user=request.user if request.user.is_authenticated else None,
        order=order,
        reply_type=CyberSourceReply.REPLY_TYPE_SA,
        data=response,
        auth_avs_code=response.get("auth_avs_code"),
        auth_code=response.get("auth_code"),
        auth_response=response.get("auth_response"),
        auth_trans_ref_no=response.get("auth_trans_ref_no"),
        decision=response.get("decision"),
        message=response.get("message"),
        reason_code=response.get("reason_code"),
        req_bill_to_address_postal_code=response.get("req_bill_to_address_postal_code"),
        req_bill_to_forename=response.get("req_bill_to_forename"),
        req_bill_to_surname=response.get("req_bill_to_surname"),
        req_card_expiry_date=response.get("req_card_expiry_date"),
        req_reference_number=response.get("req_reference_number"),

        req_transaction_type=response.get("req_transaction_type"),