Skip to content

Commit

Permalink
Adding other related constants, settings, urls
Browse files Browse the repository at this point in the history
*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.)
  • Loading branch information
jkachel committed Feb 29, 2024
1 parent e8b1c48 commit 86d01eb
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 4 deletions.
103 changes: 99 additions & 4 deletions unified_ecommerce/constants.py
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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,
]
3 changes: 3 additions & 0 deletions unified_ecommerce/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@
# Application modules
"unified_ecommerce",
"system_meta",
"payments",
"cart",
"mitol.payment_gateway.apps.PaymentGatewayApp",
]

MIDDLEWARE = [
Expand Down
1 change: 1 addition & 0 deletions unified_ecommerce/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions unified_ecommerce/urls_spectacular.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@

urlpatterns = [
re_path(r"", include("system_meta.urls")),
re_path(r"^api/v0/payments/", include("payments.urls")),
]

0 comments on commit 86d01eb

Please sign in to comment.