gpt4 book ai didi

codeigniter - paypal notify_url 时的路由问题

转载 作者:太空宇宙 更新时间:2023-11-03 16:11:26 24 4
gpt4 key购买 nike

我在构造中调用它。

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

最佳答案

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

  • 确保将正确的 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

-Controllers/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('/');
}


}

关于codeigniter - paypal notify_url 时的路由问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13610784/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com