I try to redirect to some route:url
to capture my payment, and I have to passed the payment_id
and amount
to capture from controller, but the routes gives error like below
Thanks in advance
Errors I got
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)
My Route
Route::prefix('razorpay/standard')->group(function () {
Route::get('/success/{rzpId}/{amount}', 'RazorPayController@success')->name('razorpay.standard.success');
}
Controller
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;
},
You can't use the javascript variables inside PHP
try this solution:
Route::prefix('razorpay/standard')->group(function () {
Route::get('/success/{rzpId?}/{amount?}', 'RazorPayController@success')->name('razorpay.standard.success');
}
and then change the route to
"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;
},