Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/ISPP-G5/NexONG_Backend i…
Browse files Browse the repository at this point in the history
…nto hotfix/188-fix-put-and-patch-donation
  • Loading branch information
JuanluRM committed Apr 27, 2024
2 parents ce901b9 + 0d9cc75 commit f150c6f
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 4 deletions.
20 changes: 16 additions & 4 deletions nexong/api/PunctualDonationByCard/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from django.shortcuts import render
from rest_framework.viewsets import ModelViewSet
from rest_framework.response import Response
from rest_framework import status
Expand Down Expand Up @@ -95,14 +96,25 @@ def payment_success(request):
amount=paymentAmount,
date=paymentDate,
)
# If the creation is successful, you can perform additional actions here
return JsonResponse({"message": f"Donacion de {donation.amount} euros creada!"})
success_redirect = settings.FRONTEND_URL
return render(
request,
"payment_success.html",
{"donation": donation, "success_redirect": success_redirect},
)
except Exception as e:
# If an exception occurs during creation, handle it here
return JsonResponse(
{"message": f"Algo ha fallado en la creación de la donación {str(e)}"}
)


def payment_cancel():
return JsonResponse({"error": "Error al realizar el pago", "status": "failed"})
cancel_redirect = settings.FRONTEND_URL + "/donaciones"
return render(
"payment_cancel.html",
{
"error": "Error al realizar el pago",
"status": "failed",
"cancel_redirect": cancel_redirect,
},
)
16 changes: 16 additions & 0 deletions nexong/templates/payment_cancel.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html>
<head>
<title>Pago Fallido</title>
<script>
setTimeout(function() {
window.location.href = "{{ cancel_redirect }}";
}, 5000);
</script>
</head>
<body>
<h1>Pago fallido</h1>
<p>Ha habido un problema. Intentelo de nuevo.</p>
<p>Redirigiendo a la página de la organización...</p>
</body>
</html>
16 changes: 16 additions & 0 deletions nexong/templates/payment_success.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html>
<head>
<title>Pago Exitoso</title>
<script>
setTimeout(function() {
window.location.href = "{{ success_redirect }}";
}, 5000);
</script>
</head>
<body>
<h1>¡Pago exitoso!</h1>
<p>Gracias por tu donación de {{ donation.amount }} euros.</p>
<p>Redirigiendo a la página de la organización...</p>
</body>
</html>

0 comments on commit f150c6f

Please sign in to comment.