NoMethodError (未定义的方法'update_subscription' for #<Stripe::Customer:..> Koudoku Rails 6



我正试图通过Koudoku用我的用户模型购买一个计划,但我从concer/subscription.rb文件中收到一个错误,因为缺少一个方法。如何使用update_subscription"修复此错误;指控时不在场?引发错误的代码如下:

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

#使用stripe更新包级别

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):

在stripe ruby v5.0.0版本中,update_subscription方法已被弃用并删除: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

相关内容

最新更新