Skip to content

Validate cart mint quotes server-side - #534

Open
GautamBytes wants to merge 1 commit into
shopstr-eng:mainfrom
GautamBytes:pay-fix
Open

GautamBytes wants to merge 1 commit into
shopstr-eng:mainfrom
GautamBytes:pay-fix

Conversation

@GautamBytes

@GautamBytes GautamBytes commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR closes the remaining payment validation gaps around cart checkout and MCP order creation.

  • Adds a server-side cart mint quote endpoint that fetches the latest listing events, validates cart item selections, validates discount codes, recomputes totals, and creates the Cashu mint quote using the server-controlled trusted mint.
  • Updates cart Lightning and NWC checkout to use the server-returned quote amount and product totals before polling, minting proofs, and splitting seller/donation/change tokens.
  • Fixes MCP create-order so non-sat listing totals are converted to sats before creating Lightning quotes or checking Cashu token amounts.
  • Adds shared helpers for Cashu-safe sat amounts, currency conversion, and trusted mint selection.

Note

The new /api/cart/mint-quote route treats the request body as untrusted runtime input. It validates cart order type, pickup preference, item shape, selected variants, discount-code map shape, listing availability, stock, expiration, and quantity before calling the mint.

This PR intentionally does not change direct browser Cashu-token checkout; that path does not create a mint quote. It should still get a separate server-validated amount/totals follow-up, but it is separate from the Lightning/NWC quote-manipulation issue.

Coordination

This complements #449, which validates single-listing Lightning/NWC mint quotes server-side. So ideally should merge after that.

@GautamBytes
GautamBytes marked this pull request as ready for review June 10, 2026 10:24
@GautamBytes

Copy link
Copy Markdown
Contributor Author

@calvadev ready for review!

@github-actions

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had recent activity for 45 days.
It will be closed if no further activity occurs within 15 days.
If this PR is still relevant, please leave a comment or push new commits to keep it open.
Thank you for your contribution!

@github-actions

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had recent activity for 45 days.
It will be closed if no further activity occurs within 15 days.
If this PR is still relevant, please leave a comment or push new commits to keep it open.
Thank you for your contribution!

This branch has not been deployed

No deployments
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.

1 participant