Paypal payment: How to get a success request when uploading PayPal to webview

Edit:

After logging into PayPal, I was able to successfully complete the transaction. But I need to map successUrl in paypal to check that both URLs are the same and then display a successful message with a toast.

But I do not receive the success URL from the payment. Therefore, I cannot match it. Below I posted the appropriate 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 out this discussion . Step by step, I posted screenshots and added content for a clear understanding.

I get a message . This may not match the query:

06-15 18: 12: 59.894: I / chrome (3273): [INFO: CONSOLE (0)] "Mixed Contents: page at ' https://www.sandbox.paypal.com/us/cgi-bin/webscr ? = SESSION LTy9Q59% 5fia3wiAdHTQjgQxvUF1BTzLjgXgelCew4AS% & 2dGAutAfB5WjZXVuX8 dispatch = 5885d80a13c0db1f8e263663d3faee8dcce3e160f5b9538489e17951d2c62172 'was loaded using a secure connection, but comprises a shape such that unsafe endpoint' http://www.myapi-entertainment.com/page_managements/page_featured_subscription_payment_success/4 . this content must also be submitted via HTTPS.https: //www.sandbox.paypal.com/us/cgi-bin/webscr?SESSION=LTy9Q59%5fia3wiAdHTQjgQxvUF1BTzLjgXgelCew4AS%2dGAutAfBe8b88888888888888888888888c88a8a5a5c8a8a5b8a8b8a8a8b88a8a8b8a8b8888888a8b8a8a5c8e5a8b8e8e8e8e8b8a8b8a8b8e8b8e8e8b8b8e8e8b8e1b8e1b8e1b8b8e1b8b8b8b8a8b8aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa!

This is my answer to the success http://www.myapi-entertainment.com/page_managements/page_featured_subscription_payment_success/4 "→ The server name has been changed.

Can I match a success request with paypal? If I get any suggestion, it will be useful for me.

+18
android paypal paypal-sandbox
Jun 01 '16 at 7:13
source share
5 answers

As I understand it with your request, you have the URL of your website that makes payments via Paypal, and in the mobile application you do the same with Webview (not the Paypal SDK).

Yes , you can get a callback by doing some encoding on your web end.

Value:

Whenever any user goes to the "Payment" page, your server must know whether the user has visited from the website or via Mobile Webview, the server can send additional parameter key to any payment gateway for its user logic. Later, as soon as the payment is completed, the payment gateway will return the same additional parameter key along with the result (Success or Failure).

Note. Each payment gateway has a Redirection url for Success/Failure setting

After redirecting Paypal to the result URL (Success / Failure) after the transaction is completed, the server then again checks whether the request was executed from the website or from Mobile Webview using the additional parameter key ; check case below ...

If from Mobile Webview

  • Success: redirected to www.myserver.com/success URL
  • Disclaimer: redirected to URL www.myserver.com/failure

If from Webiew then Normal flow

Now in your mobile 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; } }); 

What is it.

+6
Jun 18 '16 at 7:23
source share

Paypal returns json response after successful payment as below

 { "client": { "environment": "sandbox", "paypal_sdk_version": "2.14.1", "platform": "Android", "product_name": "PayPal-Android-SDK" }, "response": { "create_time": "2016-06-15T11:38:04Z", "id": "PAY-6CN54299U76194116K5QT4BY", "intent": "sale", "state": "approved" }, "response_type": "payment" } 

You need to check the json response object. if the state is approved, which means that PayPal payment will be successful. You can then check the Paypal website for ongoing transactions.

Make sure that you have completed the following steps: 1) private static final int REQUEST_CODE_PAYMENT = 1; private static String CONFIG_ENVIRONMENT=PayPalConfiguration.ENVIRONMENT_SANDBOX; private static final int REQUEST_CODE_PAYMENT = 1; private static String CONFIG_ENVIRONMENT=PayPalConfiguration.ENVIRONMENT_SANDBOX; // This will be PayPalConfiguration.ENVIRONMENT_PRODUCTION for live mode. 2)

 // note that these credentials will differ between live & sandbox environments. private static final String CONFIG_CLIENT_ID = "ATBvU5urlaPOhpCrAhFsoG4u63RvNoKUocFPs9yR5q_sbM0yecZawUjoJhIilW8DNg5RrJcRHgRuEP_1"; private static PayPalConfiguration config = new PayPalConfiguration() .environment(CONFIG_ENVIRONMENT) .clientId(CONFIG_CLIENT_ID) // The following are only used in PayPalFuturePaymentActivity. .merchantName("Example Merchant") .merchantPrivacyPolicyUri(Uri.parse("https://www.example.com/privacy")) .merchantUserAgreementUri(Uri.parse("https://www.example.com/legal")); Intent intent = new Intent(getActivity(), PayPalService.class); intent.putExtra(PayPalService.EXTRA_PAYPAL_CONFIGURATION, config); getActivity().startService(intent); 
+7
Jun 15 '16 at 12:02
source share

Edit

From the screenshots, it seems you are successUrl subscription page into your successUrl and trying to map successUrl to the return URL.

  • Check the response in this post to configure the retrieval URL in your profile

  • Get URL String webUrl = webView.getUrl(); if you want to do a match / check with a specific successUrl

+4
Jun 15 '16 at 7:24
source share

As mentioned above

u need to check json response object. if the condition is approved, which means that PayPal payment is successful. You can then check the Paypal website for ongoing transactions.

+1
Jun 18 '16 at 5:39
source share

I receive a request for a successful payment or failure using the codes below:

 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(); } } } 
0
Aug 05 '16 at 11:26
source share



All Articles