PHP Paypal IPN处理无法正常工作 [英] PHP Paypal IPN processing won't work
问题描述
我在电子商务方面是如此陌生,并且我已经使用PHP开发了基于 https:/的票务系统/github.com/smhack/Ticket ,一切正常,付款工作(PayPal购物车)等...(我正在使用PayPal Sandbox)
I'm such new on e-commerce and I've developed using PHP a ticketting system based on https://github.com/smhack/Ticket, well everything works fine and the payement works (PayPal Shopping Cart) etc... (I'm using PayPal Sandbox)
我已经在IPN模拟器上测试了IPN,并且可以正常工作,但是在我的项目中,我无法弄清楚为什么不考虑IPN上的PHP代码(在数据库中插入,发送确认邮件)
I have tested my IPN on the IPN simulator and it works, however in my project I can't figure why the PHP code on the IPN is not taken on consideration (Insert on the database, sending confirmation mail)
HTML:
HTML :
<form name="_xclick" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="m.bendriss-facilitator@gpayme.com">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="item_name" value="<?php echo $classTitle;?>">
<input type="hidden" name="item_number" value="Class">
<input type="hidden" name="custom" value="<?php echo $id;?>">
<input type="hidden" name="amount" value="<?php echo $price;?>">
<input type="hidden" name="return" value="http://www.croisentoi.com/ticket/">
<input type="hidden" name="notify_url" value="http://www.croisentoi.com/ticket/ipn.php">
<input type="image" src="http://www.paypalobjects.com/en_US/i/btn/btn_buynow_LG.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
</form>
ipn.php:
ipn.php :
<?php
include('ipnlistener.php');
include("config.php");
if($sqlTicketservertype = 'mysql'){
$db = new PDO('mysql:host='.$sqlTicketserver.';dbname='.$sqlTicketdbname, $sqlTicketusername, $sqlTicketpassword);
}
// tell PHP to log errors to ipn_errors.log in this directory
ini_set('log_errors', true);
ini_set('error_log', dirname(__FILE__).'/ipn_errors.log');
$listener = new IpnListener();
$listener->use_sandbox = true;
try {
$verified = $listener->processIpn();
} catch (Exception $e) {
// fatal error trying to process IPN.
error_log($e->getMessage());
exit(0);
}
if ($verified) {
// IPN response was "VERIFIED"
$email = $_POST['payer_email'];
$txn = $_POST['txn_id'];
$firstName = $_POST['first_name'];
$lastName = $_POST['last_name'];
$paymentDate = $_POST['payment_date'];
$query = $db->PREPARE("INSERT INTO tickets ( email, txn, firstName, lastName, paymentDate ) VALUES ( '$email', '$txn', '$firstName', '$lastName', '$paymentDate' )");
$query->execute();
mail('bendrissmehdi@gmail.com', 'Valid IPN', $listener->getTextReport());
} else {
// IPN response was "INVALID"
mail('bendrissmehdi@gmail.com', 'Invalid IPN', $listener->getTextReport());
}
?>
我认为付款确定后应执行IPN.那么,为什么不读取此文件?您对此有什么想法吗?
I Thought that the IPN should be executed when the payement is Ok. So why this file is not read ? Do you have any idea about this ?
项目托管在上 http://croisentoi.com/ticket
谢谢
推荐答案
您也必须在Paypal Sandbox网站中启用IPN通知,以便它可以在PHP脚本中使用.继续并使用ipn网址打开它(您以后可以在您的php脚本中使用"return"属性覆盖此网址):
You have to turn on IPN Notification in the Paypal Sandbox site too, in order for it to work from your PHP scripts. Go ahead and turn it on with an ipn url (you can later override this url using the "return" attribute in your php script):
https://www.sandbox.paypal. com/cgi-bin/customerprofileweb?cmd = _profile-ipn-notify
这篇关于PHP Paypal IPN处理无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!