[英]unknown status 419 payfast notify url in laravel
我正在尝试将 PayFast 支付网关集成到我的 laravel 应用程序中,我收到 419 错误,我认为这很奇怪,下面是代码。
我已经按照 PayFast 的文档配置了所有内容,我正在 ngrok 上检查它并通知 url 我得到 419 未知状态,我不知道我错过了什么。 请查看我的代码,让我知道我缺少什么。
PayFast 表单视图
<form target="_blank" action="https://sandbox.payfast.co.za/eng/process" method="POST">
<input type="hidden" name="merchant_id" value="10015150">
<input type="hidden" name="merchant_key" value="aaid6ctdo8lxz">
<input type="hidden" name="custom_str1" value="{{$business->id}}">
<input type="hidden" name="amount" value="200.00">
<input type="hidden" name="name_first" value="">
<input type="hidden" name="name_last" value="">
<input type="hidden" name="email_address" value="">
<input type="hidden" name="cell_number" value="0823456789">
<input type="hidden" name="item_name" value="Making your business Featured on our Website">
<input type="hidden" name="return_url" value="http://95d16c17.ngrok.io/return">
<input type="hidden" name="cancel_url" value="http://95d16c17.ngrok.io/cancel">
<input type="hidden" name="notify_url" value="http://95d16c17.ngrok.io/notify">
<button type="submit" title="You will have to pay to make your business featured" class="btn btn-primary">Make Business Featured</button>
</form>
web.php
Route::post('notify','HomeController@updatedBusiness');
主页 Controller
public function updatedBusiness(Request $request){
header('HTTP/1.0 200 OK');
flush();
$business = Business::find($request->get('custom_str1'));
$business->featured_business = 1;
$business->save();
return 'success';
}
任何帮助将非常感激。
这是 csrf 的问题,因为 laravel 在每条路由上应用了 VerifyCsrfToken 中间件,当 PayFast 在通知 url 上发回 POST 请求时,然后 ZA5C95B86291EA2909FCBE64458ED197 在评论中提到了 Theries。 在 VerifyCsrfToken 中间件中禁用它的技巧如下
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
class VerifyCsrfToken extends Middleware
{
/**
* Indicates whether the XSRF-TOKEN cookie should be set on the response.
*
* @var bool
*/
protected $addHttpCookie = true;
/**
* The URIs that should be excluded from CSRF verification.
*
* @var array
*/
protected $except = [
'notify',
];
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.