我试图找出使用 Stripe 于 2019 年 7 月 1 日提供的新工具集编写简单订阅的方法(请参阅此处https://stripe.com/docs/payments/checkout/fulfillment)以满足 SCA 规定,但它对我不起作用。如果有人可以在 Flask/Python 中分享一个完整的示例(结帐、查看等),那就太好了。
我附上了我在使用 Stripe 仪表板创建产品和计划后实现的代码。我的客户将来自我的代码/数据库,这是我尚未真正开发的东西。
视图.py
@app.route('/checkout', methods=['GET', 'POST'])
def checkout():
session = stripe.checkout.Session.create(
payment_method_types=['card'],
subscription_data={
'items': [{
'plan': 'my_plan_id',
}],
},
success_url='https://mywebsite.com',
cancel_url='https://mywebsite.com',
)
print(session)
return render_template('/web/premium/checkout.html')
Run Code Online (Sandbox Code Playgroud)
checkout.html 是
<script src="https://js.stripe.com/v3/"></script>
<script>
var stripe = Stripe('pk_test_jOuM3bOylIuDHhxMk19ut3CH');
stripe.redirectToCheckout({
items: [
{sku: 'my_product_id', quantity: 1}
],
successUrl: 'https://mywebsite.com',
cancelUrl: 'https://mywebsite.com',
submitType: 'donate',
}).then(function (result) {
});
</script>
Run Code Online (Sandbox Code Playgroud)
这是我打印“会话”时得到的:
{
"billing_address_collection": null,
"cancel_url": "https://mywebsite.com",
"client_reference_id": null,
"customer": null,
"customer_email": …Run Code Online (Sandbox Code Playgroud)