Skip to content

Commit

Permalink
add check for subscription create webhook
Browse files Browse the repository at this point in the history
  • Loading branch information
sirodoht committed May 29, 2024
1 parent c4fba81 commit 7be931d
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/controllers/webhooks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7be931d

Please sign in to comment.