so I'm trying to create a customer in stripe using django, according to the documentation in stripe, the code stripe.Customer.create should work, but it just appears this error, can someone tell me why is this happening?
views.py
from django.shortcuts import render, redirect
from django.urls import reverse
from django.http import JsonResponse
import stripe
# Create your views here.
stripe.api_key = "xxxx"
def index(request):
return render(request, 'sales/index.html')
def charge(request):
amount = 5
if request.method == 'POST':
print('Data', request.POST)
stripe.Customer.create(
email=request.POST['email']
)
return redirect(reverse('success', args=[amount]))
def successMsg(request, args):
amount = args
return render(request, 'sales/success.html', {'amount':amount})
Traceback
Traceback (most recent call last):
File "C:\Users\snin2\anaconda3\envs\MyDjangoEnv\lib\site-packages\django\core\handlers\exception.py", line 47, in inner
response = get_response(request)
File "C:\Users\snin2\anaconda3\envs\MyDjangoEnv\lib\site-packages\django\core\handlers\base.py", line 179, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Users\snin2\Desktop\django braintree\stripe\sales\views.py", line 17, in charge
stripe.Customer.create(
AttributeError: module 'stripe' has no attribute 'Customer'
[18/Sep/2020 08:36:39] "POST /charge/ HTTP/1.1" 500 66773
from Django and Stripe, Module 'stripe' has no 'Customer' member
No comments:
Post a Comment