Skip to content

Commit

Permalink
Add mastercard mcc list
Browse files Browse the repository at this point in the history
  • Loading branch information
SavingFrame committed Dec 29, 2023
1 parent 23df74d commit 35778fc
Show file tree
Hide file tree
Showing 2 changed files with 920 additions and 0 deletions.
8 changes: 8 additions & 0 deletions iso18245/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class MCC(NamedTuple):
visa_description: str
visa_req_clearing_name: str
alipay_description: str
mastercard_description: str


_cached_csv: Dict[str, List[List[str]]] = {}
Expand All @@ -49,6 +50,7 @@ def _load_csv(path: str) -> List[List[str]]:

def _find_mcc_in_csv(mcc: str, path: str) -> List[str]:
for row in _load_csv(path):
print(row)
if row[0] == mcc:
return row[1:]
return []
Expand All @@ -72,6 +74,7 @@ def get_mcc(mcc: str) -> MCC:
visa_description = ""
visa_req_clearing_name = ""
alipay_description = ""
mastercard_description = ""

if not mcc_range.reserved:
data = _find_mcc_in_csv(mcc, "iso18245_official_list.csv")
Expand All @@ -98,6 +101,10 @@ def get_mcc(mcc: str) -> MCC:
if alipay_info:
alipay_description, found = alipay_info[0], True

mastercard_info = _find_mcc_in_csv(mcc, "mastercard_list.csv")
if mastercard_info:
mastercard_description, found = mastercard_info[0], True

if not found:
raise MCCNotFound(mcc)

Expand All @@ -111,6 +118,7 @@ def get_mcc(mcc: str) -> MCC:
visa_description=visa_description,
visa_req_clearing_name=visa_req_clearing_name,
alipay_description=alipay_description,
mastercard_description=mastercard_description,
)


Expand Down
Loading

0 comments on commit 35778fc

Please sign in to comment.