Skip to content

fix: only print "Paid" on successful x402 payment response#191

Open
Sertug17 wants to merge 2 commits intoopen-wallet-standard:mainfrom
Sertug17:fix/x402-paid-message
Open

fix: only print "Paid" on successful x402 payment response#191
Sertug17 wants to merge 2 commits intoopen-wallet-standard:mainfrom
Sertug17:fix/x402-paid-message

Conversation

@Sertug17
Copy link
Copy Markdown
Contributor

@Sertug17 Sertug17 commented Apr 4, 2026

Fixes #129

Previously ows pay request printed "Paid $X via x402" immediately after signing, before checking whether the server accepted the payment. If the server rejected with HTTP 402, the user saw both "Paid" and an error — contradictory and misleading.

Fix

Move the status check before the "Paid" print. Now:

  • status < 400 → prints "Paid $X on {network} via {protocol}" as before
  • status >= 400 → prints "HTTP {status} — payment rejected by server"

Changes

  • ows-cli/src/commands/pay.rs — reorder status check and payment confirmation print

Note

Low Risk
Low risk: changes only CLI output ordering/wording based on HTTP status, with no effect on payment signing or request execution.

Overview
Adjusts ows pay request output to avoid claiming a payment succeeded when the server returns an error.

The command now checks result.status before printing "Paid" and, on >= 400, prints HTTP {status} (or HTTP {status} — payment rejected by server when a payment was attempted) while still printing the response body.

Reviewed by Cursor Bugbot for commit bfef1f8. Bugbot is set up for automated code reviews on this repo. Configure here.

Fixes open-wallet-standard#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.
@Sertug17 Sertug17 requested a review from njdawn as a code owner April 4, 2026 19:21
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 4, 2026

@Sertug17 is attempting to deploy a commit to the MoonPay Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 2f14365. Configure here.

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}'.
@Sertug17
Copy link
Copy Markdown
Contributor Author

Sertug17 commented Apr 6, 2026

Fixed the Cursor Bugbot finding:

The error branch now distinguishes between a genuine payment rejection
(payment.is_some() → "payment rejected by server") and a plain HTTP
error where no payment flow occurred (payment.is_none() → "HTTP {status}").
Previously a 404 or 500 on the initial request would incorrectly print
"payment rejected by server" even though no payment was attempted.

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.

fix: "Paid" message prints even when x402 payment is rejected by server

1 participant