我有一个paypal按钮如下:
<form id="fmPaypal" method="post" action= "https://www.sandbox.paypal.com/cgi-bin/webscr">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="currency_code" value="NZD">
<input type="hidden" name="business" value="blah01@yahoo.com">
<input type="hidden" name="item_name" value="Order">
<input type="hidden" id="item_number" name="item_number" value="123">
<input type="hidden" name="amount" value="0.01">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="return" value="http://www.blah.com/checkout/return.cfm" />
<input type="hidden" name="cancel_return" value="http://www.blah.com/checkout/cancel" />
</form>
这有效,用户被重定向到 paypal 准备付款。
但是,我应该期望通过返回 URL 从 paypal 返回一些数据吗?例如交易结果?或者,如果用户被重定向到返回网址,我是否应该假设付款已成功处理?
尝试从文档中获取此信息但没有成功。
最佳答案
要使用返回 url,必须在表单上启用 rm 选项
return(Optional) The URL to which PayPal redirects buyers' browser after they complete their payments. For example, specify a URL on your site that displays a "Thank you for your payment" page. Default – PayPal redirects the browser to a PayPal webpage. 1,024
rm: (Optional) Return method. The FORM METHOD used to send data to the URL specified by the return variable. Allowable values are:
0 – all shopping cart payments use the GET method
1 – the buyer's browser is redirected to the return URL by using the GET method, but no payment variables are included
2 – the buyer's browser is redirected to the return URL by using the POST method, and all payment variables are included The default is 0.
Note: The rm variable takes effect only if the return variable is set.
这里是IPN返回的引用文档
https://developer.paypal.com/webapps/developer/docs/classic/ipn/gs_IPN/
那我这里引用一下,方便复习
$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'];
你应该已经有了这个文档 PDF,但我想我也应该把它放在这里 https://www.paypalobjects.com/webstatic/en_US/developer/docs/pdf/ipnguide.pdf
因为我必须提醒一件重要的事情,你必须在你的帐户上启用“自动返回”
Auto Return is turned off by default. To turn on Auto Return:
Log in to your PayPal account at https://www.paypal.com. The My Account Overview page appears. Click the Profile subtab. The Profile Summary page appears. Click the My Selling Tools link in the left column. Under the Selling Online section, click the Update link in the row for Website Preferences. The Website Payment Preferences page appears Under Auto Return for Website Payments, click the On radio button to enable Auto Return. In the Return URL field, enter the URL to which you want your payers redirected after they complete their payments. NOTE: PayPal checks the Return URL that you enter. If the URL is not properly formatted or cannot be validated, PayPal will not activate Auto Return. Scroll to the bottom of the page, and click the Save button.
关于支付宝结账返回数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18007480/