"1012",
"VK_VERSION" => "008",
"VK_SND_ID" => "uid100052",
"VK_STAMP" => "12",
"VK_AMOUNT" => "51.00",
"VK_CURR" => "EUR",
"VK_REF" => "123",
"VK_MSG" => "Vaheajatellimus 2109280001 30.09.2021 15:42",
"VK_RETURN" => "http://127.0.0.1:8000/en/orders/banks/thorbanks_response/",
"VK_CANCEL" => "http://127.0.0.1:8000/en/orders/banks/thorbanks_response/",
"VK_DATETIME" => "2021-09-28T12:47:39+0000",
"VK_LANG" => "EST",
"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"] . /* 1012 */
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"] . /* 12 */
str_pad (mb_strlen($fields["VK_AMOUNT"], "UTF-8"), 3, "0", STR_PAD_LEFT) . $fields["VK_AMOUNT"] . /* 51.00 */
str_pad (mb_strlen($fields["VK_CURR"], "UTF-8"), 3, "0", STR_PAD_LEFT) . $fields["VK_CURR"] . /* EUR */
str_pad (mb_strlen($fields["VK_REF"], "UTF-8"), 3, "0", STR_PAD_LEFT) . $fields["VK_REF"] . /* 123 */
str_pad (mb_strlen($fields["VK_MSG"], "UTF-8"), 3, "0", STR_PAD_LEFT) . $fields["VK_MSG"] . /* Vaheajatellimus 2109280001 30.09.2021 15:42 */
str_pad (mb_strlen($fields["VK_RETURN"], "UTF-8"), 3, "0", STR_PAD_LEFT) . $fields["VK_RETURN"] . /* http://127.0.0.1:8000/en/orders/banks/thorbanks_response/ */
str_pad (mb_strlen($fields["VK_CANCEL"], "UTF-8"), 3, "0", STR_PAD_LEFT) . $fields["VK_CANCEL"] . /* http://127.0.0.1:8000/en/orders/banks/thorbanks_response/ */
str_pad (mb_strlen($fields["VK_DATETIME"], "UTF-8"), 3, "0", STR_PAD_LEFT) . $fields["VK_DATETIME"]; /* 2021-09-28T12:47:39+0000 */
/* $data = "0041012003008009uid1000520021200551.00003EUR003123043Vaheajatellimus 2109280001 30.09.2021 15:42057http://127.0.0.1:8000/en/orders/banks/thorbanks_response/057http://127.0.0.1:8000/en/orders/banks/thorbanks_response/0242021-09-28T12:47:39+0000"; */
// STEP 4. Sign the data with RSA-SHA1 to generate MAC code
// ========================================================
openssl_sign ($data, $signature, $private_key, OPENSSL_ALGO_SHA1);
/* q3Dfb6RhNB7e4UH4A+5KLS7vz0UMoNupkz0ahcqUu1HKqo4NXrAbvr7HAKYf1Zgy9l9NdgSXe83yAolTmOyrG3OdOYmk0+KOcDxkKfmi0FvIJdRa2xD6hGK7gCgrMHeFFBwsUbbqygEzv687Gt/XvtATrz/z4jpXeE62bQwGPfRECPjRNXnnFhWnrMUHj1Yh2KwJw8QY2uCRh0BlSMfskV1IAvRMuNWN6s27zH8GHWcyB+EKTlqtz4e//V+OunTAVxWqP3wKFbUMeR+yU8KjT2RTd4WFwX8a4+BCHEZay9waNXJzfdgos6F4Pg/gnJxmPU0RE92b70i/Ocdd4LRyXw== */
$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"