Laravel 5

méthodes de paiement

Avatar de nachafi
nachafi

salut un utilisateur peut choisir une méthode de paiement (handcash,visa card ,master card,debit card,...) et entrer les informations de la carte pour acheter des produits et cliquer sur place order et cette bouton reorienter l'utilisateur vers la page view('site.pages.success') donc j'ai fait ça pour handcash seulement et ça marche mais mon probléme avec les cartes je ne sait pas comment faire ça avec code et surtout pour la securité et la protection des informations des utilisateurs et comment savoir si un utilisateur entrer les vrais informations de la carte s'il vous plait aider moi pour m'améliorer et en savoir plus quel code je peut ajouter pour mettre les paiements marche merci beaucoup et j'ai fait ça : dans checkout.blade.php:

 <input type="radio" name="payment_method" value="handcash"> Hand-Cash<br><br>
                             <input type="radio" name="payment_method" value="card"> Debit-Card<br><br>
                             <input type="radio" name="payment_method" value="visa"> Visa card<br><br>
                             <input type="radio" name="payment_method" value="master"> Master card<br><br>
                             <input type="radio" name="payment_method" value="bank"> Bank transfer<br><br>

checkout.blade.php:

  <form action="{{ route('checkout.place.order') }}" method="POST" role="form">
                @csrf
                <div class="row">
                    <div class="col-md-8">
                        <div class="card">
                            <header class="card-header">
                                <h4 class="card-title mt-2">Billing Details</h4>
                            </header>
                            <article class="card-body">
                                <div class="form-row">
                                    <div class="col form-group">
                                    <label for="first_name">First name</label>
                                    <input type="text" class="form-control @error('first_name') is-invalid @enderror" name="first_name" id="first_name" value="{{ old('first_name') }}">
                                    @error('first_name')
                                    <span class="invalid-feedback" role="alert">
                                        <strong>{{ $message }}</strong>
                                    </span>
                                    @enderror
                                    </div>
                                    <div class="col form-group">
                                    <label for="last_name">Last name</label>
                                    <input type="text" class="form-control @error('last_name') is-invalid @enderror" name="last_name" id="last_name" value="{{ old('last_name') }}">
                                    @error('last_name')
                                    <span class="invalid-feedback" role="alert">
                                        <strong>{{ $message }}</strong>
                                    </span>
                                    @enderror
                                    </div>
                                </div>
..........

                        <div class="d-block my-3">
                  
                             <input type="radio" name="payment_method" value="handcash"> Hand-Cash<br><br>
                             <input type="radio" name="payment_method" value="card"> Debit-Card<br><br>
                             <input type="radio" name="payment_method" value="visa"> Visa card<br><br>
                             <input type="radio" name="payment_method" value="master"> Master card<br><br>
                             <input type="radio" name="payment_method" value="bank"> Bank transfer<br><br>


                            <div class="col-md-12 mt-4">
                                <button type="submit" class="subscribe btn btn-success btn-lg btn-block">Place Order</button>
                            </div>
                        </div>

checkoutController:

 public function placeOrder(Request $request)
    {
       
        $validatedData = $request->validate([
            'first_name' => 'required|max:191',
            'last_name' => 'required|max:191',
            'address' => 'required', 
            'city' => 'required', 
            'country' => 'required', 
            'post_code' => 'required', 
            'phone_number' => 'required', 
            
        ]);
        $order = $this->orderRepository->storeOrderDetails($request->all());
       
       
   
  
        $order->payment_method='handcash';
        $order->save();
      
        Cart::clear();
    return view('site.pages.success', compact('order'));

        return redirect()->back()->with('message','Order not placed');
    }

order repository:

 public function storeOrderDetails($params)
    {
        $order = Order::create([
            'order_number'      =>  'ORD-'.strtoupper(uniqid()),
            'user_id'           => auth()->user()->id,
            'status'            =>  'pending',
            'grand_total'       =>  Cart::getSubTotal(),
            'item_count'        =>  Cart::getTotalQuantity(),
            'payment_status'    =>  0,
            'payment_method'    => null,
            'first_name'        =>  $params['first_name'],
            'last_name'         =>  $params['last_name'],
            'address'           =>  $params['address'],
            'city'              =>  $params['city'],
            'country'           =>  $params['country'],
            'post_code'         =>  $params['post_code'],
            'phone_number'      =>  $params['phone_number'],
            'notes'             =>  $params['notes']
        ]);

web.php

 Route::get('/checkout', 'Site\CheckoutController@getCheckout')->name('checkout.index');
    Route::post('/checkout/order', 'Site\CheckoutController@placeOrder')->name('checkout.place.order');

et comment faire pour ajouter ça correctement:

 <div class="row">
                <div class="col-md-6 mb-3">
                    <label for="cc-name">Name on card</label>
                    <input type="text" class="form-control" id="cc-name" placeholder="" required>
                    <small class="text-muted">Full name as displayed on card</small>
                    <div class="invalid-feedback">
                        Name on card is required
                    </div>
                </div>
                <div class="col-md-6 mb-3">
                    <label for="cc-number">Credit card number</label>
                    <input type="text" class="form-control" id="cc-number" placeholder="" required>
                    <div class="invalid-feedback">
                        Credit card number is required
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-md-3 mb-3">
                    <label for="cc-expiration">Expiration</label>
                    <input type="text" class="form-control" id="cc-expiration" placeholder="" required>
                    <div class="invalid-feedback">
                        Expiration date required
                    </div>
                </div>
                <div class="col-md-3 mb-3">
                    <label for="cc-cvv">CVV</label>
                    <input type="text" class="form-control" id="cc-cvv" placeholder="" required>
                    <div class="invalid-feedback">
                        Security code required
                    </div>
                </div>
            </div>

Vous ne pouvez pas répondre à ce sujet.