From af2e77c83ffcad2412335c3807938aa5894d6ce4 Mon Sep 17 00:00:00 2001 From: James Kachel Date: Wed, 28 Feb 2024 15:19:45 -0600 Subject: [PATCH] adding some constants that got missed --- unified_ecommerce/constants.py | 128 +++++++++++++++++++++++++++++++-- 1 file changed, 124 insertions(+), 4 deletions(-) diff --git a/unified_ecommerce/constants.py b/unified_ecommerce/constants.py index 96996529..beb9fc72 100644 --- a/unified_ecommerce/constants.py +++ b/unified_ecommerce/constants.py @@ -1,6 +1,45 @@ """Constants for ecommerce.""" # ruff: noqa: ERA001 +from mitol.payment_gateway.api import ProcessorResponse + +# Application constants + +USER_MSG_COOKIE_NAME = "user-message" +# Max age value = number of seconds +USER_MSG_COOKIE_MAX_AGE = 20 +USER_MSG_TYPE_ENROLLED = "enrolled" +USER_MSG_TYPE_ENROLL_FAILED = "enroll-failed" +USER_MSG_TYPE_ENROLL_BLOCKED = "enroll-blocked" +USER_MSG_TYPE_ENROLL_DUPLICATED = "enroll-duplicated" +USER_MSG_TYPE_COMPLETED_AUTH = "completed-auth" +USER_MSG_TYPE_COURSE_NON_UPGRADABLE = "course-non-upgradable" +USER_MSG_TYPE_DISCOUNT_INVALID = "discount-invalid" + +USER_MSG_TYPE_PAYMENT_DECLINED = "payment-declined" +USER_MSG_TYPE_PAYMENT_ERROR = "payment-error" +USER_MSG_TYPE_PAYMENT_CANCELLED = "payment-cancelled" +USER_MSG_TYPE_PAYMENT_REVIEW = "payment-review" +USER_MSG_TYPE_PAYMENT_ACCEPTED = "payment-accepted" +USER_MSG_TYPE_PAYMENT_ACCEPTED_NOVALUE = "payment-accepted-no-value" +USER_MSG_TYPE_PAYMENT_ERROR_UNKNOWN = "payment-error-unknown" + +DISALLOWED_CURRENCY_CUBAN_PESO = "CUP" +DISALLOWED_CURRENCY_CUBAN_PESO_CONVERTED = "CUC" +DISALLOWED_CURRENCY_IRANIAN_RIAL = "IRR" +DISALLOWED_CURRENCY_SYRIAN_POUND = "SYP" +DISALLOWED_CURRENCY_NORTH_KOREAN_WON = "KPW" + +DISALLOWED_CURRENCY_TYPES = [ + DISALLOWED_CURRENCY_CUBAN_PESO, + DISALLOWED_CURRENCY_CUBAN_PESO_CONVERTED, + DISALLOWED_CURRENCY_IRANIAN_RIAL, + DISALLOWED_CURRENCY_SYRIAN_POUND, + DISALLOWED_CURRENCY_NORTH_KOREAN_WON, +] + +# Discount constants + DISCOUNT_TYPE_PERCENT_OFF = "percent-off" DISCOUNT_TYPE_DOLLARS_OFF = "dollars-off" DISCOUNT_TYPE_FIXED_PRICE = "fixed-price" @@ -42,6 +81,8 @@ PAYMENT_TYPES = list(zip(ALL_PAYMENT_TYPES, ALL_PAYMENT_TYPES)) +# Transaction constants + TRANSACTION_TYPE_REFUND = "refund" TRANSACTION_TYPE_PAYMENT = "payment" @@ -75,9 +116,88 @@ "062": "China UnionPay", } -# REFUND_SUCCESS_STATES = [ -# ProcessorResponse.STATE_ACCEPTED, -# ProcessorResponse.STATE_PENDING, -# ] +REFUND_SUCCESS_STATES = [ + ProcessorResponse.STATE_ACCEPTED, + ProcessorResponse.STATE_PENDING, +] ZERO_PAYMENT_DATA = {"amount": 0, "data": {"reason": "No payment required"}} + +CYBERSOURCE_REASON_CODE_SUCCESS = 100 +CYBERSOURCE_REASON_CODE_MISSING_FIELDS = 101 +CYBERSOURCE_REASON_CODE_INVALID_DATA = 102 +CYBERSOURCE_REASON_CODE_DUPLICATE_TRANSACTION = 104 +CYBERSOURCE_REASON_CODE_PARTIAL_APPROVE = 110 +CYBERSOURCE_REASON_CODE_SYSTEM_FAILURE = 150 +CYBERSOURCE_REASON_CODE_SERVER_TIMEOUT = 151 +CYBERSOURCE_REASON_CODE_SERVICE_TIMEOUT = 152 +CYBERSOURCE_REASON_CODE_DECLINE_AVS_FAIL = 200 +CYBERSOURCE_REASON_CODE_DECLINE_VERBAL_AUTH = 201 +CYBERSOURCE_REASON_CODE_DECLINE_EXPIRED_CARD = 202 +CYBERSOURCE_REASON_CODE_DECLINE_DECLINED = 203 +CYBERSOURCE_REASON_CODE_DECLINE_NSF = 204 +CYBERSOURCE_REASON_CODE_DECLINE_CARD_STOLEN_LOST = 205 +CYBERSOURCE_REASON_CODE_DECLINE_ISSUING_UNAVAILALBE = 207 +CYBERSOURCE_REASON_CODE_DECLINE_CARD_INACTIVE = 208 +CYBERSOURCE_REASON_CODE_DECLINE_CARD_LIMIT = 210 +CYBERSOURCE_REASON_CODE_DECLINE_CVN_INVALID = 211 +CYBERSOURCE_REASON_CODE_DECLINE_NEGATIVE_FILE = 221 +CYBERSOURCE_REASON_CODE_DECLINE_ACCOUNT_FROZEN = 222 +CYBERSOURCE_REASON_CODE_DECLINE_CVN_FAILED = 230 +CYBERSOURCE_REASON_CODE_DECLINE_INVALID_ACCOUNT = 231 +CYBERSOURCE_REASON_CODE_DECLINE_CARD_TYPE_INVALID = 232 +CYBERSOURCE_REASON_CODE_DECLINE_GENERAL_DECLINE = 233 +CYBERSOURCE_REASON_CODE_DECLINE_ACCOUNT_INFORMATION_INCORRECT = 234 +CYBERSOURCE_REASON_CODE_DECLINE_PROCESSOR_FAILURE = 236 +CYBERSOURCE_REASON_CODE_DECLINE_CARD_TYPE_MISMATCH = 240 +CYBERSOURCE_REASON_CODE_PAYER_AUTHENTICATION = 475 +CYBERSOURCE_REASON_CODE_PAYER_AUTHENTICATION_FAILED = 476 +CYBERSOURCE_REASON_CODE_PAYER_AUTHENTICATION_SCA_REQUIRED = 478 +CYBERSOURCE_REASON_CODE_DECLINE_PROFILE_SETTINGS = 481 +CYBERSOURCE_REASON_CODE_DECLINE_DECISION_MANAGER = 520 + +CYBERSOURCE_ACCEPT_CODES = [ + CYBERSOURCE_REASON_CODE_SUCCESS, + CYBERSOURCE_REASON_CODE_PARTIAL_APPROVE, +] + +CYBERSOURCE_REVIEW_CODES = [ + CYBERSOURCE_REASON_CODE_DECLINE_AVS_FAIL, + CYBERSOURCE_REASON_CODE_DECLINE_VERBAL_AUTH, + CYBERSOURCE_REASON_CODE_DECLINE_CVN_FAILED, + CYBERSOURCE_REASON_CODE_DECLINE_DECISION_MANAGER, +] + +CYBERSOURCE_DECLINE_CODES = [ + CYBERSOURCE_REASON_CODE_INVALID_DATA, + CYBERSOURCE_REASON_CODE_DECLINE_AVS_FAIL, + CYBERSOURCE_REASON_CODE_DECLINE_EXPIRED_CARD, + CYBERSOURCE_REASON_CODE_DECLINE_DECLINED, + CYBERSOURCE_REASON_CODE_DECLINE_NSF, + CYBERSOURCE_REASON_CODE_DECLINE_CARD_STOLEN_LOST, + CYBERSOURCE_REASON_CODE_DECLINE_ISSUING_UNAVAILALBE, + CYBERSOURCE_REASON_CODE_DECLINE_CARD_INACTIVE, + CYBERSOURCE_REASON_CODE_DECLINE_CARD_LIMIT, + CYBERSOURCE_REASON_CODE_DECLINE_CVN_INVALID, + CYBERSOURCE_REASON_CODE_DECLINE_NEGATIVE_FILE, + CYBERSOURCE_REASON_CODE_DECLINE_ACCOUNT_FROZEN, + CYBERSOURCE_REASON_CODE_DECLINE_CVN_FAILED, + CYBERSOURCE_REASON_CODE_DECLINE_INVALID_ACCOUNT, + CYBERSOURCE_REASON_CODE_DECLINE_CARD_TYPE_INVALID, + CYBERSOURCE_REASON_CODE_DECLINE_GENERAL_DECLINE, + CYBERSOURCE_REASON_CODE_DECLINE_ACCOUNT_INFORMATION_INCORRECT, + CYBERSOURCE_REASON_CODE_DECLINE_PROCESSOR_FAILURE, + CYBERSOURCE_REASON_CODE_DECLINE_CARD_TYPE_MISMATCH, + CYBERSOURCE_REASON_CODE_PAYER_AUTHENTICATION, + CYBERSOURCE_REASON_CODE_PAYER_AUTHENTICATION_FAILED, + CYBERSOURCE_REASON_CODE_PAYER_AUTHENTICATION_SCA_REQUIRED, + CYBERSOURCE_REASON_CODE_DECLINE_PROFILE_SETTINGS, +] + +CYBERSOURCE_ERROR_CODES = [ + CYBERSOURCE_REASON_CODE_INVALID_DATA, + CYBERSOURCE_REASON_CODE_DUPLICATE_TRANSACTION, + CYBERSOURCE_REASON_CODE_SYSTEM_FAILURE, + CYBERSOURCE_REASON_CODE_SERVER_TIMEOUT, + CYBERSOURCE_REASON_CODE_SERVICE_TIMEOUT, +]