【问题标题】:Route issue when paypal notify_url贝宝 notify_url 时的路由问题
【发布时间】:2012-11-28 17:17:40
【问题描述】:

我称之为建筑。

function __construct()
{
    parent::__construct();

    if( !$this->authentication->authenticate( $this->router->class ) ) {
        redirect('clients/');
    }

    $this->load->model('client_model', 'client');
    $this->layout = 'layout/web/client';
}

当 paypal NOTIFY_URL 访问 url 时,我遇到了问题,它不保存凭据,如果我从构造函数中删除它,它可以工作。

function payment_notification()
{
    if( $this->input->post(NULL, TRUE) ) 
    {
        $this->saveintodb( $this->input->post() );          
    } else {
        show_error('Post data not found in request', 500);
    }
}

【问题讨论】:

    标签: codeigniter paypal


    【解决方案1】:

    此处提供的信息不足...!

    • 确保将正确的 notify_url 发送到 paypal
    • 如果启用 CSRF,Codeigniter 将不允许该操作!
    • 您应该检查 $_POST 数组而不是 $this->input->post()

    Config.php

    $config['uri_protocol'] = 'REQUEST_URI';
    /*
    |--------------------------------------------------------------------------
    | Check to see if the request uri contains paypal
    |--------------------------------------------------------------------------
    */
    if( stripos($_SERVER["REQUEST_URI"],'/paypal') )
    {
        $config['csrf_protection'] = FALSE;
    }
    

    - Routes.php

    $route['paypal/notify'] = 'paypal/recieve_notification'; // www.mysite.com/paypal/notify
    

    - 控制器/Paypal.php

    class Paypal extends CI_Controller{
    
        public function __construct(){ parent::__construct(); }
    
        public function recieve_notification() //simplified function
        {
            try(
                if( !$_POST )
                    throw new Exception('No POST data recieved from Paypal');
    
                if( $_POST['verified'] !== 'VERIFIED') //im guessing here
                    throw new Exception('User not verified by paypal');
    
    
            )catch(Exception $e){
                //debugging: show_error($e->getMessage());
                log_message('error', $e->getMessage());
                redirect('/');
                exit;
            }
    
                //Save to DB
                $this->saveintodb( $_POST ); //expecting Exception thrown from DB ?
    
            $this->session->flashdata('success', 'Data Saved!');
            redirect('/');
        }
    
    
    }
    

    【讨论】:

    • 它不是 Paypal 问题,它的建设问题......它甚至无法通过 url 访问。我的意思是localhost/site/client/function 由于构造函数class Clients extends MY_Controller { function __construct() { parent::__construct(); if( !$this->authentication->authenticate( $this->router->class ) ) { redirect('clients/'); } $this->load->model('client_model', 'client'); $this->layout = 'layout/web/client'; } },这会将我重定向到客户页面@
    猜你喜欢
    • 2017-08-13
    • 2014-08-29
    • 1970-01-01
    • 1970-01-01
    • 2023-03-16
    • 2017-04-16
    • 2013-07-28
    • 2022-01-10
    • 2021-02-12
    相关资源
    最近更新 更多