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

[12.x] Fix adding invoice item with quantities #1161

Merged
merged 1 commit into from
May 20, 2021

Conversation

driesvints
Copy link
Member

Apparently if you use a quantity here you're required to use unit_amount instead of amount. No idea why no-one ever stumbled on this before.

Fixes #1153

@taylorotwell taylorotwell merged commit b944612 into 12.x May 20, 2021
@taylorotwell taylorotwell deleted the fix-amount-single-charge branch May 20, 2021 12:55
@PHLAK
Copy link

PHLAK commented Jun 3, 2021

FYI, this (minor) change broke our app after a routine dependency update. Before this change we were doing the following

$account->tab($description, null, [
    'unit_amount' => $unitAmount,
    'quantity' => $quantity,
]);

This resulted in amount being null and unit_amount and quantity being set in the request as expected.

However, after this change unit_amount gets overridden with the value of $amount (null) and resulted in neither amount nor unit_amount being set in the request. That in turn resulted in the same error mentioned in #1153 that this PR was supposed to fix.

I'm not saying this PR is bad or wrong (we may have been misusing this method to begin with), I just wanted to shed some light in case someone else runs into the same issue.

@driesvints
Copy link
Member Author

@PHLAK thanks for reporting that. Definitely a use case I wasn't thinking of. I tagged v12.14.1 with a fix for that.

You could just upgrade to the following now:

$account->tab($description, $unitAmount, [
    'quantity' => $quantity,
]);

@PHLAK
Copy link

PHLAK commented Jun 4, 2021

Thanks @driesvints, this is what we're doing now.

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.

Charge with Invoice quantity bug
3 participants