From 8291b1590999a63e693eeb806b70869f0382ecde Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Tue, 29 Mar 2022 14:11:36 -0500 Subject: [PATCH] If customer already has enough balance, just bill them and finish --- config-schema.dhall | 1 + config.dhall.sample | 1 + lib/registration.rb | 2 ++ test/test_helper.rb | 1 + 4 files changed, 5 insertions(+) diff --git a/config-schema.dhall b/config-schema.dhall index fd5ab67..1e6f5ed 100644 --- a/config-schema.dhall +++ b/config-schema.dhall @@ -1,4 +1,5 @@ { activation_amount : Natural +, activation_amount_accept : Natural , admins : List Text , adr : Text , approved_domains : List { mapKey : Text, mapValue : Optional Text } diff --git a/config.dhall.sample b/config.dhall.sample index 3e19598..61b0e87 100644 --- a/config.dhall.sample +++ b/config.dhall.sample @@ -66,6 +66,7 @@ in }, oxr_app_id = "", activation_amount = 15, + activation_amount_accept = 15, credit_card_url = \(jid: Text) -> \(customer_id: Text) -> "https://pay.jmp.chat/${jid}/credit_cards?customer_id=${customer_id}", electrum_notify_url = \(address: Text) -> \(customer_id: Text) -> diff --git a/lib/registration.rb b/lib/registration.rb index 8195975..ca21c80 100644 --- a/lib/registration.rb +++ b/lib/registration.rb @@ -38,6 +38,8 @@ class Registration jid = ProxiedJID.new(customer.jid).unproxied if customer.active? Finish.new(customer, tel) + elsif customer.balance >= CONFIG[:activation_amount_accept] + BillPlan.new(customer, tel) elsif CONFIG[:approved_domains].key?(jid.domain.to_sym) Allow.for(customer, tel, jid) else diff --git a/test/test_helper.rb b/test/test_helper.rb index f397d15..981decc 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -68,6 +68,7 @@ CONFIG = { }, notify_from: "notify_from@example.org", activation_amount: 1, + activation_amount_accept: 1, plans: [ { name: "test_usd", -- 2.38.5