Incorrect redirect on declined credit card payments – customers sent to “Thank you” page instead of back to checkout

When building a credit card payments extension, declined transactions are redirecting customers to the Shopify “Thank you” page with the message “Your order is confirmed,” instead of returning them to checkout with an error message. This behavior previously worked as expected (redirecting back to checkout on failure), but now all outcomes go to the Thank you page. We need guidance on how to correctly use the Payments Apps API mutations so that only successful payments lead to the Thank you page, and failed or declined payments send customers back to checkout to retry their card details.

RequestUrl : Ccaavenue UAE QA2

PaymentSession Request from Shopify :

{“id”:“rmWo3v05pLXvwCVTaoz2hwsgk”,“gid”:“gid://shopify/PaymentSession/rmWo3v05pLXvwCVTaoz2hwsgk”,“session_id”:“SIWDx22HKrgmY4v1VC86FTXV24HJ7Lo8968IQeKGfSU=”,“group”:“HTj6rVv6WK0ei7b8J5JHdoiNxcwPbeHodHXPBHL42Zo=”,“amount”:“78.25”,“currency”:“AED”,“test”:true,“proposed_at”:“2026-09-16T06:50:43Z”,“kind”:“authorization”,“payment_method”:{“type”:“credit_card”,“data”:{“encrypted_message”:“d2Zlzlt2ePtL8wB0AeiAdEfD2L+vt8evkaVki7Y9qMHVN8EAbNQjTdLvZoAjUd9Mbo2Zt0BnJaHleKZUF7aGIvQ+LIAiuJFt2GNKtBbmArA9FLoEu5ltteKRtNyXeJiUqjP6LOK3XT6rhSGlhA6nAhXqi7r5RE2z55cZtRqaE1WdQ/E66XHYv+DRv6cMVwES1A==”,“ephemeral_public_key”:“-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEW+By4og5deKG8J+3Zqn+A5cm7umV\nmkdibFgfEZOD8gePillGumDasl4pxLmobUtkpjhGy5O0H1zF5zjtWO5M2w==\n-----END PUBLIC KEY-----\n”,“tag”:“3+cWwWLJX2OCm3biP7rFJA==”,“fingerprint”:“Test Certificate”,“moto”:false}},“customer”:{“billing_address”:{“given_name”:“Akshay”,“family_name”:“Vartak”,“line1”:“Downtown”,“city”:“Virar”,“province”:“Dubai”,“province_code”:“DU”,“country_code”:“AE”},“shipping_address”:{“given_name”:“Akshay”,“family_name”:“Vartak”,“line1”:“Downtown”,“city”:“Virar”,“province”:“Dubai”,“province_code”:“DU”,“country_code”:“AE”},“email”:“akshay.vartak@avenues.info”,“locale”:“en-AE”},“merchant_locale”:“en-AE”,“client_details”:{“ip_address”:“103.196.78.196”,“user_agent”:“Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36”,“accept_language”:“en-AE”}}

paymentSessionRedirect

Request :
{“variables”:{“redirectUrl”:“https://xyz.com/transaction.do?command=initiatePayloadTransaction&access_code=AVZA02ME51BW04AZWB&encRequest=a8af44be918d089eb6f40567fcb0f36085a9059f82ae62ca97722bdd2b5012deb106e04f4786cf9b28360025ed763229c05c0cc3d2341c27950923402d58c57708e09f03e33447b52a82e27e6f07befef84a51143df596a3163c0e10c498d89ab624d8d8b0f6f8bd6ace8dddd6c780a1abf34dd82c6724eccad0e5527403d7ab0631805cef9ca07d2f3b70e47cbef08cf433cbe0646a91516081938992884ab5f79c348b70faf64d7d47641591477d7df04c640cd8c03fa331ca4c258cf4cbb8130a2c8ba77cddbc7503537cac22d86630edf0e5b78c89ead161c86020a2ba0e72b3d8f00a920c33bc7a8e6e3ffa57e97468178accbe94ae20302d8e15a8884268848a6f2f0f040e6e940be0b9b28a85736761192a867f272fdfbb56dc673d88ab0e086976ba004ed6da088d7c4bfad06c7fbb5a254ac62adfb44b8f66724d512cf3835322833c49ef81297f4d400482eda673e71089e17f580c34e5c630e2023034397a99334a56df7a9762be07ab47ebb02951e49049c47224fa4ae49e47cbdf05d7ccf3b00351917633a206d49be1d24faf8da814433a695a9ccda51883040f14bfa3b666e6eccbac04ace820ef7e9ea0cfffaf1738d78e8213e5a482104ed8ba74eb4fb12bce3f13f50f1765b59873bc060a3ca8d650f83ccb8860ad3501a31d4339eab0c54acfba8326ed2550595785d164b371e8b24bf2c53c0d45017a48ee7483229cf2a85d549145d62f8734e95659b37782cf938b0e6775e1dc9c5987f70687f18a8b635c22c68273d073716efa134207683aeb2958561cf54f7fcb85858b9829553652cb7f200029fec7fcf63cb1d376be631cba8a7a97462b7cde093c156ca834fba5cb63885c18a820bc0a924586465058f309ba17cd1c53bac08fdc38edc381dc9c96a6b27c1a9885eb313235fc426a2ea5b53627a442a35bc26544a010b02369c825971e318e44e19dfca6d091b5c16a0cb77398d51b67827bf07dc6f7e5aa857356948dcdece219b92c3742d9bb2dd989184e68cbdcc2ae81fa7b57e2b9e230f3ea0c330d753bd059b62e061ad6b42a34c35f36e48c9dc690affa55c7a2ecc5dcd21b239f83c5fdddf6ee7d6a50214681dd09302306388fd613641b598efc35712a1a93ce2589c137ad8078b76b39adb3fb3c8c9b9f72e38bfef5fb9bdbbf72357bd13e2025fd9b11838772882e6a6ee5c90d671a79a5bc0fb2c81c1ebe0adedb0b7cdecb12f783d6e6a79a4c375d930989306080f3dfb9f4176702e61d8b897382d7a93749061361679d852ae81712b3350e8a73e176cf0643edf3fe4d44ea981b2936c7d2c4f021c0f841346b8e0637be0a27d9b6b821ddce02804420a5574885894ae2272a4560afca236b6cafd129b3c982b85fc1fb5b76c5676868a69e12d264318317c885ebe42e0b53fe3e8ee80c5d3250f126307847fb6aa251a6cb6c554b86da6a7c64b711c9ed496abebf01e904e8db7abe435c56c553ae852595aaf3ad3e0717458ce5a1b1a6be1706fb0ea1f0eac719f2276527873fae837807c5fbbb40a6f6e0402b81cba0dba60c3f118e23d6fdb38b81de2c46441d866daefde7c666016f8921dc90e5dc91aa9994528a63a211bf788de30c931df5da7e7ce35502e004c03027c6379dc4c3ff5513d97e4fbfd7560cca623ba3bc4f72454c4a6986c222bfcefdfd561ac23048c041bb93f42de896a162e5c2b79cc398185fec1d627c96daea1e6f",“id”:“gid://shopify/PaymentSession/rmWo3v05pLXvwCVTaoz2hwsgk”},“query”:"mutation paymentSessionRedirect($id: ID!, $redirectUrl: URL!) { paymentSessionRedirect( id: $id, redirectUrl: $redirectUrl ) { paymentSession { id state { __typename … on PaymentSessionStateResolved { code } } nextAction { action context { __typename … on PaymentSessionActionsRedirect { redirectUrl } } } } userErrors { field message } }}”}

Response :
{“data”:{“paymentSessionRedirect”:{“paymentSession”:{“id”:“gid://shopify/PaymentSession/rmWo3v05pLXvwCVTaoz2hwsgk”,“state”:{“__typename”:“PaymentSessionStateRedirecting”},“nextAction”:null},“userErrors”:}},“extensions”:{“cost”:{“requestedQueryCost”:13,“actualQueryCost”:13,“throttleStatus”:{“maximumAvailable”:546000.0,“currentlyAvailable”:545987,“restoreRate”:27300.0}}}}

paymentSessionConfirm

Request :
{“variables”:{“id”:“gid://shopify/PaymentSession/rmWo3v05pLXvwCVTaoz2hwsgk”},“query”:“mutation paymentSessionConfirm($id: ID!) { paymentSessionConfirm(id: $id) { paymentSession { id state { … on PaymentSessionState { code } } nextAction { action context { … on PaymentSessionActionsRedirect { redirectUrl } } } } userErrors { field message code } }}”}

Response :
{“data”:{“paymentSessionConfirm”:{“paymentSession”:{“id”:“gid://shopify/PaymentSession/rmWo3v05pLXvwCVTaoz2hwsgk”,“state”:{“code”:“CONFIRMING”},“nextAction”:{“action”:“REDIRECT”,“context”:{“redirectUrl”:“Ccaavenue UAE QA2”:27300.0}}}}

PaymentReject

Request :
{“variables”:{“reason”:{“code”:“CARD_DECLINED”,“merchantMessage”:“Transaction Declined”,“source”:“NETWORK”},“id”:“gid://shopify/PaymentSession/rmWo3v05pLXvwCVTaoz2hwsgk”,“authentication”:{“partnerError”:“PROCESSING_ERROR”}},“query”:“mutation paymentSessionReject($authentication: PaymentSessionThreeDSecureAuthentication, $id: ID!, $paymentDetails: PaymentSessionPaymentDetails, $reason: PaymentSessionRejectionReasonInput!) { paymentSessionReject( authentication: $authentication, id: $id, paymentDetails: $paymentDetails, reason: $reason ) { paymentSession { id state { __typename } nextAction { action context { … on PaymentSessionActionsRedirect { redirectUrl } } } } userErrors { field message } }}”}

Response :
{“data”:{“paymentSessionReject”:{“paymentSession”:{“id”:“gid://shopify/PaymentSession/rmWo3v05pLXvwCVTaoz2hwsgk”,“state”:{“__typename”:“PaymentSessionStateRejected”},“nextAction”:{“action”:“REDIRECT”,“context”:{“redirectUrl”:“Ccaavenue UAE QA2”:27300.0}}}}