Skip to content

fix: add Zod validation for payment endpoint#3363

Open
biocai wants to merge 1 commit into
SecureBananaLabs:mainfrom
biocai:fix/issue-3358-payment-validation
Open

fix: add Zod validation for payment endpoint#3363
biocai wants to merge 1 commit into
SecureBananaLabs:mainfrom
biocai:fix/issue-3358-payment-validation

Conversation

@biocai
Copy link
Copy Markdown

@biocai biocai commented Jun 1, 2026

Summary

  • Add Zod schema validation for payment request body before passing to payment service
  • Prevents invalid or missing fields (e.g. negative amount, invalid currency) from reaching the service layer

Changes

  • New file apps/api/src/validators/payment.js with createPaymentSchema (amount: positive number, currency: 3-char string, defaults to "usd")
  • Updated apps/api/src/controllers/paymentController.js to parse request body with the schema

Testing

  • Validates amount is a positive number
  • Validates currency is a 3-character string (ISO 4217), defaults to "usd"
  • Returns 400 with Zod error details on invalid input

Fixes #3358

Validate payment request body with createPaymentSchema before passing to payment service. Prevents invalid or missing fields from reaching the service layer.

Fixes SecureBananaLabs#3358
github-actions Bot added a commit that referenced this pull request Jun 1, 2026
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.

[LHF-004] Add input validation to payment endpoint

1 participant