From 003b40c7a392e1744eceb005f7dba93c60c7ce6e Mon Sep 17 00:00:00 2001 From: Mark Mroz Date: Wed, 21 Aug 2024 13:25:33 -0400 Subject: [PATCH] Fix currency formatting using locale instead of region --- Sources/Afterpay/AfterpayV3.swift | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Sources/Afterpay/AfterpayV3.swift b/Sources/Afterpay/AfterpayV3.swift index b3d7850d..eedf3853 100644 --- a/Sources/Afterpay/AfterpayV3.swift +++ b/Sources/Afterpay/AfterpayV3.swift @@ -347,18 +347,19 @@ public struct CheckoutV3Configuration { return currencyCode } - private static var formatter: NumberFormatter = { - var formatter = NumberFormatter() + private var formatter: NumberFormatter { + let formatter = NumberFormatter() formatter.numberStyle = .decimal // ISO 4217 specifies 2 decimal points formatter.maximumFractionDigits = 2 formatter.roundingMode = .halfEven // Banker's rounding formatter.groupingSeparator = "" + formatter.locale = locale return formatter - }() + } func formatted(currency: Decimal) -> String { - return Self.formatter.string(from: currency as NSDecimalNumber)! + return formatter.string(from: currency as NSDecimalNumber)! } } }