Skip to content

Commit

Permalink
Fix has card check
Browse files Browse the repository at this point in the history
  • Loading branch information
tspenov committed Dec 15, 2024
1 parent 266d243 commit 9d551f9
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lib/sanbase/email/mailer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,17 @@ defmodule Sanbase.Mailer do

defp has_card?(user) do
case Sanbase.StripeApi.fetch_stripe_customer(user) do
{:ok, customer} -> not is_nil(customer.default_source)
_ -> false
{:ok, customer} ->
has_default_source = not is_nil(customer.default_source)

has_default_payment_method =
not is_nil(customer.invoice_settings) and
not is_nil(customer.invoice_settings.default_payment_method)

has_default_source or has_default_payment_method

_ ->
false
end
end

Expand Down

0 comments on commit 9d551f9

Please sign in to comment.