two changes related to registration forms

Phillip Davis created

- new buy_number.rb form for premium nums
- change mail.rb to accept a @price

Change summary

forms/registration/mail.rb |  2 +-
lib/registration.rb        | 17 ++++++++++++++---
test/test_registration.rb  |  3 ++-
3 files changed, 17 insertions(+), 5 deletions(-)

Detailed changes

forms/registration/mail.rb 🔗

@@ -3,7 +3,7 @@ title "Activate by Mail or Interac e-Tranfer"
 
 instructions(
 	"Activate your account by sending at least " \
-	"$#{CONFIG[:activation_amount]}\nWe support payment by " \
+	"$#{'%.2f' % @price}\nWe support payment by " \
 	"postal mail or, in Canada, by Interac e-Transfer.\n\n" \
 	"You will receive a notification when your payment is complete."
 )

lib/registration.rb 🔗

@@ -253,10 +253,10 @@ class Registration
 			@kinds ||= {}
 		end
 
-		def self.for(iq, customer, tel, finish: Finish)
+		def self.for(iq, customer, tel, finish: Finish, maybe_bill: MaybeBill)
 			kinds.fetch(iq.form.field("activation_method")&.value&.to_s&.to_sym) {
 				raise "Invalid activation method"
-			}.call(customer, tel, finish: finish)
+			}.call(customer, tel, finish: finish, maybe_bill: maybe_bill)
 		end
 
 		class CryptoPaymentMethod
@@ -386,6 +386,10 @@ class Registration
 					Command.execution.customer_repo.find(@customer.customer_id)
 				end
 			end
+
+			def self.bill?
+				true
+			end
 		end
 
 		class JustCharge
@@ -396,6 +400,10 @@ class Registration
 			def call
 				yield @customer
 			end
+
+			def self.bill?
+				false
+			end
 		end
 
 		class CreditCard
@@ -522,15 +530,18 @@ class Registration
 		class Mail
 			Payment.kinds[:mail] = method(:new)
 
-			def initialize(customer, tel, **)
+			def initialize(customer, tel, maybe_bill: MaybeBill, **)
 				@customer = customer
 				@tel = tel
+				@maybe_bill = maybe_bill
 			end
 
 			def form
+				price = @maybe_bill.bill? ? CONFIG[:activation_amount] + @tel.price : @tel.price
 				FormTemplate.render(
 					"registration/mail",
 					currency: @customer.currency,
+					price: price,
 					**onboarding_extras
 				)
 			end

test/test_registration.rb 🔗

@@ -877,9 +877,10 @@ class RegistrationTest < Minitest::Test
 
 		class MailTest < Minitest::Test
 			def setup
+				@tel = TelSelections::ChooseTel::Tn.for_pending_value("+15555550000")
 				@mail = Registration::Payment::Mail.new(
 					customer(plan_name: "test_cad"),
-					"+15555550000"
+					@tel
 				)
 			end