diff --git a/payme/classes/cards.py b/payme/classes/cards.py index af0c424..09ba852 100644 --- a/payme/classes/cards.py +++ b/payme/classes/cards.py @@ -1,6 +1,5 @@ from typing import Optional -from payme.util import input_type_checker from payme.classes.http import HttpClient from payme.types.response import cards as response @@ -20,8 +19,6 @@ class Cards: services. It allows you to create new cards and retrieve verification codes for existing cards. """ - - @input_type_checker def __init__(self, url: str, payme_id: str) -> "Cards": """ Initialize the Cards client. @@ -35,7 +32,6 @@ def __init__(self, url: str, payme_id: str) -> "Cards": } self.http = HttpClient(url, headers) - @input_type_checker def create(self, number: str, expire: str, save: bool = False, timeout: int = 10) -> response.CardsCreateResponse: """ @@ -53,7 +49,6 @@ def create(self, number: str, expire: str, save: bool = False, params = {"card": {"number": number, "expire": expire}, "save": save} return self._post_request(method, params, timeout) - @input_type_checker def get_verify_code(self, token: str, timeout: int = 10) -> \ response.GetVerifyResponse: """ @@ -68,7 +63,6 @@ def get_verify_code(self, token: str, timeout: int = 10) -> \ params = {"token": token} return self._post_request(method, params, timeout) - @input_type_checker def verify(self, token: str, code: str, timeout: int = 10) -> \ response.VerifyResponse: """ @@ -84,7 +78,6 @@ def verify(self, token: str, code: str, timeout: int = 10) -> \ params = {"token": token, "code": code} return self._post_request(method, params, timeout) - @input_type_checker def remove(self, token: str, timeout: int = 10) -> response.RemoveResponse: """ Remove a card from the Paycom system. @@ -98,7 +91,6 @@ def remove(self, token: str, timeout: int = 10) -> response.RemoveResponse: params = {"token": token} return self._post_request(method, params, timeout) - @input_type_checker def check(self, token: str, timeout: int = 10) -> response.CheckResponse: """ Check the status of a card. @@ -112,7 +104,6 @@ def check(self, token: str, timeout: int = 10) -> response.CheckResponse: params = {"token": token} return self._post_request(method, params, timeout) - @input_type_checker def _post_request(self, method: str, params: dict, timeout: int = 10) -> response.Common: """ diff --git a/payme/classes/client.py b/payme/classes/client.py index f8d98bb..02f8d69 100644 --- a/payme/classes/client.py +++ b/payme/classes/client.py @@ -3,7 +3,6 @@ from payme.const import Networks from payme.classes.cards import Cards -from payme.util import input_type_checker from payme.classes.receipts import Receipts from payme.classes.initializer import Initializer @@ -12,7 +11,6 @@ class Payme: """ The payme class provides a simple interface """ - @input_type_checker def __init__( self, payme_id: str, @@ -24,7 +22,7 @@ def __init__( url = Networks.PROD_NET if is_test_mode is True: - url = Networks.TEST_NET + url = Networks.TEST_NET.value self.cards = Cards(url=url, payme_id=payme_id) self.initializer = Initializer(payme_id=payme_id) diff --git a/payme/classes/initializer.py b/payme/classes/initializer.py index e43daf8..f17799c 100644 --- a/payme/classes/initializer.py +++ b/payme/classes/initializer.py @@ -2,8 +2,6 @@ from django.conf import settings -from payme.util import input_type_checker - class Initializer: """ @@ -15,7 +13,6 @@ class Initializer: The Payme ID associated with your account """ - @input_type_checker def __init__(self, payme_id: str = None): self.payme_id = payme_id @@ -58,20 +55,3 @@ def generate_pay_link( ) params = base64.b64encode(params.encode("utf-8")).decode("utf-8") return f"https://checkout.paycom.uz/{params}" - - def test(self): - """ - Test method for the Initializer class. - - This method generates a payment link for a sample order and checks - if the result is a valid string. If successful, it prints a - confirmation message. - """ - result = self.generate_pay_link( - id=12345, - amount=7000, - return_url="https://example.com" - ) - - assert isinstance(result, str), "Failed to generate payment link" - print("Success: Payment link generated successfully.") diff --git a/payme/classes/receipts.py b/payme/classes/receipts.py index 0607cc5..0f75840 100644 --- a/payme/classes/receipts.py +++ b/payme/classes/receipts.py @@ -1,7 +1,6 @@ from typing import Union, Optional from payme.classes.cards import Cards -from payme.util import input_type_checker from payme.classes.http import HttpClient from payme.types.response import receipts as response @@ -37,7 +36,6 @@ def __init__(self, payme_id: str, payme_key: str, url: str) -> "Receipts": } self.http = HttpClient(url, headers) - @input_type_checker def create( self, account: dict, @@ -64,7 +62,6 @@ def create( } return self._post_request(method, params, timeout) - @input_type_checker def pay( self, receipts_id: str, token: str, timeout: int = 10 ) -> response.PayResponse: @@ -83,7 +80,6 @@ def pay( } return self._post_request(method, params, timeout) - @input_type_checker def send( self, receipts_id: str, phone: str, timeout: int = 10 ) -> response.SendResponse: @@ -101,7 +97,6 @@ def send( } return self._post_request(method, params, timeout) - @input_type_checker def cancel( self, receipts_id: str, timeout: int = 10 ) -> response.CancelResponse: @@ -117,7 +112,6 @@ def cancel( } return self._post_request(method, params, timeout) - @input_type_checker def check( self, receipts_id: str, timeout: int = 10 ) -> response.CheckResponse: @@ -133,7 +127,6 @@ def check( } return self._post_request(method, params, timeout) - @input_type_checker def get( self, receipts_id: str, timeout: int = 10 ) -> response.GetResponse: @@ -149,7 +142,6 @@ def get( } return self._post_request(method, params, timeout) - @input_type_checker def get_all( self, count: int, from_: int, to: int, offset: int, timeout: int = 10 ) -> response.GetAllResponse: @@ -171,7 +163,6 @@ def get_all( } return self._post_request(method, params, timeout) - @input_type_checker def _post_request( self, method: str, params: dict, timeout: int = 10 ) -> response.Common: diff --git a/payme/const.py b/payme/const.py index 26ed981..84af072 100644 --- a/payme/const.py +++ b/payme/const.py @@ -4,29 +4,6 @@ from enum import Enum -class Methods(str, Enum): - """ - The enumeration of create transaction methods. - - Available Methods: - - GET_STATEMENT: Fetches transaction statement. - - CHECK_TRANSACTION: Checks a transaction. - - CREATE_TRANSACTION: Creates a new transaction. - - CANCEL_TRANSACTION: Cancels an existing transaction. - - PERFORM_TRANSACTION: Performs a transaction. - - CHECK_PERFORM_TRANSACTION: Checks if the transaction can be performed. - """ - GET_STATEMENT = "GetStatement" - CHECK_TRANSACTION = "CheckTransaction" - CREATE_TRANSACTION = "CreateTransaction" - CANCEL_TRANSACTION = "CancelTransaction" - PERFORM_TRANSACTION = "PerformTransaction" - CHECK_PERFORM_TRANSACTION = "CheckPerformTransaction" - - def __str__(self): - return str(self.value) - - class Networks(str, Enum): """ Payme networks diff --git a/payme/util.py b/payme/util.py index 11cb81b..e1bcc72 100644 --- a/payme/util.py +++ b/payme/util.py @@ -1,6 +1,4 @@ -from functools import wraps from datetime import datetime -from typing import get_type_hints def time_to_payme(datatime) -> int: @@ -26,28 +24,3 @@ def time_to_service(milliseconds: int) -> datetime: Converts milliseconds since the epoch to a datetime object. """ return datetime.fromtimestamp(milliseconds / 1000) - - -def input_type_checker(func): - """ - input type checker decorator helps to - validate the input types of the function before executing it. - """ - @wraps(func) - def wrapper(*args, **kwargs): - """ - Get the type hints of the function - """ - hints = get_type_hints(func) - - all_args = kwargs.copy() - all_args.update(zip(func.__code__.co_varnames, args)) - - for arg_name, arg_type in hints.items(): - if arg_name in all_args and not isinstance(all_args[arg_name], arg_type): # noqa - raise TypeError( - f"Argument '{arg_name}' in {func.__name__} must be of type {arg_type.__name__}, " # noqa - f"but got {type(all_args[arg_name]).__name__}." - ) - return func(*args, **kwargs) - return wrapper diff --git a/setup.py b/setup.py index e947c1d..0778558 100644 --- a/setup.py +++ b/setup.py @@ -1,9 +1,13 @@ +import pathlib from setuptools import setup, find_packages +here = pathlib.Path(__file__).parent.resolve() + +long_description = (here / "README.md").read_text(encoding="utf-8") setup( name='payme-pkg', - version='3.0.6', + version='3.0.8', license='MIT', author="Muhammadali Akbarov", author_email='muhammadali17abc@gmail.com', @@ -15,4 +19,6 @@ "dataclasses==0.*;python_version<'3.7'", # will only install on py3.6 'djangorestframework==3.*' ], + long_description=long_description, + long_description_content_type="text/markdown", ) diff --git a/tests.py b/tests.py index 01e8932..dca21e8 100644 --- a/tests.py +++ b/tests.py @@ -31,12 +31,6 @@ def test_receipts_all_methods(self): """ return self.payme.receipts.test() - def test_initializer_all_methods(self): - """ - Verify that the initializer test method works without errors - """ - return self.payme.initializer.test() - if __name__ == '__main__': unittest.main()