在 django 的 pinax-stripe 模块中收取一次性付款时出错 python

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

我正在 python 在 django 框架中开发一个应用程序,我必须向客户收取一次性付款。我正在使用 pinax-stripe 模块进行支付(https://github.com/pinax/pinax-stripe).

当我向客户收费时,在我看来是这样的:

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

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

它给我以下错误:

Exception Type: NameError

Exception Value: name 'customer' is not defined

我知道我需要将一些东西从 pinax.stripe 导入到我的应用 views.py 中。有人知道是什么吗?

你应该看看 getting started guide

它提到要创建客户,您需要像

这样的代码
from pinax.stripe.actions import customers
customer = customers.create(user=new_user)

编辑

如果客户对象已经存在,您可以尝试使用类似

的方法来获取它
customer = Customer.objects.get(user=relevant_user) # or similar