flutter-plugin icon indicating copy to clipboard operation
flutter-plugin copied to clipboard

Failed to present payment controller

Open sveinn19 opened this issue 3 years ago • 13 comments

On occasion showPaymentSelecter throws 'PlatformException(paymentError, Failed to present payment controller, null, null)' when opening paymentSelector with Apple Pay after several seconds of waiting.

Have tested using Flutter version 3.0.4 and 2.8.1. With pay version 1.0.10 and 1.0.8.

` final Pay _payClient = Pay.withAssets(<String>['applepay.json']);

final Map<String, dynamic> result = await _payClient.showPaymentSelector( paymentItems: _paymentItems, ); `

sveinn19 avatar Jul 11 '22 15:07 sveinn19

Since we started logging this error(21 July) to sentry 800 people have encountered this error. It would be great to get an answer ASAP @JlUgia

atlid8 avatar Aug 02 '22 12:08 atlid8

Hi everyone, this error surfaces when the payment UI is shown unsuccessfully. As you can see in the source, this is a 1:1 response from the payments SDK.

Some users facing the same issue natively connect the problem with unexpected or malformed configuration sent through the parameters (eg.: malformed decimal numbers). Are you able to gather additional information to determine the origin of the problem? (eg.: logs with the configuration used during failures).

JlUgia avatar Aug 17 '22 10:08 JlUgia

This only happens occasionally and if we call our handler function again with same parameters it works most of the time, but it takes some time for the first error to throw and therefore not our ideal solution. We are certain that are configuration is not the factor in this error. @JlUgia

atlid8 avatar Aug 18 '22 08:08 atlid8

@JlUgia

sveinn19 avatar Aug 24 '22 11:08 sveinn19

You'll need additional telemetry to find out the root cause for the issue. Note that, most certainly, if the configuration has not changed, this issue is not related to this package, but with the native Apple Pay SDK.

I'd suggest overriding the ios implementation in the package to use a modified version that includes additional logging when the payment selector is presented natively on iOS:

  1. Override the pay_ios dependency in your application (see the pubspec.yaml in the example application for reference):
dependency_overrides:
  pay_ios:
    path: ../../pay_ios
  1. Look for situations when the payment sheet cannot be presented and inspect the payment request used to gather additional evidence (eg.: send out a copy of the payment request to your logging stack when the sheet can't be presented).

Feel free to share any findings.

In addition, have you confirmed that certain price amounts are not causing trouble?

JlUgia avatar Sep 12 '22 10:09 JlUgia

We are experiencing the same issue. This issue happens more often if app gets to background for some time before proceeding with apple pay.

ldemyanenko avatar Dec 07 '22 15:12 ldemyanenko

Any update on this issue?

oande avatar Dec 08 '22 08:12 oande

I'm also facing this issue, But in my case, apple pay is working flawlessly in Simulator. I'm getting this error when I try it in Real Device. Any update?

red-star25 avatar Jan 20 '23 07:01 red-star25

We resolved the issue through the workaround - by retrying the call one more time if the error appears

ldemyanenko avatar Jan 20 '23 13:01 ldemyanenko

we are also facing the same problem.

PlatformException(paymentError, Failed to present payment controller, null, null)

I get an error when running showPaymentSelector for the first time. Subsequent executions work fine.

akihisasengoku avatar Feb 05 '23 13:02 akihisasengoku

any updates?

ostk0069 avatar Mar 14 '23 01:03 ostk0069

PR #200 is extending the payment flow for iOS. I suggest that we revisit this issue once the change is published.

JlUgia avatar Aug 02 '23 15:08 JlUgia

PlatformException(paymentError, Failed to present payment controller, null, null) [VERBOSE-2:profiler_metrics_ios.mm(203)] Error retrieving thread information: (os/kern) invalid argument

mostafiz9900 avatar Oct 31 '23 19:10 mostafiz9900