Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle opaque URIs in PaymentAuthWebViewClient #1428

Merged
merged 1 commit into from
Aug 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,15 @@ private boolean isReturnUrl(@NonNull Uri uri) {
mReturnUrl.getHost() != null &&
mReturnUrl.getHost().equals(uri.getHost());
} else {
// Skip opaque (i.e. non-hierarchical) URIs
if (uri.isOpaque()) {
return false;
}

// If the `returnUrl` is unknown, look for URIs that contain a
// `payment_intent_client_secret` or `setup_intent_client_secret`
// query parameter, and check if its values matches the given `clientSecret`
// as a query parameter.

final Set<String> paramNames = uri.getQueryParameterNames();
final String clientSecret;
if (paramNames.contains(PARAM_PAYMENT_CLIENT_SECRET)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,14 @@ public void onPageFinished_witRedirectCompleteUrl_shouldFinish() {
"https://hooks.stripe.com/redirect/complete/src_1ExLWoCRMbs6FrXfjPJRYtng");
verify(mActivity).finish();
}

@Test
public void shouldOverrideUrlLoading_withOpaqueUri_shouldNotCrash() {
final String deepLink = "mailto:[email protected]?payment_intent=pi_123&" +
"payment_intent_client_secret=pi_123_secret_456&source_type=card";
final PaymentAuthWebView.PaymentAuthWebViewClient paymentAuthWebViewClient =
new PaymentAuthWebView.PaymentAuthWebViewClient(mActivity, mProgressBar,
"pi_123_secret_456", null);
paymentAuthWebViewClient.shouldOverrideUrlLoading(mWebView, deepLink);
}
}