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?
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