System check identified no issues (0 silenced).
May 28, 2020 - 13:23:50
Django version 3.0.6, using settings 'ecommerce.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
Internal Server Error: /cart/checkout/
Traceback (most recent call last):
File "C:\Users\Mahesh\himalaya\lib\site-packages\django\core\handlers\exception.py", line 34, in inner
response = get_response(request)
File "C:\Users\Mahesh\himalaya\lib\site-packages\django\core\handlers\base.py", line 115, in _get_response
response = self.process_exception_by_middleware(e, request)
File "C:\Users\Mahesh\himalaya\lib\site-packages\django\core\handlers\base.py", line 113, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Users\Mahesh\himalaya\ecommerce\carts\views.py", line 89, in checkout_home
did_charge, crg_msg = billing_profile.charge(order_obj)
File "C:\Users\Mahesh\himalaya\ecommerce\billing\models.py", line 46, in charge
return Charge.objects.do(self, order_obj, card)
File "C:\Users\Mahesh\himalaya\ecommerce\billing\models.py", line 107, in do
c = stripe.Charge.create(
NameError: name 'stripe' is not defined
Please confirm below steps,
Is your virtual env activated? Did you install stripe package??. If yes , what is the package you installed? Show me the import & usage code ?
- scott 4 years, 11 months agoyes it is installed and activated. (himalaya) C:\Users\Mahesh\himalaya\ecommerce>pip freeze asgiref==3.2.7 astroid==2.4.1 certifi==2020.4.5.1 chardet==3.0.4 colorama==0.4.3 Django==3.0.6 djangorestframework==3.11.0 idna==2.9 isort==4.3.21 lazy-object-proxy==1.4.3 mccabe==0.6.1 Pillow==7.0.0 pylint==2.5.2 pytz==2019.3 requests==2.23.0 six==1.15.0 somepackage==1.2.3 sqlparse==0.3.1 stripe==2.48.0 toml==0.10.1 typed-ast==1.4.1 urllib3==1.25.9 wrapt==1.12.1
(himalaya) C:\Users\Mahesh\himalaya\ecommerce>
- maheshbist111 4 years, 11 months agoNameError at /cart/checkout/
name 'stripe' is not defined
Request Method: POST
Request URL: http://127.0.0.1:8000/cart/checkout/
Django Version: 3.0.6
Exception Type: NameError
Exception Value:
name 'stripe' is not defined
Exception Location: C:\Users\Mahesh\himalaya\ecommerce\billing\models.py in do, line 107
Python Executable: C:\Users\Mahesh\himalaya\Scripts\python.exe
Python Version: 3.7.4
Python Path:
['C:\Users\Mahesh\himalaya\ecommerce',
'C:\Users\Mahesh\AppData\Local\Programs\Python\Python37-32\python37.zip',
'C:\Users\Mahesh\AppData\Local\Programs\Python\Python37-32\DLLs',
'C:\Users\Mahesh\AppData\Local\Programs\Python\Python37-32\lib',
'C:\Users\Mahesh\AppData\Local\Programs\Python\Python37-32',
'C:\Users\Mahesh\himalaya',
'C:\Users\Mahesh\himalaya\lib\site-packages']
Server time: Thu, 28 May 2020 07:55:26 +0000
Traceback Switch to copy-and-paste view
C:\Users\Mahesh\himalaya\lib\site-packages\django\core\handlers\exception.py in inner
response = get_response(request) …
▶ Local vars
C:\Users\Mahesh\himalaya\lib\site-packages\django\core\handlers\base.py in _get_response
response = self.process_exception_by_middleware(e, request) …
▶ Local vars
C:\Users\Mahesh\himalaya\lib\site-packages\django\core\handlers\base.py in _get_response
response = wrapped_callback(request, callback_args, *callback_kwargs) …
▶ Local vars
C:\Users\Mahesh\himalaya\ecommerce\carts\views.py in checkout_home
did_charge, crg_msg = billing_profile.charge(order_obj) …
▶ Local vars
C:\Users\Mahesh\himalaya\ecommerce\billing\models.py in charge
return Charge.objects.do(self, order_obj, card) …
▶ Local vars
C:\Users\Mahesh\himalaya\ecommerce\billing\models.py in do
c = stripe.Charge.create( …
▶ Local vars
import stripe
from django.http import JsonResponse, HttpResponse from django.shortcuts import render, redirect from django.utils.http import is_safe_url
stripe.api_key = "sk_test_kKKjtffSyYqvfFFw3ifXaLth00G0ia6Ke1" STRIPE_PUB_KEY = 'pk_test_blksRJqozhNmHJhS50p8eqLc00Tebc1PTT'
from .models import BillingProfile, Card
def payment_method_view(request): # if request.user.is_authenticated(): # billingprofile = request.user.billingprofile # my_customer_id = billing_profile.my_customer_id billing_profile, billing_profile_created = BillingProfile.objects.new_or_get(request) if not billing_profile: return redirect("/cart") next_url = None next_ = request.GET.get('next') if is_safe_url(next_, request.get_host()): next_url = next_ return render(request, 'billing/payment-method.html', {"publish_key": STRIPE_PUB_KEY, "next_url": next_url})
def payment_method_createview(request): if request.method == "POST" and request.is_ajax(): billing_profile, billing_profile_created = BillingProfile.objects.new_or_get(request) if not billing_profile: return HttpResponse({"message": "Cannot find this user"}, status_code=401) token = request.POST.get("token") if token is not None: customer = stripe.Customer.create(billing_profile.customer_id) card_response = customer.sources.create(source=token) new_card_obj = Card.objects.add_new(billing_profile, card_response) print(new_card_obj) return JsonResponse({"message": "Success! Your card was added."}) return HttpResponse("error", status_code=401)
- maheshbist111 4 years, 11 months agoalso make sure to use markup language when you paste the code ,.. that help us to grab the code and take a look
- Vengatno i mean function name you are caling and getting this error.. because i installed stripe my end .. i dont see any issue.. so atleast there is no issue in package... problem may be how you are using in your view
- VengatAfter adding card When I go for submit checkout I get this error...
- maheshbist111 4 years, 11 months agoAfter adding card When I go for submit checkout I get this error...
- maheshbist111 4 years, 11 months agook please provide me the URL & view details(i mean function details) submit button calling
- Vengatno .. you are not get my point ..ok send me the html file, urls.py & views.py.. send me to learnswvarn@gmail.com
- Vengatcan we connect in zoom meeting?.. because i dont understand the issue
- VengatSure...IAM from Nepal so is this time (9:45)according to my time zone or yours...
- maheshbist111 4 years, 11 months ago
Acknowledged.assigned to our techie