From b758f57392508cafa30c63634f1d4956a981540e Mon Sep 17 00:00:00 2001 From: Bug Magnet Date: Thu, 6 Jul 2023 17:29:08 +0200 Subject: [PATCH] Hotfix for presenting cancelled payment in a nicer way --- ios/MullvadVPN/Extensions/SKError+Localized.swift | 2 +- .../Extensions/StorePaymentManagerError+Display.swift | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ios/MullvadVPN/Extensions/SKError+Localized.swift b/ios/MullvadVPN/Extensions/SKError+Localized.swift index 6367877fc4cd..024e258d2757 100644 --- a/ios/MullvadVPN/Extensions/SKError+Localized.swift +++ b/ios/MullvadVPN/Extensions/SKError+Localized.swift @@ -29,7 +29,7 @@ extension SKError: LocalizedError { return NSLocalizedString( "PAYMENT_CANCELLED", tableName: "StoreKitErrors", - value: "User cancelled the request.", + value: "The payment request was cancelled.", comment: "" ) case .paymentInvalid: diff --git a/ios/MullvadVPN/Extensions/StorePaymentManagerError+Display.swift b/ios/MullvadVPN/Extensions/StorePaymentManagerError+Display.swift index a2adb551ad1b..c516840755b3 100644 --- a/ios/MullvadVPN/Extensions/StorePaymentManagerError+Display.swift +++ b/ios/MullvadVPN/Extensions/StorePaymentManagerError+Display.swift @@ -80,7 +80,11 @@ extension StorePaymentManagerError: DisplayError { return errorString case let .storePayment(storeError): - return (storeError as? SKError)?.errorDescription ?? storeError.localizedDescription + guard let error = storeError as? SKError else { return storeError.localizedDescription } + if error.code.rawValue == 0, error.underlyingErrorChain.map({ $0 as NSError }).first?.code == 825 { + return SKError(.paymentCancelled).errorDescription + } + return SKError(error.code).errorDescription } } }