Skip to content

fix: remove code duplication in billing controller and use proper struct access method#3281

Open
nelsonmestevao wants to merge 2 commits intoLogflare:mainfrom
nelsonmestevao:ne/billing-controller
Open

fix: remove code duplication in billing controller and use proper struct access method#3281
nelsonmestevao wants to merge 2 commits intoLogflare:mainfrom
nelsonmestevao:ne/billing-controller

Conversation

@nelsonmestevao
Copy link
Copy Markdown
Contributor

No description provided.

%{"plan" => plan_id, "type" => "metered"}
) do
%{"plan" => plan_id, "type" => type}
) when billing_plan_type in ["standard", "metered"] and type in ["standard", "metered"] do
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just 4 combinations of "standard" and "metered" billing types.

Comment thread lib/logflare_web/controllers/billing_controller.ex
@nelsonmestevao nelsonmestevao force-pushed the ne/billing-controller branch 3 times, most recently from 623cf8c to 8738499 Compare March 13, 2026 16:59
Comment thread lib/logflare_web/controllers/billing_controller.ex
@nelsonmestevao nelsonmestevao force-pushed the ne/billing-controller branch from 8738499 to 9550eea Compare March 16, 2026 07:11
Copy link
Copy Markdown
Contributor

@Ziinc Ziinc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

billing controller needs tests before we can do this.

@nelsonmestevao
Copy link
Copy Markdown
Contributor Author

Hi @Ziinc. I will add those. I didn't before because there's some mocking of stripe calls involved.

@nelsonmestevao nelsonmestevao changed the title refactor: remove code duplication in billing controller WIP refactor: remove code duplication in billing controller Mar 19, 2026
@nelsonmestevao nelsonmestevao force-pushed the ne/billing-controller branch 5 times, most recently from 8e740a4 to b7ea70e Compare March 27, 2026 14:45
@nelsonmestevao nelsonmestevao force-pushed the ne/billing-controller branch from b7ea70e to 1ed95de Compare March 31, 2026 22:27
@nelsonmestevao nelsonmestevao force-pushed the ne/billing-controller branch from 1ed95de to 46686ab Compare April 13, 2026 16:30
@nelsonmestevao nelsonmestevao changed the title WIP refactor: remove code duplication in billing controller refactor: remove code duplication in billing controller Apr 13, 2026
@nelsonmestevao nelsonmestevao requested a review from Ziinc April 13, 2026 17:49
@nelsonmestevao nelsonmestevao force-pushed the ne/billing-controller branch from 8f75759 to 647fcbf Compare April 13, 2026 17:49
Logger.error("Billing error: #{inspect(err)}", %{billing: %{error_string: inspect(err)}})

{:ok, _response} = Stripe.delete_customer(customer["id"])
{:ok, _response} = Stripe.delete_customer(customer.id)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was actually a bug. Stripe API calls change these to structs.

@nelsonmestevao nelsonmestevao force-pushed the ne/billing-controller branch from 647fcbf to 96678d2 Compare April 13, 2026 19:18
@nelsonmestevao nelsonmestevao changed the title refactor: remove code duplication in billing controller fix: remove code duplication in billing controller and use proper struct access method Apr 13, 2026
@nelsonmestevao nelsonmestevao force-pushed the ne/billing-controller branch 5 times, most recently from 3269b54 to 39b4423 Compare April 17, 2026 14:14
@nelsonmestevao nelsonmestevao force-pushed the ne/billing-controller branch 2 times, most recently from 2a59308 to cf34889 Compare April 20, 2026 09:13
@nelsonmestevao nelsonmestevao force-pushed the ne/billing-controller branch from cf34889 to 29a12dd Compare April 20, 2026 09:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants