mardi 27 mars 2018

Laravel mollie - Foreach payment methods

I'm working with Mollie in laravel and I want a screen where the user is able to choose a payment method because now I just hardcoded it to iDeal like this:

"method" => Mollie_API_Object_Method::IDEAL,

Currently I have an empty form which doesn't contain anything. There needs to be a foreach loop which displays all available mollie payment methods (If possible with images) and make the user able to choose one. Then in my method I can do something like $request->paymentMethod to make it dynamic.

The form currently looks like this

<form method="POST" action="">

<input type="hidden" name="user_id" value="">
 <div class="card depth-1">
  <div class="card-body">
   <div class="row">
    <div class="col-md-4 items-center-left">
      <a href="" class="back-link">
        <p class="m-0"><i class="fal fa-chevron-left fa-lg mr-2"></i> <span style="font-size: 24px;">Terug</span></p>
      </a>

    </div>
    <div class="col-md-4 text-center">
      <h3>Betaalmethodes</h3>
      <p class="m-0">Stap 1 van de 5</p>
    </div>
    <div class="col-md-4 text-right items-center-right">
      <button class="btn btn-next bg-transparent" type="submit"><span style="font-size: 24px;">Volgende stap</span> <i class="fal fa-chevron-right fa-lg ml-2"></i></button>
    </div>
  </div>
 </div>
</div>

<div class="card depth-2 mt-3 mb-5">
 <div class="card-body">
  <div class="row">
    @foreach()
    <div class="col-md-3">
      <div class="card depth-2">
        <div class="card-body text-center">

        </div>
      </div>
    </div>
    @endforeach
  </div>
 </div>
</div>

<div class="row mb-5">
 <div class="col-md-6 items-center-left">
  <a href="" class="back-link">
    <p class="m-0"><i class="fal fa-chevron-left fa-lg mr-2"></i> <span style="font-size: 24px;">Terug</span></p>
  </a>
 </div>
  <div class="col-md-6 text-right">
   <button class="btn btn-next bg-transparent" type="submit"><span style="font-size: 24px;">Volgende stap</span> <i class="fal fa-chevron-right fa-lg ml-2"></i></button>
  </div>
 </div>
</form>

How can I make it so it displays all the payment methods? (If possible with images) The function where to payment is made looks like this:

public function payment(Request $request, $id) {

    $order = Order::find($id);

    $payment = Mollie::api()->payments()->create([
        "amount" => $order->price_sum, 
        "description" => "Description", 
        "redirectUrl" => "http://stage.io/order/" . $order->id, 
        "method" => Mollie_API_Object_Method::IDEAL,
        "webhookUrl"  => "http://2041c6dd.ngrok.io/webhook/",
    ]);

    return redirect($payment->links->paymentUrl);
}

Thanks in advance!



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2pHVdpZ
via IFTTT

Aucun commentaire:

Enregistrer un commentaire