Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(pay_ios): Fixed app freeze after canceling payment #295

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions pay_ios/ios/Classes/PaymentHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}
}