fix: remove incorrect amount×100 conversion in paymentService (Bounty #1)#26
Open
malsony wants to merge 1 commit into
Open
fix: remove incorrect amount×100 conversion in paymentService (Bounty #1)#26malsony wants to merge 1 commit into
malsony wants to merge 1 commit into
Conversation
- amount is already in smallest currency unit (cents) per issue SecureBananaLabs#1 spec - add positive integer validation before Stripe call - re-throw original Stripe errors instead of wrapping them - make Stripe client lazy-initialized to avoid import-time failures - add unit tests for amount validation edge cases Fixes the bug introduced in PR SecureBananaLabs#21 where payload.amount was multiplied by 100 before being passed to Stripe.
Code Review — Bounty #30 ($750)PR: fix: remove incorrect amount×100 conversion in paymentService (Bounty #1) by @malsony
Wallet: Code review under Bounty #30 — API Benchmark Suite ($750) |
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
Fixes the bug in the closed PR #21 where
payload.amountwas multiplied by 100 before being passed to Stripe. Per issue #1 acceptance criteria,payload.amountis already in the smallest currency unit (cents) and must be passed to Stripe as-is.Changes
apps/api/src/services/paymentService.js: Removed theamount * 100conversion. Added positive integer validation (throws descriptive errors for missing/non-integer/zero/negative amounts). Stripe errors are now re-thrown with original message preserved rather than wrapped. Stripe client is lazy-initialized to avoid import-time crashes whenSTRIPE_SECRET_KEYis not set during testing.apps/api/src/tests/paymentService.test.js: New unit test file covering all amount validation edge cases (missing, null, float, zero, negative, string).apps/api/package.json: Addedstripedependency.Issue Reference
Closes #1