Initial commit
This commit is contained in:
0
app/core/__init__.py
Normal file
0
app/core/__init__.py
Normal file
BIN
app/core/__pycache__/__init__.cpython-312.pyc
Normal file
BIN
app/core/__pycache__/__init__.cpython-312.pyc
Normal file
Binary file not shown.
BIN
app/core/__pycache__/config.cpython-312.pyc
Normal file
BIN
app/core/__pycache__/config.cpython-312.pyc
Normal file
Binary file not shown.
BIN
app/core/__pycache__/constants.cpython-312.pyc
Normal file
BIN
app/core/__pycache__/constants.cpython-312.pyc
Normal file
Binary file not shown.
BIN
app/core/__pycache__/security.cpython-312.pyc
Normal file
BIN
app/core/__pycache__/security.cpython-312.pyc
Normal file
Binary file not shown.
18
app/core/config.py
Normal file
18
app/core/config.py
Normal file
@@ -0,0 +1,18 @@
|
||||
from pydantic_settings import BaseSettings
|
||||
|
||||
|
||||
class Settings(BaseSettings):
|
||||
PAYME_MERCHANT_ID: str
|
||||
PAYME_SECRET_KEY: str
|
||||
|
||||
SHOPIFY_ACCESS_TOKEN: str
|
||||
SHOPIFY_STORE_URL: str
|
||||
SHOPIFY_WEBHOOK_SECRET: str
|
||||
|
||||
DATABASE_URL: str
|
||||
|
||||
class Config:
|
||||
env_file = ".env"
|
||||
|
||||
|
||||
settings = Settings()
|
||||
10
app/core/constants.py
Normal file
10
app/core/constants.py
Normal file
@@ -0,0 +1,10 @@
|
||||
# Payme states
|
||||
STATE_NEW = 0
|
||||
STATE_CREATED = 1
|
||||
STATE_COMPLETED = 2
|
||||
STATE_CANCELLED = -1
|
||||
|
||||
# Payme error codes
|
||||
ERROR_INVALID_AMOUNT = -31001
|
||||
ERROR_TRANSACTION_NOT_FOUND = -31003
|
||||
ERROR_CANNOT_PERFORM = -31008
|
||||
18
app/core/security.py
Normal file
18
app/core/security.py
Normal file
@@ -0,0 +1,18 @@
|
||||
import base64
|
||||
from fastapi import Request, HTTPException
|
||||
from app.core.config import settings
|
||||
|
||||
|
||||
def verify_payme_auth(request: Request):
|
||||
auth_header = request.headers.get("Authorization")
|
||||
|
||||
if not auth_header:
|
||||
raise HTTPException(status_code=401, detail="Missing auth")
|
||||
|
||||
encoded = auth_header.split(" ")[1]
|
||||
decoded = base64.b64decode(encoded).decode()
|
||||
|
||||
merchant_id, secret = decoded.split(":")
|
||||
|
||||
if merchant_id != settings.PAYME_MERCHANT_ID or secret != settings.PAYME_SECRET_KEY:
|
||||
raise HTTPException(status_code=403, detail="Invalid Payme credentials")
|
||||
Reference in New Issue
Block a user