This commit is contained in:
Andras Bacsai 2023-10-27 10:30:15 +02:00
parent ebe6655349
commit 38f59b9410

View File

@ -281,26 +281,13 @@
break;
case 'invoice.paid':
$customerId = data_get($data, 'customer');
$email = data_get($data, 'customer_email');
$subscription = Subscription::where('stripe_customer_id', $customerId)->first();
if ($subscription) {
$subscription = Subscription::where('stripe_customer_id', $customerId)->firstOrFail();
$planId = data_get($data, 'lines.data.0.plan.id');
$subscription->update([
'stripe_plan_id' => $planId,
'stripe_invoice_paid' => true,
]);
break;
}
$team = Team::where('email', $email)->first();
if ($team) {
$subscription = data_get($team, 'subscription');
$planId = data_get($data, 'lines.data.0.plan.id');
$subscription->update([
'stripe_plan_id' => $planId,
'stripe_invoice_paid' => true,
]);
}
break;
case 'payment_intent.payment_failed':
$customerId = data_get($data, 'customer');
$subscription = Subscription::where('stripe_customer_id', $customerId)->firstOrFail();