贝宝notify_url和return_url.使用PHP接收没有IPN的变量 [英] Paypal notify_url and return_url. Receiving variables without IPN using PHP

查看:110
本文介绍了贝宝notify_url和return_url.使用PHP接收没有IPN的变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为paypal设置一个简单的付款方式,但是在退货和通知URL时遇到一些麻烦/困惑.我对php还是相当陌生,以前在asp中已经做到了,但是现在我迷路了.

所以我的基本Paypal表格是

<form action="https://www.paypal.com/cgi-bin/webscr" method="post" id="PayPalForm" name="PayPalForm"  target="_top">
 <input type="hidden" name="cmd" value="_xclick">
 <input type="hidden" name="business" value="email@hotmail.com">
 <input type="hidden" name="amount" value="0.01">
 <input type="hidden" name="item_name" value="Composite Door">
 <input type="hidden" name="item_number" value="<?php echo $orderID ?>">
 <input type="hidden" name="currency_code" value="GBP">
 <input type="hidden" name="cancel_return" value="http://www.mydomain.co.uk/paypal-notcompleted.php">
<input type="hidden" name="return" value="http://www.mydomain.co.uk/paypal-completed.php">
<input type="hidden" name="notify_url" value="http://www.mydomain.co.uk/paypal-completed.php"> 
</form>


  <script>
    document.PayPalForm.submit();
   </script>

如您所见,表单发布到paypal,然后根据结果返回,如果失败/取消,它将进入paypal-notcompleted.php.

如果成功,则转到paypal-completed.php.这就是我无法理解的地方,我还没有设置IPN,我要做的就是将一些PayPal变量返回给我,以运行简单的插入查询并在确认消息中显示一些详细信息给客户.

我可以将notify_url和return_url设置为同一页面吗?

为什么贝宝(Paypal)无法发布完整的期望值(如此处所示:通知贝宝的网址 )返回页面?

我知道与XML等有关,但我只是想知道,我可以$ _GET paypal发送回的变量.有谁做过这种事,他们能告诉我我要去哪里了吗?

解决方案

要将详细信息返回到您的返回URL,您需要使用 PDT .它与 IPN 非常相似,不同之处在于它专门用于您的返回URL,而 IPN 侦听器脚本一起使用.

PDT 非常适合在返回URL页面上简单地向用户显示交易,但不建议发布任何帖子 PDT 进行付款处理(即数据库更新,发送电子邮件回执等),因为无法保证用户会即使在您的PayPal帐户中启用了自动返回功能,也可以返回到此页面.

每次交易时,都会触发

IPN ,无论用户是否在完成付款后将其返回到您的网站

通知URL仅用于IPN,它将覆盖您在PayPal配置文件中为IPN进行的任何设置.需要在您的PayPal帐户资料中配置PDT,以便将数据返回到您的返回URL.

您将要使用不同的URL进行返回和通知,否则相同的代码将运行两次:一次是在用户返回您的网站时,另一次是从PayPal IPN POST.

I am trying to set up a simple payment option to paypal, but am having some trouble/confusion with the return and notify URLS. I am fairly new to php and have accomplished this previously in asp, but I have now become lost.

SO my basic paypal form:

<form action="https://www.paypal.com/cgi-bin/webscr" method="post" id="PayPalForm" name="PayPalForm"  target="_top">
 <input type="hidden" name="cmd" value="_xclick">
 <input type="hidden" name="business" value="email@hotmail.com">
 <input type="hidden" name="amount" value="0.01">
 <input type="hidden" name="item_name" value="Composite Door">
 <input type="hidden" name="item_number" value="<?php echo $orderID ?>">
 <input type="hidden" name="currency_code" value="GBP">
 <input type="hidden" name="cancel_return" value="http://www.mydomain.co.uk/paypal-notcompleted.php">
<input type="hidden" name="return" value="http://www.mydomain.co.uk/paypal-completed.php">
<input type="hidden" name="notify_url" value="http://www.mydomain.co.uk/paypal-completed.php"> 
</form>


  <script>
    document.PayPalForm.submit();
   </script>

As you can see the form posts to paypal, and then returns depending on the outcome, if failed/cancelled it goes to paypal-notcompleted.php.

If its successful it goes to paypal-completed.php. And this is where I am unable to understand, I haven't set up an IPN, all I want to do is grab some of the variables paypal posts back to me, to run a simple insert query and display some details in a confirmation message to the customer.

Am I allowed to have the notify_url and return_url as the same page?

Why does paypal not post the full expected (as seen here: Notify url of Paypal ) back to the page?

I understand there is something to do with XML and such, but I just figured that I would be able to $_GET the variables that paypal sent back. Has anyone done it this way, can they tell me where I am going wrong?

解决方案

To return details back to the your return URL you'll need to use PDT. It's very similar to IPN except it's intended for use with your return URL, while IPN is intended for use with a 3rd party IPN listener script on your server.

PDT is fine for simply displaying transaction to the user on the return URL page, but it's not recommended to do any any post-payment processing with PDT (ie. database updates, sending out email receipts, etc.) because there is no guarantee the user will make it back to this page, even with Auto-Return enabled in your PayPal account.

IPN will be triggered every time a transaction occurs regardless of whether or not the user makes it back to your site after completing payment.

The notify URL is used for IPN only, and it would override any setting you have in your PayPal profile for IPN. PDT needs to be configured in your PayPal account profile in order to get data returned to your return URL.

You're going to want to use different URL's for return and notify, otherwise that same code would run twice: once when the user returns to your site, and again from the PayPal IPN POST.

这篇关于贝宝notify_url和return_url.使用PHP接收没有IPN的变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆