diff --git a/finance/views.py b/finance/views.py
index 13e6308..5af8fd6 100644
--- a/finance/views.py
+++ b/finance/views.py
@@ -484,20 +484,30 @@ class DemoYandexCheckView(APIView):
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
+ try:
+ for i in request.body.decode('utf-8').split('&'):
+ key = i.split('=')[0]
+ val = i.split('=')[1]
+ data[key] = val
+ except IndexError:
+ logger_yandex.error(
+ "Не предвиденная ошибка проверки тестогого платежа", request.body.decode('utf-8').split('&'))
+ return Response(status=204)
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')
+ try:
+ if data['invoiceId'] == "abc1111111":
+ xml_res = """
+ """ % (now.isoformat(), str(data['invoiceId']), str(data['shopId']))
+ else:
+ xml_res = """""" % (now.isoformat(), str(data['invoiceId']), str(data['shopId']))
+ logger_yandex.warning("Ошибка проверки тестогого платежа (скорее всего так было задуманно)", xml_res)
+ return HttpResponse(xml_res, content_type='application/xml')
+ except KeyError:
+ logger_yandex.error(
+ "Не предвиденная ошибка проверки тестогого платежа", data)
+ return Response(status=204)
class DemoYandexAvisoView(APIView):
@@ -513,10 +523,10 @@ class DemoYandexAvisoView(APIView):
now = timezone.now()
if data['orderSumAmount'] < 1001:
xml_res = """
- """ % (now.isoformat(), str(data['invoiceId']), str(data['shop_id']))
+ """ % (now.isoformat(), str(data['invoiceId']), str(data['shopId']))
else:
- logger_yandex.warning("Ошибка подтверждения тестогого платежа (скорее всего так было задуманно)")
xml_res = """""" % (now.isoformat(), str(data['invoiceId']), str(data['shop_id']))
+ >""" % (now.isoformat(), str(data['invoiceId']), str(data['shopId']))
+ logger_yandex.warning("Ошибка подтверждения тестогого платежа (скорее всего так было задуманно)", xml_res)
return HttpResponse(xml_res, content_type='application/xml')
\ No newline at end of file
diff --git a/templates/yandex/test_pay.html b/templates/yandex/test_pay.html
index 61f262c..abbbe84 100644
--- a/templates/yandex/test_pay.html
+++ b/templates/yandex/test_pay.html
@@ -11,6 +11,7 @@
Код CVV: 000
Больше инфы https://tech.yandex.ru/money/doc/payment-solution/examples/examples-test-data-docpage/
+