Robokassa and Yandex ticket office are connected to the Django project. Is it possible to programmatically give the url to the robokassa (Yandex cashier) so that, with a successful transaction, the user is transferred to this success url?

For example, a person switched to a robocassa after visiting a certain page, I would like him to get there after a successful payment.

    1 answer 1

    For Yandex.Cashi you need to transfer 2 parameters to the PaymentForm payment form:

    shopFailURL = 'url' shopSuccessURL = 'url' 

    They are a URLField. They can also be transmitted by hidden fields inside the template:

     <input hidden name="shopFailURL" value="сюда_ссылку"> <input hidden name="shopSuccessURL" value="сюда_ссылку"> 

    For robokassy. Overriding in the class view of the Robokassa form:

     def get(self, request, *args, **kwargs): request.session['next'] = self.request.get_full_path() return super().get(request, *args, **kwargs) 

    Make a view into which we will go when the form is Success'e:

     class SuccessRobokassaView(View): def get(self, request, *args, **kwargs): if 'next' in request.session: return HttpResponseRedirect(request.session['next']) else: return HttpResponseRedirect(request.META['HTTP_REFERER']) 

    Add this view to the list of URLs:

     path('success_url/', SuccessRobokassaView.as_view(), name='success-robokassa'), 

    In the personal account of Robokassa send Success URL to our new link.

    • url can be put into the session - eri
    • Yes indeed. I completely forgot about the session. Updated. - floydya pm
    • I have this to make a single way for Yandex and Robocash Desk - eri