Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AccessDeniedError.__init__() got an unexpected keyword argument 'message' #95

Closed
ChogirmaliYigit opened this issue Nov 22, 2024 · 1 comment

Comments

@ChogirmaliYigit
Copy link
Collaborator

image

Here's my code snippet that gave me the error

from django.conf import settings

from payme import Payme


payme_client = Payme(
    payme_id=settings.PAYME_ID,
    payme_key=settings.PAYME_KEY,
    is_test_mode=True,
)


payme_response = payme_client.cards.check("<my_token>")

The reason is the PAYME_ID and PAYME_KEY variables are both None. So Payme Subscribe API returned Access Denied error and the package had tried to raise the exception with payme.exceptions.general.AccessDeniedError class.

The error occurred in the payme.classes.http.HttpClient.handle_payme_error method. There the package tries to get the exception class by error code:

def handle_payme_error(self, error: dict):
    """
    Handle Paycom-specific errors from the JSON-RPC error response.

    Parameters
    ----------
    error : dict
        The error dictionary from Paycom's response, typically containing
        error details such as code, message, and data.

    Returns
    -------
    None
        Raises an exception based on the error code received from
        Paycom's response.
    """
    error_code = error.get("code", "Unknown code")
    error_message = error.get("message", "Unknown error")
    error_data = error.get("data", "")

    exception_class = exc.errors_map.get(error_code, exc.BaseError)
    raise exception_class(message=error_message, data=error_data)

The main problem is the handle_payme_error method tries to get exception class and pass message and data arguments. But there are no such arguments in the __init__ methods of some classes (AccessDeniedError, InvalidParamsError, CardNotFoundError, etc.).

@Muhammadali-Akbarov
Copy link
Member

Muhammadali-Akbarov commented Nov 22, 2024

image

Muhammadali-Akbarov/payme-pkg@a3d5fb5

Thanks for reporting, it was small issue and now it's working without issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants