From 9dd19f4a85ac8c1cff75e95501ac831471fa3877 Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Tue, 23 Feb 2021 15:10:49 -0500 Subject: [PATCH] Only ask which card to use if there is more than one --- sgx_jmp.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sgx_jmp.rb b/sgx_jmp.rb index 69163baf606277d9afeac28e41f09fb41fc80224..f10717a0758355c2a19113c68c09f18a14f45483 100644 --- a/sgx_jmp.rb +++ b/sgx_jmp.rb @@ -330,7 +330,7 @@ command :execute?, node: "buy-credit", sessionid: nil do |iq| type: "fixed", value: "Current balance: $#{balance.to_s('F')}" }, - { + ({ var: "payment_method", type: "list-single", label: "Credit card to pay with", @@ -342,7 +342,7 @@ command :execute?, node: "buy-credit", sessionid: nil do |iq| label: "#{method.card_type} #{method.last_4}" } end - }, + } if payment_methods.length > 1), XEP0122Field.new( "xs:decimal", range: (0..1000), @@ -350,7 +350,7 @@ command :execute?, node: "buy-credit", sessionid: nil do |iq| label: "Amount of credit to buy", required: true ).field - ] + ].compact EMPromise.all([ payment_methods, @@ -359,7 +359,7 @@ command :execute?, node: "buy-credit", sessionid: nil do |iq| }.then { |(payment_methods, iq2)| iq = iq2 # This allows the catch to use it also payment_method = payment_methods.fetch( - iq.form.field("payment_method").value.to_i + iq.form.field("payment_method")&.value.to_i ) BRAINTREE.transaction.sale( amount: iq.form.field("amount").value.to_s,