Español →

Oliver Servín

Handle Paddle's marketing consent with Laravel

On Paddle, a buyer can opt-in to receive marketing emails and is stored as a new audience member.

But, by using an event listener, you can handle the Paddle's marketing consent on Laravel Cashier too.

The following example code uses a subscribed user attribute, but you can use an external service or tool like Spatie's Mailcoach and have it synced.

3namespace App\Listeners;
5use App\Models\User;
6use Laravel\Paddle\Events\WebhookReceived;
8class PaddleEventListener
10 public function handle (WebhookReceived $event)
11 {
12 if ($event->payload['alert_name' ] === 'new_audience member') {
13 if ($user = User::whereEmail($event->payload['email'])->first()) {
14 $user->fill([
15 'subscribed' => $event->payload['marketing_consent'],
16 ])->save();
17 }
18 }
20 if ($event->payload['alert_name'] === 'update_audience_member') {
21 if ($user = User::whereEmail($event->payload['new_customer_email'])->first()) {
22 $user->fill([
23 'subscribed' => $event->payload['new_marketing_consent'],
24 ])->save();
25 }
26 }
27 }

Interact with API result values as object properties in Laravel

Get relative path with `route()` in Laravel

Chokidar file watcher to auto-run Pest tests

Chaining "Where" conditions using dynamic methods

Model factories with relationships by using magic methods

Show amount to pay in next billing cycle with Laravel Cashier (Stripe)

Tax calculation with Laravel Cashier for Stripe

How to keep in sync your customers details with Stripe in Laravel

Handle Paddle's marketing consent with Laravel

Custom styling the pay button with Laravel Cashier Paddle

Embed Paddle's checkout widget with Laravel Cashier

Weekly auto-reset a Laravel demo app

Remove the personal_access_tokens table on a fresh Laravel App

Deploy Umami analytics with Launcher

Fix Laravel storage:link using Launcher

Launcher: first impressions

Integrating Tiptap in a Laravel-Livewire project

How to run a Ghost blog on Laravel Forge