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.