diff options
Diffstat (limited to 'alphabetlearning/payments/views.py')
-rw-r--r-- | alphabetlearning/payments/views.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/alphabetlearning/payments/views.py b/alphabetlearning/payments/views.py index d32542b..95eb5c8 100644 --- a/alphabetlearning/payments/views.py +++ b/alphabetlearning/payments/views.py @@ -1,5 +1,5 @@ import stripe -from django.http import HttpResponse +from django.http import HttpResponse, HttpResponseBadRequest from django.core.mail import send_mail from django.conf import settings from django.contrib.auth.decorators import login_required @@ -21,9 +21,11 @@ from .models import ShoppingCart # TODO get the cart integrated with Stripe # Steps to convert our Cart into something that can be used with Stripe: # +# - Fix the total in the cart # - X Sort out the webhook # - Associate the purchases with the users profile page # - We need a profile page! +# - Link in navbar (when logged in) # - Fix the email and make it nice # - Associate each of our resources with a Product item # - this should be done in the create resource page @@ -94,7 +96,10 @@ def add_to_cart(request, resource_id): def cart_detail(request): cart, created = ShoppingCart.objects.get_or_create(user=request.user) resources = [i.resource for i in cart.items.all()] - total = sum([r.price_obj.first().price for r in resources]) + try: + total = sum([r.price_obj.first().price for r in resources]) + except AttributeError: + return HttpResponseBadRequest(f"There is no price assigned to at least one of the resources you have added to the basket. Please contact Alphabet Learning Support.") context = { "cart": cart, "resources": resources, |