<form id="dvrr" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<table border="0" cellpadding="5" cellspacing="5" align="center" width="100%">
<tr>
<td></td>
<td><input type="hidden" name="business" value="ceo@world-airport-city-transfer.com">
<!-- Specify a Buy Now button. -->
<input type="hidden" name="cmd" value="_xclick">
<!-- Specify details about the item that buyers will purchase. -->
<input type="hidden" name="item_name" value="Cab Booking">
<input type="hidden" name="item_number" value="<?php echo $orderid; ?>">
<input type="hidden" name="amount" value="<?php echo number_format((float)$data['price'], 2, '.', ''); ?>">
<input type="hidden" name="currency_code" value="USD">
<!-- Specify URLs -->
<input type="hidden" name="cancel_return" value="http://www.wer.com/payment-cancel/">
<input type="hidden" name="return" value="http://www.wer.com/payment-processing/">
<input type="hidden" name="notify_url" value="http://www.wer.com/notify-payment/">
<!-- Display the payment button. -->
<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" ></td>
</tr>
</table>
这是我用于付款的 PayPal 表单,在感谢页面上,我们添加代码以获取响应并在我们的系统上更新交易是否完成。
我们将此代码放在 weburl.com/payment-processing/上,这是我们的返回 URL
$data=$_POST;
if($_POST['payment_status']!=''){
$item_name=$_POST['item_name'];
$item_number=$_POST['item_number'];
$txn_id=$_POST['txn_id'];
$payer_email=$_POST['payer_email'];
$payment_gross=$_POST['payment_gross'];
$payment_status=$_POST['payment_status'];
$insert = mysql_query("INSERT INTO cr_payments(item_name,item_number,txn_id,payer_email,payment_gross,payment_status) VALUES('".$item_name."','".$item_number."','".$txn_id."','".$payer_email."','".$payment_gross."','".$payment_status."')") or die(mysql_error());
global $wpdb;
$is_added = $wpdb->query("UPDATE cr_booking SET fld_booking_status = '$payment_status' WHERE fld_booking_id = '$item_number'");
但是当我们在沙盒模式下运行代码时我们得到数据..但是在实时模式下我们得到空白数组
最佳答案
PayPal 网站支付标准,包括您使用的 PayPal 按钮,不会将任何内容带回您的返回 URL。
在跳转到 PayPal 支付页面之前,您必须在购物车中存储数据。
您可以使用的另一种 PayPal 产品是快速结帐,它与您正在使用的产品截然不同。它需要你编写你的服务器和PayPal之间的API调用,但实际收费是通过在你的服务器上调用doexoresscheckout来完成的,所以你可以根据这个API调用的结果来决定显示什么。
关于 Paypal 返回网址给出空白数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30821923/