mollie / laravel-mollie

Mollie API client wrapper for Laravel & Mollie Connect provider for Laravel Socialite
https://www.mollie.com/
MIT License
322 stars 62 forks source link

Get payment info from the redirectURL #203

Closed luckie12 closed 1 year ago

luckie12 commented 1 year ago

So, im able to do a test payment etc on localhost, i installed ngrok so i can test the webhook on my localhost aswell.

After making a payment im being redirected to the redirectURL, but the Request is empty, theres nothing in the input bags (eg $request->input('id'); ) does not work/exist.

Since i added the webhook to the mollie payment, im not sure where i can view that data, because i put a (dd) in the webhook handle but it doesnt 'run'.

My MollieController

    public function preparePayment(){
        $payment = Mollie::api()->payments->create([
            'amount' => [
                'currency' => 'EUR',
                'value' => '10.00'
            ],
            'description' => 'Payment for nicks takeout',
            'redirectUrl' => route('payment.success'),
            'webhookUrl' => "****.eu.ngrok.io/mollie-webhook",
            'metadata' => [
                'order_id' => '12345'
            ]
        ]);

        // $payment = Mollie::api()->payments()->get($payment->id);

        return redirect($payment->getCheckoutUrl(), 303);
    }

    public function paymentSuccess(Request $request){
        dd($request->input('id'));
        echo 'Payment received';
    }

Web.php

Route::get('molliePayment', [MollieController::class, "preparePayment"])->name('mollie.payment');
Route::get('paymentSuccess', [MollieController::class, "paymentSuccess"])->name('payment.success');
Route::post('mollie-webhook', [MollieWebhookController::class, "handle"])->name('mollie.webhook');

and my MollieWebhookController (never fires visibly)

    public function handle(Request $request) {
        $paymentId = $request->input('id');
        dd($paymentId);
    }

I hope someone can enlighten me, because all i can see is Payment received EDIT: Mollie dashboard says: Webhook called successfully, it took 0.1 seconds

sandervanhooft commented 1 year ago

Hi @luckie12,

The webhook gets called on a separate request. If you'd like to inspect this it's recommended to log it instead of using dd.