|
|
|
@ -21,7 +21,6 @@ from courses.models import Course |
|
|
|
from courses.api import CourseParamsApi |
|
|
|
from courses.api import CourseParamsApi |
|
|
|
from finance.models import Bill, Invoice, InvoiceRebilling |
|
|
|
from finance.models import Bill, Invoice, InvoiceRebilling |
|
|
|
from finance.serializers import BillSerializer, InvoiceSerializer |
|
|
|
from finance.serializers import BillSerializer, InvoiceSerializer |
|
|
|
from finance.tasks import setup_periodic_billing |
|
|
|
|
|
|
|
from lms.global_decorators import transaction_decorator |
|
|
|
from lms.global_decorators import transaction_decorator |
|
|
|
from lms.tools import get_real_name |
|
|
|
from lms.tools import get_real_name |
|
|
|
from django.utils import timezone |
|
|
|
from django.utils import timezone |
|
|
|
@ -60,13 +59,13 @@ class UnFreezeView(APIView): |
|
|
|
|
|
|
|
|
|
|
|
@staticmethod |
|
|
|
@staticmethod |
|
|
|
def post(request, pk): |
|
|
|
def post(request, pk): |
|
|
|
if request.user.is_authenticated: |
|
|
|
try: |
|
|
|
try: |
|
|
|
bill = Bill.objects.get(id=pk) |
|
|
|
bill = Bill.objects.get(id=pk) |
|
|
|
except Bill.DoesNotExist: |
|
|
|
bill.freeze = False |
|
|
|
return Response("Счёт не найден", status=404) |
|
|
|
bill.save() |
|
|
|
|
|
|
|
except Bill.DoesNotExist: |
|
|
|
if request.user.is_authenticated and request.user.email == bill.user.email: |
|
|
|
return Response("Счёт не найден", status=404) |
|
|
|
bill.unfreeze_course() |
|
|
|
return Response(status=204) |
|
|
|
return Response(status=204) |
|
|
|
return Response("Permission denied", status=403) |
|
|
|
return Response("Permission denied", status=403) |
|
|
|
|
|
|
|
|
|
|
|
@ -444,13 +443,10 @@ class YandexAvisoView(APIView): |
|
|
|
@staticmethod |
|
|
|
@staticmethod |
|
|
|
def post(request): |
|
|
|
def post(request): |
|
|
|
data = dict() |
|
|
|
data = dict() |
|
|
|
rebilling = None |
|
|
|
|
|
|
|
for i in request.body.decode('utf-8').split('&'): |
|
|
|
for i in request.body.decode('utf-8').split('&'): |
|
|
|
key = i.split('=')[0] |
|
|
|
key = i.split('=')[0] |
|
|
|
val = i.split('=')[1] |
|
|
|
val = i.split('=')[1] |
|
|
|
data[key] = val |
|
|
|
data[key] = val |
|
|
|
if key == 'rebillingOn': |
|
|
|
|
|
|
|
rebilling = val |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try: |
|
|
|
try: |
|
|
|
pay = Payment.objects.get(order_number=data['orderNumber']) |
|
|
|
pay = Payment.objects.get(order_number=data['orderNumber']) |
|
|
|
@ -465,6 +461,9 @@ class YandexAvisoView(APIView): |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
pay.shop_amount = data['shopSumAmount'] |
|
|
|
pay.shop_amount = data['shopSumAmount'] |
|
|
|
|
|
|
|
invoice = pay.invoice |
|
|
|
|
|
|
|
invoice.key = data['invoiceId'] |
|
|
|
|
|
|
|
invoice.save() |
|
|
|
pay.status = Payment.STATUS.SUCCESS |
|
|
|
pay.status = Payment.STATUS.SUCCESS |
|
|
|
now = timezone.now() |
|
|
|
now = timezone.now() |
|
|
|
pay.performed_datetime = now.isoformat() |
|
|
|
pay.performed_datetime = now.isoformat() |
|
|
|
@ -495,10 +494,6 @@ class YandexAvisoView(APIView): |
|
|
|
msg.attach_alternative(html_content, "text/html") |
|
|
|
msg.attach_alternative(html_content, "text/html") |
|
|
|
msg.send() |
|
|
|
msg.send() |
|
|
|
|
|
|
|
|
|
|
|
if rebilling: |
|
|
|
|
|
|
|
InvoiceRebilling.objects.get(yandex_pay=pay) |
|
|
|
|
|
|
|
setup_periodic_billing(pay.order_number) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return HttpResponse(xml_res, content_type='application/xml') |
|
|
|
return HttpResponse(xml_res, content_type='application/xml') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|