AttributeError: module 'stripe' has no attribute 'PaymentIntent'

AttributeError: module 'stripe' has no attribute 'PaymentIntent'

我已经安装了 Stripe python 模块 (1.70.0) 并想创建一个 PaymentIntent 来为移动设备收费。却做不到。

import stripe
stripe.api_key = "sk_test_XXXXXXXXX"
stripe.PaymentIntent.create(
  amount=1099,
  currency='usd',
  payment_method_types=['card'],
)

AttributeError:模块 'stripe' 没有属性 'PaymentIntent'。任何帮助将不胜感激。

版本 1.70.0 来自 2017 年,不支持 PaymentIntents(在 1.84.0 中添加)。您应该更新到最新版本的库。

https://github.com/stripe/stripe-python/wiki/Migration-guide-for-v2

https://github.com/stripe/stripe-python/blob/master/CHANGELOG.md#1700---2017-10-23 https://github.com/stripe/stripe-python/blob/master/CHANGELOG.md#1840---2018-06-29

我有同样的错误,但在我的例子中,我的错误是我将 django 应用命名为与 stripe 库同名。

一个基本错误,但可能会发生在新手身上。