This repository contains sample implementations for machine-payments flows, including:
mppexamplesx402examples
Current examples include Node/TypeScript and Python server samples.
- Prefer minimal, sample-quality code over heavy abstractions.
- Keep implementations across languages structurally aligned when practical.
- Favor consistency in endpoint naming and behavior across comparable samples.
- Preserve existing sample conventions unless there is a clear reason to change them.
- For payment-protected sample endpoints, prefer
GET /paidunless a sample explicitly demonstrates a different route for protocol-specific reasons. - Keep README test commands aligned with the implemented endpoint.
- Prefer
FastAPI+uvicornfor Python HTTP server samples. - Prefer
uvwith a localpyproject.tomlfor dependency management. - Use
python-dotenvwhen environment-based setup is needed. - Keep code straightforward and easy to compare with the TypeScript equivalent.
- Prefer small, directly runnable examples.
- Keep
tsconfig.jsonminimal unless stricter settings are required. - Ensure sample code passes the local typecheck/build script.
- When SDK preview fields have incomplete typings, use narrow, localized type assertions rather than broad
any.
- Reuse the Stripe app info used elsewhere in the repo when adding new samples.
- Validate required environment variables at startup with clear error messages.
- When a server creates dynamic deposit addresses, cache and validate them before accepting them back from client-submitted credentials.
- Each sample directory should include a concise
README.mdwith:- what the sample demonstrates,
- requirements,
- setup steps,
- run command,
- a simple test command.
- Keep setup instructions consistent with the language ecosystem used by that sample.
- Update related README commands/examples if routes or filenames change.
- Prefer small, targeted edits over repo-wide refactors.
- If changing one sample for consistency, check the sibling sample in the other language too.