diff --git a/finance/views.py b/finance/views.py index c629ed5..13e6308 100644 --- a/finance/views.py +++ b/finance/views.py @@ -477,10 +477,46 @@ class YandexFailView(APIView): return redirect(to=settings.DOMAIN) -class DemoYandexCheckView(YandexCheckView): - """для тестирования платежей""" - pass +class DemoYandexCheckView(APIView): + renderer_classes = (JSONRenderer,) + + @staticmethod + def post(request): + # Деалем допущение, что orderNumber=abc1111111 иначе всё плохо + data = dict() + for i in request.body.decode('utf-8').split('&'): + key = i.split('=')[0] + val = i.split('=')[1] + data[key] = val + + now = timezone.now() + if data['orderSumAmount'] == "abc1111111": + xml_res = """ + """ % (now.isoformat(), str(data['invoiceId']), str(data['shop_id'])) + else: + logger_yandex.warning("Ошибка проверки тестогого платежа (скорее всего так было задуманно)") + xml_res = """""" % (now.isoformat(), str(data['invoiceId']), str(data['shop_id'])) + return HttpResponse(xml_res, content_type='application/xml') + +class DemoYandexAvisoView(APIView): -class DemoYandexAvisoView(YandexAvisoView): - pass + @staticmethod + def post(request): + data = dict() + for i in request.body.decode('utf-8').split('&'): + key = i.split('=')[0] + val = i.split('=')[1] + data[key] = val + + now = timezone.now() + if data['orderSumAmount'] < 1001: + xml_res = """ + """ % (now.isoformat(), str(data['invoiceId']), str(data['shop_id'])) + else: + logger_yandex.warning("Ошибка подтверждения тестогого платежа (скорее всего так было задуманно)") + xml_res = """""" % (now.isoformat(), str(data['invoiceId']), str(data['shop_id'])) + return HttpResponse(xml_res, content_type='application/xml') \ No newline at end of file