[14.x] Add fallback for null value in unitAmountExcludingTax method #1447
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Why
I updated my installation of Cashier to
v14.2.0
and noticed that my invoices can't be downloaded. Did some digging around and found that the newly addedunitAmountExcludingTax
method in theInvoiceLineItem
class doesn't handlenull
values coming through from the Stripe PHP library. This pull request aims to fix the issue by settingnull
values to0
(int), this will ensure that values passed toCashier::formatAmount()
is always aint
orstring
type.Context
For some context around why I am likely to get a
null
value. My application charges a fixed price perwebsite
and a fixed price peruser
(team members). This means that ateam
in my application can possibly have0
websites but always have 1 or more users, this would mean their subscription would still be active but have a $0 charge on the website line item for a given month. This situation usually only happens when ateam
is new or rarely has published websites.