from django.shortcuts import renderfrom django.contrib.auth.decorators import login_requiredfrom django.conf import settingsimport stripe
stripe.api_key = settings.STRIPE_SECRET_KEY# Create your views here.@login_requireddef checkout(request): publishKey = settings.STRIPE_PUBLISHABLE_KEY customer_id = request.user.userstripe.stripe_id print(customer_id) if request.method == 'POST': customer = stripe.Customer.retrieve(customer_id) token = request.POST['stripeToken'] charge = stripe.Charge.create( amount = 1000, currency = 'usd', customer = customer, description = 'Example Charge', ) context = {'publishKey':publishKey} template = 'checkout.html' return render(request, template, context)File "C:\Program Files\Python37-32\lib\site-packages\django\core\handlers\exception.py" in inner 34. response = get_response(request)
File "C:\Program Files\Python37-32\lib\site-packages\django\core\handlers\base.py" in _get_response 126. response = self.process_exception_by_middleware(e, request)
File "C:\Program Files\Python37-32\lib\site-packages\django\core\handlers\base.py" in _get_response 124. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Program Files\Python37-32\lib\site-packages\django\contrib\auth\decorators.py" in _wrapped_view 21. return view_func(request, *args, **kwargs)
File "C:\Users\Patrice\Desktop\ecommerce web\ecommerce\checkout\views.py" in checkout 22. description = 'Example Charge',
File "C:\Program Files\Python37-32\lib\site-packages\stripe\api_resources\abstract\createable_api_resource.py" in create 22. response, api_key = requestor.request("post", url, params, headers)
File "C:\Program Files\Python37-32\lib\site-packages\stripe\api_requestor.py" in request 121. resp = self.interpret_response(rbody, rcode, rheaders)
File "C:\Program Files\Python37-32\lib\site-packages\stripe\api_requestor.py" in interpret_response 372. self.handle_error_response(rbody, rcode, resp.data, rheaders)
File "C:\Program Files\Python37-32\lib\site-packages\stripe\api_requestor.py" in handle_error_response 151. raise err
Exception Type: CardError at /checkout/Exception Value: Request req_En9Ipi3bygWUWY: Cannot charge a customer that has no active card--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/04423272-5bf9-4b26-9963-c180b926c909%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
I am not sure about this.
But the issue seems to be that the user in question has a stripe account and that stripe account does not have any cards associated with the account. Maybe try adding a card to the account, if it does not have any. If it has, delete it and create a new one. See if it helps.
To unsubscribe from this group and stop receiving emails from it, send an email to django...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/04423272-5bf9-4b26-9963-c180b926c909%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.