"1002",
"VK_VERSION" => "008",
"VK_SND_ID" => "uid100010",
"VK_STAMP" => "12345",
"VK_AMOUNT" => "150",
"VK_CURR" => "EUR",
"VK_REF" => "1234561",
"VK_LANG" => "EST",
"VK_MSG" => "Torso Tiger",
"VK_RETURN" => "https://pangalink.indoorsman.ee/project/SIfDsws65RpmZmZL?payment_action=success",
"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 Lithuania 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"] . /* 1002 */
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"] . /* uid100010 */
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_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 */
/* $data = "0041002003008009uid10001000512345003150003EUR0071234561011Torso Tiger"; */
// STEP 4. Sign the data with RSA-SHA1 to generate MAC code
// ========================================================
openssl_sign ($data, $signature, $private_key, OPENSSL_ALGO_SHA1);
/* hma41PVc0Uw5sGB7vipH8ggw33CD+zXH/OTauaV/d/sqVowEBlU6D6QeLvKP3C3RJdVMKlaPNBwEy5X0FCX72zrWS+GCw7uup12oVoL0OX/KxsixniONT3RBUgjr/O8APOWfX0O+exC93k/8G3G6tNtryZTq3TQInAtwQVdrVt6o+BinEDdAKRB17CEMgDs/oh1dCZokxO1UgxF3u3rxNIvl6CpFSrmDLPqmTfPDaaf2iv4pUGj9yVhTOaiBABnmt7pDytbN31G+hfmEqKmjwpqImpKlYUrbhPA+QxuTo7JFuUUHoVhE1kdd8ZFBIK/JTPFUPLLeg4/r/lmG6im/6w== */
$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 Lithuania"