mirror of
https://github.com/plausible/analytics.git
synced 2024-12-23 17:44:43 +03:00
Fix webhook
This commit is contained in:
parent
1bb756362d
commit
b458b5a392
@ -8,7 +8,7 @@ defmodule Plausible.Billing do
|
|||||||
end
|
end
|
||||||
|
|
||||||
def subscription_created(params) do
|
def subscription_created(params) do
|
||||||
params = if params["passthrough"] do
|
params = if present?(params["passthrough"]) do
|
||||||
params
|
params
|
||||||
else
|
else
|
||||||
user = Repo.get_by(Plausible.Auth.User, email: params["email"])
|
user = Repo.get_by(Plausible.Auth.User, email: params["email"])
|
||||||
@ -137,4 +137,9 @@ defmodule Plausible.Billing do
|
|||||||
next_bill_amount: params["unit_price"] || params["new_unit_price"]
|
next_bill_amount: params["unit_price"] || params["new_unit_price"]
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp present?(""), do: false
|
||||||
|
defp present?(nil), do: false
|
||||||
|
defp present?(_), do: true
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -45,6 +45,7 @@ defmodule Plausible.BillingTest do
|
|||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
|
|
||||||
Billing.subscription_created(%{
|
Billing.subscription_created(%{
|
||||||
|
"passthrough" => "",
|
||||||
"email" => user.email,
|
"email" => user.email,
|
||||||
"alert_name" => "subscription_created",
|
"alert_name" => "subscription_created",
|
||||||
"subscription_id" => @subscription_id,
|
"subscription_id" => @subscription_id,
|
||||||
|
Loading…
Reference in New Issue
Block a user