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

[11.x] Fix add and remove plan #926

Merged
merged 1 commit into from
Apr 27, 2020
Merged

Conversation

driesvints
Copy link
Member

Fixes #922

@driesvints driesvints mentioned this pull request Apr 27, 2020
@taylorotwell taylorotwell merged commit b425f26 into 11.x Apr 27, 2020
@Nuranto
Copy link

Nuranto commented Apr 27, 2020

@driesvints I don't know the code, I just saw your commit, so maybe I will say something stupid.
But should'nt we create the single plan item if not exist before setting plan to null ?

Something like this :

if ($this->hasSinglePlan()) {
           if ($this->items()->count() == 0 ) { // Can occurs after upgrading from version 10 to 11
                   $this->items()->create([
                           'stripe_id' => $subscription->stripe_id,
                           'stripe_plan' => $subscription->stripe_plan,
                           'quantity' => $subscription->quantity,
                   ]);
            }
            $this->fill([
                'stripe_plan' => null,
                'quantity' => null,
            ])->save();
}

If you think that's ugly, I think https://github.com/laravel/cashier/blob/master/UPGRADE.md should be updating to explicitly announce that the items should be created manually.

@driesvints driesvints deleted the fix-add-and-remove-plan branch April 27, 2020 13:48
@driesvints
Copy link
Member Author

@Nuranto no that's not needed. Your webhooks will take care of that.

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

Successfully merging this pull request may close these issues.

Multiple Plans
3 participants