<?php
define ('HMAC_SHA256', 'sha256');
define ('SECRET_KEY', 'f577866b4ef34d97909b7abe554481ee813797851cbc40f591e37e2e636474e7d3ce29dde16245bd8733fb320e3acd2d8c48ca108ff347c78da800cee2be209015e3935c4a904029a2443768f894bb6e21e62895b1204939b98e1efeca318b19f937a5660c0244e1bc58e8e11b4ccd42cd53ea2506d44a3b87ff506b69304889');
function sign ($params) {
  return signData(buildDataToSign($params), SECRET_KEY);
}
function signData($data, $secretKey) {
    return base64_encode(hash_hmac('sha256', $data, $secretKey, true));
}
function buildDataToSign($params) {
        $signedFieldNames = explode(",",$params["signed_field_names"]);
        foreach ($signedFieldNames as $field) {
           $dataToSign[] = $field . "=" . $params[$field];
        }
        return commaSeparate($dataToSign);
}
function commaSeparate ($dataToSign) {
    return implode(",",$dataToSign);
}
?>
