简体   繁体   English

PayPal-IPN侦听器和加密付款

[英]PayPal - IPN Listener and encrypting payment

I need to add payments to a website I'm working on and I'm not sure what to do. 我需要向正在工作的网站添加付款,但不确定该怎么做。 On the website, users will be able to purchase virtual points. 用户可以在网站上购买虚拟积分。 So once they pay, their account will be credited with x number of points. 因此,一旦他们付款,他们的帐户将被记入x点数。

I came across this tutorial on 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 ). 我在我使用的IPN http://phprocks.letsnurture.com/paypal-ipn-with-php/上遇到了本教程,并且能够使用PayPal IPN模拟器进行一些测试( https://developer.paypal .com / developer / ipnSimulator )。 Everything went well and the user's data was saved to the database after the "payment". 一切顺利,“付款”后,用户的数据已保存到数据库中。

However someone suggested another way to handle payments. 但是有人建议另一种方式来处理付款。 Using this http://blog.scrobbld.com/paypal/protecting-your-payments-with-ewp/ tutorial which encrypts the payment. 使用此http://blog.scrobbld.com/paypal/protecting-your-payments-with-ewp/教程对付款进行加密。

In the second tutorial the author mentions this: "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:" 在第二个教程中,作者提到了这一点:“如果他们使用Firefox并安装了Firebug,则编辑页面的DOM并将其发布到PayPal上要容易得多。因此,与其使用12.99来实现,我可以将其设置为:“

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

but doesn't this if from the first tutorial take care of this aspect? 但是, if从第一个教程讲起,这不是吗? Or does the encryption from the second tutorial offer more security for the payment? 还是第二个教程中的加密为付款提供了更多安全性?

// 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";
}

So if I understand this right, I can use the ipn listener class from the first tutorial, together with the encrypted payment from the second tutorial? 因此,如果我理解这项权利,那么我可以使用第一个教程中的ipn侦听器类以及第二个教程中的加密付款吗?

Within IPN the transaction has already occurred. 在IPN内,交易已经发生。 So if it doesn't match you can send yourself a notification, automatically refund the payment, or handle it however you want. 因此,如果不匹配,您可以向自己发送通知,自动退款,也可以根据需要进行处理。

A secure button, though, whether encrypted or hosted by PayPal (which is how I prefer) would not show the pricing data in the button code at all, so there's no way for anybody to even make a payment without the correct pricing. 但是,无论是由PayPal加密还是由PayPal托管的安全按钮(我偏爱这种方式)都根本不会在按钮代码中显示定价数据,因此,如果没有正确的定价,任何人都无法付款。

So you could use both together, but the logic in the IPN really would be obsolete if you're using secure buttons in the first place. 因此,您可以将两者同时使用,但是如果您首先使用安全按钮,则IPN中的逻辑确实会过时。

The key phrase in Andrew's answer is "has already occurred" (IPN). 安德鲁的答案中的关键词是“已经发生” (IPN)。

If you can actually verify the pricing beforehand , aside from opting for encrypting things, you could use Express Checkout where data is handled server side instead of an HTML form that POSTs directly to Paypal as shown in the sample. 如果您实际上可以事先核实价格,除了选择对事物进行加密之外,还可以使用Express Checkout(在其中,数据是在服务器端处理的),而不是示例中所示的直接过到Paypal的HTML form

This way you can treat IPN more like what it really is - a "messaging" service based on events in the transaction, rather than making it part of the transaction (where you somehow need to invalidate transactions after the fact ). 这样,您可以将IPN更像是真正的IP地址-基于事务中的事件的“消息传递”服务,而不是使其成为事务的一部分 (在这种情况下 ,您需要在事后使事务无效)。

While "invalidating" (credit/refund/cancel) transactions do occur normally, IMHO, it "should" be because of your business rules (instead of some validation issue, like dealing with tampered data). 恕我直言,虽然“无效”(信贷/退款/取消)交易确实确实发生了,恕我直言,这“应该”是由于您的业务规则(而不是某些验证问题,例如处理篡改的数据)。

"If they use Firefox, and have installed Firebug, it is more than easy to edit the DOM of the page..." “如果他们使用Firefox并安装了Firebug,那么编辑页面的DOM就不那么容易了……”

Tampering with HTML form data is an inherent risk in all <form /> and all modern browsers have internal tools (Firefox, Chrome, Internet Explorer) to inspect everything it ("client-side") is involved in. That is why validation (both client and server side) are required in any time of web development. 篡改 HTML form数据是所有<form />固有风险 ,并且所有现代浏览器都具有内部工具(Firefox,Chrome,Internet Explorer)来检查其涉及的所有内容(“客户端”)。这就是验证 ( Web开发的任何时候都需要客户端和服务器端)。

Hth.. Hth ..

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM