New BillPay registration step

Stephen Paul Weber created

Assumes they have enough balance (anyone using this step must be sure of this)
and then does the billing before proceeding to finish.

Change summary

lib/registration.rb | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)

Detailed changes

lib/registration.rb 🔗

@@ -253,10 +253,8 @@ class Registration
 			protected
 
 				def sold(tx)
-					tx.insert.then {
-						@customer.bill_plan
-					}.then do
-						@finish.new(@customer, @tel).write
+					tx.insert.then do
+						BillPlan.new(@customer, @tel, finish: @finish).write
 					end
 				end
 
@@ -407,6 +405,20 @@ class Registration
 		end
 	end
 
+	class BillPlan
+		def initialize(customer, tel, finish: Finish)
+			@customer = customer
+			@tel = tel
+			@finish = finish
+		end
+
+		def write
+			@customer.bill_plan.then do
+				@finish.new(@customer, @tel).write
+			end
+		end
+	end
+
 	class Finish
 		def initialize(customer, tel)
 			@customer = customer