Skip to content

docs: add Stripe example (server + client)#147

Merged
grandizzy merged 2 commits intogeorgen/stripe-method-scaffoldfrom
georgen/stripe-example
Mar 25, 2026
Merged

docs: add Stripe example (server + client)#147
grandizzy merged 2 commits intogeorgen/stripe-method-scaffoldfrom
georgen/stripe-example

Conversation

@decofe
Copy link
Member

@decofe decofe commented Mar 24, 2026

Follow-up to PR #145 per @brendanjryan's review — adds a working example showing client/server Stripe SPT usage, mirroring pympp's stripe example.

Changes

  • examples/stripe/src/server.rs — Axum server with /api/create-spt SPT proxy + /api/fortune paid endpoint ($1.00)
  • examples/stripe/src/client.rs — headless CLI client using pm_card_visa test card + send_with_payment()
  • examples/stripe/README.md — setup instructions + flow diagram
  • examples/README.md — add Stripe entry to examples table

Co-Authored-By: grandizzy 38490174+grandizzy@users.noreply.github.com

Prompted by: georgen

Pay-per-fortune example demonstrating the full SPT flow:
- Axum server with /api/create-spt proxy and /api/fortune gated endpoint
- Headless CLI client using pm_card_visa test card
- Mirrors the pympp examples/stripe/ structure

Co-authored-by: grandizzy <38490174+grandizzy@users.noreply.github.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019d20a8-7850-76dc-a346-432e5d2f4f5f
@github-actions
Copy link
Contributor

Tempo Lint Results

Summary

Found 683 issue(s) across 43 file(s)

Severity Count
Errors 1
Warnings 682
Hints 0

Issues by Rule Type

no-unwrap-in-lib (668 occurrences)
  • /home/runner/work/mpp-rs/mpp-rs/src/body_digest.rs:1 - Avoid .unwrap() in library code. Use proper error handling with ? or .expect() with context.
  • /home/runner/work/mpp-rs/mpp-rs/src/client/fetch.rs:1 - Avoid .unwrap() in library code. Use proper error handling with ? or .expect() with context.
  • /home/runner/work/mpp-rs/mpp-rs/src/client/fetch.rs:1 - Avoid .unwrap() in library code. Use proper error handling with ? or .expect() with context.
  • /home/runner/work/mpp-rs/mpp-rs/src/client/fetch.rs:1 - Avoid .unwrap() in library code. Use proper error handling with ? or .expect() with context.
  • /home/runner/work/mpp-rs/mpp-rs/src/client/fetch.rs:1 - Avoid .unwrap() in library code. Use proper error handling with ? or .expect() with context.
  • /home/runner/work/mpp-rs/mpp-rs/src/client/fetch.rs:1 - Avoid .unwrap() in library code. Use proper error handling with ? or .expect() with context.
  • /home/runner/work/mpp-rs/mpp-rs/src/client/fetch.rs:1 - Avoid .unwrap() in library code. Use proper error handling with ? or .expect() with context.
  • /home/runner/work/mpp-rs/mpp-rs/src/client/fetch.rs:1 - Avoid .unwrap() in library code. Use proper error handling with ? or .expect() with context.
  • /home/runner/work/mpp-rs/mpp-rs/src/client/stripe/provider.rs:1 - Avoid .unwrap() in library code. Use proper error handling with ? or .expect() with context.
  • /home/runner/work/mpp-rs/mpp-rs/src/client/tempo/session/channel_ops.rs:1 - Avoid .unwrap() in library code. Use proper error handling with ? or .expect() with context.

... and 658 more

no-leading-whitespace-strings (10 occurrences)
  • /home/runner/work/mpp-rs/mpp-rs/src/proxy/service.rs:1 - String literals should not start with leading whitespace. Found: ' — '
  • /home/runner/work/mpp-rs/mpp-rs/src/error.rs:1 - String literals should not start with leading whitespace. Found: ' for '
  • /home/runner/work/mpp-rs/mpp-rs/src/error.rs:1 - String literals should not start with leading whitespace. Found: ' ({})'
  • /home/runner/work/mpp-rs/mpp-rs/src/error.rs:1 - String literals should not start with leading whitespace. Found: ' is invalid.'
  • /home/runner/work/mpp-rs/mpp-rs/src/error.rs:1 - String literals should not start with leading whitespace. Found: ' is invalid: already used.'
  • /home/runner/work/mpp-rs/mpp-rs/src/error.rs:1 - String literals should not start with leading whitespace. Found: ' (Premium access).'
  • /home/runner/work/mpp-rs/mpp-rs/src/protocol/core/types.rs:1 - String literals should not start with leading whitespace. Found: ' and backslashes '
  • /home/runner/work/mpp-rs/mpp-rs/src/protocol/core/headers.rs:1 - String literals should not start with leading whitespace. Found: ' now'
  • /home/runner/work/mpp-rs/mpp-rs/src/protocol/core/headers.rs:1 - String literals should not start with leading whitespace. Found: ' now'
  • /home/runner/work/mpp-rs/mpp-rs/src/protocol/core/headers.rs:1 - String literals should not start with leading whitespace. Found: ' now'
unsafe-needs-safety-comment (4 occurrences)
  • /home/runner/work/mpp-rs/mpp-rs/src/server/mpp.rs:1 - Unsafe block requires a SAFETY comment explaining why this is safe.
  • /home/runner/work/mpp-rs/mpp-rs/src/server/mpp.rs:1 - Unsafe block requires a SAFETY comment explaining why this is safe.
  • /home/runner/work/mpp-rs/mpp-rs/src/server/mpp.rs:1 - Unsafe block requires a SAFETY comment explaining why this is safe.
  • /home/runner/work/mpp-rs/mpp-rs/src/server/mpp.rs:1 - Unsafe block requires a SAFETY comment explaining why this is safe.
no-emojis (1 occurrence)
  • /home/runner/work/mpp-rs/mpp-rs/examples/stripe/src/client.rs:1 - Emojis are not allowed in code. Use descriptive text instead.

Issues by File

View grouped by file

/home/runner/work/mpp-rs/mpp-rs/src/protocol/core/challenge.rs (85 issues)

  • Line 1: [warning] no-unwrap-in-lib
  • Line 1: [warning] no-unwrap-in-lib
  • Line 1: [warning] no-unwrap-in-lib
  • Line 1: [warning] no-unwrap-in-lib
  • Line 1: [warning] no-unwrap-in-lib
  • ... and 80 more

/home/runner/work/mpp-rs/mpp-rs/src/client/tempo/session/mod.rs (58 issues)

  • Line 1: [warning] no-unwrap-in-lib
  • Line 1: [warning] no-unwrap-in-lib
  • Line 1: [warning] no-unwrap-in-lib
  • Line 1: [warning] no-unwrap-in-lib
  • Line 1: [warning] no-unwrap-in-lib
  • ... and 53 more

/home/runner/work/mpp-rs/mpp-rs/src/client/tempo/signing/mod.rs (54 issues)

  • Line 1: [warning] no-unwrap-in-lib
  • Line 1: [warning] no-unwrap-in-lib
  • Line 1: [warning] no-unwrap-in-lib
  • Line 1: [warning] no-unwrap-in-lib
  • Line 1: [warning] no-unwrap-in-lib
  • ... and 49 more

/home/runner/work/mpp-rs/mpp-rs/src/server/mpp.rs (53 issues)

  • Line 1: [warning] no-unwrap-in-lib
  • Line 1: [warning] no-unwrap-in-lib
  • Line 1: [warning] no-unwrap-in-lib
  • Line 1: [warning] no-unwrap-in-lib
  • Line 1: [warning] no-unwrap-in-lib
  • ... and 48 more

/home/runner/work/mpp-rs/mpp-rs/src/protocol/methods/tempo/session_method.rs (39 issues)

  • Line 1: [warning] no-unwrap-in-lib
  • Line 1: [warning] no-unwrap-in-lib
  • Line 1: [warning] no-unwrap-in-lib
  • Line 1: [warning] no-unwrap-in-lib
  • Line 1: [warning] no-unwrap-in-lib
  • ... and 34 more

/home/runner/work/mpp-rs/mpp-rs/src/client/tempo/session/channel_ops.rs (38 issues)

  • Line 1: [warning] no-unwrap-in-lib
  • Line 1: [warning] no-unwrap-in-lib
  • Line 1: [warning] no-unwrap-in-lib
  • Line 1: [warning] no-unwrap-in-lib
  • Line 1: [warning] no-unwrap-in-lib
  • ... and 33 more

/home/runner/work/mpp-rs/mpp-rs/src/protocol/methods/tempo/method.rs (35 issues)

  • Line 1: [warning] no-unwrap-in-lib
  • Line 1: [warning] no-unwrap-in-lib
  • Line 1: [warning] no-unwrap-in-lib
  • Line 1: [warning] no-unwrap-in-lib
  • Line 1: [warning] no-unwrap-in-lib
  • ... and 30 more

/home/runner/work/mpp-rs/mpp-rs/src/protocol/core/headers.rs (32 issues)

  • Line 1: [warning] no-leading-whitespace-strings
  • Line 1: [warning] no-leading-whitespace-strings
  • Line 1: [warning] no-leading-whitespace-strings
  • Line 1: [warning] no-unwrap-in-lib
  • Line 1: [warning] no-unwrap-in-lib
  • ... and 27 more

/home/runner/work/mpp-rs/mpp-rs/src/server/middleware.rs (27 issues)

  • Line 1: [warning] no-unwrap-in-lib
  • Line 1: [warning] no-unwrap-in-lib
  • Line 1: [warning] no-unwrap-in-lib
  • Line 1: [warning] no-unwrap-in-lib
  • Line 1: [warning] no-unwrap-in-lib
  • ... and 22 more

/home/runner/work/mpp-rs/mpp-rs/src/mcp.rs (25 issues)

  • Line 1: [warning] no-unwrap-in-lib
  • Line 1: [warning] no-unwrap-in-lib
  • Line 1: [warning] no-unwrap-in-lib
  • Line 1: [warning] no-unwrap-in-lib
  • Line 1: [warning] no-unwrap-in-lib
  • ... and 20 more

Showing 10 of 43 files


Posted by https://github.com/tempoxyz/lints

Copy link
Collaborator

@brendanjryan brendanjryan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@grandizzy grandizzy marked this pull request as ready for review March 25, 2026 05:32
@grandizzy grandizzy merged commit 55cd3af into georgen/stripe-method-scaffold Mar 25, 2026
grandizzy added a commit that referenced this pull request Mar 25, 2026
* feat: scaffold Stripe payment method support

Adds the initial implementation for Stripe charge method (TOOLS-322):

- src/protocol/methods/stripe/ — types (StripeChargeRequest,
  StripeCredentialPayload) and server-side ChargeMethod that verifies
  payments by creating a Stripe PaymentIntent with an SPT
- src/client/stripe/ — StripeProvider implementing PaymentProvider
  with a user-provided createToken callback
- src/server/ — StripeBuilder, StripeConfig, stripe() builder fn,
  Mpp::create_stripe(), Mpp::stripe_charge()
- tests/integration_stripe.rs — e2e tests against a mock Stripe API
  (full 402 flow, challenge format, requires_action rejection)
- Cargo.toml — stripe and integration-stripe feature flags

Co-Authored-By: grandizzy <38490174+grandizzy@users.noreply.github.com>

* chore: add changelog

* feat: complete Stripe method implementation

- Add spec-required methodDetails (networkId, paymentMethodTypes) to challenges
- Add StripeChargeOptions (description, external_id, expires, metadata)
- Add ChargeChallenger impl so MppCharge extractor works with Stripe
- Parse Stripe error response bodies for better error messages
- Add Stripe unit and integration tests

Amp-Thread-ID: https://ampcode.com/threads/T-019d1969-811c-7725-aaa6-1e0116d5652c
Co-authored-by: Amp <amp@ampcode.com>

* Run stripe integration tests in CI

* docs: add Stripe examples to README

Amp-Thread-ID: https://ampcode.com/threads/T-019d1969-811c-7725-aaa6-1e0116d5652c
Co-authored-by: Amp <amp@ampcode.com>

* fix: align Stripe method with mppx TS SDK wire format

- Replace StripeChargeRequest with StripeMethodDetails (correct wire
  shape: networkId/paymentMethodTypes/metadata nested under methodDetails)
- stripe_charge() now emits methodDetails with networkId and
  paymentMethodTypes from config (fixes challenge schema bug)
- Add stripe_charge_with_options() + StripeChargeOptions
- Server verify() propagates metadata: analytics keys (mpp_version,
  mpp_is_mpp, mpp_intent, mpp_challenge_id, mpp_server_id,
  mpp_client_id) + user metadata from methodDetails
- Callback returns CreateTokenResult { spt, external_id } instead of
  plain String (per-payment externalId support)
- Provider extracts metadata from methodDetails.metadata and passes
  challenge JSON to callback
- Remove CreateTokenFn trait alias; use plain generic F: Fn(...)
- Provider reads networkId from methodDetails (not top-level)

Co-Authored-By: grandizzy <38490174+grandizzy@users.noreply.github.com>

* fix: clippy lints and update README examples

Co-Authored-By: grandizzy <38490174+grandizzy@users.noreply.github.com>

* refactor: deduplicate INTENT_CHARGE/INTENT_SESSION constants into protocol::intents

Amp-Thread-ID: https://ampcode.com/threads/T-019d1969-811c-7725-aaa6-1e0116d5652c
Co-authored-by: Amp <amp@ampcode.com>

* refactor: use typed serde structs and ResultExt across Stripe code

Amp-Thread-ID: https://ampcode.com/threads/T-019d1969-811c-7725-aaa6-1e0116d5652c
Co-authored-by: Amp <amp@ampcode.com>

* feat: add live Stripe integration tests + CI support

- tests/integration_stripe_live.rs: tests against real Stripe test-mode
  API using test_helpers/shared_payment/granted_tokens endpoint.
  Skipped when STRIPE_SECRET_KEY is not set.
- CI runs live tests only when STRIPE_SECRET_KEY secret exists
- Tests: happy path (real SPT + PaymentIntent), invalid SPT rejection,
  expired challenge rejection

Co-Authored-By: grandizzy <38490174+grandizzy@users.noreply.github.com>

* fix: live Stripe test fallback for seller_details + suppress dead_code warning

- create_test_spt now retries without seller_details when Stripe
  returns 'Received unknown parameter' (matches mppx fallback)
- Suppress dead_code warning on ResultExt trait

Co-Authored-By: grandizzy <38490174+grandizzy@users.noreply.github.com>

* refactor: merge live Stripe tests into integration_stripe, runtime-gated

Remove integration-stripe-live feature flag. Live tests now live in
integration_stripe.rs and skip at runtime when STRIPE_SECRET_KEY is
not set (matching mppx pattern). CI passes STRIPE_SECRET_KEY as env
var to the test step.

Revert #[allow(dead_code)] on ResultExt — pre-existing, not ours.

Co-Authored-By: grandizzy <38490174+grandizzy@users.noreply.github.com>

* refactor: extract server tempo/stripe config into submodules

Amp-Thread-ID: https://ampcode.com/threads/T-019d1f49-ad9f-74a8-9268-37d860491bb8
Co-authored-by: Amp <amp@ampcode.com>

* docs: add Stripe example (server + client) (#147)

* docs: add Stripe example (server + client)

Pay-per-fortune example demonstrating the full SPT flow:
- Axum server with /api/create-spt proxy and /api/fortune gated endpoint
- Headless CLI client using pm_card_visa test card
- Mirrors the pympp examples/stripe/ structure

Co-authored-by: grandizzy <38490174+grandizzy@users.noreply.github.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019d20a8-7850-76dc-a346-432e5d2f4f5f

* chore: add changelog

---------

Co-authored-by: grandizzy <38490174+grandizzy@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* fix: remove emoji from stripe example to pass no-emojis lint

Co-Authored-By: grandizzy <38490174+grandizzy@users.noreply.github.com>

---------

Co-authored-by: grandizzy <38490174+grandizzy@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: grandizzy <grandizzy.the.egg@gmail.com>
Co-authored-by: Amp <amp@ampcode.com>
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.

3 participants