Please wait ...


Loading...

Hash - MD5 security check

Hash - MD5 security check

This article describes how to calculate the hash value sent to Bambora and how to check the hash value received from Bambora.
Notice for payment modules

If you’re using one of our payment modules (open source modules), please find your shop solution on this list, and click on it to see our online guide. 

You can find more information about MD5 under ‘Configuration’ in the respective guides. 
Notice

Please set MD5 security check to On accepturl and by authorization in the Bambora administration under the menu Settings -> Payment system.

Sent to Bambora

The hash you send to (and receive from) Bambora must be the value of all parameters in the order they are sent + the MD5 key.
<?php
$params = array('merchantnumber' => "ENTER YOUR MERCHANT NUMBER HERE", 'amount' => "10095", 'currency' => "DKK");
?>

<script type="text/javascript" src="https://ssl.ditonlinebetalingssystem.dk/integration/ewindow/paymentwindow.js" charset="UTF-8">
</script>
 
<script type="text/javascript">
    paymentwindow = new PaymentWindow({
        <?php
        foreach ($params as $key => $value)
        {
            echo "'" . $key . "': \"" . $value . "\",\n";
        }
        ?>
        'hash': "<?php echo md5(implode("", array_values($params)) . "SecretMD5Key"); ?>"
    });
</script>
 
<input type="button" onclick="javascript: paymentwindow.open()" value="Go to payment" />

Recieved from Bambora

The hash received from Bambora is the value of all GET parameters received except the parameter hash + the MD5 key.
<?php
$params = $_GET;
$var = "";

foreach ($params as $key => $value)
{
    if($key != "hash")
    {
        $var .= $value;
    }
}

$genstamp = md5($var . "SecretMD5Key");

if($genstamp != $_GET["hash"])
{
    echo "Hash is not valid";
    exit();
}
else
{
    //Hash is OK   
}
?>