0

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.

Michal Diviš
  • 2,008
  • 12
  • 19
  • I can't ensure the cause of `fails to open the Google Pay overlay` is the webview not support 3 part popup or not. You can try to custom the webview renderder such as [this case](https://stackoverflow.com/questions/60654960/handling-3rd-party-popup-windows-within-a-xamarin-forms-webview). In addition, you can try to use the libs in your project such as the [link](https://stackoverflow.com/questions/54023320/how-to-integrate-google-pay-in-my-android-app-for-payment). – Liyun Zhang - MSFT May 24 '22 at 06:45
  • @LiyunZhang-MSFT Thanks! I'll check that out. – Michal Diviš May 24 '22 at 06:46
  • But when I search on the internet, I found that most of the payment on android use the Stripe sdk in their projects. It seems that there are some limits in the webview. – Liyun Zhang - MSFT May 24 '22 at 06:48
  • I've noticed that too, however, my payment processor doesn't have a Xamarin SDK. – Michal Diviš May 24 '22 at 06:53
  • So you may need to use the Xamarin libs in your project just like the [link](https://social.msdn.microsoft.com/Forums/en-US/c3a865ed-373f-482c-9ddb-f7fe57f44b7c/how-to-integrate-apply-pay-and-google-pay-in-xamarin-forms?forum=xamarinforms) I provided. – Liyun Zhang - MSFT May 24 '22 at 07:05

0 Answers0