From 3a40a54ff05212d924ab9ce4c174b3e675ae4aa9 Mon Sep 17 00:00:00 2001 From: koladev Date: Mon, 5 Feb 2024 20:58:15 +0100 Subject: [PATCH 1/8] =?UTF-8?q?Bump=20version:=200.2.3=20=E2=86=92=200.2.4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 3 +++ pyproject.toml | 2 +- setup.cfg | 2 +- transfa/version.py | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 35ef37f..e31a70e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ Changelog [Unreleased] ------------ +[v0.2.4] - 2024-02-05 +------------------ + [v0.2.3] - 2023-04-21 ------------------ - Fix Webhook's Header Identifier bug diff --git a/pyproject.toml b/pyproject.toml index bc3b797..f111064 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,4 +6,4 @@ build-backend = "setuptools.build_meta" [project] name = "transfa" -version = "0.2.3" \ No newline at end of file +version = "0.2.4" \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index bfd14ba..fdb6f4f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.2.3 +current_version = 0.2.4 commit = True tag = True diff --git a/transfa/version.py b/transfa/version.py index ae50f1f..4b51ef6 100644 --- a/transfa/version.py +++ b/transfa/version.py @@ -1 +1 @@ -VERSION = "0.2.3" +VERSION = "0.2.4" From a4fa9be5a9e6760b69ff24777b6d53b6a7ac0066 Mon Sep 17 00:00:00 2001 From: koladev Date: Mon, 5 Feb 2024 20:58:18 +0100 Subject: [PATCH 2/8] =?UTF-8?q?Bump=20version:=200.2.4=20=E2=86=92=200.2.5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 3 +++ pyproject.toml | 2 +- setup.cfg | 2 +- transfa/version.py | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e31a70e..da6eff8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ Changelog [Unreleased] ------------ +[v0.2.5] - 2024-02-05 +------------------ + [v0.2.4] - 2024-02-05 ------------------ diff --git a/pyproject.toml b/pyproject.toml index f111064..d0726f0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,4 +6,4 @@ build-backend = "setuptools.build_meta" [project] name = "transfa" -version = "0.2.4" \ No newline at end of file +version = "0.2.5" \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index fdb6f4f..ab87a1d 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.2.4 +current_version = 0.2.5 commit = True tag = True diff --git a/transfa/version.py b/transfa/version.py index 4b51ef6..c56061d 100644 --- a/transfa/version.py +++ b/transfa/version.py @@ -1 +1 @@ -VERSION = "0.2.4" +VERSION = "0.2.5" From a3fb4a7496bf913b1ee48b474aca4682fce90205 Mon Sep 17 00:00:00 2001 From: koladev Date: Sun, 7 Apr 2024 03:16:33 +0100 Subject: [PATCH 3/8] :fire: remove prefix from requests --- tests/test_payment.py | 10 ++++------ transfa/__init__.py | 2 -- transfa/api_client.py | 5 ++--- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/tests/test_payment.py b/tests/test_payment.py index 4bd1a80..ef13526 100644 --- a/tests/test_payment.py +++ b/tests/test_payment.py @@ -4,8 +4,6 @@ import responses from responses import matchers -from transfa import default_auth_header_bearer - from transfa.api_client import client from transfa.version import VERSION @@ -32,7 +30,7 @@ def test_request_payment(payment): match=[ matchers.header_matcher( { - "Authorization": f"{default_auth_header_bearer} {client.api_key}", + "Authorization": f"{client.api_key}", "accept": "application/json", "content-type": "application/json;charset=utf-8", "Idempotency-Key": idempotency_key, @@ -68,7 +66,7 @@ def test_list_payments(payments): match=[ matchers.header_matcher( { - "Authorization": f"{default_auth_header_bearer} {client.api_key}", + "Authorization": f"{client.api_key}", "user-agent": "Transfa API SDK-Python/%s" % VERSION, } ) @@ -97,7 +95,7 @@ def test_retrieve_payment(payment): match=[ matchers.header_matcher( { - "Authorization": f"{default_auth_header_bearer} {client.api_key}", + "Authorization": f"{client.api_key}", "user-agent": "Transfa API SDK-Python/%s" % VERSION, } ), @@ -127,7 +125,7 @@ def test_refund_payment(payment): match=[ matchers.header_matcher( { - "Authorization": f"{default_auth_header_bearer} {client.api_key}", + "Authorization": f"{client.api_key}", "user-agent": "Transfa API SDK-Python/%s" % VERSION, } ) diff --git a/transfa/__init__.py b/transfa/__init__.py index e5858af..0643795 100644 --- a/transfa/__init__.py +++ b/transfa/__init__.py @@ -10,8 +10,6 @@ private_secret = None api_base = "https://api.transfapp.com" verify_ssl = True -default_auth_header_bearer = "Api-Transfa-Key" - # API Resources diff --git a/transfa/api_client.py b/transfa/api_client.py index 83c6d97..b288012 100644 --- a/transfa/api_client.py +++ b/transfa/api_client.py @@ -2,7 +2,7 @@ from requests import request -from transfa import api_key, api_base, default_auth_header_bearer +from transfa import api_key, api_base from transfa.api_resources.payments import PaymentResource from transfa.version import VERSION @@ -10,7 +10,6 @@ class TransfaAPIClient: _base_url = api_base - auth_header_prefix = default_auth_header_bearer __version__ = VERSION def __init__( @@ -44,7 +43,7 @@ def _request(self, method, endpoint, data=None, params=None, **kwargs): headers = { "user-agent": "Transfa API SDK-Python/%s" % self.__version__, "accept": "application/json", - "Authorization": f"{self.auth_header_prefix} {self.api_key}", + "Authorization": f"{self.api_key}", } if "headers" in kwargs: From 3abaf3dd2b41d5f1addce982d794da32680553d6 Mon Sep 17 00:00:00 2001 From: koladev Date: Sun, 7 Apr 2024 03:19:57 +0100 Subject: [PATCH 4/8] =?UTF-8?q?Revert=20"Bump=20version:=200.2.4=20?= =?UTF-8?q?=E2=86=92=200.2.5"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit a4fa9be5a9e6760b69ff24777b6d53b6a7ac0066. --- CHANGELOG.md | 3 --- pyproject.toml | 2 +- setup.cfg | 2 +- transfa/version.py | 2 +- 4 files changed, 3 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index da6eff8..e31a70e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,9 +4,6 @@ Changelog [Unreleased] ------------ -[v0.2.5] - 2024-02-05 ------------------- - [v0.2.4] - 2024-02-05 ------------------ diff --git a/pyproject.toml b/pyproject.toml index d0726f0..f111064 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,4 +6,4 @@ build-backend = "setuptools.build_meta" [project] name = "transfa" -version = "0.2.5" \ No newline at end of file +version = "0.2.4" \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index ab87a1d..fdb6f4f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.2.5 +current_version = 0.2.4 commit = True tag = True diff --git a/transfa/version.py b/transfa/version.py index c56061d..4b51ef6 100644 --- a/transfa/version.py +++ b/transfa/version.py @@ -1 +1 @@ -VERSION = "0.2.5" +VERSION = "0.2.4" From 00fc06e6c829cf4bc1714011aac66931398737c0 Mon Sep 17 00:00:00 2001 From: koladev Date: Sun, 7 Apr 2024 03:24:56 +0100 Subject: [PATCH 5/8] :memo: update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e31a70e..476e0f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ Changelog [v0.2.4] - 2024-02-05 ------------------ +- Remove prefix for requests + [v0.2.3] - 2023-04-21 ------------------ - Fix Webhook's Header Identifier bug From a271c5a47172781420a94c3533c54337df258027 Mon Sep 17 00:00:00 2001 From: koladev Date: Sun, 7 Apr 2024 03:28:45 +0100 Subject: [PATCH 6/8] :pencil2: fix typos --- pyproject.toml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index f111064..a443d4e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ [build-system] requires = ["setuptools>=61.0.0", "wheel"] build-backend = "setuptools.build_meta" - -[project] -name = "transfa" -version = "0.2.4" \ No newline at end of file +# +#[project] +#name = "transfa" +#version = "0.2.4" \ No newline at end of file From e955d9e660b66a69ae713cac058064922596f9d6 Mon Sep 17 00:00:00 2001 From: koladev Date: Sun, 7 Apr 2024 03:32:37 +0100 Subject: [PATCH 7/8] :pencil2: fix typos --- pyproject.toml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index a443d4e..ead99db 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,8 @@ [build-system] requires = ["setuptools>=61.0.0", "wheel"] build-backend = "setuptools.build_meta" -# -#[project] -#name = "transfa" -#version = "0.2.4" \ No newline at end of file + +[project] +name = "transfa" +version = "0.2.4" +dynamic = ["version", "description", "readme"] \ No newline at end of file From 1d74eaa59918ca4eafea3ca7a1b715141bc8b80b Mon Sep 17 00:00:00 2001 From: koladev Date: Sun, 7 Apr 2024 03:35:03 +0100 Subject: [PATCH 8/8] :pencil2: fix typos --- pyproject.toml | 2 +- tests/test_webhook.py | 51 ++++++++++++++++++++----------- transfa/api_resources/payments.py | 4 +-- transfa/webhook.py | 9 ++---- 4 files changed, 38 insertions(+), 28 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index ead99db..f5469c9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,4 +7,4 @@ build-backend = "setuptools.build_meta" [project] name = "transfa" version = "0.2.4" -dynamic = ["version", "description", "readme"] \ No newline at end of file +dynamic = ["description", "readme", "optional-dependencies", "dependencies", "classifiers", "authors", "license"] \ No newline at end of file diff --git a/tests/test_webhook.py b/tests/test_webhook.py index 9e529f5..d003fcd 100644 --- a/tests/test_webhook.py +++ b/tests/test_webhook.py @@ -7,7 +7,6 @@ class WebhookData: - def __init__(self): self.valid_webhook_token = get_random_string(64) self.invalid_webhook_token = get_random_string(64) @@ -26,11 +25,15 @@ def generate_signature(self, body, webhook_token, algorithm=hashlib.sha512): def test_valid_webhook_signature(valid_webhook_payload): webhook_data = WebhookData() - signature = webhook_data.generate_signature(valid_webhook_payload, webhook_data.valid_webhook_token) + signature = webhook_data.generate_signature( + valid_webhook_payload, webhook_data.valid_webhook_token + ) - webhook = Webhook(webhook_token=webhook_data.valid_webhook_token, body=valid_webhook_payload, headers={ - "X-Webhook-Transfa-Signature": signature - }) + webhook = Webhook( + webhook_token=webhook_data.valid_webhook_token, + body=valid_webhook_payload, + headers={"X-Webhook-Transfa-Signature": signature}, + ) verified = webhook.verify() @@ -39,11 +42,15 @@ def test_valid_webhook_signature(valid_webhook_payload): def test_invalid_webhook_signature(valid_webhook_payload, invalid_webhook_payload): webhook_data = WebhookData() - invalid_signature = webhook_data.generate_signature(invalid_webhook_payload, webhook_data.valid_webhook_token) + invalid_signature = webhook_data.generate_signature( + invalid_webhook_payload, webhook_data.valid_webhook_token + ) - webhook = Webhook(webhook_token=webhook_data.valid_webhook_token, body=valid_webhook_payload, headers={ - "X-Webhook-Transfa-Signature": invalid_signature - }) + webhook = Webhook( + webhook_token=webhook_data.valid_webhook_token, + body=valid_webhook_payload, + headers={"X-Webhook-Transfa-Signature": invalid_signature}, + ) verified = webhook.verify() @@ -52,11 +59,15 @@ def test_invalid_webhook_signature(valid_webhook_payload, invalid_webhook_payloa def test_valid_webhook_token(valid_webhook_payload): webhook_data = WebhookData() - valid_signature = webhook_data.generate_signature(valid_webhook_payload, webhook_data.valid_webhook_token) + valid_signature = webhook_data.generate_signature( + valid_webhook_payload, webhook_data.valid_webhook_token + ) - webhook = Webhook(webhook_token=webhook_data.valid_webhook_token, body=valid_webhook_payload, headers={ - "X-Webhook-Transfa-Signature": valid_signature - }) + webhook = Webhook( + webhook_token=webhook_data.valid_webhook_token, + body=valid_webhook_payload, + headers={"X-Webhook-Transfa-Signature": valid_signature}, + ) verified = webhook.verify() @@ -65,11 +76,15 @@ def test_valid_webhook_token(valid_webhook_payload): def test_invalid_webhook_token(valid_webhook_payload): webhook_data = WebhookData() - valid_signature = webhook_data.generate_signature(valid_webhook_payload, webhook_data.valid_webhook_token) - - webhook = Webhook(webhook_token=webhook_data.invalid_webhook_token, body=valid_webhook_payload, headers={ - "X-Webhook-Transfa-Signature": valid_signature - }) + valid_signature = webhook_data.generate_signature( + valid_webhook_payload, webhook_data.valid_webhook_token + ) + + webhook = Webhook( + webhook_token=webhook_data.invalid_webhook_token, + body=valid_webhook_payload, + headers={"X-Webhook-Transfa-Signature": valid_signature}, + ) verified = webhook.verify() diff --git a/transfa/api_resources/payments.py b/transfa/api_resources/payments.py index 25acdf6..9df6d06 100644 --- a/transfa/api_resources/payments.py +++ b/transfa/api_resources/payments.py @@ -78,8 +78,8 @@ def status(self, payment_id): status_data = { "status": response_data.get("status"), - "financial_status": response_data.get("financial_status") - } + "financial_status": response_data.get("financial_status"), + } return status_data diff --git a/transfa/webhook.py b/transfa/webhook.py index 42dfd93..0e705dc 100644 --- a/transfa/webhook.py +++ b/transfa/webhook.py @@ -14,14 +14,10 @@ def __init__(self, webhook_token=private_secret, body=None, headers=None): ) if body is None: - raise NotImplementedError( - "Can't work without the body of the request." - ) + raise NotImplementedError("Can't work without the body of the request.") if headers is None: - raise NotImplementedError( - "Can't work without the headers." - ) + raise NotImplementedError("Can't work without the headers.") if isinstance(body, bytes): body = body.decode("utf-8") @@ -42,7 +38,6 @@ def sign_body(self, body, algorithm=hashlib.sha512): return signature.hexdigest() def has_data_not_tempered(self, body, transfa_api_signature): - if isinstance(body, dict): body = json.dumps(body)