@jimrising/easymerchantsdk-react-native 2.7.6 → 2.7.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -551,9 +551,20 @@ class PaymentInfoVC: BaseVC, BillingInfoVCDelegate {
|
|
|
551
551
|
// let rawAmount = Double(self.request?.amount ?? 0)
|
|
552
552
|
// let amountText = String(format: "$%.2f", rawAmount)
|
|
553
553
|
|
|
554
|
-
// ✅
|
|
555
|
-
let
|
|
556
|
-
|
|
554
|
+
// ✅ Use decimal-safe amount from backend (avoids binary rounding drift)
|
|
555
|
+
let amountText: String = {
|
|
556
|
+
if let savedAmount = UserStoreSingleton.shared.amount,
|
|
557
|
+
let decimal = Decimal(string: savedAmount) {
|
|
558
|
+
var value = decimal
|
|
559
|
+
var rounded = Decimal()
|
|
560
|
+
NSDecimalRound(&rounded, &value, 2, .plain)
|
|
561
|
+
return "$" + NSDecimalNumber(decimal: rounded).stringValue
|
|
562
|
+
} else if let resolvedAmount = self.amount {
|
|
563
|
+
return String(format: "$%.2f", resolvedAmount)
|
|
564
|
+
} else {
|
|
565
|
+
return "$0.00"
|
|
566
|
+
}
|
|
567
|
+
}()
|
|
557
568
|
|
|
558
569
|
var buttonText: String
|
|
559
570
|
if !billingVisible && !additionalVisible {
|
|
@@ -573,8 +584,19 @@ class PaymentInfoVC: BaseVC, BillingInfoVCDelegate {
|
|
|
573
584
|
self.btnPayNowSingleAccountView.setTitle(buttonText, for: .normal)
|
|
574
585
|
} else {
|
|
575
586
|
/// When no billingInfoData present
|
|
576
|
-
let
|
|
577
|
-
|
|
587
|
+
let amountText: String = {
|
|
588
|
+
if let savedAmount = UserStoreSingleton.shared.amount,
|
|
589
|
+
let decimal = Decimal(string: savedAmount) {
|
|
590
|
+
var value = decimal
|
|
591
|
+
var rounded = Decimal()
|
|
592
|
+
NSDecimalRound(&rounded, &value, 2, .plain)
|
|
593
|
+
return "$" + NSDecimalNumber(decimal: rounded).stringValue
|
|
594
|
+
} else if let resolvedAmount = self.amount {
|
|
595
|
+
return String(format: "$%.2f", resolvedAmount)
|
|
596
|
+
} else {
|
|
597
|
+
return "$0.00"
|
|
598
|
+
}
|
|
599
|
+
}()
|
|
578
600
|
|
|
579
601
|
let submitText = self.request?.submitButtonText?.isEmpty == false ? self.request!.submitButtonText! : "Pay Now"
|
|
580
602
|
let defaultTitle = "\(submitText) (\(amountText))"
|