From 8f0c7be466049d16c477c744f59594cd1b196633 Mon Sep 17 00:00:00 2001 From: avalentic Date: Wed, 12 Feb 2025 09:18:55 +0100 Subject: [PATCH] fix(pay_ios): Fixed app freeze after canceling payment --- pay_ios/ios/Classes/PaymentHandler.swift | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/pay_ios/ios/Classes/PaymentHandler.swift b/pay_ios/ios/Classes/PaymentHandler.swift index 887aadf0..80d9362b 100644 --- a/pay_ios/ios/Classes/PaymentHandler.swift +++ b/pay_ios/ios/Classes/PaymentHandler.swift @@ -194,17 +194,13 @@ extension PaymentHandler: PKPaymentAuthorizationControllerDelegate { } func paymentAuthorizationControllerDidFinish(_ controller: PKPaymentAuthorizationController) { - controller.dismiss { - DispatchQueue.main.async { - // There was no attempt to authorize. - if self.paymentHandlerStatus == .presented { - self.paymentResult(FlutterError(code: "paymentCanceled", message: "User canceled payment authorization", details: nil)) - } - // Authorization started, but it did not succeed - if self.paymentHandlerStatus == .authorizationStarted { - self.paymentResult(FlutterError(code: "paymentFailed", message: "Failed to complete the payment", details: nil)) - } - } + controller.dismiss() + // There was no attempt to authorize. + if self.paymentHandlerStatus == .presented { + self.paymentResult(FlutterError(code: "paymentCanceled", message: "User canceled payment authorization", details: nil)) + } + // Authorization started, but it did not succeed + if self.paymentHandlerStatus == .authorizationStarted { + self.paymentResult(FlutterError(code: "paymentFailed", message: "Failed to complete the payment", details: nil)) } - } }