我按照PHP的简单代码进行paypal集成
这是我的代码,
<form action="<?php echo $paypal_url; ?>" method="post">
<input type="hidden" name="business" value="<?php echo $paypal_id; ?>">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="item_name" value="<?php echo $row['name']; ?>">
<input type="hidden" name="item_number" value="<?php echo $row['id']; ?>">
<input type="hidden" name="amount" value="<?php echo $row['price']; ?>">
<input type="hidden" name="currency_code" value="USD">
<input type='hidden' name='cancel_return' value='http://localhost/paypal_integration_php/cancel.php'>
<input type='hidden' name='return' value='http://localhost/paypal_integration_php/success.php'>
<input type="image" name="submit" border="0"
src="https://www.paypalobjects.com/en_US/i/btn/btn_buynow_LG.gif" alt="PayPal - The safer, easier way to pay online">
<img alt="" border="0" width="1" height="1" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" >
</form>
和, 这是Success.php
<?php
include 'db_config.php';
$item_number = $_REQUEST['item_number'];
$txn_id = $_REQUEST['tx'];
$payment_gross = $_REQUEST['amount'];
$currency_code = $_REQUEST['currency_code'];
$payment_status = $_REQUEST['st'];
?>
我不清楚IPN和PDT概念是否清晰......
答案 0 :(得分:3)
试试这个
$item_name = $_POST['item_name'];
$item_number = $_POST['item_number'];
$payment_status = $_POST['payment_status'];
$payment_amount = $_POST['mc_gross'];
$payment_currency = $_POST['mc_currency'];
$txn_id = $_POST['txn_id'];
$receiver_email = $_POST['receiver_email'];
$payer_email = $_POST['payer_email'];
答案 1 :(得分:2)
我对此并不完全确定,但我相信PDT正在使用GET参数进行响应。因此,当你回去时检查网址,它可能看起来像:
xxxxx.com/?TX=XXXX&AMOUNT=XXXX等
如果是这种情况那么你的变量应该是
$txn_id = $_GET['TX'];
$amount = $_GET['AMOUNT'];
等,其中包含网址中的所有详细信息。
如果您正在使用IPN,我建议您在$ _POST上执行var_dump或print_r,以查看您从paypal收到的数据类型。然后你就可以将它们添加到变量中。例如:
$item_name = $_POST['whatever post data you got from paypal'];