Refactor payment service, fix DB session, and consolidate endpoints
- Fix critical NameError in database.py by restoring Session factory - Refactor payment_service.py and crud.py to use shared constants.py and utils.py - Deduplicate state mapping and input sanitization logic - Move transaction amount calculation logic from CRUD to Router layer - Enforce type safety in schemas using IntEnum for TransactionType/Status - Move capture endpoint from transaction.py to payment.py (now /payments/capture) - Update create_customer_profile signature for clarity
This commit is contained in:
28
app/constants.py
Normal file
28
app/constants.py
Normal file
@@ -0,0 +1,28 @@
|
||||
"""
|
||||
Constants shared across the EAMCO Authorize service.
|
||||
"""
|
||||
import enum
|
||||
|
||||
class TransactionStatus(enum.IntEnum):
|
||||
"""Transaction status codes used throughout the payment system."""
|
||||
APPROVED = 0
|
||||
DECLINED = 1
|
||||
|
||||
|
||||
class TransactionType(enum.IntEnum):
|
||||
"""Transaction type codes for different payment operations."""
|
||||
CHARGE = 0
|
||||
AUTHORIZE = 1
|
||||
CAPTURE = 2
|
||||
|
||||
# State ID to abbreviation mapping for Authorize.net billing address
|
||||
# This maps the integer state IDs from the database to state abbreviations
|
||||
STATE_ID_TO_ABBREVIATION = {
|
||||
0: "MA",
|
||||
1: "RI",
|
||||
2: "NH",
|
||||
3: "ME",
|
||||
4: "VT",
|
||||
5: "CT",
|
||||
6: "NY"
|
||||
}
|
||||
Reference in New Issue
Block a user