Failed Transaction Response Validation

Your browser will receive a response from the Clearent Transaction Processing Portal containing an error message for a failed or unsuccessful transaction.

Error message: "We were unable to process your payment. Please verify your card details and try again or contact us to complete your order."

The Hosted Payment Page application looks for a callback function named ClearentOnError for a failed or unsuccessful transaction. When you call the ClearentOnError function, your browser will receive the raw and signed response from the server, as well as a JSON object representation of the raw response.

You can see the following sample code that contains the raw and JSON-formatted response, as well as an error message and transaction ID, using the browser’s Developer Console.

<script>
            // called after failed complete
               function ClearentOnError(responseRaw,ResponseJSON)
            {
                console.log("transaction failed");
                console.log(responseRaw);
                console.log(ResponseJSON);
                // use JS short-circuiting to determine if we have an error message
                if(ResponseJSON.payload && ResponseJSON.payload.error && ResponseJSON.payload.error['error-message'])
                {
                    console.log("error = " + ResponseJSON.payload.error['error-message']);
                }
                else
                {
                    console.log("unable to determine error");
                }
                // use JS short-circuiting to determine if we have a transaction id
                if(ResponseJSON.payload && ResponseJSON.payload.transaction && ResponseJSON.payload.transaction.id)
                {
                    console.log("transaction id = " + ResponseJSON.payload.transaction.id);
                }
                else
                {
                    console.log("transaction id not found");
                }
}
</script>

See the following ways to validate the response for a failed or unsuccessful transaction:

  • Using an error message: The response object with an error message that is intentionally vague to prevent scammers from using the service to test cards and security codes.

  • Using the Virtual Terminal: You can search for the transaction ID manually to validate the failed transaction details.

Last updated