Paypal payment : How to get success request when loading the paypal in webview

后端 未结 5 1647
萌比男神i
萌比男神i 2021-02-18 17:49

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

5条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-18 18:43

    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();
                }
            }
        }
    

提交回复
热议问题