Commit 5f46ac2
feat: add Stripe payment method support (#145)
* 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>1 parent 04353f3 commit 5f46ac2
25 files changed
Lines changed: 2628 additions & 220 deletions
File tree
- .changelog
- .github/workflows
- examples
- stripe
- src
- src
- client
- stripe
- protocol
- intents
- methods
- stripe
- tempo
- server
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
55 | 58 | | |
56 | 59 | | |
57 | 60 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| |||
40 | 41 | | |
41 | 42 | | |
42 | 43 | | |
| 44 | + | |
43 | 45 | | |
44 | 46 | | |
45 | 47 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
51 | 68 | | |
52 | 69 | | |
53 | 70 | | |
| |||
62 | 79 | | |
63 | 80 | | |
64 | 81 | | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
65 | 105 | | |
66 | 106 | | |
67 | 107 | | |
68 | 108 | | |
69 | 109 | | |
70 | 110 | | |
71 | 111 | | |
| 112 | + | |
72 | 113 | | |
73 | 114 | | |
74 | 115 | | |
| |||
77 | 118 | | |
78 | 119 | | |
79 | 120 | | |
80 | | - | |
| 121 | + | |
81 | 122 | | |
82 | 123 | | |
83 | 124 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
19 | | - | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
24 | 30 | | |
25 | 31 | | |
26 | 32 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
0 commit comments