Php Codeigniter Paypal IPN问题-它没有';付款成功后,请不要应用任何设置
我已经成功地实现了Ran的Paypal库,我正在使用下面的Paypal IPN控制器。就我用Paypal sandbox测试而言,它工作正常。付款后,我点击返回商户,成功代码正确显示。只是IPN不想发送任何电子邮件,所以我可以验证它是否100%有效。IPN电子邮件发送功能是否存在任何可能导致此行为的问题 谢谢Php Codeigniter Paypal IPN问题-它没有';付款成功后,请不要应用任何设置,php,codeigniter,paypal,paypal-ipn,Php,Codeigniter,Paypal,Paypal Ipn,我已经成功地实现了Ran的Paypal库,我正在使用下面的Paypal IPN控制器。就我用Paypal sandbox测试而言,它工作正常。付款后,我点击返回商户,成功代码正确显示。只是IPN不想发送任何电子邮件,所以我可以验证它是否100%有效。IPN电子邮件发送功能是否存在任何可能导致此行为的问题 谢谢 <?php /** * paypal_lib Controller Class (Paypal IPN Class) * * Paypal controller that pr
<?php
/**
* paypal_lib Controller Class (Paypal IPN Class)
*
* Paypal controller that provides functionality to the creation for PayPal forms,
* submissions, success and cancel requests, as well as IPN responses.
*
* The class requires the use of the paypal_lib library and config files.
*
* @package CodeIgniter
* @subpackage Libraries
* @category Commerce
* @author Ran Aroussi <ran@aroussi.com>
* @copyright Copyright (c) 2006, http://aroussi.com/ci/
*
*/
class Paypal extends Controller {
function Paypal()
{
parent::Controller();
$this->load->library('paypal_Lib');
}
function index()
{
$this->form();
}
function form()
{
$this->paypal_lib->add_field('business', 'demo@demo.com');
$this->paypal_lib->add_field('return', site_url('paypal/success'));
$this->paypal_lib->add_field('cancel_return', site_url('paypal/cancel'));
$this->paypal_lib->add_field('notify_url', site_url('paypal/ipn')); // <-- IPN url
$this->paypal_lib->add_field('custom', '1234567890'); // <-- Verify return
$this->paypal_lib->add_field('item_name', 'Paypal Test Transaction');
$this->paypal_lib->add_field('item_number', '6941');
$this->paypal_lib->add_field('amount', '197');
// if you want an image button use this:
$this->paypal_lib->image('button_03.gif');
// otherwise, don't write anything or (if you want to
// change the default button text), write this:
// $this->paypal_lib->button('Click to Pay!');
$data['paypal_form'] = $this->paypal_lib->paypal_form();
$this->load->view('paypal/form', $data);
}
function auto_form()
{
$sessionid = $this->session->userdata('session_id') ;
$this->paypal_lib->add_field('business', 'demo@demo.com');
$this->paypal_lib->add_field('return', site_url('paypal/success'));
$this->paypal_lib->add_field('cancel_return', site_url('paypal/cancel'));
$this->paypal_lib->add_field('notify_url', site_url('paypal/ipn')); // <-- IPN url
$this->paypal_lib->add_field('custom', $sessionid); // <-- Verify return
/* $this->paypal_lib->add_field('item_name', 'Paypal Test Transaction');
$this->paypal_lib->add_field('item_number', '6941');
$this->paypal_lib->add_field('amount', '197'); */
$this->paypal_lib->add_field('cmd', '_cart');
$this->paypal_lib->add_field('upload', 1);
/*$this->paypal_lib->add_field('item_name_1', 'Nokia N70');
$this->paypal_lib->add_field('amount_1', 600);
$this->paypal_lib->add_field('quantity_1', 5);
$this->paypal_lib->add_field('item_name_2', 'Google Nexus One');
$this->paypal_lib->add_field('quantity_2', 1);
$this->paypal_lib->add_field('amount_2', 800);*/
$i = 1;
foreach($this->cart->contents() as $key => $value)
{
$this->paypal_lib->add_field('item_name_'.$i, $value['name']);
$this->paypal_lib->add_field('quantity_'.$i, $value['qty']);
$this->paypal_lib->add_field('amount_'.$i, $value['price']);
$i++;
}
$this->paypal_lib->paypal_auto_form();
}
function cancel()
{
$this->cart->destroy();
$this->load->view('paypal/cancel');
}
function success()
{
// This is where you would probably want to thank the user for their order
// or what have you. The order information at this point is in POST
// variables. However, you don't want to "process" the order until you
// get validation from the IPN. That's where you would have the code to
// email an admin, update the database with payment status, activate a
// membership, etc.
// You could also simply re-direct them to another page, or your own
// order status page which presents the user with the status of their
// order based on a database (which can be modified with the IPN code
// below).
$sessionid = '507';
$data = array('users_logged_count' => 1);
$this->db->where('users_id', $sessionid);
$this->db->update('users', $data);
$data['pp_info'] = $_POST;
$this->load->view('paypal/success', $data);
}
function ipn()
{
// Payment has been received and IPN is verified. This is where you
// update your database to activate or process the order, or setup
// the database with the user's order details, email an administrator,
// etc. You can access a slew of information via the ipn_data() array.
// Check the paypal documentation for specifics on what information
// is available in the IPN POST variables. Basically, all the POST vars
// which paypal sends, which we send back for validation, are now stored
// in the ipn_data() array.
// For this example, we'll just email ourselves ALL the data.
$to = 'tftestemail@gmail.com'; // your email
if ($this->paypal_lib->validate_ipn())
{
$body = 'An instant payment notification was successfully received from ';
$body .= $this->paypal_lib->ipn_data['payer_email'] . ' on '.date('m/d/Y') . ' at ' . date('g:i A') . "\n\n";
$body .= " Details:\n";
foreach ($this->paypal_lib->ipn_data as $key=>$value)
$body .= "\n$key: $value";
// load email lib and email results
$this->load->library('email');
$this->email->to($to);
$this->email->from($this->paypal_lib->ipn_data['payer_email'], $this->paypal_lib->ipn_data['payer_name']);
$this->email->subject('CI paypal_lib IPN (Received Payment)');
$this->email->message($body);
$this->email->send();
}
}
}
?>
IPN的发送与按下“后退”按钮无关。据我所知,您的日志是否显示IPN已发送?请记住,您还需要允许paypal帐户使用IPN。我正在使用paypal沙箱,并使用进行测试demo@demo.com贝宝帐户作为商家。我不拥有它。我是否也必须在Paypal沙箱中创建商户帐户?我只有一个做假货的测试demo@demo.comI很久没有和paypal打过交道了,但我记得我有一个注册为开发者的选项——你可以创建自己的假商户帐户和买家帐户。在商户账户本身就是你设置IPN url的地方,我的话有点言过其实,因为已经有一段时间了:)我就是这么做的。并对其进行了全面测试。Paypal根本不发送IPN通知。我检查了商户帐户的IPN历史记录,没有发送IPN。可能是什么原因造成的?我想最后一件事,对不起,我帮不了你什么忙,就是确保你在商户账户中激活了IPN选项,因为我猜整个交易都可以正常进行,但它不会通知你。