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 then display successful toast message.
But I am not getting success url from payment.So I can't match it.Below I have posted the relevant code:
WebActivity.java:
public class PaypalWebActivity extends Activity {
private WebView webView;
String payUrlStr;
ProgressDialog dialog;
String successUrl;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.paypal_web_layout);
successUrl = LOAD_WEBVIEW_PAYMENT_PAYPAL_SUCCESS;
dialog = ProgressDialog.show(PaypalWebActivity.this, "", "Please wait..", false);
loadWebViewPaypal();
}
private void loadWebViewPaypal() {
payUrlStr = LOAD_WEBVIEW_PAYMENT_PAYPAL(PAGE_ID);
Log.e("payUrlStr", ""+payUrlStr);
webView = (WebView) findViewById(R.id.webView);
webView.loadUrl(payUrlStr);
webView.getSettings().setJavaScriptEnabled(true);
@SuppressWarnings("unused")
WebSettings settings= webView.getSettings();
if (Build.VERSION.SDK_INT >= 21) {
webView.getSettings().setMixedContentMode( WebSettings.MIXED_CONTENT_ALWAYS_ALLOW );
}
webView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
Log.e("Loading url...", url);
view.loadUrl(url);
String loadWebUrl = view.getUrl();
Log.e("loadWebUrl", ""+loadWebUrl);
return true;
}
@Override
public void onPageFinished(WebView view, String url) {
Log.e("Finished url...", url);
String webUrl = view.getUrl();
Log.e("webUrl", ""+webUrl);
if(webUrl.substring(0,95).equals(successUrl)){
Log.e("Getting Success Request", "Test");
}else{
Log.e("Failed to get Request", "Test");
}
if(dialog.isShowing()){
dialog.dismiss();
}
}
@Override
public void onReceivedError(WebView view, int errorCode,
String description, String failingUrl) {
Log.e("Error in url...", description);
Log.e("Error in failingUrl...", failingUrl);
}
});
}
}
Manifest:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
check this discussion.step by step I put screenshots and added content for clear understanding.
I am getting this error message.So cant able to match success request:
06-15 18:12:59.894: I/chromium(3273): [INFO:CONSOLE(0)] "Mixed Content: The page at 'https://www.sandbox.paypal.com/us/cgi-bin/webscr?SESSION=LTy9Q59%5fia3wiAdHTQjgQxvUF1BTzLjgXgelCew4AS%2dGAutAfB5WjZXVuX8&dispatch=5885d80a13c0db1f8e263663d3faee8dcce3e160f5b9538489e17951d2c62172' was loaded over a secure connection, but contains a form which targets an insecure endpoint 'http://www.myapi-entertainment.com/page_managements/page_featured_subscription_payment_success/4. this content should also be submitted over HTTPS. https://www.sandbox.paypal.com/us/cgi-bin/webscr?SESSION=LTy9Q59%5fia3wiAdHTQjgQxvUF1BTzLjgXgelCew4AS%2dGAutAfB5WjZXVuX8&dispatch=5885d80a13c0db1f8e263663d3faee8dcce3e160f5b9538489e17951d2c62172 (0)
This is my success response "http://www.myapi-entertainment.com/page_managements/page_featured_subscription_payment_success/4" -> Changed server name.
is it possible to match success request with paypal? If I get any suggestion, it will be helpful to me.
payUrlStr
please, did you integrate with simple payment button or PayPal Express API in there? – pp_pduan