【发布时间】:2019-03-09 01:19:15
【问题描述】:
我使用了 Stripe 的 Element 示例 1,在此处找到:https://jsfiddle.net/ywain/2qyamjga/ 用 Flask 测试 Stripe Elements。在我的应用中,姓名和电话号码字段允许用户输入,但卡片字段不允许。
这是我的视图函数代码:
@billing.route('/charge', methods=['GET', 'POST'])
def charge():
if request.method == 'POST':
customer = stripe.Customer.create(
email='customer@example.com',
source=request.form['stripeToken']
)
charge = stripe.Charge.create(
customer=customer.id,
amount=request.form['amountInCents'],
currency='usd',
description='Flask Charge'
)
return render_template('billing/charge.html')
查看网络控制台后,我收到此错误:
Error: The selector you specified (#card-element) applies to no DOM elements that are currently on the page.
Make sure the element exists on the page before calling mount().
我该怎么做呢?任何建议将不胜感激。条带源代码可以在这里找到:https://github.com/stripe/elements-examples/#example-1
【问题讨论】:
标签: javascript stripe-payments