"1011",
"VK_VERSION" => "008",
"VK_SND_ID" => "uid100052",
"VK_STAMP" => "12345",
"VK_AMOUNT" => "150",
"VK_CURR" => "EUR",
"VK_ACC" => "EE152200221234567897",
"VK_NAME" => "ÕIE MÄGER",
"VK_REF" => "1234561",
"VK_LANG" => "EST",
"VK_MSG" => "Torso Tiger",
"VK_RETURN" => "https://banks.pastel.thorgate.eu/project/sjZfG6RrKJT4YbY5?payment_action=success",
"VK_CANCEL" => "https://banks.pastel.thorgate.eu/project/sjZfG6RrKJT4YbY5?payment_action=cancel",
"VK_DATETIME" => "2023-04-14T19:06:59+0000",
"VK_ENCODING" => "utf-8",
);
// STEP 3. Generate data to be signed
// ==================================
// Data to be signed is in the form of XXXYYYYY where XXX is 3 char
// zero padded length of the value and YYY the value itself
// NB! Swedbank expects symbol count, not byte count with UTF-8,
// so use `mb_strlen` instead of `strlen` to detect the length of a string
$data = str_pad (mb_strlen($fields["VK_SERVICE"], "UTF-8"), 3, "0", STR_PAD_LEFT) . $fields["VK_SERVICE"] . /* 1011 */
str_pad (mb_strlen($fields["VK_VERSION"], "UTF-8"), 3, "0", STR_PAD_LEFT) . $fields["VK_VERSION"] . /* 008 */
str_pad (mb_strlen($fields["VK_SND_ID"], "UTF-8"), 3, "0", STR_PAD_LEFT) . $fields["VK_SND_ID"] . /* uid100052 */
str_pad (mb_strlen($fields["VK_STAMP"], "UTF-8"), 3, "0", STR_PAD_LEFT) . $fields["VK_STAMP"] . /* 12345 */
str_pad (mb_strlen($fields["VK_AMOUNT"], "UTF-8"), 3, "0", STR_PAD_LEFT) . $fields["VK_AMOUNT"] . /* 150 */
str_pad (mb_strlen($fields["VK_CURR"], "UTF-8"), 3, "0", STR_PAD_LEFT) . $fields["VK_CURR"] . /* EUR */
str_pad (mb_strlen($fields["VK_ACC"], "UTF-8"), 3, "0", STR_PAD_LEFT) . $fields["VK_ACC"] . /* EE152200221234567897 */
str_pad (mb_strlen($fields["VK_NAME"], "UTF-8"), 3, "0", STR_PAD_LEFT) . $fields["VK_NAME"] . /* ÕIE MÄGER */
str_pad (mb_strlen($fields["VK_REF"], "UTF-8"), 3, "0", STR_PAD_LEFT) . $fields["VK_REF"] . /* 1234561 */
str_pad (mb_strlen($fields["VK_MSG"], "UTF-8"), 3, "0", STR_PAD_LEFT) . $fields["VK_MSG"] . /* Torso Tiger */
str_pad (mb_strlen($fields["VK_RETURN"], "UTF-8"), 3, "0", STR_PAD_LEFT) . $fields["VK_RETURN"] . /* https://banks.pastel.thorgate.eu/project/sjZfG6RrKJT4YbY5?payment_action=success */
str_pad (mb_strlen($fields["VK_CANCEL"], "UTF-8"), 3, "0", STR_PAD_LEFT) . $fields["VK_CANCEL"] . /* https://banks.pastel.thorgate.eu/project/sjZfG6RrKJT4YbY5?payment_action=cancel */
str_pad (mb_strlen($fields["VK_DATETIME"], "UTF-8"), 3, "0", STR_PAD_LEFT) . $fields["VK_DATETIME"]; /* 2023-04-14T19:06:59+0000 */
/* $data = "0041011003008009uid10005200512345003150003EUR020EE152200221234567897009ÕIE MÄGER0071234561011Torso Tiger080https://banks.pastel.thorgate.eu/project/sjZfG6RrKJT4YbY5?payment_action=success079https://banks.pastel.thorgate.eu/project/sjZfG6RrKJT4YbY5?payment_action=cancel0242023-04-14T19:06:59+0000"; */
// STEP 4. Sign the data with RSA-SHA1 to generate MAC code
// ========================================================
openssl_sign ($data, $signature, $private_key, OPENSSL_ALGO_SHA1);
/* iP/XN4cWR/KxVozk39vGjdLKgsWqUQxuInz1B+9ySCc9Znm/U5NIcXx1i9OZIjSgI99wMlEiabXjFDkRnsrEd9D+2Xj2yiOYM3j3M7u/iHOsNPE/7rtMSsrx5OFtAtJegGv/9nFRWF13BkfGpFyllnI67vug0XgByg7B6KWLYgfaoxna5wXspdMkOcryucNXI/ccyJbpeBT0WGZVM0wbclDkhFCHuBaZ1NpTFDBiq1HDKyVoU+mQOTd0UfCtrnkWm/uOAWaqeSvOMRPo/JvV/AwvCHxH4WtIZ+K4+I3gxJ5bXHfdOT6ZZKJt8e1h2xfMMGe8ZbNQ2l6e1XdKePebUg== */
$fields["VK_MAC"] = base64_encode($signature);
// STEP 5. Generate POST form with payment data that will be sent to the bank
// ==========================================================================
?>
Makse teostamise näidisrakendus "Swedbank"