Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

spatie/spatie.be

493 stars
2 code files
View spatie/spatie.be on GitHub

app/Actions/HandlePurchaseAction.php

Open in GitHub
use App\Models\User;
use App\Models\Purchasable;
use App\Support\Paddle\PaddlePayload;
 
class HandlePurchaseAction
{
//
public function execute(
User $user,
Purchasable $purchasable,
PaddlePayload $paddlePayload,
?Referrer $referrer = null
): Purchase {
//
 
if ($user->email) {
Mail::to($user->email)->queue(new PurchaseConfirmationMail($purchase));
}
 
return $purchase->refresh();
}
//
}

app/Mail/PurchaseConfirmationMail.php

Open in GitHub
use App\Models\Purchase;
use Illuminate\Mail\Mailable;
 
class PurchaseConfirmationMail extends Mailable
{
public function __construct(
public Purchase $purchase
) {}
 
public function build()
{
return $this
->subject("Getting started with {$this->purchase->purchasable->product->title}")
->to($this->purchase->user->email)
->markdown('mails.purchaseConfirmation');
}
}

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.