Dev.to Security 🔐 Cybersecurity 👁 0 📖 1 min read

The return URL is not a payment confirmation

A checkout we reviewed marked orders as paid when the customer landed on /return?status=success after 3DS. It looked fine in testing, because the redirect and the gateway result always agreed. In production they drifted

A checkout we reviewed marked orders as paid when the customer landed on /return?status=success after 3DS. It looked fine in testing, because the redirect and the gateway result always agreed.

In production they drifted apart in three ways:

  1. The customer pressed Back during the challenge and later reopened the return URL from browser history. The order flipped to paid on a stale redirect.
  2. The bank's ACS confirmed the challenge, but the authorization then declined at the issuer. The redirect still said the 3DS step succeeded, so the order was marked paid while no money moved.
  3. Anyone could edit the query string. Changing status=failed to status=success worked on a test order, because the handler never checked a signature.

The redirect only tells you the browser came back. It says nothing about the transaction.

What we changed: the return page now shows "checking your payment" and never writes order state. State changes only from the signed webhook, or from a server-side status call by transaction id when the webhook is late. The page polls our own order status for up to about 20 seconds, then tells the customer we'll email them.

The unpaid-but-shipped orders stopped, and so did the paid-but-not-fulfilled ones.

Do you let the return URL touch order state at all, or is that strictly webhook territory in your system?

Payneteasy handles this kind of payment flow for merchants and PSPs — see how it works.

📰 Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.