我正在使用 Stripe gem 为测试 Web 应用程序创建订阅模型。我可以创建订阅并通过手动输入订阅 ID 来删除它,但我想将订阅保存到我的数据库中,这样我就不必这样做。这是我到目前为止所拥有的:
customer = Stripe::Customer.create(
card: token,
email: current_user.email
)
Stripe::Subscription.create(
customer: customer.id,
plan: 000
)
current_user.stripe_id = customer.id
current_user.stripe_subscription_id = subscription.id
我收到一条错误消息,指出没有订阅 ID。如何获取订阅 ID?我需要它,以便我可以在需要时取消订阅。我厌倦了查看 API,但它没有明确说明如何检索订阅 API。
最佳答案
哎呀...我忘记分配订阅了。我将第一行更改为:
Stripe::Subscription.create()
至:
订阅 = Stripe::Subscription.create()
现在它可以工作了。
关于ruby-on-rails - Stripe 创建后获取订阅 ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43184278/