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.
On Fri, Mar 29, 2019 at 6:16 PM Patrice Chaula <chaulapsx@gmail.com> wrote:
I am using Stripe to process payments from my website. Yesterday it was working ok. That was before I changed code my code so It can process payments using a customer_id. I am using test keys--My code below. Help I'm still a beginner in django. I'm sorry my English is bad.
from django.shortcuts import renderfrom django.contrib.auth.decorators import login_requiredfrom django.conf import settingsimport stripestripe.api_key = settings.STRIPE_SECRET_KEY# Create your views here.@login_requireddef checkout(request):publishKey = settings.STRIPE_PUBLISHABLE_KEYcustomer_id = request.user.userstripe.stripe_idprint(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)The error I am getting is below
File "C:\Program Files\Python37-32\lib\site-packages\django\core\handlers\exception.py" in inner34. response = get_response(request)File "C:\Program Files\Python37-32\lib\site-packages\django\core\handlers\base.py" in _get_response126. response = self.process_exception_by_middleware(e, request)File "C:\Program Files\Python37-32\lib\site-packages\django\core\handlers\base.py" in _get_response124. response = wrapped_callback(request, *callback_args, **callback_kwargs)File "C:\Program Files\Python37-32\lib\site-packages\django\contrib\auth\decorators.py" in _wrapped_view21. return view_func(request, *args, **kwargs)File "C:\Users\Patrice\Desktop\ecommerce web\ecommerce\checkout\views.py" in checkout22. description = 'Example Charge',File "C:\Program Files\Python37-32\lib\site-packages\stripe\api_resources\abstract\createable_api_resource.py" in create22. response, api_key = requestor.request("post", url, params, headers)File "C:\Program Files\Python37-32\lib\site-packages\stripe\api_requestor.py" in request121. resp = self.interpret_response(rbody, rcode, rheaders)File "C:\Program Files\Python37-32\lib\site-packages\stripe\api_requestor.py" in interpret_response372. 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_response151. raise errException 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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@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.
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@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/CAMKMUjteR%2Be92Dx13aighSDA8%3DpbA3udHctncxFcixhpfCB1%2Bg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment