Skip to content

Commit

Permalink
Tag related payment methods while suspending an account
Browse files Browse the repository at this point in the history
We are suspending an account if we think it is a fraud. With this
commit we are getting all projects of which the account is member of, then
tag all payment methods of those projects as fraud.
  • Loading branch information
velioglu committed May 9, 2024
1 parent 17e1ec7 commit 2871097
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions model/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,7 @@ def create_project_with_default_policy(name, policy_body: nil)
def suspend
update(suspended_at: Time.now)
DB[:account_active_session_keys].where(account_id: id).delete(force: true)

projects.each { _1.billing_info&.payment_methods_dataset&.update(fraud: true) }
end
end
6 changes: 6 additions & 0 deletions spec/routes/web/project/billing_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@
expect(page).to have_content "Billing is not enabled. Set STRIPE_SECRET_KEY to enable billing."
end

it "tag payment method fraud after account suspension" do
expect(payment_method.reload.fraud).to be(false)
user.suspend
expect(payment_method.reload.fraud).to be(true)
end

context "when Stripe enabled" do
before do
allow(Config).to receive(:stripe_secret_key).and_return("secret_key")
Expand Down

0 comments on commit 2871097

Please sign in to comment.