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,