Allow new users to opt-in to balance auto-top-up

Stephen Paul Weber created

We don't have auto top up built yet, but once we do they will be able to start
getting it right away instead of needing to manually turn it on later.

Change summary

config.ru           |  6 ++++++
views/activate.slim | 11 +++++++++++
2 files changed, 17 insertions(+)

Detailed changes

config.ru 🔗

@@ -291,6 +291,12 @@ class JmpPay < Roda
 							request.ip
 						)
 					end
+					if request.params["auto_top_up_amount"].to_i >= 15
+						REDIS.set(
+							"jmp_customer_auto_top_up_amount-#{gateway.customer_id}",
+							request.params["auto_top_up_amount"].to_i
+						)
+					end
 					if result
 						r.redirect request.params["return_to"], 303
 					else

views/activate.slim 🔗

@@ -16,6 +16,11 @@ scss:
 			}
 		}
 
+		details {
+			margin: 2em auto;
+			input { max-width: 3em; }
+		}
+
 		button {
 			display: block;
 			width: 10em;
@@ -56,6 +61,12 @@ form method="post" action=""
 			' $17.95 CAD
 			input type="radio" name="plan_name" value="cad_beta_unlimited-v20210223" required="required"
 
+	details
+		summary Auto top-up when account balance is low?
+		label
+			| When balance drops below $5, add $
+			input type="number" name="auto_top_up_amount" min="15" value=""
+
 	input type="hidden" name="customer_id" value=customer_id
 	input type="hidden" name="braintree_nonce"