diff --git a/forms/registration/mail.rb b/forms/registration/mail.rb index 8020de25516553ab59bfa60f02ae8585a43db7e9..c4fe3f76c73e95b0bf7993e803b8731c86c443fb 100644 --- a/forms/registration/mail.rb +++ b/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." ) diff --git a/lib/registration.rb b/lib/registration.rb index 554503757e21f71929edd2e0c3ba3b6e8fec8cda..510698e9fc8757883f983c8a4ba11fc99d7a9990 100644 --- a/lib/registration.rb +++ b/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 diff --git a/test/test_registration.rb b/test/test_registration.rb index 6503c18a9987c680567f57add1d6052d9188ccd8..dc3117c738c3cc0ab1a57adc64e2e1b89b59f93a 100644 --- a/test/test_registration.rb +++ b/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