Nikki
7 months ago

Passing a variable through the route without affecting the url

Posted 7 months ago by Nikki

This might be a silly question but can you pass a variable through the route without affecting the url?

I need to pass a variable to my controller but I don't want my url to display it and I can't use the request method.

Here is the code

<form action="https://sandbox.payfast.co.za/eng/process" method="POST">
    <input type="hidden" name="merchant_id" value="">
    <input type="hidden" name="merchant_key" value="">
    <!-- THIS IS WHERE I WOULD LIKE TO PASS THE $TOTALPRICE TO MY CONTROLLER -->
    <input type="hidden" name="return_url" value="{{ route('payfast.success', ['totalPrice'=> $totalPrice]) }}">
    <input type="hidden" name="cancel_url" value="{{ route('payfast.cancel') }}">
    <input type="hidden" name="m_payment_id" value="01AB">
    <input type="hidden" name="amount" value="{{ $totalPrice }}">
    <input type="hidden" name="item_name" value="Test Item">
    <input type="hidden" name="item_description" value="A test product">
    <input type="hidden" name="email_confirmation" value="1">
    <input type="hidden" name="confirmation_address" value="">
    <input type="hidden" name="payment_method" value="eft">

    <button class="btn btn-dark" type="submit"><img src="{{ asset('img/eft-payfast.jpg') }}"></button>
</form>

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