Edit:
After paypal login, I could successfully complete transaction.But I need to match the successUrl in paypal to verify both url is same and
I am getting a Payment success or failure request using this below Codes:
private void loadWebViewPaypal() {
payUrlStr = LOAD_WEBVIEW_PAYMENT_PAYPAL(PAGE_ID);
Log.e("payUrlStr", "" + payUrlStr);
webView = (WebView) findViewById(R.id.webView);
webView.setWebViewClient(new WebClient());
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl(payUrlStr);
@SuppressWarnings("unused")
WebSettings settings= webView.getSettings();
if (Build.VERSION.SDK_INT >= 21) {
webView.getSettings().setMixedContentMode( WebSettings.MIXED_CONTENT_ALWAYS_ALLOW );
}
}
public class WebClient extends WebViewClient
{
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
Log.e("Page Started", ""+url);
super.onPageStarted(view, url, favicon);
if(url.contains(successUrl)) {
Log.e("Getting Success Request", "Test");
Intent i = new Intent(PaypalWebActivity.this, TabhostActivity.class);
PAYPAL_WEB_BACK = "fulfilled";
startActivity(i);
finish();
} else if(url.equalsIgnoreCase(failureUrl)) {
Intent i = new Intent(PaypalWebActivity.this, TabhostActivity.class);
PAYPAL_WEB_BACK = "fulfilled";
startActivity(i);
finish();
}
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
Log.e("Override Url", ""+url);
view.loadUrl(url);
return true;
}
@Override
public void onPageFinished(WebView view, String url) {
// TODO Auto-generated method stub
super.onPageFinished(view, url);
Log.e("Finished Url :", "" + url);
if(dialog.isShowing()){
dialog.dismiss();
}
}
}