"1011",
"VK_VERSION" => "008",
"VK_SND_ID" => "uid100052",
"VK_STAMP" => "10",
"VK_AMOUNT" => "74.9",
"VK_CURR" => "EUR",
"VK_REF" => "107",
"VK_MSG" => "mts.ee tellimus nr. 10",
"VK_RETURN" => "https://new.eemeli.ee/et/order/validate/8f85b2ff559018a0fcb40af8c9e0e5a5",
"VK_CANCEL" => "https://new.eemeli.ee/et/order/validate/8f85b2ff559018a0fcb40af8c9e0e5a5",
"VK_DATETIME" => "2021-01-19T16:56:08+0200",
"VK_LANG" => "EST",
"VK_NAME" => "MTS Test",
"VK_ACC" => "EE982200221054154260",
"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"] . /* 10 */
str_pad (mb_strlen($fields["VK_AMOUNT"], "UTF-8"), 3, "0", STR_PAD_LEFT) . $fields["VK_AMOUNT"] . /* 74.9 */
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"] . /* EE982200221054154260 */
str_pad (mb_strlen($fields["VK_NAME"], "UTF-8"), 3, "0", STR_PAD_LEFT) . $fields["VK_NAME"] . /* MTS Test */
str_pad (mb_strlen($fields["VK_REF"], "UTF-8"), 3, "0", STR_PAD_LEFT) . $fields["VK_REF"] . /* 107 */
str_pad (mb_strlen($fields["VK_MSG"], "UTF-8"), 3, "0", STR_PAD_LEFT) . $fields["VK_MSG"] . /* mts.ee tellimus nr. 10 */
str_pad (mb_strlen($fields["VK_RETURN"], "UTF-8"), 3, "0", STR_PAD_LEFT) . $fields["VK_RETURN"] . /* https://new.eemeli.ee/et/order/validate/8f85b2ff559018a0fcb40af8c9e0e5a5 */
str_pad (mb_strlen($fields["VK_CANCEL"], "UTF-8"), 3, "0", STR_PAD_LEFT) . $fields["VK_CANCEL"] . /* https://new.eemeli.ee/et/order/validate/8f85b2ff559018a0fcb40af8c9e0e5a5 */
str_pad (mb_strlen($fields["VK_DATETIME"], "UTF-8"), 3, "0", STR_PAD_LEFT) . $fields["VK_DATETIME"]; /* 2021-01-19T16:56:08+0200 */
/* $data = "0041011003008009uid1000520021000474.9003EUR020EE982200221054154260008MTS Test003107022mts.ee tellimus nr. 10072https://new.eemeli.ee/et/order/validate/8f85b2ff559018a0fcb40af8c9e0e5a5072https://new.eemeli.ee/et/order/validate/8f85b2ff559018a0fcb40af8c9e0e5a50242021-01-19T16:56:08+0200"; */
// STEP 4. Sign the data with RSA-SHA1 to generate MAC code
// ========================================================
openssl_sign ($data, $signature, $private_key, OPENSSL_ALGO_SHA1);
/* juPLRe6lDZLhoc+m3koVTMcPu4syehl6rHLGU6aMJjk0vR1W6ECPAnuV2KYp18LGOSqyAhhtaAPrY8npVKF54X3Pq/hVaEEZAd0Jd795Sj4Aw0NvHjNimC0ShoXsjmq3LazD08LrnCjDA9bGyXeUPG9B0pIb5odfG5mf6DAgV+6qJHmglrXI21UGACTAnLaqTkxhedqEYaom8c3tzR08oIPp3t+Dv8oMY2eBn/l6VfsKBK4asmJRv4qsQAEcCMj6uTaQKIQpRmJ+kGxm1PY+oLca9Jd2h+dREOUbFI1DHch5yKaWLy14C9vsFf2u1zj9lMvmqpRgPuQwmS83DjHStA== */
$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"