Successful Transaction Response Validation

Your browser will receive a response from the Clearent Transaction Processing Portal for each transaction request. The Hosted Payment Page application looks for a callback function named ClearentOnSuccess for a successful transaction. When you call the ClearentOnSuccess 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 the transaction ID, using the browser’s Developer Console. You will pass the response below to your server-side solution to complete the transaction.

<script>
        // called after successful complete
           function ClearentOnSuccess(responseRaw,ResponseJSON)
        {
            console.log("transaction successful");
            console.log(responseRaw);
            console.log(ResponseJSON);
        // 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 before completing the transaction:

  • Using a hash signature: The hash is made up of the response object. You can validate the response parameters on your server to check whether the parameters are tampered with. You can also ensure the response is valid and the transaction ID is unique.

  • Using Clearent’s API: You can check whether the transaction ID in the response matches the client-side transaction ID.

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

Last updated