Skip to content

Commit

Permalink
chore(backends): make request method static to ease debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
nijel committed Dec 2, 2024
1 parent 4d82143 commit ce591c4
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions weblate_web/payments/backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -636,14 +636,16 @@ class ThePay2Card(Backend):
description = "Payment Card (The Pay)"
recurring = True

def get_headers(self) -> dict[str, str]:
@staticmethod
def get_headers() -> dict[str, str]:
timestamp = http_date()
payload = f"{settings.THEPAY_MERCHANT_ID}{settings.THEPAY_PASSWORD}{timestamp}"
hash256 = sha256(payload.encode(), usedforsecurity=True)
return {"SignatureDate": timestamp, "Signature": hash256.hexdigest()}

@classmethod
def request(
self,
cls,
method: str,
url: str,
params: dict | None = None,
Expand All @@ -654,7 +656,7 @@ def request(
params = {}
params["merchant_id"] = settings.THEPAY_MERCHANT_ID

headers = self.get_headers()
headers = cls.get_headers()

base_url = f"https://{settings.THEPAY_SERVER}/{api_version}/projects/{settings.THEPAY_PROJECT_ID}"

Expand Down

0 comments on commit ce591c4

Please sign in to comment.