unable to save or cancel subscriptions using Stripe

↘锁芯ラ 提交于 2020-01-01 10:02:26

问题


Using stripe's API with Ruby on Rails I am unable to save subscriptions.

I am able to retrieve and update and save customer objects:

customer = Stripe::Customer.retrieve(some_customer_id) #this works
customer.save #this works

I am also able to retrieve subscriptions: subscription=customer.subscriptions.retrieve("some_subscription_id") #this works

However, when trying to save a subscription: subscription.save #this doesn't work

I keep getting this:

NoMethodError: undefined method `save' for 
#<Stripe::StripeObject:0x007ff37147c720>
from /Users/me/.rvm/gems/ruby-2.0.0-p353/gems/stripe-    
1.9.9/lib/stripe/stripe_object.rb:158:in `method_missing'

Similarly when trying to cancel a subscription:

customer.subscriptions.retrieve("sub_3QM09lOz64QuSf").delete()

I get:

NoMethodError: undefined method `delete' for 
    #<Stripe::StripeObject:0x007ff36d3f0d50>
from /Users/me/.rvm/gems/ruby-2.0.0-p353/gems/stripe-
    1.9.9/lib/stripe/stripe_object.rb:158:in `method_missing'

Without this I am not able to allow customers to cancel directly from the site.

What am I missing?


回答1:


Upgrade to their latest gem with bundle update stripe and try again. Subscriptions were changed sometime around 1.10.0 and requires a version after that to save them. By configuring your gemfile to use their github repository you're essentially using the latest version available at the time of your bundle.



来源:https://stackoverflow.com/questions/21517728/unable-to-save-or-cancel-subscriptions-using-stripe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!