Xamarin.Forms
Xamarin.Forms copied to clipboard
[Question] How to enable Google/Apple Pay to be invoked from a WebView?
Hi, this is more of a question that a bug report.
Is there a way to enable Google/Apple Pay to be invoked from a WebView? I'm using a payment service (similar to Stripe) that will gives me a payment URL. To finish a payment, I have to open a browser, navigate to that URL and let the user pay.
I'm using a WebView because I need to be able to intercept the browser navigation and close it when it's navigating to the return URL I've provided to the payment service. That's why I'm not opening the URL in a browser intent.
The problem is that when opened in a WebView, clicking on the Google Pay button fails to open the Google Pay overlay (where you can pick a card and pay) and the payment cannot be finished. I suspect that the WebView isn't able to invoke the Google Pay API, is there a way to enable that? If not, I'd have to switch to opening the payment URL in a browser intent (using the Xamarin.Essentials's Browser API) and I'd lose the option to intercept the browser navigation.
Thanks for any advice!
EDIT:
I've received advice from the my payment processor in the meantime. They said:
Use the Chrome Custom Tabs
for Android instead of the WebView
. It works similarly but also supports standard functionality (such as Google Pay). To use Apple Pay on iOS, use the SFSafariController
.
I'll try that and report back here.
Hi @michaldivis , I came to your problem today. Do you manage to resolve the problem with Chrome Custom Tabs and SFSafariController? Can you post an example maybe? Thank you in advance, Jacopo