GithubHelp home page GithubHelp logo

Comments (9)

sandervanhooft avatar sandervanhooft commented on April 28, 2024 1

Just found the culprit, preparing a PR to fix it.

Appears that using a EloquentModel::update(...) on a related model does not work in a DB transaction. Which makes kind of sense now I think of it.

from cashier-mollie.

sandervanhooft avatar sandervanhooft commented on April 28, 2024

The controller essentially picks the strategy for handling the request, and returns it:

  • already on this plan: redirect to previous page with a message
  • not yet on this plan, but a valid mandate: create the subscription and redirect to previous page with a success message
  • not yet on this plan and no valid mandate: redirect away from this page, to Mollie’s checkout. After checkout the subscription will be started (this logic is in a separate controller). Mollie redirects the customer to the redirectUrl defined on the plan. You can define your own route and pass it in, triggering your own controller.

from cashier-mollie.

sandervanhooft avatar sandervanhooft commented on April 28, 2024

Regarding not updating the mandate_id field:

  • make sure that Mollie can reach your app (so no localhost etc) for calling the cashier webhooks
  • generally Mollie calls the webhook before redirecting the customer. I recommend treating the webhook call and redirect as independent, async requests.

from cashier-mollie.

DeBelserArne avatar DeBelserArne commented on April 28, 2024

Hello,

I understand why it's using the standard redirect. Something seems to go wrong when it tries to create a valid mandate.

For testing purposes I used one of my digital ocean droplets to have a website which is available from the outside. I tried to create a subscription and I can see on Mollie's end that everything went well.

Here's what I can see in my Mollie test dashboard:
https://i.gyazo.com/565677074d68f6e1e9667d4b3b7834e8.png

As you can see the webhook was called succesfully. Anyhow there was no mandate created for the user.
https://i.gyazo.com/8823c628a5af8ea5cb04b5891a8fa671.png

I'm going to scratch everything and go through the documentation from A-Z again to see if I missed something. In the meanwhile, do you think I could be forgetting something or so?

Thanks in advance!

from cashier-mollie.

sandervanhooft avatar sandervanhooft commented on April 28, 2024

Hi @aFluxx ,

Thanks for clearing that up.

Can you check whether the FirstPaymentPaid event is dispatched, by listening for it? Can you dump the payment contained in it? I'm wondering if the mandateId is available there.

from cashier-mollie.

DeBelserArne avatar DeBelserArne commented on April 28, 2024

Hey Sander,

I tried to do as you asked (Bear with me since I'm a beginning developer learning all this stuff whilest I'm doing it💃 ).

I've created a FirstPaymentPaidListener.php listener class which is listening in the Laravel\Cashier\Events namespace.

<?php

// namespace App\Listeners;
namespace Laravel\Cashier\Events;

use Illuminate\Support\Facades\Log;
use Laravel\Cashier\Events\FirstPaymentPaid;

class FirstPaymentPaidListener
{
    /**
     * Create the event listener.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Handle the event.
     *
     * @param  object  $event
     * @return void
     */
    public function handle(FirstPaymentPaid $event)
    {
        Log::debug($event);
    }
}

I've registered the FirstPaymentPaid event with the listener in the EventServiceProvider class.

<?php

namespace App\Providers;

use Laravel\Cashier\Events\FirstPaymentPaid;
use Laravel\Cashier\Events\FirstPaymentPaidListener;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;

class EventServiceProvider extends ServiceProvider
{
    /**
     * The event listener mappings for the application.
     *
     * @var array
     */
    protected $listen = [
        FirstPaymentPaid::class => [
            FirstPaymentPaidListener::class,
        ],
    ];

    /**
     * Register any events for your application.
     *
     * @return void
     */
    public function boot()
    {
        parent::boot();

        //
    }
}

Ive then used a service you recommended to test webhooks locally. mollie/laravel-mollie#55 (comment)

https://i.gyazo.com/4a578f11f0714163b8b3745059fca935.png

So I know the webhook is working since I can see in the Mollie dashboard that I'm actually creating testusers: https://i.gyazo.com/44569dbeb45b786acca6fa74bded17d3.png

But I don't see any $event data appear in my laravel.log file. So I'm either forgetting something, doing something wrong, or the event is not called. But from my judgement I think it's one of the prior two :(

from cashier-mollie.

sandervanhooft avatar sandervanhooft commented on April 28, 2024

Hi @aFluxx ,

That webhook service is great, but it does not forward the call to the app itself. So the app webhook does not get triggered, and so the event does not get dispatched.

For this to work you will need to make a request to the app webhook manually. You can use something like curl (Mac command line) or PostMan (free tool or chrome plugin) to do that.

The request:

  • method POST
  • include a value of id=<you_payment_id>
  • url: <your_app_url>/webhooks/mollie/first-payment

from cashier-mollie.

DeBelserArne avatar DeBelserArne commented on April 28, 2024

Hey Sander,

Just to let you know, I updated the package to the latest version, everything works fine. Also, the correct redirect is now triggered via the controller. Thanks man!

Have a nice day!

PS: First bug squashed ^^

from cashier-mollie.

sandervanhooft avatar sandervanhooft commented on April 28, 2024

Thanks @aFluxx , also for following up! :)

from cashier-mollie.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.