[英]Laravel: MethodNotAllowedHttpException: The GET method is not supported for this route. Supported methods: POST
[英]The GET method is not supported for this route. Supported methods: POST on Flutterwave implementation with laravel
我正在实施Medium上的 Flutterwave 实施,但出现错误:
此路由不支持 GET 方法。 支持的方法:POST。 http://localhost:8000/rave/callback?resp=%7B%22name%22%3A%22opop%22%2C%22data%22%3A%7B%22data%22%3A%7B%22responsecode%22%3A %2200%22%2C%22responsetoken%22%3Anull%2C%22responsemessage%22%3A%22successful%22%7D%2C%22tx%22%3A%7B%22id%22%3A2424493%2C%22txRef%22%3A %22rave_611fc5fe12df9%22%2C%22orderRef%22%3A%22URF_1629472286526_3670035%22%2C%22flwRef%22%3A%22FLW-MOCK-44b7ecdb3a2183c971db03d669dc1554%22%2C%22redirectUrl%22%3A%22http%3A%2F%2Flocalhost%3A8000 %2Frave%2Fcallback%22%2C%22device_fingerprint%22%3A%22888b449800a5003eaf1eeea02d5d52db%22%2C%22settlement_token%22%3_
我正在实施 Post 路线,如下所示:
Route::post('/pay', 'RaveController@initialize')->name('pay');
Route::post('/rave/callback', 'RaveController@callback')->name('callback');
在我的 controller 上,我有:
public function initialize() {
//This initializes payment and redirects to the payment gateway
//The initialize method takes the parameter of the redirect URL
Rave::initialize(route('callback'));
}
/**
* Obtain Rave callback information
* @return void
*/
public function callback() {
$data = Rave::verifyTransaction(request()->txref);
dd($data); // view the data response
if ($data->status == 'success') {
//do something to your database
} else {
//return invalid payment
}
}
请问谁能帮我解决这个问题? 特别是自从更改路线以获取回报 null 以来。非常感谢!
我想Route::post('/rave/callback', 'RaveController@callback')->name('callback');
是你的问题。 应该是 Route:: get
你好。 很抱歉直接编辑这个,因为我找不到回复按钮。 Route::get() 为这个特定的实现返回 null。
那是因为你在这里再次调用路由,这意味着你将使用 get 方法将 go 指向这个方向
public function initialize(){
Rave::initialize(route('callback'));
}
最好的解决方案是您必须调用此 function 而无需按以下方式路由
public function initialize(Request $request){
//here now you will not routing with get you will call the function inside it
Rave::initialize($this->callback($request->all()));
}
/**
* Obtain Rave callback information
* @return void
*/public function callback($request){
$data = Rave::verifyTransaction($request->txref);
dd($data); // view the data response
if ($data->status == 'success') {
//do something to your database
}
else {
//return invalid payment
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.