An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
feat: early fraud warning webhook
Andras Bacsai42fb8ab37942
diff --git a/app/Http/Controllers/Webhook/Stripe.php b/app/Http/Controllers/Webhook/Stripe.phpindex 15484f7f32..c3e393bf90 100644--- a/app/Http/Controllers/Webhook/Stripe.php+++ b/app/Http/Controllers/Webhook/Stripe.php@@ -54,6 +54,34 @@ class Stripe extends Controller$type = data_get($event, 'type');$data = data_get($event, 'data.object');switch ($type) {+ case 'radar.early_fraud_warning.created':+ $stripe = new \Stripe\StripeClient(config('subscription.stripe_api_key'));+ $id = data_get($data, 'id');+ $charge = data_get($data, 'charge');+ if ($charge) {+ $stripe->refunds->create(['charge' => $charge]);+ }+ $pi = data_get($data, 'payment_intent');+ $piData = $stripe->paymentIntents->retrieve($pi, []);+ $customerId = data_get($piData, 'customer');+ $subscription = Subscription::where('stripe_customer_id', $customerId)->first();+ if (! $subscription) {+ Sleep::for(5)->seconds();+ $subscription = Subscription::where('stripe_customer_id', $customerId)->firstOrFail();+ }+ if (! $subscription) {+ Sleep::for(5)->seconds();+ $subscription = Subscription::where('stripe_customer_id', $customerId)->firstOrFail();+ }+ if ($subscription) {+ $subscriptionId = data_get($subscription, 'stripe_subscription_id');+ $stripe->subscriptions->cancel($subscriptionId, []);+ $subscription->update([+ 'stripe_invoice_paid' => false,+ ]);+ }+ send_internal_notification("Early fraud warning created Refunded, subscription canceled. Charge: {$charge}, id: {$id}, pi: {$pi}, customer: {$customerId}, subscription: {$subscriptionId}");+ break;case 'checkout.session.completed':$clientReferenceId = data_get($data, 'client_reference_id');if (is_null($clientReferenceId)) {