我尝试重定向到一些route:url
来捕获我的付款,并且我必须通过payment_id
和amount
才能从控制器中捕获,但是路由会出现如下错误>
预先感谢
我遇到的错误
ErrorException (E_ERROR)
Missing required parameters for [Route: razorpay.standard.success] [URI: razorpay/standard/success/{rzpId}/{amount}]. (View: /home/valpuia/projects/bagisto/packages/Vaube/Razorpay/src/Resources/views/standard-redirect.blade.php)
我的路线
Route::prefix('razorpay/standard')->group(function () {
Route::get('/success/{rzpId}/{amount}', 'RazorPayController@success')->name('razorpay.standard.success');
}
控制器
public function success($rzpId, $amt)
{
dd($rzpId);
}
Blade.php after razorpay completed
"handler": function (response){
// alert(response.razorpay_payment_id);
if (typeof response.razorpay_payment_id == 'undefined' || response.razorpay_payment_id < 1) {
redirect_url = '{{ route('razorpay.standard.cancel') }}';
} else {
redirect_url = '{{ route('razorpay.standard.success', [ "rzp_id" => 'response.razorpay_payment_id', "amount" => '$total_amount * 100']) }}';
}
location.href = redirect_url;
},
答案 0 :(得分:1)
您不能在PHP中使用javascript变量
尝试此解决方案:
Route::prefix('razorpay/standard')->group(function () {
Route::get('/success/{rzpId?}/{amount?}', 'RazorPayController@success')->name('razorpay.standard.success');
}
然后将路线更改为
"handler": function (response){
// alert(response.razorpay_payment_id);
if (typeof response.razorpay_payment_id == 'undefined' || response.razorpay_payment_id < 1) {
redirect_url = '{{ route('razorpay.standard.cancel') }}';
} else {
redirect_url = '{{ route("razorpay.standard.success")}}/'+response.razorpay_payment_id+'/'+'{{$total_amount * 100}}';
}
location.href = redirect_url;
},
答案 1 :(得分:0)
我认为您在参数名称中有错字。
请替换
"rzp_id" => 'response.razorpay_payment_id'
与
"rzpId" => 'response.razorpay_payment_id'
然后尝试