Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with canceling at end of subscription #138

Closed
growthboot opened this issue Jul 17, 2019 · 5 comments
Closed

Issue with canceling at end of subscription #138

growthboot opened this issue Jul 17, 2019 · 5 comments

Comments

@growthboot
Copy link

Code:
$subscription = $stripe->subscriptions()->cancel('cus_4EBumIjyaKooft', 'sub_4ETjGeEPC5ai9J', true);

Issue:
When $atPeriodEnd is present the following error appears:

Caught exception: Received unknown parameter: at_period_end

Potential fix:
As mentioned here:
laravel/cashier-stripe#551
You can use cancel_at_period_end on the subscription update endpoints instead.

@brunogaspar
Copy link
Member

Unfortunately, it's not as straightforward as you might think as i can't just rename an attribute and that's it :\

This will most likely need to wait until a new major version and i'm aware of this "field" and many others that have been renamed on Stripe end.

For the time being, you can use the update method and pass the cancel_at_period_end attribute until then, it's the only doable fix i have for now.

@growthboot
Copy link
Author

That is unfortunate. I'm very surprised the renaming of a parameter can cause such a complicated issue. It's not clear in your documentation how I could use the update to achieve the same result.

@brunogaspar
Copy link
Member

That is unfortunate. I'm very surprised the renaming of a parameter can cause such a complicated issue.

Yes, it's mostly due to how Stripe handles versioning.

It's not clear in your documentation how I could use the update to achieve the same result.

You just need to pass the cancel_at_period_end on the parameters array:

<?php

$customerId = 'cus_4EBumIjyaKooft';

$subscriptionId = 'sub_4ETjGeEPC5ai9J';

$subscription = $stripe->subscriptions()->update($customerId, $subscriptionId, [
    'cancel_at_period_end' => true,
]);

It's not difficult.

Let me know how it goes :)

@growthboot
Copy link
Author

Worked beautifully! My confusion came from the fact that I thought I would still need to call cancel and reactivate methods but I tried just updating the parameter alone and checking stripe which shows it works. Very happy now that it works, thank you :)

@brunogaspar
Copy link
Member

No problem :)

Let me know if you find any other issues or have other questions ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants