diff --git a/payments/migrations/0001_initial.py b/payments/migrations/0001_initial.py new file mode 100644 index 0000000..27db43e --- /dev/null +++ b/payments/migrations/0001_initial.py @@ -0,0 +1,26 @@ +# Generated by Django 3.1.3 on 2021-04-04 16:24 + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ] + + operations = [ + migrations.CreateModel( + name='Invoice', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('total', models.FloatField(blank=True, null=True)), + ('amount', models.FloatField(blank=True, null=True)), + ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), + ], + ), + ] diff --git a/payments/migrations/0002_invoice_payment_complete.py b/payments/migrations/0002_invoice_payment_complete.py new file mode 100644 index 0000000..84b3de6 --- /dev/null +++ b/payments/migrations/0002_invoice_payment_complete.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.3 on 2021-04-04 16:54 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('payments', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='invoice', + name='payment_complete', + field=models.BooleanField(default=False), + ), + ] diff --git a/payments/migrations/0003_invoice_invoice_code.py b/payments/migrations/0003_invoice_invoice_code.py new file mode 100644 index 0000000..282be31 --- /dev/null +++ b/payments/migrations/0003_invoice_invoice_code.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.3 on 2021-04-05 05:02 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('payments', '0002_invoice_payment_complete'), + ] + + operations = [ + migrations.AddField( + model_name='invoice', + name='invoice_code', + field=models.CharField(blank=True, max_length=200, null=True), + ), + ] diff --git a/payments/models.py b/payments/models.py index 71a8362..6c32b82 100644 --- a/payments/models.py +++ b/payments/models.py @@ -1,3 +1,12 @@ from django.db import models +from django.contrib.auth.views import get_user_model -# Create your models here. +User = get_user_model() + + +class Invoice(models.Model): + user = models.ForeignKey(User, on_delete=models.CASCADE) + total = models.FloatField(null=True, blank=True) + amount = models.FloatField(null=True, blank=True) + payment_complete = models.BooleanField(default=False) + invoice_code = models.CharField(max_length=200, blank=True, null=True) diff --git a/payments/templates/invoice_detail.html b/payments/templates/invoice_detail.html new file mode 100644 index 0000000..b2b81c7 --- /dev/null +++ b/payments/templates/invoice_detail.html @@ -0,0 +1,5 @@ +

Invoices

+ +

{{ invoice.user }}

+

{{ invoice.amount }}

+

{{ invoice.total }}

diff --git a/payments/templates/invoices.html b/payments/templates/invoices.html new file mode 100644 index 0000000..4dbde04 --- /dev/null +++ b/payments/templates/invoices.html @@ -0,0 +1,13 @@ +

Invoices

+ +
{% csrf_token %} + + +
+ +{% for invoice in invoices %} +

{{ invoice.user }}

+

{{ invoice.amount }}

+

{{ invoice.total }}

+

{{ invoice.payment_complete }}

+{% endfor %} diff --git a/payments/templates/payments/home.html b/payments/templates/payments/home.html deleted file mode 100644 index f7d0fa8..0000000 --- a/payments/templates/payments/home.html +++ /dev/null @@ -1,9 +0,0 @@ -

Buy for $5.00

-
- {% csrf_token %} - -
diff --git a/payments/templates/payments/payment_gateways.html b/payments/templates/payments/payment_gateways.html index 53e3520..c05cebb 100644 --- a/payments/templates/payments/payment_gateways.html +++ b/payments/templates/payments/payment_gateways.html @@ -3,6 +3,9 @@ {% load static %} {% block header %} + + + {% endblock %} @@ -68,13 +71,16 @@

Payment GateWays

+ +
+ {% csrf_token %} + +
+ +

Paypal

-
-
-
-
-
+

Stripe

@@ -87,7 +93,6 @@ data-locale="auto"> -

Make payment with stripe and get jobs done.

@@ -106,10 +111,6 @@ Make payment with stripe and get jobs done.

-
@@ -119,35 +120,85 @@ {% block js %} - - + + - onApprove: function(data, actions) { - return actions.order.capture().then(function(details) { - alert('Transaction completed by ' + details.payer.name.given_name + '!'); - }); - }, - onError: function(err) { - console.log(err); - } - }).render('#paypal-button-container'); - } - initPayPalButton(); - {% endblock js %} diff --git a/payments/templates/payments/payment_succeed.html b/payments/templates/payments/payment_succeed.html new file mode 100644 index 0000000..8b49780 --- /dev/null +++ b/payments/templates/payments/payment_succeed.html @@ -0,0 +1,50 @@ +{% extends 'base.html' %} +{% block title %}PayPal{% endblock title %} +{% load static %} + +{% block header %} + +{% endblock %} + +{% block content %} + +
+
+

Payment Succeed, You has been make payment successfuly.

+
Redirect to the invoice in 8
+
+ +
+{% endblock content %} + +{% block js %} + + + +{% endblock %} diff --git a/payments/templates/payments/paypal.html b/payments/templates/payments/paypal.html index bb0e0d2..6cdac4e 100644 --- a/payments/templates/payments/paypal.html +++ b/payments/templates/payments/paypal.html @@ -1,45 +1,56 @@ - - - + + + + + + + + PayPal Smart Payment Buttons Integration | Client Demo - + + -
-