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.


Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


<https://www.avast.com/en-in/recommend?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=default3&tag=7ce9710f-d0c2-48a2-a0ba-76107578348e>
I’m
protected online with Avast Free Antivirus. Get it here — it’s free forever.
<https://www.avast.com/en-in/recommend?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=default3&tag=7ce9710f-d0c2-48a2-a0ba-76107578348e>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Fri, Mar 29, 2019 at 6:16 PM Patrice Chaula <chaula...@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 render
> from django.contrib.auth.decorators import login_required
> from django.conf import settings
> import stripe
>
>
> stripe.api_key =  settings.STRIPE_SECRET_KEY
> # Create your views here.
> @login_required
> def 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)
>
>
> The error I am getting is below
>
> 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+unsubscr...@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
> <https://groups.google.com/d/msgid/django-users/04423272-5bf9-4b26-9963-c180b926c909%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

<https://www.avast.com/en-in/recommend?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=default3&tag=7ce9710f-d0c2-48a2-a0ba-76107578348e>
I’m
protected online with Avast Free Antivirus. Get it here — it’s free forever.
<https://www.avast.com/en-in/recommend?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=default3&tag=7ce9710f-d0c2-48a2-a0ba-76107578348e>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

-- 
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+unsubscr...@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.

Reply via email to