Context
src/mpp/mod.rs currently implements step 1 of the MPP / HTTP-402 flow: MppClient::request(url) hits a URL and returns either Success(body) or PaymentRequired(options). The trailing TODOs (pay(), session(), pay_and_retry()) are what close the loop — they turn a half-answer into a real autonomous-payment path. Implementing the 402 → pay → retry dance end-to-end on a mock server is a perfect newcomer ticket.
Scope
- In
src/mpp/mod.rs, implement:
MppClient::pay(&self, options: &PaymentOptions, wallet: &Wallet) -> Result<PaymentReceipt> — for now, support only method_type == "tempo" (simplest: POST to a payment endpoint encoded in details). Other methods return ArkaError::Mpp("unsupported").
MppClient::pay_and_retry(&self, url: &str, wallet: &Wallet) -> Result<String> — calls request, if PaymentRequired then pay, then re-requests with the receipt attached as an X-MPP-Receipt header, returning the body.
- Spin up a mock server test with
wiremock (add as dev-dep) that:
- First call to
/data returns 402 with a PaymentOptions JSON body.
- POST to
/pay returns a PaymentReceipt JSON.
- Second call to
/data with header X-MPP-Receipt: <tx_hash> returns 200 with a payload.
Assert pay_and_retry returns that payload.
- Remove the matching
// TODO: comments.
Acceptance criteria
cargo test mpp passes including the new wiremock test.
cargo clippy clean.
- New method has rustdoc explaining the 402-retry state machine.
- Unsupported payment methods return a typed error, not a panic.
Reference: the MppClient::request method already shows how reqwest + serde_json are used in the crate; PR #4 sets the CI conventions.
Estimated effort
S (3–5 hours)
— kcolbchain / Abhishek Krishna
Context
src/mpp/mod.rscurrently implements step 1 of the MPP / HTTP-402 flow:MppClient::request(url)hits a URL and returns eitherSuccess(body)orPaymentRequired(options). The trailing TODOs (pay(),session(),pay_and_retry()) are what close the loop — they turn a half-answer into a real autonomous-payment path. Implementing the 402 → pay → retry dance end-to-end on a mock server is a perfect newcomer ticket.Scope
src/mpp/mod.rs, implement:MppClient::pay(&self, options: &PaymentOptions, wallet: &Wallet) -> Result<PaymentReceipt>— for now, support onlymethod_type == "tempo"(simplest: POST to a payment endpoint encoded indetails). Other methods returnArkaError::Mpp("unsupported").MppClient::pay_and_retry(&self, url: &str, wallet: &Wallet) -> Result<String>— callsrequest, ifPaymentRequiredthenpay, then re-requests with the receipt attached as anX-MPP-Receiptheader, returning the body.wiremock(add as dev-dep) that:/datareturns 402 with aPaymentOptionsJSON body./payreturns aPaymentReceiptJSON./datawith headerX-MPP-Receipt: <tx_hash>returns 200 with a payload.Assert
pay_and_retryreturns that payload.// TODO:comments.Acceptance criteria
cargo test mpppasses including the new wiremock test.cargo clippyclean.Reference: the
MppClient::requestmethod already shows howreqwest+serde_jsonare used in the crate; PR #4 sets the CI conventions.Estimated effort
S (3–5 hours)
— kcolbchain / Abhishek Krishna