Skip to content

fix: remove incorrect amount×100 conversion in paymentService (Bounty #1)#26

Open
malsony wants to merge 1 commit into
SecureBananaLabs:mainfrom
malsony:fix/payment-amount-cents
Open

fix: remove incorrect amount×100 conversion in paymentService (Bounty #1)#26
malsony wants to merge 1 commit into
SecureBananaLabs:mainfrom
malsony:fix/payment-amount-cents

Conversation

@malsony
Copy link
Copy Markdown

@malsony malsony commented May 17, 2026

Summary

Fixes the bug in the closed PR #21 where payload.amount was multiplied by 100 before being passed to Stripe. Per issue #1 acceptance criteria, payload.amount is already in the smallest currency unit (cents) and must be passed to Stripe as-is.

Changes

  • apps/api/src/services/paymentService.js: Removed the amount * 100 conversion. 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 when STRIPE_SECRET_KEY is 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: Added stripe dependency.

Issue Reference

Closes #1

- 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.
github-actions Bot added a commit that referenced this pull request May 17, 2026
@BossChaos
Copy link
Copy Markdown

Code Review — Bounty #30 ($750)

PR: fix: remove incorrect amount×100 conversion in paymentService (Bounty #1) by @malsony

  • ✅ Bug fix

Wallet: 0xdaE5d307339074A24F579dB48e7c639359D94904

Code review under Bounty #30 — API Benchmark Suite ($750)

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.

Implement Secure Payment Gateway and Payment Service

2 participants