Commit f5d3bd62 authored by frekk's avatar frekk
Browse files

fixed bugs

parent 6ff3010a
......@@ -2,6 +2,7 @@ import uuid
from django.db import models
from django.urls import reverse
from django.utils import timezone
from memberdb.models import Membership, make_token
......@@ -15,9 +16,9 @@ class CardPayment(models.Model):
date_paid = models.DateTimeField('Date paid (payment captured)', null=True, blank=True)
def set_paid(self):
card_payment.is_paid = True
card_payment.date_paid = timezone.now()
card_payment.save()
self.is_paid = True
self.date_paid = timezone.now()
self.save()
class MembershipPayment(CardPayment):
"""
......
......@@ -5,7 +5,6 @@ import logging
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.utils import timezone
import squareconnect
from squareconnect.rest import ApiException
......
......@@ -31,11 +31,12 @@ class PaymentFormMixin:
return context
def payment_success(self, payment):
set_paid(payment)
messages.success(request, "Your payment of $%1.2f was successful." % amount_aud)
payment.set_paid()
messages.success(self.request, "Your payment of $%1.2f was successful." % (payment.amount / 100.0))
def payment_error(self, payment):
messages.error(request, "Your payment of $%1.2f was unsuccessful. Please try again later." % amount_aud)
messages.error(self.request, "Your payment of $%1.2f was unsuccessful. Please try again later." % (payment.amount / 100.0))
payment.delete()
def post(self, request, *args, **kwargs):
nonce = request.POST.get('nonce', None)
......@@ -47,9 +48,9 @@ class PaymentFormMixin:
return self.get(request)
if try_capture_payment(card_payment, nonce):
payment_success(card_payment)
self.payment_success(card_payment)
else:
payment_error(card_payment)
self.payment_error(card_payment)
# redirect to success URL, or redisplay the form with a success message if none is given
return HttpResponseRedirect(self.get_completed_url())
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment