Reputation: 63
I am trying to cancel any Subscription that I created in StripeAPI. I have schedule id from created schedule subscription. How to cancel schedule subscription in php? I tried to call cancel function.
\Stripe\SubscriptionSchedule::cancel
But I face below error:
Deprecated: Non-static method Stripe\SubscriptionSchedule::cancel() should not be called statically
Could you tell me what function should be called and what params I should use?
Upvotes: 2
Views: 362
Reputation: 25552
The stripe-php library added support for client and services in 7.33.0. This is documented in details here. If you're on a version after that one, you can call the cancel()
method on the service directly which is what the API Reference shows here:
$stripe = new \Stripe\StripeClient('sk_test_123');
$stripe->subscriptionSchedules->cancel('sub_sched_ABC');
On the other hand, if you have an older version of the library, you need to use the old methods via the resource. In that case, there wasn't a static cancel()
method (one of the upsides of the services infrastructure). Because of this, you had to retrieve the schedule first and then cancel it:
\Stripe\Stripe::setApiKey('sk_test_123');
$schedule = \Stripe\SubscriptionSchedule::retrieve('sub_sched_ABC');
$schedule->cancel();
Upvotes: 2