Php paypal ipn开发人员脚本要长吗?
嘿,我想问你一个特定的脚本,这里是: 我了解一切,它的结构非常好,我真的很喜欢它,我看起来也很安全,但我对其他部分有一个问题:Php paypal ipn开发人员脚本要长吗?,php,paypal,paypal-ipn,Php,Paypal,Paypal Ipn,嘿,我想问你一个特定的脚本,这里是: 我了解一切,它的结构非常好,我真的很喜欢它,我看起来也很安全,但我对其他部分有一个问题: } else { // PayPal payment is valid // Process order here } 我在这里要做什么?在数据库中插入值??但这是以前做过的 } else { // Transaction not processed, store it in the dat
} else {
// PayPal payment is valid
// Process order here
}
我在这里要做什么?在数据库中插入值??但这是以前做过的
} else {
// Transaction not processed, store it in the database
$payer_email = mysql_real_escape_string($_POST[‘payer_email’]);
$gross = mysql_real_escape_string($_POST[‘mc_gross’]);
你好
编辑:好的,我可以用这个防止重播攻击吗
if($f[‘count’] > 0) {
$errors[] = “Transaction already processed”;
} else {
if (count($errors) > 0) {
// IPN data is incorrect - possible fraud
// It is a good practice to send the transaction details to your e-mail and investigate manually
$message = "IPN failed fraud checks";
mail(‘youremail@example.com’, 'IPN Fraud Warning', $message, $headers);
} else {
// Transaction not processed, store it in the database
$payer_email = mysql_real_escape_string($_POST[‘payer_email’]);
$gross = mysql_real_escape_string($_POST[‘mc_gross’]);
$insert = mysql_query(“INSERT INTO transactions (txt_id, payer_email, mc_gross) VALUES
(‘$txt_id’,’$payer_email’,’$mc_gross’)”);
}
}
您对此有何看法?上述代码是:
if (!$fp) {
// HTTP ERROR
} else {
您必须将所有内容放在else中,因为如果$fp
为false,则意味着无法建立到Paypal IPN验证系统的连接
接下来,我们可以看到else中有一些检查,这些检查也会检查付款(paypal认为)是否实际有效:
if (strcmp ($res, "VERIFIED") == 0) {
// PAYMENT VALID
}
IPN的理念是,当用户遵循html按钮代码时,它会将他们链接到paypal的网站,并在那里付款
通常会有一个隐藏值(或者如果你使用的是托管按钮,它会保存在paypal的网站上),paypal会在该值上ping回,表示付款已通过
确保客户端和服务器安全的下一步是仔细检查ping是否来自Paypal。因此,您可以获得之前下载的SSL证书,并通过https连接到Paypal进行检查
下面的代码显示了什么也是有效的:if(count($errors)>0){
Theelse
与此链接
我必须在这里做什么?在数据库中插入值??但这是以前做的
} else {
// Transaction not processed, store it in the database
$payer_email = mysql_real_escape_string($_POST[‘payer_email’]);
$gross = mysql_real_escape_string($_POST[‘mc_gross’]);
您可以处理这些信息。例如,如果用户为您的网站购买会员资格,您可以在数据库中将其用户设置为升级状态
付款已记录在数据库中,这将防止发生错误
重放攻击
我想您已经用$errors[]=“交易已处理”;
如果您查看上面的代码,您可以看到脚本查询数据库中过去的事务。如果id与任何行匹配,那么它将被视为无效。因此,不。只要您有这些检查,就不可能进行重播攻击。这是一个代码问题还是一个业务流程问题?我只是想问一下在这方面该怎么做另外,当不在数据库中插入值时,这取决于您的业务流程。页面底部有脚本,您看到了吗?我想您已经准备好使用此代码了。下一步将是在paypal上注册托管按钮。(如果您还没有这样做)好的,我现在必须阅读更多关于贝宝及其按钮的手册,谢谢你的帮助,喝杯啤酒:)