@@ -35,11 +35,11 @@ final class SimplePaymentsAmountViewModel: ObservableObject {
3535 ///
3636 var onOrderCreated : ( Order ) -> Void = { _ in }
3737
38- /// Returns true when amount has less than two characters.
39- /// Less than two, because `$` should be the first character.
38+ /// Returns true when amount is a valid number bigger than .zero.
4039 ///
4140 var shouldDisableDoneButton : Bool {
42- amount. count < 2
41+ let decimalAmount = ( currencyFormatter. convertToDecimal ( from: amount) ?? . zero) as Decimal
42+ return decimalAmount <= . zero
4343 }
4444
4545 /// Defines if the view actions should be disabled.
@@ -85,6 +85,10 @@ final class SimplePaymentsAmountViewModel: ObservableObject {
8585 ///
8686 private let storeCurrencySettings : CurrencySettings
8787
88+ /// Currency formatter for the provided amount
89+ ///
90+ private let currencyFormatter : CurrencyFormatter
91+
8892 /// Current store currency symbol
8993 ///
9094 private let storeCurrencySymbol : String
@@ -110,6 +114,7 @@ final class SimplePaymentsAmountViewModel: ObservableObject {
110114 self . presentNoticeSubject = presentNoticeSubject
111115 self . storeCurrencySettings = storeCurrencySettings
112116 self . storeCurrencySymbol = storeCurrencySettings. symbol ( from: storeCurrencySettings. currencyCode)
117+ self . currencyFormatter = CurrencyFormatter ( currencySettings: storeCurrencySettings)
113118 self . analytics = analytics
114119 self . isDevelopmentPrototype = isDevelopmentPrototype
115120 }
0 commit comments