21 lines
918 B
PHP
21 lines
918 B
PHP
// Create PackagePurchase for one-off payment
|
|
$purchase = \App\Models\PackagePurchase::create([
|
|
'tenant_id' => $tenantId,
|
|
'package_id' => $packageId,
|
|
'provider_id' => $paymentIntent['id'],
|
|
'price' => $paymentIntent['amount_received'] / 100,
|
|
'type' => $type,
|
|
'purchased_at' => now(),
|
|
'refunded' => false,
|
|
]);
|
|
|
|
// Send purchase confirmation email
|
|
try {
|
|
$tenant = \App\Models\Tenant::find($tenantId);
|
|
if ($tenant && $tenant->user) {
|
|
Mail::to($tenant->user)->queue(new PurchaseConfirmation($purchase));
|
|
Log::info('Purchase confirmation email sent for payment intent: ' . $paymentIntent['id']);
|
|
}
|
|
} catch (\Exception $e) {
|
|
Log::error('Failed to send purchase confirmation email: ' . $e->getMessage());
|
|
} |