1

我把它叫做建筑。

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);
    }
}
4

1 回答 1

0

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

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

配置文件

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

- 路由.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('/');
    }


}
于 2012-11-28T19:43:33.230 回答