Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ config :ref_inspector,
database_path: "priv/ref_inspector"

config :plausible,
paddle_api: Plausible.Billing.PaddleApi,
paddle_classic_api: Plausible.Billing.PaddleClassic.Api,
google_api: Plausible.Google.API,
verification_checks_mod: Plausible.InstallationSupport.Verification.Checks

Expand Down
2 changes: 1 addition & 1 deletion config/dev.exs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ config :plausible, PlausibleWeb.Endpoint,
]

config :plausible,
paddle_api: Plausible.Billing.DevPaddleApiMock,
paddle_classic_api: Plausible.Billing.PaddleClassic.DevApiMock,
verification_checks_mod: Plausible.InstallationSupport.Verification.ChecksMock

config :phoenix, :stacktrace_depth, 20
Expand Down
2 changes: 1 addition & 1 deletion config/e2e_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ config :plausible, PlausibleWeb.Endpoint,
check_origin: false

config :plausible,
paddle_api: Plausible.Billing.DevPaddleApiMock,
paddle_classic_api: Plausible.Billing.PaddleClassic.DevApiMock,
google_api: Plausible.Google.API.Mock,
verification_checks_mod: Plausible.InstallationSupport.Verification.ChecksMock

Expand Down
10 changes: 5 additions & 5 deletions config/runtime.exs
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,8 @@ runtime_metadata = [
config :plausible, :runtime_metadata, runtime_metadata

sentry_dsn = get_var_from_path_or_env(config_dir, "SENTRY_DSN")
paddle_auth_code = get_var_from_path_or_env(config_dir, "PADDLE_VENDOR_AUTH_CODE")
paddle_vendor_id = get_var_from_path_or_env(config_dir, "PADDLE_VENDOR_ID")
paddle_classic_auth_code = get_var_from_path_or_env(config_dir, "PADDLE_VENDOR_AUTH_CODE")
paddle_classic_vendor_id = get_var_from_path_or_env(config_dir, "PADDLE_VENDOR_ID")
google_cid = get_var_from_path_or_env(config_dir, "GOOGLE_CLIENT_ID")
google_secret = get_var_from_path_or_env(config_dir, "GOOGLE_CLIENT_SECRET")
postmark_api_key = get_var_from_path_or_env(config_dir, "POSTMARK_API_KEY")
Expand Down Expand Up @@ -605,9 +605,9 @@ config :sentry,
send_max_attempts: 1,
before_send: {Plausible.SentryFilter, :before_send}

config :plausible, :paddle,
vendor_auth_code: paddle_auth_code,
vendor_id: paddle_vendor_id
config :plausible, :paddle_classic,
vendor_auth_code: paddle_classic_auth_code,
vendor_id: paddle_classic_vendor_id

config :plausible, :google,
client_id: google_cid,
Expand Down
2 changes: 1 addition & 1 deletion config/test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ config :plausible, Plausible.ClickhouseRepo,
config :plausible, Plausible.Mailer, adapter: Bamboo.TestAdapter

config :plausible,
paddle_api: Plausible.Billing.TestPaddleApiMock,
paddle_classic_api: Plausible.Billing.PaddleClassic.TestApiMock,
google_api: Plausible.Google.API.Mock

config :bamboo, :refute_timeout, 10
Expand Down
2 changes: 1 addition & 1 deletion extra/lib/plausible/help_scout.ex
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ defmodule Plausible.HelpScout do

defp plan_link(%{paddle_subscription_id: paddle_id}) do
Path.join([
Billing.PaddleApi.vendors_domain(),
Billing.PaddleClassic.Api.vendors_domain(),
"/subscriptions/customers/manage/",
paddle_id
])
Expand Down
2 changes: 1 addition & 1 deletion extra/lib/plausible_web/live/customer_support/team.ex
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ defmodule PlausibleWeb.Live.CustomerSupport.Team do
end

defp manage_url(%{paddle_subscription_id: paddle_id} = _subscription) do
Plausible.Billing.PaddleApi.vendors_domain() <>
Plausible.Billing.PaddleClassic.Api.vendors_domain() <>
"/subscriptions/customers/manage/" <> paddle_id
end

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defmodule Mix.Tasks.CreatePaddleProdPlans do
defmodule Mix.Tasks.PaddleClassic.CreateProdPlans do
@moduledoc """
## Utility for creating Paddle plans for production use.

Expand Down Expand Up @@ -31,7 +31,7 @@ defmodule Mix.Tasks.CreatePaddleProdPlans do
## Usage example:

```
mix create_paddle_prod_plans input_plans_v5.json
mix paddle_classic.create_prod_plans input_plans_v5.json
```

## Requirement 1: Replace the curl command
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
defmodule Mix.Tasks.CreatePaddleSandboxPlans do
defmodule Mix.Tasks.PaddleClassic.CreateSandboxPlans do
@moduledoc """
Utility for creating Sandbox plans that are used on staging. The product of
this task is a `sandbox_plans_v*.json` file matching with the production
plans, just with the monthly/yearly product_id's of the sandbox plans.

In principle, this task works like `Mix.Tasks.CreatePaddleProdPlans`, with
In principle, this task works like `Mix.Tasks.PaddleClassic.CreateProdPlans`, with
the following differences:

* The `filename` argument should be the name of the JSON file containing the
Expand All @@ -13,7 +13,7 @@ defmodule Mix.Tasks.CreatePaddleSandboxPlans do

* To copy the curl command from the browser, you need to add a plan from
https://sandbox-vendors.paddle.com/subscriptions/plans. Everything else is
the same - please see `create_paddle_prod_plans.ex` for instructions.
the same - please see `create_prod_plans.ex` for instructions.

* This task can be executed multiple times in a row - it will not create
duplicates in Sandbox Paddle. On staging we can use a specific plan-naming
Expand All @@ -25,11 +25,11 @@ defmodule Mix.Tasks.CreatePaddleSandboxPlans do
## Usage example:

```
mix create_paddle_sandbox_plans plans_v5.json
mix paddle_classic.create_sandbox_plans plans_v5.json
```
"""

alias Mix.Tasks.CreatePaddleProdPlans
alias Mix.Tasks.PaddleClassic.CreateProdPlans
use Mix.Task

@requirements ["app.config"]
Expand Down Expand Up @@ -95,7 +95,7 @@ defmodule Mix.Tasks.CreatePaddleSandboxPlans do
--data-raw '_token=#{your_unique_token}&plan-id=&default-curr=USD&tmpicon=false&name=#{name}&checkout_custom_message=&taxable_type=standard&interval=#{interval_index}&period=1&type=#{type}&trial_length=&price_USD=#{price}&active_EUR=on&price_EUR=#{price}&active_GBP=on&price_GBP=#{price}'
"""

case CreatePaddleProdPlans.curl_quietly(curl_command) do
case CreateProdPlans.curl_quietly(curl_command) do
:ok ->
IO.puts("✅ Created #{name}")

Expand All @@ -108,14 +108,14 @@ defmodule Mix.Tasks.CreatePaddleSandboxPlans do
defp fetch_all_sandbox_plans() do
url = "https://sandbox-vendors.paddle.com/api/2.0/subscription/plans"

paddle_config = Application.get_env(:plausible, :paddle)
paddle_config = Application.get_env(:plausible, :paddle_classic)

paddle_credentials = %{
vendor_id: paddle_config[:vendor_id],
vendor_auth_code: paddle_config[:vendor_auth_code]
}

CreatePaddleProdPlans.fetch_all_paddle_plans(url, paddle_credentials)
CreateProdPlans.fetch_all_paddle_plans(url, paddle_credentials)
end

@paddle_interval_indexes %{"monthly" => 2, "yearly" => 5}
Expand Down Expand Up @@ -154,7 +154,7 @@ defmodule Mix.Tasks.CreatePaddleSandboxPlans do
"monthly_product_id" => to_string(sandbox_monthly_product_id),
"yearly_product_id" => to_string(sandbox_yearly_product_id)
})
|> CreatePaddleProdPlans.order_keys()
|> CreateProdPlans.order_keys()
end)

content = Jason.encode!(sandbox_plans, pretty: true)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defmodule Mix.Tasks.PullSandboxSubscription do
defmodule Mix.Tasks.PaddleClassic.PullSandboxSubscription do
@moduledoc """
Mix task for creating subscriptions in dev environment via Paddle API.
"""
Expand All @@ -17,7 +17,7 @@ defmodule Mix.Tasks.PullSandboxSubscription do
# https://sandbox-vendors.paddle.com/subscriptions/customers
#
# 3) run from command line:
# mix pull_sandbox_subscription <subscription_ID>
# mix paddle_classic.pull_sandbox_subscription <subscription_ID>

@headers [
{"Content-type", "application/json"},
Expand All @@ -27,9 +27,10 @@ defmodule Mix.Tasks.PullSandboxSubscription do
def run([paddle_subscription_id]) do
Mix.Task.run("app.start")

config = Application.get_env(:plausible, :paddle)
config = Application.get_env(:plausible, :paddle_classic)

endpoint = Plausible.Billing.PaddleApi.vendors_domain() <> "/api/2.0/subscription/users"
endpoint =
Plausible.Billing.PaddleClassic.Api.vendors_domain() <> "/api/2.0/subscription/users"

params = %{
vendor_id: config[:vendor_id],
Expand Down
4 changes: 2 additions & 2 deletions lib/plausible/application.ex
Original file line number Diff line number Diff line change
Expand Up @@ -326,12 +326,12 @@ defmodule Plausible.Application do
end

defp maybe_add_paddle_pool(pool_config, default) do
paddle_conf = Application.get_env(:plausible, :paddle)
paddle_conf = Application.get_env(:plausible, :paddle_classic)

if paddle_conf[:vendor_id] && paddle_conf[:vendor_auth_code] do
Map.put(
pool_config,
Plausible.Billing.PaddleApi.vendors_domain(),
Plausible.Billing.PaddleClassic.Api.vendors_domain(),
Config.Reader.merge(default, conn_opts: [transport_opts: [timeout: 15_000]])
)
else
Expand Down
Loading
Loading