Nikki
296
9
Laravel

Getting a Forbidden when trying to access my controller

Posted 3 months ago by Nikki

I've created a form that when submitted it needs to go to a controller function.

At the moment when I'm submitting my form I keep getting


Forbidden

You don't have permission to access /client_area/shop/payment-gateway on this server.

Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.

I've done forms before but this is the first time this has happened to me and it has me stumped.

my form

<div class="payment-form">
    <form action="{{ route('payment.gateway') }}" method="POST">
        @csrf
        
        <input type="hidden" name="return_url" value="{{ route('payment.success') }}">
        <input type="hidden" name="cancel_url" value="{{ route('payment.cancel') }}"> 
        <input type="hidden" name="m_payment_id" value="{{ $invoice_number }}">
        <input type="hidden" name="amount" class="completePrice" value="">
        <input type="hidden" name="item_name" value="Test Item">
        <input type="hidden" name="item_description" value="A test product">

        <input type="hidden" name="delivery_collection" class="delivery_collection" value="">
        <input type="hidden" name="delivery_fee" class="delivery_fee" value="{{ $delivery }}">
        <input type="hidden" name="delivery_address" class="delivery_address" value="{{ $address }}">

        <button type="submit" class="btn btn-success float-right confirm-order">
            Confirm Order
        </button>
    </form>
</div>

my routes

Route::group(['middleware' => ['web', 'auth']], function(){
    Route::get('/account/dashboard', '[email protected]')->name('account.dashboard');
    Route::get('/account/details', '[email protected]')->name('account.details');
    Route::get('/account/track-orders', '[email protected]')->name('account.track-orders');
    Route::get('/account/invoices', '[email protected]')->name('account.invoices');
    Route::get('/account/address', '[email protected]')->name('account.addresses.index');
    Route::get('/account/sort-orders', '[email protected]')->name('account.sort-orders');
    Route::get('/account/order-details/{invoice_number}', '[email protected]')->name('account.order-details');
    Route::get('/account/invoice-pdf/{id}', '[email protected]')->name('account.invoices.pdf');
    Route::get('/account/create-address', '[email protected]')->name('account.create.address');
    Route::get('/account/edit-address/{id}', '[email protected]')->name('account.edit.address');
    Route::get('/delivery-confirmation', '[email protected]')->name('cart.deliveryConfirmation');
    Route::get('/account/edit-delivery-address/{id}', '[email protected]')->name('account.edit.delivery.address');
    Route::get('/payment-success', '[email protected]')->name('payment.success');
    Route::get('/payment-cancel', '[email protected]')->name('payment.cancel');

    Route::post('/account/personal-details', '[email protected]')->name('post.personal-details');
    Route::post('/account/business-details', '[email protected]')->name('post.business-details');
    Route::post('/account/addresses-radio/{id}', '[email protected]')->name('account.post.addresses.radio');
    Route::post('/account/create-address', '[email protected]')->name('account.post.address');
    Route::post('/account/edit-address/{id}', '[email protected]')->name('account.update.address');
    Route::post('/payment-gateway', '[email protected]')->name('payment.gateway');

    Route::delete('/account/delete-delivery-address/{id}', '[email protected]')->name('account.delete.delivery.address');
});

I've only done a dd() to make sure I hit the right function

public function paymentGateway()
{
    dd('this is a payment gateway');
}

Please sign in or create an account to participate in this conversation.