From 86d01eb179fae568caa674147ef32ce4543029f2 Mon Sep 17 00:00:00 2001 From: James Kachel Date: Thu, 29 Feb 2024 11:36:33 -0600 Subject: [PATCH] Adding other related constants, settings, urls *This won't work yet.* There are upstream changes (most notably in #97) that need to be merged, and this branch rebased, before this will work. (There's no reversion or fsm, for example.) --- unified_ecommerce/constants.py | 103 +++++++++++++++++++++++++- unified_ecommerce/settings.py | 3 + unified_ecommerce/urls.py | 1 + unified_ecommerce/urls_spectacular.py | 1 + 4 files changed, 104 insertions(+), 4 deletions(-) diff --git a/unified_ecommerce/constants.py b/unified_ecommerce/constants.py index 96996529..50055c23 100644 --- a/unified_ecommerce/constants.py +++ b/unified_ecommerce/constants.py @@ -1,6 +1,22 @@ """Constants for ecommerce.""" # ruff: noqa: ERA001 +from mitol.payment_gateway.api import ProcessorResponse + +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_TYPE_PERCENT_OFF = "percent-off" DISCOUNT_TYPE_DOLLARS_OFF = "dollars-off" DISCOUNT_TYPE_FIXED_PRICE = "fixed-price" @@ -75,9 +91,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, +] diff --git a/unified_ecommerce/settings.py b/unified_ecommerce/settings.py index e77f0b4c..28a10b58 100644 --- a/unified_ecommerce/settings.py +++ b/unified_ecommerce/settings.py @@ -88,6 +88,9 @@ # Application modules "unified_ecommerce", "system_meta", + "payments", + "cart", + "mitol.payment_gateway.apps.PaymentGatewayApp", ] MIDDLEWARE = [ diff --git a/unified_ecommerce/urls.py b/unified_ecommerce/urls.py index 8bbeb60e..3f7c6528 100644 --- a/unified_ecommerce/urls.py +++ b/unified_ecommerce/urls.py @@ -43,6 +43,7 @@ ), # App Paths re_path(r"^api/v0/meta/", include("system_meta.urls")), + re_path(r"^api/v0/payments/", include("payments.urls")), ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) if settings.DEBUG: diff --git a/unified_ecommerce/urls_spectacular.py b/unified_ecommerce/urls_spectacular.py index 9436fdb9..5b23eb63 100644 --- a/unified_ecommerce/urls_spectacular.py +++ b/unified_ecommerce/urls_spectacular.py @@ -5,4 +5,5 @@ urlpatterns = [ re_path(r"", include("system_meta.urls")), + re_path(r"^api/v0/payments/", include("payments.urls")), ]