Successful Transaction Response Validation

A success message appears on your website when a transaction is completed successfully.

Add the ClearentOnSuccess function to your website to detect successful transactions and return a JSON object with the raw and signed server response.

The following sample code includes the raw and JSON-formatted response, along with the message and transaction ID for a successful 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>

You can 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 API: You can check whether the transaction ID in the response matches the client-side transaction ID.

Each transaction ID is unique. You cannot see the transaction ID again once you have accepted it for payment.

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

Last updated

Was this helpful?