django-getpaid/django-getpaid-payu

CredentialsError at /payments/new/

pceuropa opened this issue · 3 comments

  • django-getpaid version: 2.2.0
  • django-getpaid-payu version: 0.2.0
  • Django version: 3.0.6
  • Python version: 3.7.5
  • Operating System: Ubuntu 19

I'm trying to finish the process of order with default settings of example app.
Action click on checkout button (http://127.0.0.1:8000/order/3/) does POST to http://127.0.0.1:8000/payments/new/ with data

{"csrfmiddlewaretoken":"2Nmmhzp4MXWaR5cZxdFTHBnrfWdK5Vk0BOmr05g43o6VZfytiV7I85IFmE8Yw0bH","backend":"getpaid_payu","order":"4","amount_required":"199.99","description":"Lock,+Stock+and+Two+Smoking+Barrels","currency":"EUR"}

But response is 500

Request Method: 	POST
Request URL: 	http://127.0.0.1:8000/payments/new/
Django Version: 	3.0.6
Exception Type: 	CredentialsError
Exception Value: 	Cannot authenticate.
Exception Location: 	/home/m/Desktop/localhost/django-getpaid/example/venv/lib/python3.7/site-packages/getpaid_payu/client.py in _authorize, line 78
Python Executable: 	/home/m/Desktop/localhost/django-getpaid/example/venv/bin/python3
Python Version: 	3.7.5


Environment:


Request Method: POST
Request URL: http://127.0.0.1:8000/payments/new/

Django Version: 3.0.6
Python Version: 3.7.5
Installed Applications:
['django.contrib.auth',
 'django.contrib.admin',
 'django.contrib.messages',
 'django.contrib.sessions',
 'django.contrib.contenttypes',
 'django_fsm',
 'getpaid',
 'getpaid_payu',
 'orders',
 'paywall']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware']



Traceback (most recent call last):
  File "/home/m/Desktop/localhost/django-getpaid/example/venv/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/home/m/Desktop/localhost/django-getpaid/example/venv/lib/python3.7/site-packages/django/core/handlers/base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/home/m/Desktop/localhost/django-getpaid/example/venv/lib/python3.7/site-packages/django/core/handlers/base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/m/Desktop/localhost/django-getpaid/example/venv/lib/python3.7/site-packages/django/views/generic/base.py", line 71, in view
    return self.dispatch(request, *args, **kwargs)
  File "/home/m/Desktop/localhost/django-getpaid/example/venv/lib/python3.7/site-packages/django/views/generic/base.py", line 97, in dispatch
    return handler(request, *args, **kwargs)
  File "/home/m/Desktop/localhost/django-getpaid/example/venv/lib/python3.7/site-packages/django/views/generic/edit.py", line 172, in post
    return super().post(request, *args, **kwargs)
  File "/home/m/Desktop/localhost/django-getpaid/example/venv/lib/python3.7/site-packages/django/views/generic/edit.py", line 142, in post
    return self.form_valid(form)
  File "/home/m/Desktop/localhost/django-getpaid/example/venv/lib/python3.7/site-packages/getpaid/views.py", line 24, in form_valid
    return payment.prepare_transaction(request=self.request, view=self)
  File "/home/m/Desktop/localhost/django-getpaid/example/venv/lib/python3.7/site-packages/getpaid/models.py", line 343, in prepare_transaction
    return self.processor.prepare_transaction(request=request, view=None, **kwargs)
  File "/home/m/Desktop/localhost/django-getpaid/example/venv/lib/python3.7/site-packages/getpaid/models.py", line 199, in processor
    self._processor = self.get_processor()
  File "/home/m/Desktop/localhost/django-getpaid/example/venv/lib/python3.7/site-packages/getpaid/models.py", line 219, in get_processor
    return processor(self)
  File "/home/m/Desktop/localhost/django-getpaid/example/venv/lib/python3.7/site-packages/getpaid/processor.py", line 47, in __init__
    self.client = self.get_client()
  File "/home/m/Desktop/localhost/django-getpaid/example/venv/lib/python3.7/site-packages/getpaid/processor.py", line 60, in get_client
    return self.get_client_class()(**self.get_client_params())
  File "/home/m/Desktop/localhost/django-getpaid/example/venv/lib/python3.7/site-packages/getpaid_payu/client.py", line 60, in __init__
    self._authorize()
  File "/home/m/Desktop/localhost/django-getpaid/example/venv/lib/python3.7/site-packages/getpaid_payu/client.py", line 78, in _authorize
    "Cannot authenticate.", context={"raw_response": self.last_response}

Exception Type: CredentialsError at /payments/new/
Exception Value: Cannot authenticate.

Credentials to PayU is default to sandbox

GETPAID_BACKEND_SETTINGS = {
    "getpaid_payu": {
        "pos_id": 300746,
        "second_key": "b6ca15b0d1020e8094d9b5f8d163db54",
        "client_id": 300746,
        "client_secret": "2ee86a66e5d97e3fadc400c9f19b065d",
        "confirmation_method": "PULL",  # required for local testing
    },
}

I'm new one with PayU, then probably I don't know something about PayU setup process.

Thanks for reporting. It looks like PayU doesn't allow its own test credentials that are used in their examples. I need to fix the example project and documentation.

Hi, credentials works. Just documentation leads to many misunderstandings.
Change client_id to oauth_id and client_secret to oauth_secret

I have a problem with payments, I set up my sandbox, I changed the credentials in the settings, and when I create a new order, it goes to payments, I use test cards from payu, in the sandbox the payment appears but on the django site and in the admin panel the transaction status does not change, how to approach this