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

后端 未结 5 1667
萌比男神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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-18 18:49

    What I understand with your query is, you have an URL of your Website which perform payment using Paypal, and in Mobile app you are performing the same using the Webview(not Paypal SDK).

    Yes, you can get the callback by doing some coding at your WEB end.

    Meaning:

    Whenever any user navigate to Payment page then your Server must know whether User visited from Website or through Mobile Webview, Server can send additional parameter key to any Payment gateway for their custom logic. Later once Payment transaction completed, Payment gateway will return the same additional parameter key alongwith the result(Success or Failure).

    Note: Every Payment gateway has a setting of Redirection url for Success/Failure

    Once Paypal redirect to result url(Success/Failure) after Transaction gets completed, Server then again check whether the request has been made from Website or from Mobile Webview with the help of additional parameter key; check case below...

    If from Mobile Webview

    • Success: Redirected to URL www.myserver.com/success
    • Failure: Redirected to URL www.myserver.com/failure

    If from Webiew then Normal flow

    Now in your Mobile's Webview

    webView.setWebViewClient(new WebViewClient() {
    
                @Override
                public boolean shouldOverrideUrlLoading(WebView view, String url)
                    if(url.equalsIgnoreCase("www.myserver.com/success"))
                      //Success Toast
                    else if(url.equalsIgnoreCase("www.myserver.com/failure"))
                       //Failure Toast
                    return true;
                }
    
    });
    

    That's it.

提交回复
热议问题