ecshop的paypal sandbox 测试支付,需要修改的部分

QQ截图20130503164129

QQ截图20130503163955

下面是代码,方便复制

get_code函数里面
 $def_url  = '<br /><form style="text-align:center;" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" target="_blank">' .   // 不能省略
respond 函数里面
// post back to PayPal system to validate
$header = "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "HOST: www.sandbox.paypal.com\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) ."\r\n\r\n";
$fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);

同一paypal 在多个ecshop站点使用代码修改

症状: 同一个paypal账号在多个ecshop 站点使用,出现paypal订单已经支付从而无法支付的状况

includes\modules\payment\paypal.php

修改 function get_code($order, $payment) 函数内

$data_order_id = $order['log_id'];
改为
$data_order_id = 'site2'. $order['log_id'];
修改 function respond() 函数内
$order_sn = substr($_POST['invoice'],5); // 5 是 'site2' 这5个字符的长度,要根据这个修改

paypal ipn的精髓 关于ecshop 的paypal 贝宝支付模块错误的问题

With IPN the code will run regardless of whether or not the  buyer reaches your final checkout page or not.   Again, it is server-to-server communication and is entirely separate  from the user’s interaction with your application.

翻译来的意思就是
ipn 代码不管客户端(浏览器) 购买者是否到达最终的反馈页面,IPN是服务器到服务器端的通信,IPN完全独立于用户浏览器和网站应用程序之间的交互(指购买者浏览器和商品网站)

如下文章可以解释的很清晰 IPN 和 PDT 的区别了

一句话解释就是 PDT 是依靠客户浏览器返回到商品网站来确认付款成功,而IPN则可独立于浏览器和服务器之间,IPN 是端到端(Paypal 到 网站) 的沟通,他可防止所谓的掉单现象的发生,对于一些需要自动化的任务有较好的效果,(比如游戏币的自动发卡,自动充值)。

看图

英文的

详细的上下文如下https://www.x.com/docs/DOC-2502
中文说明在
http://paypal.ebay.cn/integrationcenter/list__resource_2.html

How is IPN Different from PDT?

I’d like to backup just a little bit now and discuss some of  the differences between Instant Payment Notification (IPN) and Payment Data  Transfer (PDT).  They are very similar in  the way they work so if you’re already familiar with PDT you may feel right at  home with IPN.  There is really one major  difference that is very important to understand.

PDT was designed with one simple goal in mind: provide  transaction data to checkout systems using Payments Standard so that it can be  displayed on the merchant’s “thank you” or “completed” page.  When utilizing PDT you have the option of data  being returned as form data (POST) or as URL parameters (GET).  You can then build your thank you page in a  dynamic fashion so that users can print the page as a receipt, simply save it  for their records, etc.  It is a very  useful tool when this is necessary, however, you cannot rely on PDT for  automating tasks because there is no guarantee that the user will ever make it  to your “thank you” page when working with PayPal Standard Payments.  Even with Auto-Return enabled in your PayPal  profile the user could close the browser before being redirected and the code  on your thank you page will never run.

With IPN the code will run regardless of whether or not the  buyer reaches your final checkout page or not.   Again, it is server-to-server communication and is entirely separate  from the user’s interaction with your application.  Once that transaction is complete the data  will be sent to your IPN listener and will be handled accordingly.  This is why it is highly recommended you  utilize Instant Payment Notification instead of Payment Data Transfer when  automating tasks on the back-end.