If customer already has enough balance, just bill them and finish

Stephen Paul Weber created

Change summary

config-schema.dhall | 1 +
config.dhall.sample | 1 +
lib/registration.rb | 2 ++
test/test_helper.rb | 1 +
4 files changed, 5 insertions(+)

Detailed changes

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 }

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) ->

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

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",