Skip to content

Commit

Permalink
Remove support for legacy Paddle webhook passthrough formats
Browse files Browse the repository at this point in the history
  • Loading branch information
zoldar committed Jan 6, 2025
1 parent 27fac66 commit 4c88975
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 29 deletions.
8 changes: 0 additions & 8 deletions lib/plausible/billing/billing.ex
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,6 @@ defmodule Plausible.Billing do
["ee:true", "user:" <> user_id] ->
{user_id, "0"}

# NOTE: legacy pattern, to be removed in a follow-up
["user:" <> user_id, "team:" <> team_id] ->
{user_id, team_id}

# NOTE: legacy pattern, to be removed in a follow-up
[user_id] ->
{user_id, "0"}

_ ->
raise "Invalid passthrough sent via Paddle: #{inspect(passthrough)}"
end
Expand Down
19 changes: 0 additions & 19 deletions test/plausible/billing/billing_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -225,25 +225,6 @@ defmodule Plausible.BillingTest do
assert subscription.currency_code == "EUR"
end

test "supports old format without prefix" do
user = new_user()
{:ok, team} = Plausible.Teams.get_or_create(user)

%{@subscription_created_params | "passthrough" => "user:#{user.id};team:#{team.id}"}
|> Billing.subscription_created()

assert user |> team_of() |> Plausible.Teams.with_subscription() |> Map.fetch!(:subscription)
end

test "supports old format without prefix for user without a team" do
user = new_user()

%{@subscription_created_params | "passthrough" => user.id}
|> Billing.subscription_created()

assert user |> team_of() |> Plausible.Teams.with_subscription() |> Map.fetch!(:subscription)
end

test "unlocks sites if user has any locked sites" do
user = new_user()
site = new_site(owner: user, locked: true)
Expand Down
6 changes: 4 additions & 2 deletions test/plausible_web/controllers/api/paddle_controller_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ defmodule PlausibleWeb.Api.PaddleControllerTest do
test "is verified when signature is correct", %{conn: conn} do
insert(:user, id: 235)

conn = post(conn, Routes.paddle_path(conn, :webhook), @webhook_body)
assert conn.status == 200
# NOTE: signature check happens sooner
assert_raise RuntimeError, ~r/Invalid passthrough sent via Paddle/, fn ->
post(conn, Routes.paddle_path(conn, :webhook), @webhook_body)
end
end

test "not verified when signature is corrupted", %{conn: conn} do
Expand Down

0 comments on commit 4c88975

Please sign in to comment.