WebToPay

<?php

require_once(‘WebToPay.php’);

function get_self_url()
{
$s = substr(strtolower($_SERVER[‘SERVER_PROTOCOL’]), 0, strpos($_SERVER[‘SERVER_PROTOCOL’], ‘/’));

if (count($_SERVER[‘HTTPS’]) > 0) {
$s .= ($_SERVER[‘HTTPS’] == ‘on’) ? ‘s’ : ”;
}

$s .= ‘://’ . $_SERVER[‘HTTP_HOST’];

if (count($_SERVER[‘SERVER_PORT’]) > 0 && $_SERVER[‘SERVER_PORT’] != ’80’) {
$s .= ‘:’ . $_SERVER[‘SERVER_PORT’];
}

$s .= dirname($_SERVER[‘SCRIPT_NAME’]);

return $s;
}

function checkMagicQuotesOption()
{
if (version_compare(PHP_VERSION, ‘5.4.0’) >= 0) {
return false;
} else {
return get_magic_quotes_gpc();
}
}

$request = [];

try {
$request = WebToPay::buildRequest([
‘projectid’ => 239705,
‘sign_password’ => 4c1d160c669f361c1e48dac11891ff84,
‘orderid’ => 0,
‘country’ => ‘LT’,
‘lang’ => ‘LIT’,
‘paytext’ => ‘Donation for [site_name].’,
‘accepturl’ => get_self_url() . ‘/accept.php’,
‘cancelurl’ => get_self_url() . ‘/cancel.php’,
‘callbackurl’ => get_self_url() . ‘/callback.php’,
‘test’ => 0,
]);
} catch (WebToPayException $e) {
echo $e->getMessage();
}

?>
<form method=”post” action=”<?= WebToPay::PAY_URL; ?>”>
<?php foreach ($request as $key => $val): ?>
<input type=”hidden” name=”<?= $key ?>” value=”<?= checkMagicQuotesOption() ? $val : addslashes($val); ?>”/>
<?php endforeach; ?>
<input type=”image” name=”submit” style=”border: none” alt=”donation-button”
src=”https://developers.paysera.com/bundles/evppayseradoc/img/support-button-en.gif”/&gt;
</form>