From c778eaf8e27dc0b77b8a4d6754e504ba1d192132 Mon Sep 17 00:00:00 2001 From: Ruidy Date: Thu, 28 Jan 2021 21:43:53 +0100 Subject: [PATCH] add payment page --- rental/templates/rental/pay.html | 68 ++++++++++++++++++++++++++++++++ rental/urls.py | 1 + rental/views/booking.py | 23 +++++++++++ requirements.txt | 1 + 4 files changed, 93 insertions(+) create mode 100644 rental/templates/rental/pay.html diff --git a/rental/templates/rental/pay.html b/rental/templates/rental/pay.html new file mode 100644 index 0000000..0e38b02 --- /dev/null +++ b/rental/templates/rental/pay.html @@ -0,0 +1,68 @@ +{% extends 'rental/base.html' %} {% load static %} {% block content %} + + +
+
+
+
+
+

Merci pour votre réservation

+ En cliquant sur le bouton ci-dessous vous serez redirigé vers une page de paiement sécurisé.
+
+
+
+
+ +
+
+
+
+
+
+ +
+
+
+
+
+
+ + +{% endblock %} diff --git a/rental/urls.py b/rental/urls.py index 933fa3f..3671eb0 100644 --- a/rental/urls.py +++ b/rental/urls.py @@ -17,6 +17,7 @@ urlpatterns = [ path('contact/', contact.view, name='contact'), path('reservation/', booking.view, name='reservation'), + path('paiement/', booking.pay, name='payment'), path('', place.index, name='index'), path('hebergements/', place.all, name='list_place'), diff --git a/rental/views/booking.py b/rental/views/booking.py index 46c7029..36812c5 100644 --- a/rental/views/booking.py +++ b/rental/views/booking.py @@ -7,7 +7,30 @@ from rental.forms.booking import BookingForm from rental.models.booking import Booking from rental.models.guest import Guest from rental.models.place import Place +import stripe +def pay(request): + if request.method == 'GET': + return render(request, 'rental/pay.html', {}) + + session = stripe.checkout.Session.create( + payment_method_types=["card"], + line_items=[ + { + "price_data": { + "currency": "eur", + "product_data": {"name": "Nassira Basmaison: Réservation du 28/01/2021 au 8/02/2021"}, + "unit_amount": 91300, + }, + "quantity": 1, + } + ], + mode="payment", + success_url="http://villafleuriegp.com/", + cancel_url="http://villafleuriegp.com/paiement", + ) + + return {"id": session.id} def view(request): """Return initial booking form.""" diff --git a/requirements.txt b/requirements.txt index b01f7f5..c889de4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -32,6 +32,7 @@ rsa==4.0 six==1.14.0 soupsieve==2.0 sqlparse==0.3.1 +stripe==2.55.1 uritemplate==3.0.1 urllib3==1.25.8 vine==1.3.0