|
|
|
|
@ -1,8 +1,10 @@ |
|
|
|
|
from django.utils.decorators import method_decorator |
|
|
|
|
from django.contrib import messages |
|
|
|
|
from django.http import HttpResponse |
|
|
|
|
from django.shortcuts import redirect |
|
|
|
|
from django.views.generic import View, TemplateView |
|
|
|
|
from django.views.decorators.csrf import csrf_exempt |
|
|
|
|
from django.http import HttpResponse |
|
|
|
|
from django.urls import reverse_lazy |
|
|
|
|
from django.utils.decorators import method_decorator |
|
|
|
|
|
|
|
|
|
from paymentwall import Pingback, Product, Widget |
|
|
|
|
|
|
|
|
|
@ -43,6 +45,41 @@ class CourseBuyView(TemplateView): |
|
|
|
|
return self.render_to_response(context={'widget': widget.get_html_code()}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SchoolBuyView(TemplateView): |
|
|
|
|
template_name = 'payment/paymentwall_widget.html' |
|
|
|
|
|
|
|
|
|
def get(self, request, *args, **kwargs): |
|
|
|
|
host = request.scheme + '://' + request.get_host() |
|
|
|
|
weekdays = request.GET.get('weekdays', []) |
|
|
|
|
if not weekdays: |
|
|
|
|
messages.error(request, 'Выберите несколько дней недели.') |
|
|
|
|
return redirect('index') |
|
|
|
|
weekdays = [int(weekday) for weekday in weekdays] |
|
|
|
|
school_payment = SchoolPayment.objects.create( |
|
|
|
|
user=request.user, |
|
|
|
|
weekdays=weekdays, |
|
|
|
|
) |
|
|
|
|
product = Product( |
|
|
|
|
f'school_{school_payment.id}', |
|
|
|
|
school_payment.amount, |
|
|
|
|
'RUB', |
|
|
|
|
'Школа', |
|
|
|
|
) |
|
|
|
|
widget = Widget( |
|
|
|
|
str(request.user.id), |
|
|
|
|
'p1', |
|
|
|
|
[product], |
|
|
|
|
extra_params={ |
|
|
|
|
'lang': 'ru', |
|
|
|
|
'evaluation': 1, |
|
|
|
|
'success_url': host + str(reverse_lazy('payment-success')), |
|
|
|
|
'failure_url': host + str(reverse_lazy('payment-error')), |
|
|
|
|
} |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
return self.render_to_response(context={'widget': widget.get_html_code()}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@method_decorator(csrf_exempt, name='dispatch') |
|
|
|
|
class PaymentwallCallbackView(View): |
|
|
|
|
|
|
|
|
|
|