1

I am trying to create a recurring payment by using Stripe. It works just fine, but the problem is that I have 4 different payment plans, and the first time the user is paying, I am subscribing him to the lowest plan. Then, if I try to change the subscription, and set it to another plan, just like in their official documentation, it does not work for me. The code from their documentation looks like this:

 Stripe::setApiKey("sk_test_cTYCUNuIv8w6NeJcXSoAeLDO"); 
 $cu = Stripe_Customer::retrieve("cus_4keRPGExpTWMwe"); 
 $subscription = $cu->subscriptions->retrieve("sub_4keRoLrCJiHzAq"); 
 $subscription->plan = "gold"; 
 $subscription->save();

If I try to save the subscription, it gives me an error which says that the save method is not defined. Do you know any workarounds?

Thank you.

Ilie Gurzun
  • 61
  • 2
  • 6
  • are you passing in the correct customer & subscription id's? – FuzzyTree Sep 10 '14 at 12:48
  • Yes, and the subscription object that I want to change is a Stripe_Object, and I took a look in vendor, and examined this class, and it doesn't have the save() method. – Ilie Gurzun Sep 10 '14 at 12:58
  • possible duplicate of [unable to save or cancel subscriptions using Stripe](http://stackoverflow.com/questions/21517728/unable-to-save-or-cancel-subscriptions-using-stripe) – FuzzyTree Sep 10 '14 at 14:53
  • @user3906380 Did this ever get solved because I am seeing the same issue? – peacemaker Oct 13 '14 at 20:39
  • yes, I've managed to fix the problem by making first an api call to Stripe and retrieve the plan object, then done something like this "$subscription->plan = $StripePlan;" – Ilie Gurzun Oct 14 '14 at 11:50
  • 2
    Another option for changing plans looks like this: $cu->updateSubscription(["plan" => "new_plan_id"]); $cu->save(); – dperjar Nov 12 '15 at 16:39

0 Answers0