Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

MarlonV's avatar

Mollie payment API

good morning everyone,

Does anyone have experience with the mollie payment API? I run into minor problems. I do not know exactly where to place what.

I have all payment data together on a user / payment blade. Can I set up and save a prepepayment from the user? or is this something I should do in a payment table right away.

Is it possible to request $ user-> mollieId () from the user.model? Is this something that I have to do again in the controller, or is it better to simply send this via the request?

thank you in advance

public function preparePayment()
    {
        $user = User::whereId(Auth::id())->get();
        $payment = Mollie::api()->payments()->create([
        'amount' => [
            'currency' => 'EUR',
            'value' => $user->getTotalPrice(), 
        ],
        'description' => 'payment'.$user->mollieId(),
        'method' => 'ideal',
        'webhookUrl' => route('webhooks.mollie'),
        'redirectUrl' => route('order.success'),
        'metadata' => [
            'ouder_id' => $user->id+"",
            'ouder_naam' => $user->first_name+" "+$user->last_name],
        
        ]);
    
        $payment = Mollie::api()->payments()->get($payment->id);
    
        // redirect customer to Mollie checkout page
        return redirect($payment->getCheckoutUrl(), 303);
    }

0 likes
0 replies

Please or to participate in this conversation.