config-schema.dhall 🔗
@@ -27,6 +27,7 @@
, notify_from : Text
, ogm_path : Text
, ogm_web_root : Text
+, onboarding_domain : Text
, oxr_app_id : Text
, payable : Text
, plans :
Stephen Paul Weber created
* reg-new:
Show Bitcoin registration info as form not note
Include customer id when onboarding
config-schema.dhall | 1 +
config.dhall.sample | 1 +
forms/alt_top_up/interac.rb | 2 +-
forms/alt_top_up/mailing_address.rb | 2 +-
forms/registration/btc.rb | 19 +++++++++++++++++++
forms/registration/mail.rb | 8 ++++++++
lib/registration.rb | 29 ++++++++++++++++++++---------
test/test_registration.rb | 10 ++--------
8 files changed, 53 insertions(+), 19 deletions(-)
@@ -27,6 +27,7 @@
, notify_from : Text
, ogm_path : Text
, ogm_web_root : Text
+, onboarding_domain : Text
, oxr_app_id : Text
, payable : Text
, plans :
@@ -82,6 +82,7 @@ in
keep_area_codes = ["555"],
keep_area_codes_in = { account = "", site_id = "", sip_peer_id = "" },
snikket_hosting_api = "",
+ onboarding_domain = "",
rev_ai_token = "",
upstream_domain = "example.net",
approved_domains = toMap { `example.com` = Some "customer_id" },
@@ -2,6 +2,6 @@ field(
var: "interac_email",
type: "fixed",
label: "Interac e-Transfer Address",
- description: "Please include your Jabber ID in the note",
+ description: "Please include your #{@in_note || 'Jabber ID'} in the note",
value: CONFIG[:interac]
)
@@ -4,6 +4,6 @@ field(
label: "Mailing Address",
description:
"Make payable to #{CONFIG[:payable]} and include your " \
- "Jabber ID in the mailing somewhere.",
+ "#{@in_note || 'Jabber ID'} in the mailing somewhere.",
value: CONFIG[:adr]
)
@@ -0,0 +1,19 @@
+result!
+title "Activate using Bitcoin"
+
+field(
+ label: "Minimum initial Bitcoin deposit for activation",
+ var: "amount",
+ value: "%.6f" % @amount
+)
+
+field(
+ label: "Bitcoin address",
+ var: "btc_addresses",
+ value: @addr
+)
+
+instructions(
+ "You will received a notification when your payment is complete." \
+ "#{@final_message}"
+)
@@ -9,5 +9,13 @@ instructions(
"#{@final_message}"
)
+if @customer_id
+ field(
+ label: "Customer ID",
+ var: "customer_id",
+ value: @customer_id
+ )
+end
+
render "alt_top_up/mailing_address"
render "alt_top_up/interac" if @currency == :CAD
@@ -188,14 +188,15 @@ class Registration
REDIS.setex("pending_tel_for-#{@customer.jid}", THIRTY_DAYS, tel)
end
- def note_text(rate, addr)
+ def form(rate, addr)
amount = CONFIG[:activation_amount] / rate
- <<~NOTE
- Activate your account by sending at least #{'%.6f' % amount} BTC to
- #{addr}
- You will receive a notification when your payment is complete.
- NOTE
+ FormTemplate.render(
+ "registration/btc",
+ amount: amount,
+ addr: addr,
+ final_message: @final_message
+ )
end
def write
@@ -203,8 +204,7 @@ class Registration
Command.reply { |reply|
reply.allowed_actions = [:prev]
reply.status = :canceled
- reply.note_type = :info
- reply.note_text = note_text(rate, addr) + @final_message.to_s
+ reply.command << form(rate, addr)
}.then(&method(:handle_possible_prev))
end
end
@@ -418,10 +418,21 @@ class Registration
FormTemplate.render(
"registration/mail",
currency: @customer.currency,
- final_message: @final_message
+ final_message: @final_message,
+ **onboarding_extras
)
end
+ def onboarding_extras
+ jid = ProxiedJID.new(@customer.jid).unproxied
+ return {} unless jid.domain == CONFIG[:onboarding_domain]
+
+ {
+ customer_id: @customer.customer_id,
+ in_note: "Customer ID"
+ }
+ end
+
def write
Command.reply { |reply|
reply.allowed_actions = [:prev]
@@ -340,20 +340,14 @@ class RegistrationTest < Minitest::Test
EMPromise.resolve([]),
["jmp_customer_btc_addresses-test"]
)
- reply_text = <<~NOTE
- Activate your account by sending at least 1.000000 BTC to
- testaddr
-
- You will receive a notification when your payment is complete.
- NOTE
blather = Minitest::Mock.new
Command::COMMAND_MANAGER.expect(
:write,
EMPromise.reject(SessionManager::Timeout.new),
[Matching.new do |reply|
assert_equal :canceled, reply.status
- assert_equal :info, reply.note_type
- assert_equal reply_text, reply.note.content
+ assert_equal "1.000000", reply.form.field("amount").value
+ assert_equal "testaddr", reply.form.field("btc_addresses").value
true
end]
)