valcod3r
valcod3r

Reputation: 331

NoMethodError (undefined method `update_subscription' for #<Stripe::Customer:..> Koudoku Rails 6

I'm attempting to purchase a plan with my user model through Koudoku and I receive an error from the concer/subscription.rb file for a method being missing. How do I fix this error with the update_subscription" not being present when a charge is being made? The code that throws the error is below:

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

# update the package level with stripe.

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

Server development log

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

Upvotes: 1

Views: 276

Answers (1)

Paul Asjes
Paul Asjes

Reputation: 5847

The update_subscription method was deprecated and removed in stripe-ruby v5.0.0 release: https://github.com/stripe/stripe-ruby/releases/tag/v5.0.0

The current version of stripe-ruby is v5.26.0, it's likely that Koudoku is using a very old version as it hasn't been updated in 3+ years.

Koudoku is at this point far behind the Stripe SDK. You can use a version of stripe-ruby prior to v5.0.0, but I don't recommend it as you'll be missing out on a lot of modern features such as PaymentIntents, which are used for billing now. I suggest you instead look at the Stripe docs on how to build what you want: https://stripe.com/docs/billing/subscriptions/fixed-price

Upvotes: 2

Related Questions