wave
wave copied to clipboard
Fix plan switching updating role if Paddle returns error
Found an issue with the subscription plan switching on my Laravel 9 fork and decided to backport it here. The issue happens if the API call to Paddle happens to return an error, for instance, the plan_id
exists in the APP but doesn't on Paddle. Or say the Paddle API happens to be down. The subscription doesn't update on Paddle's system but the users' role still changes.
This PR fixes this issue by only updating the users' role if we get a successful response from the Paddle API. It also now updates the plan_id
on the subscription model.