Comments (9)
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.
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.
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.
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.
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.
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.
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.
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.
Thanks @aFluxx , also for following up! :)
from cashier-mollie.
Related Issues (20)
- Same plan with different intervals HOT 1
- Questions HOT 3
- First 1500 customer one year €25 discount / Exclude customers from discount when they have already have one HOT 3
- Guzzle timeout when trying to create a new customer. HOT 5
- PHP8 update confilct HOT 1
- Recurrent payment HOT 17
- Testing webhooks locally HOT 3
- Question about events HOT 6
- Get checkout URL for failed order payments HOT 1
- user id rounded up HOT 1
- Question regarding API KEY HOT 1
- Not Understanding HOT 1
- See when a subscription is up for renewal HOT 1
- Event OrderInvoiceAvailable is dispatched multiple times HOT 1
- 1305 SAVEPOINT trans2 does not exist HOT 1
- Charge based on days of the month left HOT 1
- How to create different pricings for subscriptions based on user country? HOT 2
- Current subscription end date HOT 5
- Is it possible to mandate multiple subscriptions in one initial payment HOT 3
- Interval of subscription not updating
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cashier-mollie.