CodeIgniter 的 IPN 库 - 脚本忽略了我的代码

标签 codeigniter paypal paypal-ipn

我正在使用 CI IPN 库,就其功能而言,一切运行顺利,所有交易信息都提交给数据库,这意味着脚本被调用并运行。 但是,当我尝试在 txn 成功的情况下添加我自己的指令时 - 即向客户端发送电子邮件并将他的详细信息添加到数据库 - 它完全忽略了我的代码。我尝试去掉“if successful”条件,还是不行。 重要的是要注意,当我通过来自另一个 Controller 的直接调用在 IPN Controller 外部运行这些模型时,它们运行完美。 这是代码:

    class Ipn extends CI_Controller {

    // To handle the IPN post made by PayPal (uses the Paypal_Lib library).
    public function index()

    {

    $this->load->library('PayPal_IPN'); // Load the library

    // Try to get the IPN data.
    if ($this->paypal_ipn->validateIPN())
    {
        // Succeeded, now let's extract the order
        $this->paypal_ipn->extractOrder();

        // And we save the order now 
        $this->paypal_ipn->saveOrder();

        // Now let's check what the payment status is and act accordingly
        if ($this->paypal_ipn->orderStatus == PayPal_IPN::PAID)
        { 
            $this->load->model("register_model"); // my own code
            $this->register_model->insert(); // my own code
            $this->register_model->email_customer(); //my own code
        } // end if PAID
    } 
    else // Just redirect to the root URL
    {
        $this->load->helper('url');
        redirect('/', 'refresh');
    } // end if validates
  } // end function
 } // end class

TIA 感谢您的帮助。 马塔尼亚

最佳答案

调试您的 Paypal IPN 代码可能有点像噩梦,我遇到了类似的麻烦,最终将 Controller 中的变量记录到一个文件中。

您确定您的“register_model”模型没有问题吗?也许尝试添加一些 logs ,检查您收到的变量。如果它记录下来并且一切看起来都是正确的,那么您需要查看您的“register_model”模型。

关于CodeIgniter 的 IPN 库 - 脚本忽略了我的代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10671285/

相关文章:

php - 如何将图像与数据库中的记录链接起来?

paypal - Sandbox api curl (5) SSL 连接错误

paypal 快速结帐不与 magento 2.2.4 同步

c# - 获取堆栈跟踪错误并且不明白为什么

php - Paypal IPN HTTP/1.1 - 根本不提供任何响应,它是一个空字符串

paypal - 通过 GA Measurement Protocol 跟踪 PayPal 定期付款

php - $this->db->insert_id();对于插入 Id 工作正常。但我也想插入公司名称如何

php - Codeigniter - 使用 jQuery 刷新发送到 View 的数据

Codeigniter 不记录

paypal - 将 Paypal PDT 与其他 paypal 按钮一起使用,不想覆盖那些按钮上的成功 url?