예제 #1
0
파일: pay.php 프로젝트: vcgato29/poff
/**
 * Loome n??itliku ostukorvi ning nende v????rtuste p??hjal loome
 * vormi tehingu parameetritega.
 * Ostukorvi sisu v??iks tegelikult tulla andmebaasist, kus vastava
 * rea ID pannakse ka tehingu identifikaatoriks
 */
$shoppingCart = array('price' => 1.5, 'currency' => 'LTL', 'description' => 'Torso Tiger', 'transaction_id' => 12345);
/**
 * Loome massiivi tehingu andmetega, mis l??hevad panka
 */
$macFields = array('VK_SERVICE' => '1001', 'VK_VERSION' => '008', 'VK_SND_ID' => $preferences['my_id'], 'VK_STAMP' => $shoppingCart['transaction_id'], 'VK_AMOUNT' => $shoppingCart['price'], 'VK_CURR' => $shoppingCart['currency'], 'VK_ACC' => $preferences['account_number'], 'VK_NAME' => $preferences['account_owner'], 'VK_REF' => '', 'VK_MSG' => $shoppingCart['description'], 'VK_RETURN' => 'http' . ($_SERVER['HTTPS'] ? 's' : '') . '://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . '/notify.php');
/**
 * Genereerime tehingu v????rtustest signatuuri
 */
$key = openssl_pkey_get_private(file_get_contents($preferences['my_private_key']), $preferences['my_private_key_password']);
if (!openssl_sign(generateMACString($macFields), $signature, $key)) {
    trigger_error("Unable to generate signature", E_USER_ERROR);
}
$macFields['VK_MAC'] = base64_encode($signature);
/**
 * Genereerime maksmise vormi
 */
header("Content-Type: text/html; charset=utf-8");
?>
<form method="POST" action="<?php 
echo $preferences['banklink_address'];
?>
">
<?php 
foreach ($macFields as $f => $v) {
    echo '<input type="hidden" name="' . $f . '" value="' . htmlspecialchars($v) . '" />' . "\n";
예제 #2
0
파일: notify.php 프로젝트: vcgato29/poff
/**
 * Koostame VK_* muutujatest massiivi
 */
$macFields = array();
foreach ((array) $_REQUEST as $f => $v) {
    if (substr($f, 0, 3) == 'VK_') {
        $macFields[$f] = $v;
    }
}
/**
 * Kontrollime v????rtusi, mis pangast tulid.
 * Selleks arvutame nende v????rtuste p??hjal signatuuri ning
 * v??rdleme seda selle signatuuriga, mis pank koos v????rtustega meile saatis.
 */
$key = openssl_pkey_get_public(file_get_contents($preferences['bank_certificate']));
if (!openssl_verify(generateMACString($macFields), base64_decode($macFields['VK_MAC']), $key)) {
    trigger_error("Invalid signature", E_USER_ERROR);
}
header("Content-Type: text/html; charset=utf-8");
/**
 * Teavitame tehingu sooritajat tehingu ??nnestumisest v??i eba??nnestumisest
 */
if ($macFields['VK_SERVICE'] == '1901') {
    echo '<h2><font color="red">Makse sooritamine katkestati!</font></h2>' . "\n";
    ?>
<table cellpadding="0" cellspacing="0" border="2">
    <tr>
        <td>Katkestatud tehingu ID:</td>
        <td><?php 
    echo htmlspecialchars($macFields['VK_STAMP']);
    ?>