1 week ago

Pay on delivery | best method

Posted 1 week ago by rubenochoa

I am working on checkout. If a user does not choose to pay by card but pay on delivery, so i did this:


 public function payondelivery(){                
                Mail::send('shop.order_confirmation2', [
                    'user' => Auth()->user(),
                    'products' => $cart->items,
                    'totalPrice' => $cart->totalPrice,
                ], function($message) use ($user) {
                        $message->subject("Your order confirmation");
            return redirect()->route('product.index')->with('success', 'Successfully purchased products! | You will receive an oder confirmation at your email');


 Route::post('/order_confirmation2', [
            'uses' => '[email protected]',
            'as' => 'payondelivery'


<!DOCTYPE html>
<html lang="en">

    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Shipping informations</title>

    <div class="col-md-4 col-md-offset-4">
        <div class="cart">
            <p>You choose to pay on delivery</p>
            <div class="container">
                <h2>Shipping informations</h2>
                <table class="table">
                            <th>Vat number</th>

                            <td>{{ Auth::user()->name }}</td>
                            <td>{{ Auth::user()->surname }}</td>
                            <td>{{ Auth::user()->city }}</td>
                            <td>{{ Auth::user()->address }}</td>
                            <td>{{ Auth::user()->zip }}</td>
                            <td>{{ Auth::user()->vatnumber }}</td>
                            <td>{{ Auth::user()->phone }}</td>

        <h2>My Orders</h2>
        @foreach ($products as $product)
        <li class="list-group-item">
            <span class="badge badge-secondary">Quantity: {{ $product['qty'] }}</span><br>
            <span class="badge badge-secondary">Item: {{ $product['item']['title'] }}</span><br>
            <span class="badge badge-secondary">Price: ${{ $product['price'] }}</span>


and at checkout.blade.php i am using link under the form of the payment by cart

<label><a href="{{ route('payondelivery')}}">Pay on Delivery</a></label>

Is this the best method to do it? What do you think?

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