Closed molundb closed 4 years ago
Hi @molundb looking into this. I noticed in solution 1 the WebView is programmatically instantiated. Where does it get added to the view hierarchy in this case?
Also if you could provide screenshots and/or logs from a web inspector console if there are any, that would help us diagnose the issue.
@sshropshire Thank you. It does not get added to the view hierarchy I suppose; that's the idea to make it not show up and instead just show the paypal webview.
I'll look into the web inspector console thing and get back to you.
@sshropshire Here are gifs and web console logs of the two different solutions. I hope it helps, and if you need any further information I will happily provide it.
Solution 1, without activity (not working)
Gif. Notice that there's no popup saying "Approved!" as in solution 2.
Logs. The problem compared to the working solution 2 seems to be that the Paypal.buttons onApprove() callback doesn't get called.
Solution 2, with activity (working)
Gif
Logs
I solved it by adding the webview to the fragment_main.xml
with visibility="gone"
and passing it to PaypalPopup.kt
. I guess it needs to be in the view hierarchy. Thanks a lot for the help!
General information
Issue description
First of all thank you so much for this wonderful plugin.
What I am trying to achieve is this: I want put the handling of the webView used for the popupBridge in a separate class (PaypalPopup.kt), then I want to simulate a click of the paypal pay button on the button click of another button (in MainActivity.kt) (solution 1). This is for a smooth user experience. I have a working solution (solution 2) using a separate activity but that causes a second screen with the paypal button to show after the initial button click.
Everything seems to be working fine with solution 1, but for some reason the paypal callback onApprove is not called after this line in PopupBridge.java is called.
runJavaScriptInWebView(String.format("window.popupBridge.onComplete(%s, %s);", error, payload));
. I've been stuck on this issue for days and I'm clueless. Why is onApprove not getting called in this scenario?Thank you once again.
Code:
MainActivity.kt
activity_main.xml
PaypalPopupActivity.kt (this is working)
fragment_paypal_web_view.xml
PaypalPopup.kt (this is not working)
PaypalPopupHelper.kt
paypal.html
paypalJavascript.js