V
V
Vampre2020-04-22 16:58:32
Django
Vampre, 2020-04-22 16:58:32

Why are requests from Yandex.Money not accepted?

I want to set up http notifications from Yandex Money.
I send a test request, and I get 403 Forbidden. And I get an error both on the local server through ngrok and on the VPS. CSRF already checked, not from him. I just checked it through curl - the same thing ... Other views work fine.
nginx logs:
```
my ip - - [22/Apr/2020:15:48:23 +0200] "POST /billing/payments/test HTTP/1.1" 403 0 "-" "curl/7.47.0"
yandex ip - - [22/Apr/2020:15:51:20 +0200] "POST /billing/payments/test HTTP/1.1" 403 0 "-" "AHC/2.1"
```

# views.py
@method_decorator(csrf_exempt, name='dispatch')
class TestPaymentView(View):

  def post(self, request, *args, **kwargs):

    print(request.content_type)

    return http.HttpResponse("ok") # 200

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
V-ampre, 2020-04-25
@Vampre

PPC, in general, the problem was that I was bugged in urls:

app_name = 'billing'
urlpatterns = [
    path('payments/<str:uuid>', views.PaymentHookView.as_view(), name='payments'),
    path('payments/test', views.TestPaymentView.as_view(), name='test'),
]

As a result, the request went to the first view, where it throws 403 on the wrong content_type

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question