PayPal - IPN 侦听器和加密支付

PayPal - IPN Listener and encrypting payment

我需要向我正在使用的网站添加付款,但我不确定该怎么做。在该网站上,用户将能够购买虚拟积分。因此,一旦他们付款,他们的帐户就会记入 x 点。

我是在 IPN http://phprocks.letsnurture.com/paypal-ipn-with-php/ which I used, and was able to do a few tests using the PayPal IPN simulator(https://developer.paypal.com/developer/ipnSimulator 上看到这个教程的。一切顺利,用户数据在 "payment".

后保存到数据库中

然而,有人提出了另一种处理付款的方式。使用这个 http://blog.scrobbld.com/paypal/protecting-your-payments-with-ewp/ 加密支付的教程。

作者在第二篇教程中提到了这一点: "If they use Firefox, and have installed Firebug, it is more than easy to edit the DOM of the page, and post that off to PayPal instead. So instead of having the amount at 12.99 , I might set it to:"

<input type="hidden" name="amount" value="0.99">

但是第一个教程中的这个 if 没有处理这方面的问题吗?或者第二个教程中的加密是否为付款提供了更多安全性?

// 3. Make sure the amount(s) paid match
if ($_POST['mc_gross'] != '0.34')
{
  $errmsg .= "'mc_gross' does not match: ";
  $errmsg .= $_POST['mc_gross']."\n";
}

所以如果我没理解错的话,我可以使用教程一的ipn监听器class,连同教程二的加密支付吗?

IPN 内交易已经发生。因此,如果不匹配,您可以向自己发送通知、自动退款或按您的意愿处理。

但是,无论是加密的还是由 PayPal 托管的安全按钮(这是我更喜欢的方式)都不会在按钮代码中显示定价数据,因此任何人都无法在没有正确的定价。

因此您可以同时使用两者,但如果您首先使用安全按钮,IPN 中的逻辑确实会过时。

Andrew 的回答中的关键短语是 "has already occurred" (IPN)。

如果您实际上可以事先验证定价,除了选择加密之外,您还可以使用Express Checkout处理数据的地方服务器端 而不是 HTML form 直接发布到 Paypal,如示例中所示。

通过这种方式,您可以更真实地对待 IPN - 基于交易中事件的 "messaging" 服务,而不是使其成为交易的 一部分 (你不知何故需要在事后使交易无效)。

虽然 "invalidating" (credit/refund/cancel) 交易确实正常发生,恕我直言,这 "should" 是因为您的业务规则(而不是一些验证问题,例如处理篡改数据) .

"If they use Firefox, and have installed Firebug, it is more than easy to edit the DOM of the page..."

篡改 HTML form 数据是所有 <form /> 中的固有风险所有现代浏览器都有内部工具(Firefox、Chrome、Internet Explorer)来检查它("client-side")涉及的所有内容。这就是为什么验证(客户端和服务器端)在Web开发的任何时候都需要。

Hth..