Skip to content

Commit

Permalink
Update PaymentAuthWebView (#1538)
Browse files Browse the repository at this point in the history
- Enable DOM Storage
- Disable logic to load URL upon returning from bank app
  • Loading branch information
mshafrir-stripe authored Sep 13, 2019
1 parent cefc1aa commit 9a0dbfb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,21 @@ internal class PaymentAuthWebView : WebView {
setWebViewClient(webViewClient)
}

fun hasOpenedApp(): Boolean {
return webViewClient?.hasOpenedApp == true
fun onForegrounded() {
if (webViewClient?.hasOpenedApp == true) {
// If another app was opened, assume it was a bank app where payment authentication
// was completed. Upon foregrounding this screen, load the completion URL.
webViewClient?.completionUrlParam?.let {
loadUrl(it)
}
}
}

fun getCompletionUrl(): String? = webViewClient?.completionUrlParam

@SuppressLint("SetJavaScriptEnabled")
private fun configureSettings() {
settings.javaScriptEnabled = true
settings.allowContentAccess = false
settings.domStorageEnabled = true
}

internal class PaymentAuthWebViewClient(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,6 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
mWebView = webView;
}

@Override
protected void onPostResume() {
super.onPostResume();

if (mWebView != null && mWebView.hasOpenedApp()) {
// If another app was opened, assume it was a bank app where payment authentication
// was completed. Upon foregrounding this screen, load the completion URL.
final String completionUrl = mWebView.getCompletionUrl();
if (completionUrl != null) {
mWebView.loadUrl(completionUrl);
}
}
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.payment_auth_web_view_menu, menu);
Expand Down

0 comments on commit 9a0dbfb

Please sign in to comment.