def get_status(request, payment_id):
    try:
        payment_status = DjangoPayU.get_payment_status(payment_id)
    except DjangoPayException:
        return HttpResponseBadRequest()

    data = {
        "status": payment_status
    }
    return JsonResponse(data)

    #
    # def start_payment(request):
    # json_str = request.body.decode('utf-8')
    # data = json.loads(json_str)
    #
    # user_id = data.get("user_id")
    # quantity = data.get("quantity")
    #     price = data.get("price")
    #     title = data.get("title")
    #
    #     try:
    #         User.objects.get(pk=user_id)
    #     except User.DoesNotExist:
    #         raise BadParamValueException(ErrorMessages.USER_NOT_FOUND)
    #
    #     user = User.objects.get(pk=user_id)
    #
    #
    #     response = {
    #         "order_id": new_payment.uid,
    #         "payu_id": new_payment.payu_id,
    #         "follow": new_payment.payu_url,
    #     }
    #     return JsonResponse(response)
def get_status(request, payment_id):
    try:
        payment_status = DjangoPayU.get_payment_status(payment_id)
    except DjangoPayException:
        return HttpResponseBadRequest()

    data = {"status": payment_status}
    return JsonResponse(data)
 def test_get_payment_status_for_failed_payment(self):
     PayuPayment.objects.filter(pk=self.payment_id).update(
         payment_status=PaymentStatus.STATUS_FAILED)
     self.assertEqual(DjangoPayU.get_payment_status(self.payment_id),
                      PaymentStatus.STATUS_FAILED)
 def test_get_payment_status_for_started_payment(self):
     self.assertEqual(DjangoPayU.get_payment_status(self.payment_id),
                      PaymentStatus.STATUS_STARTED)
 def test_get_payment_status_for_completed_payment(self):
     PayuPayment.objects.filter(pk=self.payment_id).update(payment_status=PaymentStatus.STATUS_COMPLETED)
     self.assertEqual(DjangoPayU.get_payment_status(self.payment_id), PaymentStatus.STATUS_COMPLETED)
 def test_get_payment_status_for_started_payment(self):
     self.assertEqual(DjangoPayU.get_payment_status(self.payment_id), PaymentStatus.STATUS_STARTED)