finance email

remotes/origin/yandex_rebiling
Andrey 8 years ago
parent 7d268ba268
commit 5be5f6ecf7
  1. 46
      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 = """<checkOrderResponse performedDatetime="%s" code="0" invoiceId="%s" shopId="%s"/>
""" % (now.isoformat(), str(data['invoiceId']), str(data['shop_id']))
else:
logger_yandex.warning("Ошибка проверки тестогого платежа (скорее всего так было задуманно)")
xml_res = """<checkOrderResponse performedDatetime="%s" code="100" invoiceId="%s" shopId="%s"
message="Неверный номер ордера"/>""" % (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 = """<checkOrderResponse performedDatetime="%s" code="0" invoiceId="%s" shopId="%s"/>
""" % (now.isoformat(), str(data['invoiceId']), str(data['shop_id']))
else:
logger_yandex.warning("Ошибка подтверждения тестогого платежа (скорее всего так было задуманно)")
xml_res = """<checkOrderResponse performedDatetime="%s" code="100" invoiceId="%s" shopId="%s"
message="Нам не позволяет совесть принять от вас более 1000 рублей"/
>""" % (now.isoformat(), str(data['invoiceId']), str(data['shop_id']))
return HttpResponse(xml_res, content_type='application/xml')
Loading…
Cancel
Save