Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions lib/sanbase/billing/subscription/subscription.ex
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ defmodule Sanbase.Billing.Subscription do

require Logger

# SAN balance discount only applies to Sanbase plans
@percent_discount_1000_san 20
@generic_error_message """

Expand Down Expand Up @@ -596,12 +597,18 @@ defmodule Sanbase.Billing.Subscription do
end
end

# When user doesn't provide coupon - check if he has SAN staked
defp create_stripe_subscription(user, plan, nil) do
# When user doesn't provide coupon - check if he has SAN staked (only for Sanbase plans)
defp create_stripe_subscription(user, %Plan{product_id: product_id} = plan, nil) do
percent_off =
user
|> User.san_balance_or_zero()
|> percent_discount()
case product_id == @product_sanbase do
true ->
user
|> User.san_balance_or_zero()
|> percent_discount()

false ->
nil
end

# recalc percent off if customer buys annual subscription and is within 30 days from trial start date
# comment temporarily until we decide to bring the annual discounts back
Expand Down