Laravel MethodNotAllowedHttpException状态代码405
控制器:Laravel MethodNotAllowedHttpException状态代码405,laravel,Laravel,控制器: 如果post请求来了,并且您想要除验证CSRFTOKEN之外的内容,则更新 app/Http/Middleware/VerifyCsrfToken.php <?php namespace App\Http\Controllers; use Illuminate\Http\Request; class FlutterwaveController extends Controller { public function flutterwave_process(Re
如果post请求来了,并且您想要除验证CSRFTOKEN
之外的内容,则更新
app/Http/Middleware/VerifyCsrfToken.php
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class FlutterwaveController extends Controller
{
public function flutterwave_process(Request $request){
// $user = Auth::user();
// $subs = Subscription::findOrFail($request->subs_id);
// $settings = Generalsetting::findOrFail(1);
$PBFPubKey = '*************************************';
$name = 'Danish';
$customer_email = '***********';
$currency = "ZMW";
$amount = '100';
$redirect_url = route('flutterwave.verify');
$txref = "rave-".substr(base_convert(sha1(uniqid(mt_rand())), 16, 36), 0, 100); // ensure you generate unique references per transaction.
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.ravepay.co/flwv3-pug/getpaidx/api/v2/hosted/pay",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'amount'=>$amount,
'customer_email'=>$customer_email,
'currency'=>$currency,
'txref'=>$txref,
'PBFPubKey'=>$PBFPubKey,
'redirect_url'=>$redirect_url
]),
CURLOPT_HTTPHEADER => [
"content-type: application/json",
"cache-control: no-cache"
],
));
$response = curl_exec($curl);
$err = curl_error($curl);
if($err){
// there was an error contacting the rave API
die('Curl returned error: ' . $err);
}
$transaction = json_decode($response);
if(!$transaction->data && !$transaction->data->link){
// there was an error from the API
print_r('API returned error: ' . $transaction->message);
}
// uncomment out this line if you want to redirect the user to the payment page
//print_r($transaction->data->message);
// redirect to page so User can pay
// uncomment this line to allow the user redirect to the payment page
// header('Location: ' . $transaction->data->link);
return redirect($transaction->data->link);
}
public function flutterwave_verfiy(Request $request){
dd($request);
}
}
您在此处设置为GET
,并尝试设置为POST
如果我从参数中删除Request$Request,那么我会显示相同的内容error@RishiRaut先生,我需要你的帮助。我在过去两天一直被这个错误困扰着,但没有解决。你能告诉我路线吗?@LalitKumar Route::get(“/flatterwave”,”FlutterwaveController@flutterwave_process“);路由::get(“/verify”,”FlutterwaveController@flutterwave_verfiy')->name('flatterwave.verify')先生,这些是我的route@InoxentLarka不,我没有在sky上给出。但是告诉我服务器上有什么问题吗?我也不知道,我第一次在服务器上上传了laravel脚本,通常是在我从git下载项目时,然后它会显示与我的本地主机上的服务器上显示的相同的错误。我更新了编写器并运行key:generate after这很好,但在这里我不知道如何运行php artisan命令
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class FlutterwaveController extends Controller
{
public function flutterwave_process(Request $request){
// $user = Auth::user();
// $subs = Subscription::findOrFail($request->subs_id);
// $settings = Generalsetting::findOrFail(1);
$PBFPubKey = '*************************************';
$name = 'Danish';
$customer_email = '***********';
$currency = "ZMW";
$amount = '100';
$redirect_url = route('flutterwave.verify');
$txref = "rave-".substr(base_convert(sha1(uniqid(mt_rand())), 16, 36), 0, 100); // ensure you generate unique references per transaction.
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.ravepay.co/flwv3-pug/getpaidx/api/v2/hosted/pay",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'amount'=>$amount,
'customer_email'=>$customer_email,
'currency'=>$currency,
'txref'=>$txref,
'PBFPubKey'=>$PBFPubKey,
'redirect_url'=>$redirect_url
]),
CURLOPT_HTTPHEADER => [
"content-type: application/json",
"cache-control: no-cache"
],
));
$response = curl_exec($curl);
$err = curl_error($curl);
if($err){
// there was an error contacting the rave API
die('Curl returned error: ' . $err);
}
$transaction = json_decode($response);
if(!$transaction->data && !$transaction->data->link){
// there was an error from the API
print_r('API returned error: ' . $transaction->message);
}
// uncomment out this line if you want to redirect the user to the payment page
//print_r($transaction->data->message);
// redirect to page so User can pay
// uncomment this line to allow the user redirect to the payment page
// header('Location: ' . $transaction->data->link);
return redirect($transaction->data->link);
}
public function flutterwave_verfiy(Request $request){
dd($request);
}
}
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
class VerifyCsrfToken extends Middleware
{
protected $except = [
'verify',
];
}