Fix line item unit amount parsing from price field. - #13187
Merged
Conversation
cttsai-stripe
previously approved these changes
Jun 3, 2026
| val subtotal = obj.optLong(FIELD_SUBTOTAL, -1).takeIf { it >= 0 } ?: return@mapNotNull null | ||
| val total = obj.optLong(FIELD_TOTAL, -1).takeIf { it >= 0 } ?: return@mapNotNull null | ||
| val unitAmount = if (quantity > 0) total / quantity else null | ||
| val unitAmount = obj.optLong(FIELD_UNIT_AMOUNT_OVERRIDE, -1).takeIf { it >= 0 } |
Contributor
There was a problem hiding this comment.
Do we want to test the override case?
3 tasks
jaynewstrom-stripe
force-pushed
the
jaynewstrom/fix-line-item-unit-amount
branch
from
June 3, 2026 12:56
7f474de to
4b25284
Compare
jaynewstrom-stripe
enabled auto-merge (squash)
June 3, 2026 15:12
cttsai-stripe
approved these changes
Jun 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Updates the checkout session parser to read unit amount from the price field instead of calculating it from total/quantity.
Motivation
The previous implementation calculated unit amount by dividing total by quantity, which was incorrect when the total included taxes or other adjustments. The API provides the correct unit amount in the price field, which should be used instead.
Testing
Changelog
[Fixed] Fixed incorrect unit amount calculation for line items in checkout sessions when totals include taxes.