From 7be931d2387a5fe666a39a37c193cb154ef82c95 Mon Sep 17 00:00:00 2001 From: Theodore Keloglou Date: Wed, 29 May 2024 20:09:55 +0100 Subject: [PATCH] add check for subscription create webhook --- app/controllers/webhooks_controller.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/controllers/webhooks_controller.rb b/app/controllers/webhooks_controller.rb index 65c275fb3..8d460001a 100644 --- a/app/controllers/webhooks_controller.rb +++ b/app/controllers/webhooks_controller.rb @@ -25,6 +25,13 @@ def index subscription = Subscription.find_by!(customer_id: event.data.object.customer) on_invoice_paid(subscription, event.data.object) when 'invoice.payment_failed' + + # Do not trigger webhook if it's a subscription create webhook, which means + # it was triggered by 3D Secure. + if event.data.object.billing_reason == 'subscription_create' + return + end + subscription = Subscription.find_by!(customer_id: event.data.object.customer) on_invoice_failed(subscription, event.data.object) end