Search code examples
pythondjangostripe-paymentspinax

Error in charging a one-off payment in pinax-stripe module of django python


I am developing an application in python in django framework where I have to charge one-off payment from the customers. I am using pinax-stripe module for payments(https://github.com/pinax/pinax-stripe).

When I charge the customer in my view like this:

#views.py
from pinax.stripe.models import *

if customer.can_charge():
    customer.charge(15.00) #charge

It gives me the the following error:

Exception Type: NameError

Exception Value: name 'customer' is not defined

I know there is something I need to import from pinax.stripe into my app's views.py. Does anyone know what is it?


Solution

  • You should probably look at the getting started guide

    It mentions that to create customers, you'd need code like

    from pinax.stripe.actions import customers
    customer = customers.create(user=new_user)
    

    Edit

    If a customer object already exists, you can try to get it with something like

    customer = Customer.objects.get(user=relevant_user) # or similar