Warning: session_start(): Session cannot be started after headers have already been sent in /home/tvrreohg/public_html/manga.php on line 13
getContent(), $request->header('Stripe-Signature'), config('services.stripe.webhook_secret') ); } catch (Throwable) { return response('Invalid webhook', 400); } $object = $event->data->object; if ($event->type === 'checkout.session.completed') { $subscription = Subscription::where('stripe_checkout_session_id', $object->id)->first(); $subscription?->update([ 'stripe_subscription_id' => is_string($object->subscription) ? $object->subscription : null, 'status' => 'active', 'starts_at' => now(), ]); Payment::where('stripe_checkout_session_id', $object->id)->update([ 'stripe_payment_intent_id' => is_string($object->payment_intent) ? $object->payment_intent : null, 'status' => $object->payment_status, 'paid_at' => now(), 'subscription_id' => $subscription?->id, ]); } if (in_array($event->type, ['customer.subscription.updated', 'customer.subscription.deleted'], true)) { Subscription::where('stripe_subscription_id', $object->id)->update([ 'status' => $object->status, 'ends_at' => isset($object->current_period_end) ? \Carbon\Carbon::createFromTimestamp($object->current_period_end) : null, 'cancelled_at' => $event->type === 'customer.subscription.deleted' ? now() : null, ]); } return response('ok'); } }