<?php
include 'process_pdt.function.php';
$payment_data = isset($_GET['tx'])
? process_pdt($_GET['tx'])
: FALSE;
$current_url = 'http://'.$_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF'];
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>PDT Sample</title>
<style>
form
{
float: right;
margin: 0 3em 0 4em;
}
</style>
</head>
<body>
<h1>PDT Sample</h1>
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="JY9AFX442THDY">
<input type="image" src="https://www.sandbox.paypal.com/en_GB/i/btn/btn_subscribeCC_LG.gif" border="0" name="submit" alt="PayPal – The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.sandbox.paypal.com/en_GB/i/scr/pixel.gif" width="1" height="1">
</form>
<p>Click the button on the right to "buy" a stuffed bear. When you return the PDT data will be printed under Details below.</p>
<?php if($payment_data)
printf('<p>Thank you %s and welcome back. We will pretend to ship that stuffed bear to you ASAP.</p>', $payment_data['first_name'], $payment_data['mc_gross'], $payment_data['mc_currency']);
else
echo 'fatal';
?>
<?php if($_GET): ?>
<hr/>
<h2>Details</h2>
<pre>GET: <?php print_r($_GET) ?></pre>
<pre>PDT: <?php print_r($payment_data) ?></pre>
<?php endif ?>
</body>
</html>