flutter-plugin
flutter-plugin copied to clipboard
[pay_ios] Add more logging to `paymentFailed` error.
We are not able to reproduce or understand why some users get this error.
PlatformException(paymentFailed, Failed to complete the payment, null, null)
What may be the reasons?
Have you inspected the error included in the onError callback?
We are using showPaymentSelector directly there is no onError callback parameter.
await payClient.showPaymentSelector(
provider: pay.PayProvider.apple_pay,
paymentItems: paymentItems,
);
We think the exception comes from here. It says payment failed, but we can't understand why. It fails only for very small number of users. https://github.com/google-pay/flutter-plugin/blob/e2069bf10a7418856bd22d15e03bbeac8e44ae1d/pay_ios/ios/Classes/PaymentHandler.swift#L205
Correct, this error occurs when the payment fails during the payment authorization stage. Can you confirm that the card you are using can complete a payment? Can you verify other cards? If the issue is confirmed we can confirm the error to be more explicit about the authorization attempt.
Unfortunately we haven't been able to reproduce this ourself. We only see it in crashlytics for a few users.
This error surfaces when the following happens:
- The payment selector is presented
- An authorization of the payment was attempted.
- The payment intent finished without receiving an authorization.
In other words, this seems like a payment attempt that failed during authorization. A fraction of your payments should be expected not to authorize successfully.
That said, the error code could be updated to be more useful. Something like authorizationFailed, or paymentAuthorizationFailed.
Do you think that's consistent with your data?
authorizationFailed seems better.
If we could get error code why the authorization failed it would be even better.
It would allow us to understand the reason why authorization failed and we could give user hints how to fix the authorization failed error on their phone.
The Apple Pay library does not seem to return any error or additional information at runtime (it simply does not call didAuthorizePayment). Some Apple Pay docs and SO comments allude to a window of 30s for the payment to be confirmed before timing out on its own.
Are you able to gather additional telemetry when the error shows up to confirm the above?
I tried multiple times and ways to get the timeout but i couldn't reproduce it. For one user it happened on iOS 16.0.0 with iPhone 13 Pro Max. It's very rare exception, this has happened only once for this one user.
Feel free to reopen this issue if you have additional information on the issue.