Laravel Cashier - WebhookReceived vs WebhookHandled - laravel

On this documentation, it said that both can be used, but what's the difference between the two? Their code seems to be identical as well.

I found the answer, it seems that WebhookReceived is triggered BEFORE Laravel Cashier do any logic with the webhook event, while WebhookHandled is triggered AFTER Laravel Cashier did their logic.
So if you received a customer.subscription.created event.
WebhookReceived will trigger before there are any data on the database with that event while WebhookHandled will trigger with the new subscription available in the database.

Related

Canceling Stripe subscription throws scheduling error

I recently increased the prices of my Stripe subscription plans on my Laravel SASS application. Now, when a user cancels their subscription, it throws the following error:
"The subscription is managed by the subscription schedule sub_sched_XXXXXXXXXX, and updating any cancelation behavior directly is not allowed. Please update the schedule instead."
I'm using Laravel 5.6 and have this in my composer.json file:
"laravel/cashier": "~7.0",
Basically, I get the subscription object and just call cancel(). E.g.:
$subscription->cancel();
This worked for years until I recently changed my prices. Is this a programming error on my part, or do I need to move my subscription plans off of schedules somehow? I'm really stumped here, because Googling has not turned up any useful results on this error.
Found the issue. The recent price change moved the subscriptions onto a schedule. I had to release the subscription schedule using the API here:
https://stripe.com/docs/api/subscription_schedules/release?lang=php

Manually trigger a Stripe subscription webhook

I cannot find the answer to this question that I once found. Basically I was able to create a stripe subscription using Laravel Cashier, and then trigger via code the subscription to be billed again, so I could test my invoice succeeded webhook. I am using Laravel Cashier. I recall I used ngrok to proxy, so I could get my webhook to work.
Basically it is recharging an active subscription. Any help would be great. PHP preferably.
The best option for now is to create a Subscription with a short trial period of a few minutes using the trial_end parameter. This lets you create a Subscription that will renew a few minutes later to simulate a new period that is starting.
There is no way to "fast forward time" or similar to go through multiple cycles in a few minutes otherwise.
As for webhooks the best option is to use Stripe's CLI: https://stripe.com/docs/stripe-cli

How i can use laravel Event Listner to send mail notification before an event

I am Trying to achieve a feature in my laravel Project. I am currently doing an Event related project. And there is Event start date and Event voting start date etc. The voting will be start at a date set on the database. How i can send a notification using Laravel Event Listner feature that the Voting will be starting tomorrow. How i can set the listeners and events in this case.
I already know laravel scheduler, using scheduler i can send email notification. But using scheduler i have to check every day in the database that the date is reached or not. Without checking this how can i manage this using Laravel Event Listeners.
Events do not support dates or time in this way, so you'll have to use some additional behavior to check when the "start date" is the current time, and then have that behavior fire the event. You are correct that Laravel's scheduler would be a good fit for this.

What's the best practice to send out bulk emails in Laravel 5.3?

I'm expecting about 200 - 400 emails to be sent every 2 - 3 weeks in one go. This is based on the event and the event being a project published on the website. So once it is published, an automatic email goes out to all the subscribers. I'm using Laravel 5.3 and the new notifications API.
So the code at the moment simply looks like this
$subscribers->each(function($subscriber) use($project) {
$subscriber->notify(new ProjectPublished($project));
});
Would it make sense to implement ShouldQueue in this scenario?

Stripe Subscription problems with Laravel 4.2

I have been using cashier to create subscriptions for a couple sites but when I tried to implement it again in an new app it's not working. I am getting Stripe Notice: Undefined property of Laravel\\Cashier\\Customer instance: default_card. Is there an update to Cashier or a property/code I need to change to make it work again?
I have the BillableTrait attached to the School Model and am trying to subscribe to a subscriptions (in Stripe) using $school->subscribe($input['school_plan'])->create($input['stripeToken']);
The solution is to add 'version' => '2014-06-17' to the services.php page for the Stripe info array. It requests the older API and successfully works.

Resources