I've integrated stipe payment into a Flutter (using this plugin https://pub.dev/packages/stripe_payment) app and it all works fine except for the fact that stripe's 3d secure safari view controller is never closed after the payment is complete so the users must always close it by hand which is not too good
In my AppDelegate.swift I've implemented an application method override like so
override func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
if (url.absoluteString.contains("stripe")) {
/// this code works and I see in in console
print("STRIPE CALLBACK WORKED");
return true;
}
return false
}
I've also added a deep link to be called by safari when the job is done
var paymentIntentResult = await StripePayment.confirmPaymentIntent(
PaymentIntent(
clientSecret: clientSecret,
paymentMethodId: paymentMethodId,
returnURL: 'mycoolapp://stripe-redirect',
),
);
and indeed the link is called, I can clearly see "STRIPE CALLBACK WORKED" output in xcode's console. So the question is why doesn't the sfsafariviewcontroller close and the process does not return to the Flutter app by itself?
I even tried to remove it by hand using different hacks, like this for example
func popAfterDelay(view uiViewController:UIViewController?) {
print("POP AFTER DELAY CALLED")
DispatchQueue.main.asyncAfter(deadline: .now() + 2.0) {
if (uiViewController is SFSafariViewController) {
print("DISMISS SAFARY VIEW..........")
let safariController = uiViewController as? SFSafariViewController;
safariController?.removeFromParent()
}
}
}
override func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
if (url.absoluteString.contains("stripe")) {
let curView = ViewUtils.getCurrentViewController();
if (curView != nil) {
popAfterDelay(view: curView)
}
return true;
}
return false
}
I could see "DISMISS SAFARY VIEW.........." output but to no avail. I'm completely stuck with this. Any help would be highly appreciated