【问题标题】:NoMethodError (undefined method `update_subscription' for #<Stripe::Customer:..> Koudoku Rails 6NoMethodError(#<Stripe::Customer:..> Koudoku Rails 6 的未定义方法 `update_subscription'
【发布时间】:2021-01-19 18:30:42
【问题描述】:

我正在尝试通过 Koudoku 使用我的用户模型购买计划,但我从 concer/subscription.rb 文件中收到一个错误,说明缺少方法。如何在收费时不存在“update_subscription”来修复此错误?引发错误的代码如下:

koudoku-2.0.0/app/concerns/koudoku/subscription.rb

# 使用条带更新包级别。

line #37: customer.update_subscription(:plan => self.plan.stripe_id, :prorate => Koudoku.prorate)

服务器开发日志

Started POST "/koudoku/enterprise_users/67ce5018-497c-43ae-af3f-55454y40a1a37f9/subscriptions" for 127.0.0.1 at 2020-10-04 15:51:40 -0400
Processing by Koudoku::SubscriptionsController#create as HTML
  Parameters: {"authenticity_token"=>"CXIMMgr1LDTC5B54YcageAUz/U+ErdHnTHvDwY83co1Ob8U6no2H4434LjeiIMMXvEqWs9OZJROMYI8f6zfNhy8w==", "subscription"=>{"plan_id"=>"1", "credit_card_token"=>"tok_1HYdFA2xuZZdQdXfxf444yitL", "last_four"=>"undefined", "card_type"=>"undefined"}, "owner_id"=>"67ce5018-497c-43ae-af3f-5576780a1a37f9"}
  EnterpriseUser Load (0.3ms)  SELECT "enterprise_users".* FROM "enterprise_users" WHERE "enterprise_users"."id" = $1 ORDER BY "enterprise_users"."id" ASC LIMIT $2  [["id", 1], ["LIMIT", 1]]
  EnterpriseUser Load (0.3ms)  SELECT "enterprise_users".* FROM "enterprise_users" WHERE "enterprise_users"."id" = $1 LIMIT $2  [["id", 67], ["LIMIT", 1]]
  EnterpriseUser Load (0.4ms)  SELECT "enterprise_users".* FROM "enterprise_users" WHERE "enterprise_users"."slug" = $1 LIMIT $2  [["slug", "67ce5018-497c-43ae-af3f-55770a1a37f9"], ["LIMIT", 1]]
  Subscription Load (0.2ms)  SELECT "subscriptions".* FROM "subscriptions" WHERE "subscriptions"."enterprise_user_id" = $1 LIMIT $2  [["enterprise_user_id", 1], ["LIMIT", 1]]
   (0.1ms)  BEGIN
  Plan Load (0.2ms)  SELECT "plans".* FROM "plans" WHERE "plans"."id" = $1 LIMIT $2  [["id", 1], ["LIMIT", 1]]
   (0.3ms)  ROLLBACK
Completed 500 Internal Server Error in 754ms (ActiveRecord: 1.9ms | Allocations: 17127)


  
NoMethodError (undefined method `update_subscription' for #<Stripe::Customer:0x00007f956444e9a0>
Did you mean?  update_attributes):
  

【问题讨论】:

    标签: ruby-on-rails ruby stripe-payments


    【解决方案1】:

    update_subscription 方法已在 stripe-ruby v5.0.0 版本中弃用并删除:https://github.com/stripe/stripe-ruby/releases/tag/v5.0.0

    stripe-ruby 的当前版本是 v5.26.0,很可能 Koudoku 使用的是一个非常旧的版本,因为它已经 3 年多没有更新了。

    Koudoku 在这一点上远远落后于 Stripe SDK。您可以使用 v5.0.0 之前的 stripe-ruby 版本,但我不建议您使用它,因为您会错过许多现代功能,例如 PaymentIntents,这些功能现在用于计费。我建议您改为查看有关如何构建您想要的内容的 Stripe 文档:https://stripe.com/docs/billing/subscriptions/fixed-price

    【讨论】:

    • 好的。我将使用 stripe 的 sdk 为我的订阅模型推出一些东西
    猜你喜欢
    • 2019-02-07
    • 2021-06-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-14
    • 1970-01-01
    • 2017-12-09
    相关资源
    最近更新 更多