Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/231.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何验证PayPal返回数据?_Php_Validation_Paypal_Payment Gateway_Paypal Sandbox - Fatal编程技术网

Php 如何验证PayPal返回数据?

Php 如何验证PayPal返回数据?,php,validation,paypal,payment-gateway,paypal-sandbox,Php,Validation,Paypal,Payment Gateway,Paypal Sandbox,我正在整合paypal,我已经正确地完成了。我已经设置了返回URL,所以它会在URL$\u GET中给出下面的结果集 Array ( [tx] => 7XV08083GT683520Y [st] => Completed [amt] => 22.16 [cc] => USD [cm] => [item_number] => item_number ) 我担心的是,无法验证从Paypal返回的数据。我有过其他支付网关的经验。其他支付网关允许您执行hashMat

我正在整合paypal,我已经正确地完成了。我已经设置了返回URL,所以它会在URL
$\u GET
中给出下面的结果集

Array ( [tx] => 7XV08083GT683520Y [st] => Completed [amt] => 22.16 [cc] => USD [cm] => [item_number] => item_number )
我担心的是,无法验证从Paypal返回的数据。我有过其他支付网关的经验。其他支付网关允许您执行
hashMatch
,从而确保表单提交的数据未被编辑

我的表格如下

<form method="post" action="https://www.sandbox.paypal.com/cgi-bin/webscr">
<!-- Identify your business so that you can collect the payments. -->
<input type="hidden" value="dasun_1358759028_biz@archmage.lk" name="business">
<!-- Specify a Buy Now button. -->
<input type="hidden" value="_xclick" name="cmd">
<!-- Specify details about the item that buyers will purchase. -->
<input type="hidden" value="AM Test Item" name="item_name">
<input type="hidden" value="22.16" name="amount">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" value="item_number" name="item_number">
<!-- Display the payment button. -->
<input type="image" name="submit" border="0" src="https://www.paypalobjects.com/en_US/i/btn/btn_buynow_LG.gif" alt="PayPal - The safer, easier way to pay online">
<img alt="" border="0" width="1" height="1" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" >
</form> 

我的php代码输出

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

但我使用firebug并将其编辑到下面&完成了付款

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


尽管如此,我还是得到了结果,因为它是一个
已完成的
付款,但它不应该是,因为我已经手动进行了更改。任何有知识的人都可以编辑它们。如何确保这是一笔有效的付款?如何确保表单数据没有像我那样被编辑

在重新接收到paypal之前,请将您的数据存储在数据库中(产品id、数量、数量等)

从payapl返回后,请使用数据库检查返回值


这是正确的方法。

任何关键的、需要DB交互的数据都应该使用Paypals IPN进行验证。基本上,Paypal将在您的网站上发布包含数据的URL,并且您的脚本必须将准确的数据发回,再加上一个命令,以验证数据是否确实正确。在Paypal给出“验证”响应后,您将更新数据

另一种选择是使用Paypal的快速结帐,本质上你得到一个“确定”来向客户收取“x”金额,一旦客户同意支付该金额,你将数据与客户“协议”一起发布到Paypal,如果交易完成或未完成,你将得到响应


如果您想通知您是否从paypal返回,那么您应该使用paypal API而不是“立即购买”按钮API,以提供更大的灵活性和能力来控制您的支付过程

您可以尝试以下方法:

1) 在PayPal网站上创建加密按钮

2) 使用加密的网站付款(EWP)动态加密按钮

网址:

此外,此SO链接还有一些详细信息:

非常感谢。我想知道的是,是否有一种与其他支付网关类似的方式。类似HashMatch的东西我认为你可以向paypal发送一些自定义值,paypal也会返回这些值,所以你也可以在这些值之间建立一个comaprison,但你仍然需要将这些值存储在你的页面(会话或数据库)中。这不是我想要的。无论如何,非常感谢