Closed HelgeSverre closed 9 months ago
Thanks for submitting a PR!
Note that draft PR's are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface.
Pull requests that are abandoned in draft may be closed due to inactivity.
Too many other formatting changes here.
Shall reformat and resubmit later, is this repo using the default pint with Laravel preset?
Summary
This PR introduces a new method
updateItemsWithDifferentProration
to the Subscription model.It allows the consumer of the package to specify the proration mode to be used for adding new items or incrementing the quantity of existing items already on the subscription, with a separate proration mode than removing items or decrementing the quantity of existing items.
Why
In non-trivial subscription scenarios, it is sometimes desirable to apply different proration behaviors for addition and removal of a item on a subscription,
A Specific example of this is the following scenario:
In this scenario, the following is expected:
prorated_immediately
on addition of item)full_next_billing_period
on removal of item)Usage
Etc
The logic could probably be simplified a bit, but i have provided tests for various scenarios so we can refactor it if needed.
Fully understand if this use-case is too niche to put in "core", but it's fairly common practice for B2B SaaS, and is a PITA to implement with Paddle.
(Package does not have pint, so my editor messed with the formatting, assuming this will be auto-fixed by GitHub actions)