@@ 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,