pdt/index.php
<?php include '../config.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>
<?php include DOCROOT.'header.php'; ?>
<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" accept-charset="utf-8">
<p>
<input type="hidden" name="cmd" value="_xclick" />
<input type="hidden" name="charset" value="utf-8" />
<input type="hidden" name="business" value="paypal@business.example.com" />
<input type="hidden" name="item_name" value="Stuffed bear" />
<input type="hidden" name="item_number" value="BEAR05" />
<input type="hidden" name="amount" value="20.00" />
<input type="hidden" name="currency_code" value="USD" />
<input type="hidden" name="return" value="<?php echo $current_url ?>" />
<input type="hidden" name="cancel_return" value="<?php echo $current_url ?>" />
<input type="hidden" name="bn" value="Business_BuyNow_WPS_SE" />
<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_buynowCC_LG.gif" name="submit" alt="Buy Now" />
</p>
</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']); ?>
<?php if($_GET): ?>
<hr/>
<h2>Details</h2>
<pre>GET: <?php print_r($_GET) ?></pre>
<pre>PDT: <?php print_r($payment_data) ?></pre>
<?php endif ?>
<?php $article = 1210; include DOCROOT.'footer.php' ?>
</body>
</html>