From 2f14365d812f8a810f2b494627fdf99241cba1ef Mon Sep 17 00:00:00 2001 From: Serhat Dolmaci Date: Sat, 4 Apr 2026 22:15:33 +0300 Subject: [PATCH 1/2] fix: only print 'Paid' on successful x402 payment response MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #129 Previously 'Paid' was printed before checking the HTTP status, causing contradictory output when server rejected the payment. Now 'Paid' only prints when status < 400. On rejection, prints 'HTTP {status} — payment rejected by server' instead. --- ows/crates/ows-cli/src/commands/pay.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/ows/crates/ows-cli/src/commands/pay.rs b/ows/crates/ows-cli/src/commands/pay.rs index f33509d2..e77b2b56 100644 --- a/ows/crates/ows-cli/src/commands/pay.rs +++ b/ows/crates/ows-cli/src/commands/pay.rs @@ -105,7 +105,9 @@ pub fn run( let result = rt.block_on(ows_pay::pay(&wallet, url, method, body))?; - if let Some(ref payment) = result.payment { + if result.status >= 400 { + eprintln!("HTTP {} — payment rejected by server", result.status); + } else if let Some(ref payment) = result.payment { if !payment.amount.is_empty() { eprintln!( "Paid {} on {} via {}", @@ -116,10 +118,6 @@ pub fn run( } } - if result.status >= 400 { - eprintln!("HTTP {}", result.status); - } - println!("{}", result.body); Ok(()) } From bfef1f8de9a65992d1b0f55cfa5ec9938c0f70ad Mon Sep 17 00:00:00 2001 From: Serhat Dolmaci Date: Mon, 6 Apr 2026 21:41:49 +0300 Subject: [PATCH 2/2] fix: distinguish payment rejection from plain HTTP errors When status >= 400 and payment was attempted (result.payment.is_some), print 'payment rejected by server'. For plain HTTP errors where no payment flow occurred (404, 500, etc.), print just 'HTTP {status}'. --- ows/crates/ows-cli/src/commands/pay.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ows/crates/ows-cli/src/commands/pay.rs b/ows/crates/ows-cli/src/commands/pay.rs index e77b2b56..1cfeb143 100644 --- a/ows/crates/ows-cli/src/commands/pay.rs +++ b/ows/crates/ows-cli/src/commands/pay.rs @@ -106,7 +106,11 @@ pub fn run( let result = rt.block_on(ows_pay::pay(&wallet, url, method, body))?; if result.status >= 400 { - eprintln!("HTTP {} — payment rejected by server", result.status); + if result.payment.is_some() { + eprintln!("HTTP {} — payment rejected by server", result.status); + } else { + eprintln!("HTTP {}", result.status); + } } else if let Some(ref payment) = result.payment { if !payment.amount.is_empty() { eprintln!(