Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

unable to save or cancel subscriptions using Stripe

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?

like image 547
jco40 Avatar asked Feb 02 '14 23:02

jco40


People also ask

How do I deal with failed subscription payments on Stripe?

If a payment fails for a subscription invoice, your customers can use the Stripe-hosted page to: View the details and amounts for the failed invoice and the associated subscription. Add a new card payment method for their subscription for the payment that's due and for future subscription payments.

Why is my Stripe subscription status incomplete?

The subscription remains in status incomplete and the invoice is open during this time. If your customer pays the invoice, the subscription updates to active and the invoice to paid . If they don't make a payment, the subscription updates to incomplete_expired and the invoice becomes void .

Can you set up subscriptions with Stripe?

You can create or update a subscription using the Stripe Dashboard or the Stripe API. When creating a subscription, you can start immediately or schedule the subscription to start later.


1 Answers

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.

like image 140
McFadden Avatar answered Oct 22 '22 02:10

McFadden