| Line 64... |
Line 64... |
| 64 |
import java.util.ArrayList;
|
64 |
import java.util.ArrayList;
|
| 65 |
import java.util.Date;
|
65 |
import java.util.Date;
|
| 66 |
import java.util.LinkedList;
|
66 |
import java.util.LinkedList;
|
| 67 |
import java.util.List;
|
67 |
import java.util.List;
|
| 68 |
import java.util.StringTokenizer;
|
68 |
import java.util.StringTokenizer;
|
| - |
|
69 |
import java.util.regex.Matcher;
|
| - |
|
70 |
import java.util.regex.Pattern;
|
| 69 |
|
71 |
|
| 70 |
public class DealsHomeFragment extends Fragment implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener {
|
72 |
public class DealsHomeFragment extends Fragment implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener {
|
| 71 |
|
73 |
|
| 72 |
public DealsHomeFragment(){
|
74 |
public DealsHomeFragment(){
|
| 73 |
|
75 |
|
| 74 |
}
|
76 |
}
|
| 75 |
|
77 |
|
| 76 |
static boolean FLAG=false,REDIRECT=false,PAGE_LOAD=false;
|
78 |
static boolean FLAG=false,REDIRECT=false,PAGE_LOAD=false,PAYTMFLAG=false;
|
| 77 |
WebView webView;
|
79 |
WebView webView;
|
| 78 |
WebView amazonWebView,amazonOrderHistoryWebView,amazonOrderHistoryCancelledWebView;
|
80 |
WebView amazonWebView,amazonOrderHistoryWebView,amazonOrderHistoryCancelledWebView,paytmWebView;
|
| 79 |
WebView amazonAllUrlsWebView;
|
81 |
WebView amazonAllUrlsWebView;
|
| 80 |
SharedPreferences userData;
|
82 |
SharedPreferences userData;
|
| 81 |
SharedPreferences apiData;
|
83 |
SharedPreferences apiData;
|
| 82 |
SharedPreferences flipkartData;
|
84 |
SharedPreferences flipkartData;
|
| 83 |
SharedPreferences.Editor userDataEditor;
|
85 |
SharedPreferences.Editor userDataEditor;
|
| Line 126... |
Line 128... |
| 126 |
amazonapiSettingsEditor = amazonData.edit();
|
128 |
amazonapiSettingsEditor = amazonData.edit();
|
| 127 |
flipkartDataEditor = flipkartData.edit();
|
129 |
flipkartDataEditor = flipkartData.edit();
|
| 128 |
affliateUrl=getArguments().getString("key");
|
130 |
affliateUrl=getArguments().getString("key");
|
| 129 |
orderDetails = new OrderTransactionDetails(getActivity());
|
131 |
orderDetails = new OrderTransactionDetails(getActivity());
|
| 130 |
|
132 |
|
| - |
|
133 |
|
| 131 |
orderSuccessUrlList = new ArrayList<String>();
|
134 |
orderSuccessUrlList = new ArrayList<String>();
|
| 132 |
String issues =apiData.getString("list.order.success.url","snapdeal.com/purchaseMobileComplete?code=|flipkart.com/orderresponse?reference_id=|amazon.in/gp/buy/spc/handlers/static-submit-decoupled.html|amazon.in/gp/buy/thankyou/handlers|m.saholic.com/pay-success?paymentId=|shopclues.com/orderconfirmation|");
|
135 |
String issues =apiData.getString("list.order.success.url","snapdeal.com/purchaseMobileComplete?code=|flipkart.com/orderresponse?reference_id=|amazon.in/gp/buy/spc/handlers/static-submit-decoupled.html|amazon.in/gp/buy/thankyou/handlers|m.saholic.com/pay-success?paymentId=|shopclues.com/orderconfirmation|");
|
| 133 |
StringTokenizer st2 = new StringTokenizer(issues, "|");
|
136 |
StringTokenizer st2 = new StringTokenizer(issues, "|");
|
| 134 |
|
137 |
|
| 135 |
while (st2.hasMoreElements()) {
|
138 |
while (st2.hasMoreElements()) {
|
| 136 |
orderSuccessUrlList.add(st2.nextToken());
|
139 |
orderSuccessUrlList.add(st2.nextToken());
|
| 137 |
}
|
140 |
}
|
| 138 |
|
- |
|
| - |
|
141 |
orderSuccessUrlList.add("paytm.com/shop/summary");
|
| 139 |
if(isInternetOn()) {
|
142 |
if(isInternetOn()) {
|
| 140 |
if(orderDetails.countTotalRecords()>0){
|
143 |
if(orderDetails.countTotalRecords()>0){
|
| 141 |
sendQueuedResponse();
|
144 |
sendQueuedResponse();
|
| 142 |
}
|
145 |
}
|
| 143 |
type1 = userData.getString("type",null);
|
146 |
type1 = userData.getString("type",null);
|
| Line 184... |
Line 187... |
| 184 |
CookieSyncManager.createInstance(getActivity());
|
187 |
CookieSyncManager.createInstance(getActivity());
|
| 185 |
CookieManager cookieManager1 = CookieManager.getInstance();
|
188 |
CookieManager cookieManager1 = CookieManager.getInstance();
|
| 186 |
cookieManager1.setCookie(url, "token=" + userData.getString("token", ""));
|
189 |
cookieManager1.setCookie(url, "token=" + userData.getString("token", ""));
|
| 187 |
cookieManager1.setCookie(url, "walletAuthentication=true");
|
190 |
cookieManager1.setCookie(url, "walletAuthentication=true");
|
| 188 |
cookieManager1.setCookie(url, "shopcluesActive=true");
|
191 |
cookieManager1.setCookie(url, "shopcluesActive=true");
|
| - |
|
192 |
cookieManager1.setCookie(url, "paytmActive=true");
|
| - |
|
193 |
}
|
| - |
|
194 |
if(!(userData.getBoolean("paytmLoggedIn",false))){
|
| - |
|
195 |
Log.d("User Not Logged In","User Not logged In");
|
| - |
|
196 |
}else {
|
| - |
|
197 |
if (userData.getString("paytmOrder", "").equalsIgnoreCase("true")) {
|
| - |
|
198 |
long nextFetchTime=userData.getLong("paytmNextFetchTime", 0);
|
| - |
|
199 |
if (nextFetchTime == 0 || nextFetchTime< System.currentTimeMillis()) {
|
| - |
|
200 |
if(isInternetOn()) {
|
| - |
|
201 |
new PaytmOrderURL().execute();
|
| - |
|
202 |
}
|
| - |
|
203 |
} else {
|
| - |
|
204 |
Log.d("Paytm False", "Paytm Time False");
|
| - |
|
205 |
}
|
| - |
|
206 |
} else {
|
| - |
|
207 |
Log.d("Paytm False", "Paytm False No orders");
|
| - |
|
208 |
}
|
| 189 |
}
|
209 |
}
|
| 190 |
webView.loadUrl(url);
|
210 |
webView.loadUrl(url);
|
| 191 |
webView.setWebViewClient(webViewClient);
|
211 |
webView.setWebViewClient(webViewClient);
|
| 192 |
|
212 |
|
| 193 |
}
|
213 |
}
|
| Line 241... |
Line 261... |
| 241 |
|
261 |
|
| 242 |
@Override
|
262 |
@Override
|
| 243 |
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
263 |
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
| 244 |
|
264 |
|
| 245 |
if(url.contains(apiData.getString("wallet.auth","api.profittill.com/special/native/login")) || userData.getString("id","").isEmpty()){
|
265 |
if(url.contains(apiData.getString("wallet.auth","api.profittill.com/special/native/login")) || userData.getString("id","").isEmpty()){
|
| 246 |
//Toast.makeText(getActivity(),apiData.getString("wallet.error", "Error while logging in to the wallet. Please log in again"), Toast.LENGTH_SHORT).show();
|
- |
|
| 247 |
android.webkit.CookieManager cookieManager = android.webkit.CookieManager.getInstance();
|
266 |
android.webkit.CookieManager cookieManager = android.webkit.CookieManager.getInstance();
|
| 248 |
android.webkit.CookieSyncManager.createInstance(getActivity());
|
267 |
android.webkit.CookieSyncManager.createInstance(getActivity());
|
| 249 |
cookieManager.removeAllCookie();
|
268 |
cookieManager.removeAllCookie();
|
| 250 |
AlertDialog alert;
|
269 |
AlertDialog alert;
|
| 251 |
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
270 |
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
| Line 255... |
Line 274... |
| 255 |
try{
|
274 |
try{
|
| 256 |
if (mGoogleApiClient.isConnected()) {
|
275 |
if (mGoogleApiClient.isConnected()) {
|
| 257 |
Plus.AccountApi.clearDefaultAccount(mGoogleApiClient);
|
276 |
Plus.AccountApi.clearDefaultAccount(mGoogleApiClient);
|
| 258 |
mGoogleApiClient.disconnect();
|
277 |
mGoogleApiClient.disconnect();
|
| 259 |
mGoogleApiClient.connect();
|
278 |
mGoogleApiClient.connect();
|
| 260 |
/* userDataEditor.clear().commit();
|
- |
|
| 261 |
startActivity(new Intent(getActivity(), LoginActivity.class));*/
|
- |
|
| 262 |
redirectPage(alert);
|
279 |
redirectPage(alert);
|
| 263 |
}
|
280 |
}
|
| 264 |
else if(Session.getActiveSession() != null){
|
281 |
else if(Session.getActiveSession() != null){
|
| 265 |
Session.getActiveSession().closeAndClearTokenInformation();
|
282 |
Session.getActiveSession().closeAndClearTokenInformation();
|
| 266 |
Session.setActiveSession(null);
|
283 |
Session.setActiveSession(null);
|
| 267 |
/*userDataEditor.clear().commit();
|
- |
|
| 268 |
startActivity(new Intent(getActivity(), LoginActivity.class));*/
|
- |
|
| 269 |
redirectPage(alert);
|
284 |
redirectPage(alert);
|
| 270 |
}
|
285 |
}
|
| 271 |
else{
|
286 |
else{
|
| 272 |
if(!mGoogleApiClient.isConnected() || Session.getActiveSession()==null){
|
287 |
if(!mGoogleApiClient.isConnected() || Session.getActiveSession()==null){
|
| 273 |
/*userDataEditor.clear().commit();
|
- |
|
| 274 |
startActivity(new Intent(getActivity(), LoginActivity.class));*/
|
- |
|
| 275 |
redirectPage(alert);
|
288 |
redirectPage(alert);
|
| 276 |
}
|
289 |
}
|
| 277 |
}
|
290 |
}
|
| 278 |
}catch (Exception e){
|
291 |
}catch (Exception e){
|
| 279 |
redirectPage(alert);
|
292 |
redirectPage(alert);
|
| 280 |
/* userDataEditor.clear().commit();
|
- |
|
| 281 |
startActivity(new Intent(getActivity(), LoginActivity.class));*/
|
- |
|
| 282 |
}
|
293 |
}
|
| 283 |
return true;
|
294 |
return true;
|
| 284 |
}
|
295 |
}
|
| 285 |
if(url.contains("com.saholic.profittill")){
|
296 |
if(url.contains("com.saholic.profittill")){
|
| 286 |
Intent intent = null;
|
297 |
Intent intent = null;
|
| Line 318... |
Line 329... |
| 318 |
CookieSyncManager.createInstance(getActivity());
|
329 |
CookieSyncManager.createInstance(getActivity());
|
| 319 |
CookieManager cookieManager = CookieManager.getInstance();
|
330 |
CookieManager cookieManager = CookieManager.getInstance();
|
| 320 |
cookieManager.setCookie(url, "token=" + userData.getString("token", ""));
|
331 |
cookieManager.setCookie(url, "token=" + userData.getString("token", ""));
|
| 321 |
cookieManager.setCookie(url, "walletAuthentication=true");
|
332 |
cookieManager.setCookie(url, "walletAuthentication=true");
|
| 322 |
cookieManager.setCookie(url, "shopcluesActive=true");
|
333 |
cookieManager.setCookie(url, "shopcluesActive=true");
|
| - |
|
334 |
cookieManager.setCookie(url, "paytmActive=true");
|
| 323 |
}
|
335 |
}
|
| 324 |
if(url.contains("dl.flipkart.com/dl/")){
|
336 |
if(url.contains("dl.flipkart.com/dl/")){
|
| 325 |
flipkartUrl=url;
|
337 |
flipkartUrl=url;
|
| 326 |
|
338 |
|
| 327 |
if(flipkartData.getInt("showagainflag",0)<3) {
|
339 |
if(flipkartData.getInt("showagainflag",0)<3) {
|
| Line 427... |
Line 439... |
| 427 |
if (url.contains(apiData.getString("mobile.website.url", null)) || url.equalsIgnoreCase("http://api.profittill.com/categorydeals")) {
|
439 |
if (url.contains(apiData.getString("mobile.website.url", null)) || url.equalsIgnoreCase("http://api.profittill.com/categorydeals")) {
|
| 428 |
pd = new ProgressDialog(getActivity());
|
440 |
pd = new ProgressDialog(getActivity());
|
| 429 |
pd.setTitle("Please wait");
|
441 |
pd.setTitle("Please wait");
|
| 430 |
pd.setMessage("Loading..");
|
442 |
pd.setMessage("Loading..");
|
| 431 |
pd.show();
|
443 |
pd.show();
|
| 432 |
/*parseCookieString(CookieManager.getInstance().getCookie(".saholic.com"),".saholic.com");
|
- |
|
| 433 |
Log.d("Cookie","Cookie Overloaded");
|
- |
|
| 434 |
parseCookieString(CookieManager.getInstance().getCookie("m.saholic.com"));*/
|
- |
|
| 435 |
}
|
444 |
}
|
| 436 |
//getDisplayActionBar(url);
|
445 |
//getDisplayActionBar(url);
|
| 437 |
getOrderSuccessUrlConfirmation(url);
|
446 |
getOrderSuccessUrlConfirmation(url);
|
| 438 |
if (displayActionBar) {
|
447 |
if (displayActionBar) {
|
| 439 |
pd1 = new ProgressDialog(getActivity());
|
448 |
pd1 = new ProgressDialog(getActivity());
|
| Line 459... |
Line 468... |
| 459 |
storeSubTagId(url);
|
468 |
storeSubTagId(url);
|
| 460 |
}
|
469 |
}
|
| 461 |
} catch (Exception e) {
|
470 |
} catch (Exception e) {
|
| 462 |
e.printStackTrace();
|
471 |
e.printStackTrace();
|
| 463 |
}
|
472 |
}
|
| 464 |
// }
|
- |
|
| 465 |
}
|
473 |
}
|
| 466 |
|
474 |
|
| 467 |
|
- |
|
| 468 |
|
- |
|
| 469 |
@Override
|
475 |
@Override
|
| 470 |
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
|
476 |
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
|
| 471 |
super.onReceivedError(view, errorCode, description, failingUrl);
|
477 |
super.onReceivedError(view, errorCode, description, failingUrl);
|
| 472 |
Log.d("ErrorCode " ,"Error Code"+errorCode);
|
- |
|
| 473 |
Log.d("Errordescription " ,"description"+description);
|
- |
|
| 474 |
SearchFragment nextFrag= new SearchFragment();
|
478 |
SearchFragment nextFrag= new SearchFragment();
|
| 475 |
Bundle args = new Bundle();
|
479 |
Bundle args = new Bundle();
|
| 476 |
args.putString("finishingurl",failingUrl);
|
480 |
args.putString("finishingurl",failingUrl);
|
| 477 |
nextFrag.setArguments(args);
|
481 |
nextFrag.setArguments(args);
|
| 478 |
getActivity().getFragmentManager().beginTransaction()
|
482 |
getActivity().getFragmentManager().beginTransaction()
|
| Line 493... |
Line 497... |
| 493 |
snapdealPageLoad=0;
|
497 |
snapdealPageLoad=0;
|
| 494 |
}
|
498 |
}
|
| 495 |
if(pd2!=null){
|
499 |
if(pd2!=null){
|
| 496 |
pd2.dismiss();
|
500 |
pd2.dismiss();
|
| 497 |
}
|
501 |
}
|
| 498 |
/*if(Uri.parse(url).getHost().contains("snapdeal") && url.contains("supc")){
|
502 |
if(Uri.parse(url).getHost().equalsIgnoreCase("paytm.com")){
|
| 499 |
Log.d("In page Finished","In page finished" + snapdealJavascriptUrl);
|
503 |
view.loadUrl("javascript:try{" +
|
| 500 |
view.loadUrl(snapdealJavascriptUrl);
|
504 |
"var lastUrl=document.URL;" +
|
| - |
|
505 |
"setInterval(function(){var currentUrl=document.URL;" +
|
| - |
|
506 |
"if(currentUrl!=lastUrl){window.HTMLOUT.paytmUrls(currentUrl);lastUrl=currentUrl;}},2000)" +
|
| - |
|
507 |
"}catch(error){Android.onError(error.message);}");
|
| 501 |
}*/
|
508 |
}
|
| 502 |
if(Uri.parse(url).getHost().contains("saholic") && userData.getString("saholic.data","false").equalsIgnoreCase("true")){
|
509 |
if(Uri.parse(url).getHost().contains("saholic") && userData.getString("saholic.data","false").equalsIgnoreCase("true")){
|
| 503 |
saholicUrl=url;
|
510 |
saholicUrl=url;
|
| 504 |
view.loadUrl("javascript:window.HTMLOUT.saholicHTML('<head>'+document.getElementsByTagName('html')[0].innerHTML+'</head>');");
|
511 |
view.loadUrl("javascript:window.HTMLOUT.saholicHTML('<head>'+document.getElementsByTagName('html')[0].innerHTML+'</head>');");
|
| 505 |
}
|
512 |
}
|
| 506 |
if (url.contains(apiData.getString("amazon.tracking.order.url", ""))) {
|
513 |
if (url.contains(apiData.getString("amazon.tracking.order.url", ""))) {
|
| Line 528... |
Line 535... |
| 528 |
amazonWebView = new WebView(webView.getContext());
|
535 |
amazonWebView = new WebView(webView.getContext());
|
| 529 |
amazonWebView.setVisibility(View.GONE);
|
536 |
amazonWebView.setVisibility(View.GONE);
|
| 530 |
amazonWebView.addJavascriptInterface(new amazonInterface(getActivity()), "HTMLOUT");
|
537 |
amazonWebView.addJavascriptInterface(new amazonInterface(getActivity()), "HTMLOUT");
|
| 531 |
amazonWebView.getSettings().setJavaScriptEnabled(true);
|
538 |
amazonWebView.getSettings().setJavaScriptEnabled(true);
|
| 532 |
|
539 |
|
| - |
|
540 |
} else if(url.contains(ProfitTillConstants.PAYTM)) {
|
| - |
|
541 |
PaytmWebViewClient paytmWebViewClient = new PaytmWebViewClient();
|
| - |
|
542 |
pd1.dismiss();
|
| - |
|
543 |
paytmWebView = new WebView(webView.getContext());
|
| - |
|
544 |
paytmWebView.setVisibility(View.GONE);
|
| - |
|
545 |
paytmWebView.addJavascriptInterface(new paytmInterface(getActivity()), "HTMLOUT");
|
| - |
|
546 |
paytmWebView.getSettings().setJavaScriptEnabled(true);
|
| - |
|
547 |
paytmWebView.loadUrl(getPaytmReferer(url));
|
| - |
|
548 |
paytmWebView.setWebViewClient(paytmWebViewClient);
|
| 533 |
} else {
|
549 |
} else {
|
| 534 |
view.loadUrl("javascript:window.HTMLOUT.flipkartHTML('<head>'+document.getElementsByTagName('html')[0].innerHTML+'</head>');");
|
550 |
view.loadUrl("javascript:window.HTMLOUT.flipkartHTML('<head>'+document.getElementsByTagName('html')[0].innerHTML+'</head>');");
|
| 535 |
pd1.dismiss();
|
551 |
pd1.dismiss();
|
| 536 |
}
|
552 |
}
|
| 537 |
}
|
553 |
}
|
| Line 557... |
Line 573... |
| 557 |
if (url.contains("https://www.amazon.in/ap/signin")) {
|
573 |
if (url.contains("https://www.amazon.in/ap/signin")) {
|
| 558 |
if (!FLAG) {
|
574 |
if (!FLAG) {
|
| 559 |
FLAG = true;
|
575 |
FLAG = true;
|
| 560 |
}
|
576 |
}
|
| 561 |
} else if (FLAG) {
|
577 |
} else if (FLAG) {
|
| 562 |
//Toast.makeText(getActivity(),"True",Toast.LENGTH_SHORT).show();
|
- |
|
| 563 |
amazonOrderHistoryWebView = new WebView(webView.getContext());
|
578 |
amazonOrderHistoryWebView = new WebView(webView.getContext());
|
| 564 |
amazonOrderHistoryWebView.setVisibility(View.GONE);
|
579 |
amazonOrderHistoryWebView.setVisibility(View.GONE);
|
| 565 |
amazonOrderHistoryWebView.getSettings().setUserAgentString("Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.99 Safari/537.36");
|
580 |
amazonOrderHistoryWebView.getSettings().setUserAgentString("Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.99 Safari/537.36");
|
| 566 |
amazonOrderHistoryWebView.getSettings().setJavaScriptEnabled(true);
|
581 |
amazonOrderHistoryWebView.getSettings().setJavaScriptEnabled(true);
|
| 567 |
amazonOrderHistoryWebView.addJavascriptInterface(new amazonInterface(getActivity()), "HTMLOUT");
|
582 |
amazonOrderHistoryWebView.addJavascriptInterface(new amazonInterface(getActivity()), "HTMLOUT");
|
| Line 717... |
Line 732... |
| 717 |
|
732 |
|
| 718 |
}
|
733 |
}
|
| 719 |
|
734 |
|
| 720 |
public void storeSubTagId(String url){
|
735 |
public void storeSubTagId(String url){
|
| 721 |
|
736 |
|
| 722 |
if(url.contains(apiData.getString("store.subtag.snapdeal",null)) || url.contains(apiData.getString("store.subtag.flipkart",null)) || url.contains(apiData.getString("store.subtag.amazon",null)) || url.contains(apiData.getString("store.subtag.shopclues","UID")))
|
737 |
if(url.contains(apiData.getString("store.subtag.snapdeal",null)) || url.contains(apiData.getString("store.subtag.flipkart",null)) || url.contains(apiData.getString("store.subtag.amazon",null)) || url.contains(apiData.getString("store.subtag.shopclues","UID")) || url.contains(apiData.getString("store.subtag.paytm","utm_term")))
|
| 723 |
{
|
738 |
{
|
| 724 |
StringTokenizer st2 = new StringTokenizer(url, "&");
|
739 |
StringTokenizer st2 = new StringTokenizer(url, "&");
|
| 725 |
while (st2.hasMoreElements()) {
|
740 |
while (st2.hasMoreElements()) {
|
| 726 |
String token=st2.nextToken();
|
741 |
String token=st2.nextToken();
|
| 727 |
if(token.contains(apiData.getString("store.subtag.snapdeal",null)) || token.contains(apiData.getString("store.subtag.flipkart",null)) || token.contains(apiData.getString("store.subtag.amazon",null)) || token.contains(apiData.getString("store.subtag.shopclues","UID")) ){
|
742 |
if(token.contains(apiData.getString("store.subtag.snapdeal",null)) || token.contains(apiData.getString("store.subtag.flipkart",null)) || token.contains(apiData.getString("store.subtag.amazon",null)) || token.contains(apiData.getString("store.subtag.shopclues","UID")) || token.contains(apiData.getString("store.subtag.paytm","utm_term"))){
|
| 728 |
String subtagId=userData.getString("subtag","null");
|
743 |
String subtagId=userData.getString("subtag","null");
|
| 729 |
if(subtagId==null){
|
744 |
if(subtagId==null){
|
| 730 |
userDataEditor.putString("subtag",token.split("=")[1]);
|
745 |
userDataEditor.putString("subtag",token.split("=")[1]);
|
| 731 |
userDataEditor.commit();
|
746 |
userDataEditor.commit();
|
| 732 |
}
|
747 |
}
|
| Line 932... |
Line 947... |
| 932 |
} catch (Exception e) {
|
947 |
} catch (Exception e) {
|
| 933 |
|
948 |
|
| 934 |
}
|
949 |
}
|
| 935 |
new checkGateWayProblem().execute(saholicUrl);
|
950 |
new checkGateWayProblem().execute(saholicUrl);
|
| 936 |
}
|
951 |
}
|
| - |
|
952 |
|
| - |
|
953 |
@JavascriptInterface
|
| - |
|
954 |
public void paytmUrls(String html){
|
| - |
|
955 |
try{
|
| - |
|
956 |
obj = new JSONObject();
|
| - |
|
957 |
JSONObject j = new JSONObject();
|
| - |
|
958 |
JSONArray jsArray = new JSONArray();
|
| - |
|
959 |
Log.d("URL in page start","Url in page start " + html);
|
| - |
|
960 |
j.put("url", html);
|
| - |
|
961 |
j.put("user_id", userData.getString("id", null));
|
| - |
|
962 |
j.put("time", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
| - |
|
963 |
jsArray.put(j);
|
| - |
|
964 |
obj.put("pushdata", jsArray);
|
| - |
|
965 |
new pushData().execute();
|
| - |
|
966 |
}catch (Exception e){
|
| - |
|
967 |
e.printStackTrace();
|
| - |
|
968 |
}
|
| - |
|
969 |
if (html.contains("https://paytm.com/login")) {
|
| - |
|
970 |
if (!PAYTMFLAG) {
|
| - |
|
971 |
PAYTMFLAG = true;
|
| - |
|
972 |
userDataEditor.putString("paytmOrder","true").commit();
|
| - |
|
973 |
userDataEditor.putBoolean("paytmLoggedIn",true).commit();
|
| - |
|
974 |
}
|
| - |
|
975 |
} else if (PAYTMFLAG) {
|
| - |
|
976 |
new PaytmOrderURL().execute();
|
| - |
|
977 |
PAYTMFLAG=false;
|
| - |
|
978 |
}
|
| - |
|
979 |
}
|
| 937 |
}
|
980 |
}
|
| 938 |
|
981 |
|
| 939 |
|
982 |
|
| 940 |
|
983 |
|
| 941 |
|
984 |
|
| Line 1151... |
Line 1194... |
| 1151 |
new FetchOrderURLS().execute();
|
1194 |
new FetchOrderURLS().execute();
|
| 1152 |
}
|
1195 |
}
|
| 1153 |
}
|
1196 |
}
|
| 1154 |
|
1197 |
|
| 1155 |
|
1198 |
|
| 1156 |
/*class PushRawHTML extends AsyncTask<String, Integer, JSONObject> {
|
- |
|
| 1157 |
private StringBuilder sb;
|
- |
|
| 1158 |
|
- |
|
| 1159 |
private HttpResponse req;
|
- |
|
| 1160 |
private InputStream is;
|
- |
|
| 1161 |
|
- |
|
| 1162 |
@Override
|
- |
|
| 1163 |
protected void onPreExecute() {
|
- |
|
| 1164 |
super.onPreExecute();
|
- |
|
| 1165 |
Log.e("Pre execute", "Pre execute");
|
- |
|
| 1166 |
|
- |
|
| 1167 |
}
|
- |
|
| 1168 |
|
- |
|
| 1169 |
@Override
|
- |
|
| 1170 |
protected JSONObject doInBackground(String... arg0) {
|
- |
|
| 1171 |
|
- |
|
| 1172 |
try {
|
- |
|
| 1173 |
HttpClient httpclient = new DefaultHttpClient();
|
- |
|
| 1174 |
HttpPost httppost = new HttpPost(apiData.getString("orderpagehtml.push.api",null));
|
- |
|
| 1175 |
nameValuePairsRawHtml.add(new BasicNameValuePair("sub_tag",userData.getString("subtag",null)));
|
- |
|
| 1176 |
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairsRawHtml));
|
- |
|
| 1177 |
HttpResponse response = httpclient.execute(httppost);
|
- |
|
| 1178 |
HttpEntity entity = response.getEntity();
|
- |
|
| 1179 |
JSONObject jObjGmail = new JSONObject(EntityUtils.toString(entity));
|
- |
|
| 1180 |
System.out.println(jObjGmail.toString());
|
- |
|
| 1181 |
Log.e("pass 1", "connection success ");
|
- |
|
| 1182 |
return jObjGmail;
|
- |
|
| 1183 |
|
- |
|
| 1184 |
} catch (Exception e) {
|
- |
|
| 1185 |
Log.e("Fail 1", e.toString());
|
- |
|
| 1186 |
Toast.makeText(getActivity(), "Invalid IP Address", Toast.LENGTH_LONG).show();
|
- |
|
| 1187 |
return null;
|
- |
|
| 1188 |
}
|
- |
|
| 1189 |
|
- |
|
| 1190 |
}
|
- |
|
| 1191 |
|
- |
|
| 1192 |
@Override
|
- |
|
| 1193 |
protected void onPostExecute(JSONObject result) {
|
- |
|
| 1194 |
try {
|
- |
|
| 1195 |
if (result.getString("success").equalsIgnoreCase("true") && result.getString("message").equalsIgnoreCase("HTML_REQUIRED")) {
|
- |
|
| 1196 |
amazonapiSettingsEditor.putString("amazonurl",result.getString("url"));
|
- |
|
| 1197 |
amazonapiSettingsEditor.commit();
|
- |
|
| 1198 |
pushDataInAmazon();
|
- |
|
| 1199 |
}
|
- |
|
| 1200 |
}catch (Exception e){
|
- |
|
| 1201 |
Log.e("Post Execute", e.toString());
|
- |
|
| 1202 |
}
|
- |
|
| 1203 |
|
- |
|
| 1204 |
super.onPostExecute(result);
|
- |
|
| 1205 |
}
|
- |
|
| 1206 |
}*/
|
- |
|
| 1207 |
|
- |
|
| 1208 |
class PushRawHTML extends AsyncTask<List<NameValuePair>, Integer, JSONObject> {
|
1199 |
class PushRawHTML extends AsyncTask<List<NameValuePair>, Integer, JSONObject> {
|
| 1209 |
@Override
|
1200 |
@Override
|
| 1210 |
protected void onPreExecute() {
|
1201 |
protected void onPreExecute() {
|
| 1211 |
super.onPreExecute();
|
1202 |
super.onPreExecute();
|
| 1212 |
}
|
1203 |
}
|
| Line 1521... |
Line 1512... |
| 1521 |
super.onPageFinished(view, url);
|
1512 |
super.onPageFinished(view, url);
|
| 1522 |
view.loadUrl("javascript:window.HTMLOUT.cancelledHistory('<head>'+document.getElementsByTagName('html')[0].innerHTML+'</head>');");
|
1513 |
view.loadUrl("javascript:window.HTMLOUT.cancelledHistory('<head>'+document.getElementsByTagName('html')[0].innerHTML+'</head>');");
|
| 1523 |
}
|
1514 |
}
|
| 1524 |
}
|
1515 |
}
|
| 1525 |
|
1516 |
|
| 1526 |
/*
|
- |
|
| 1527 |
Timer timer;
|
- |
|
| 1528 |
int i=0;
|
- |
|
| 1529 |
public void callAsynchronousTask() {
|
- |
|
| 1530 |
TIMER=false;
|
- |
|
| 1531 |
timer= new Timer();
|
- |
|
| 1532 |
final Handler handler = new Handler();
|
- |
|
| 1533 |
|
- |
|
| 1534 |
TimerTask doAsynchronousTask = new TimerTask() {
|
- |
|
| 1535 |
@Override
|
- |
|
| 1536 |
public void run() {
|
- |
|
| 1537 |
handler.post(new Runnable() {
|
- |
|
| 1538 |
public void run() {
|
- |
|
| 1539 |
try {
|
- |
|
| 1540 |
|
- |
|
| 1541 |
Log.e("Url in cancelled order history data","Timer called " + (i++));
|
- |
|
| 1542 |
fetchOrderDetailsTimer();
|
- |
|
| 1543 |
//Toast.makeText(getActivity(),"Timer",Toast.LENGTH_SHORT).show();
|
- |
|
| 1544 |
} catch (Exception e) {
|
- |
|
| 1545 |
}
|
- |
|
| 1546 |
}
|
- |
|
| 1547 |
});
|
- |
|
| 1548 |
}
|
- |
|
| 1549 |
};
|
- |
|
| 1550 |
timer.schedule(doAsynchronousTask, 60000, 10800000); //execute in every 10800000 ms (3 hours)
|
- |
|
| 1551 |
}
|
- |
|
| 1552 |
*/
|
- |
|
| 1553 |
|
- |
|
| 1554 |
|
- |
|
| 1555 |
public final boolean isInternetOn() {
|
1517 |
public final boolean isInternetOn() {
|
| 1556 |
|
1518 |
|
| 1557 |
ConnectivityManager connec =
|
1519 |
ConnectivityManager connec =
|
| 1558 |
(ConnectivityManager)getActivity().getSystemService(getActivity().getBaseContext().CONNECTIVITY_SERVICE);
|
1520 |
(ConnectivityManager)getActivity().getSystemService(getActivity().getBaseContext().CONNECTIVITY_SERVICE);
|
| 1559 |
|
1521 |
|
| Line 1634... |
Line 1596... |
| 1634 |
}
|
1596 |
}
|
| 1635 |
Log.e("data","data FetchOrderURLS " + result);
|
1597 |
Log.e("data","data FetchOrderURLS " + result);
|
| 1636 |
}
|
1598 |
}
|
| 1637 |
}
|
1599 |
}
|
| 1638 |
|
1600 |
|
| 1639 |
/*public void clearCookies(String domain) {
|
- |
|
| 1640 |
DefaultHttpClient httpClient=new DefaultHttpClient();
|
- |
|
| 1641 |
Cookie cookie = null;
|
- |
|
| 1642 |
|
- |
|
| 1643 |
List<Cookie> cookies1 = httpClient.getCookieStore().getCookies();
|
- |
|
| 1644 |
for (int i = 0; i < cookies1.size(); i++) {
|
- |
|
| 1645 |
cookie = cookies1.get(i);
|
- |
|
| 1646 |
}
|
- |
|
| 1647 |
Cookie sessionCookie = cookie;
|
- |
|
| 1648 |
CookieSyncManager.createInstance(getActivity());
|
- |
|
| 1649 |
CookieManager cookieManager1 = CookieManager.getInstance();
|
- |
|
| 1650 |
Log.d("Cookie ","Session Cookie " + sessionCookie);
|
- |
|
| 1651 |
if (sessionCookie != null) {
|
- |
|
| 1652 |
|
- |
|
| 1653 |
String cookieString = sessionCookie.getName() + "=" + sessionCookie.getValue() + "; domain=" + sessionCookie.getDomain();
|
- |
|
| 1654 |
Log.d("Cookie ","Session Cookie " + cookieString);
|
- |
|
| 1655 |
cookieManager1.setCookie(domain, cookieString);
|
- |
|
| 1656 |
CookieSyncManager.getInstance().sync();
|
- |
|
| 1657 |
}
|
- |
|
| 1658 |
}*/
|
- |
|
| 1659 |
|
- |
|
| 1660 |
/* public List<Cookie> parseCookieString(String cookies) {
|
- |
|
| 1661 |
List<Cookie> cookieList = new ArrayList<Cookie>();
|
- |
|
| 1662 |
Pattern cookiePattern = Pattern.compile("([^=]+)=([^\\;]*);?\\s?");
|
- |
|
| 1663 |
Matcher matcher = cookiePattern.matcher(cookies);
|
- |
|
| 1664 |
while (matcher.find()) {
|
- |
|
| 1665 |
int groupCount = matcher.groupCount();
|
- |
|
| 1666 |
System.out.println("matched: " + matcher.group(0));
|
- |
|
| 1667 |
for (int groupIndex = 0; groupIndex <= groupCount; ++groupIndex) {
|
- |
|
| 1668 |
System.out.println("group[" + groupIndex + "]=" + matcher.group(groupIndex));
|
- |
|
| 1669 |
}
|
- |
|
| 1670 |
String cookieKey = matcher.group(1);
|
- |
|
| 1671 |
String cookieValue = matcher.group(2);
|
- |
|
| 1672 |
Log.d("Key","Cookie Key"+cookieKey);
|
- |
|
| 1673 |
Log.d("Value","Cookie value"+cookieValue);
|
- |
|
| 1674 |
android.webkit.CookieManager.getInstance().setCookie("m.saholic.com", cookieKey+"=");
|
- |
|
| 1675 |
Cookie cookie = new BasicClientCookie(cookieKey, cookieValue);
|
- |
|
| 1676 |
cookieList.add(cookie);
|
- |
|
| 1677 |
}
|
- |
|
| 1678 |
return cookieList;
|
- |
|
| 1679 |
}*/
|
- |
|
| 1680 |
/*
|
- |
|
| 1681 |
public List<Cookie> parseCookieString(String cookies,String domain) {
|
- |
|
| 1682 |
List<Cookie> cookieList = new ArrayList<Cookie>();
|
- |
|
| 1683 |
Pattern cookiePattern = Pattern.compile("([^=]+)=([^\\;]*);?\\s?");
|
- |
|
| 1684 |
Matcher matcher = cookiePattern.matcher(cookies);
|
- |
|
| 1685 |
while (matcher.find()) {
|
- |
|
| 1686 |
int groupCount = matcher.groupCount();
|
- |
|
| 1687 |
System.out.println("matched: " + matcher.group(0));
|
- |
|
| 1688 |
for (int groupIndex = 0; groupIndex <= groupCount; ++groupIndex) {
|
- |
|
| 1689 |
System.out.println("group[" + groupIndex + "]=" + matcher.group(groupIndex));
|
- |
|
| 1690 |
}
|
- |
|
| 1691 |
String cookieKey = matcher.group(1);
|
- |
|
| 1692 |
String cookieValue = matcher.group(2);
|
- |
|
| 1693 |
Log.d("Key","Cookie Key"+cookieKey);
|
- |
|
| 1694 |
Log.d("Value","Cookie value"+cookieValue);
|
- |
|
| 1695 |
android.webkit.CookieManager.getInstance().setCookie(domain, cookieKey+"=");
|
- |
|
| 1696 |
Cookie cookie = new BasicClientCookie(cookieKey, cookieValue);
|
- |
|
| 1697 |
cookieList.add(cookie);
|
- |
|
| 1698 |
}
|
- |
|
| 1699 |
return cookieList;
|
- |
|
| 1700 |
}
|
- |
|
| 1701 |
*/
|
- |
|
| 1702 |
|
1601 |
|
| 1703 |
class checkGateWayProblem extends AsyncTask<String, Integer, String> {
|
1602 |
class checkGateWayProblem extends AsyncTask<String, Integer, String> {
|
| 1704 |
|
- |
|
| 1705 |
// JSONObject jobj1;
|
- |
|
| 1706 |
|
- |
|
| 1707 |
@Override
|
1603 |
@Override
|
| 1708 |
protected void onPreExecute() {
|
1604 |
protected void onPreExecute() {
|
| 1709 |
super.onPreExecute();
|
1605 |
super.onPreExecute();
|
| 1710 |
}
|
1606 |
}
|
| 1711 |
|
1607 |
|
| 1712 |
@Override
|
1608 |
@Override
|
| 1713 |
protected String doInBackground(String... arg0) {
|
1609 |
protected String doInBackground(String... arg0) {
|
| 1714 |
HttpClient httpclient = new DefaultHttpClient();
|
1610 |
HttpClient httpclient = new DefaultHttpClient();
|
| 1715 |
try {
|
1611 |
try {
|
| 1716 |
//jobj1 = new JSONObject();
|
- |
|
| 1717 |
HttpPost httppost = new HttpPost(arg0[0]);
|
1612 |
HttpPost httppost = new HttpPost(arg0[0]);
|
| 1718 |
final String basicAuth = "Basic " + Base64.encodeToString("dtr:dtr18Feb2015".getBytes(), Base64.NO_WRAP);
|
1613 |
final String basicAuth = "Basic " + Base64.encodeToString("dtr:dtr18Feb2015".getBytes(), Base64.NO_WRAP);
|
| 1719 |
httppost.setHeader("Authorization", basicAuth);
|
1614 |
httppost.setHeader("Authorization", basicAuth);
|
| 1720 |
HttpResponse response = httpclient.execute(httppost);
|
1615 |
HttpResponse response = httpclient.execute(httppost);
|
| 1721 |
int status = response.getStatusLine().getStatusCode();
|
1616 |
int status = response.getStatusLine().getStatusCode();
|
| Line 1790... |
Line 1685... |
| 1790 |
protected void onPostExecute(String result) {
|
1685 |
protected void onPostExecute(String result) {
|
| 1791 |
super.onPostExecute(result);
|
1686 |
super.onPostExecute(result);
|
| 1792 |
}
|
1687 |
}
|
| 1793 |
}
|
1688 |
}
|
| 1794 |
|
1689 |
|
| - |
|
1690 |
public void redirectPage(final AlertDialog builder){
|
| - |
|
1691 |
Handler h =new Handler();
|
| - |
|
1692 |
h.postDelayed(new Runnable() {
|
| 1795 |
/* @Override
|
1693 |
@Override
|
| 1796 |
public void onDestroy() {
|
1694 |
public void run() {
|
| - |
|
1695 |
if(builder!=null){
|
| - |
|
1696 |
builder.dismiss();
|
| - |
|
1697 |
}
|
| 1797 |
Log.d("Deals Home on Destroy","Deals Home");
|
1698 |
userDataEditor.clear().commit();
|
| - |
|
1699 |
startActivity(new Intent(getActivity(), LoginActivity.class));
|
| - |
|
1700 |
}
|
| 1798 |
super.onDestroy();
|
1701 |
},3000);
|
| - |
|
1702 |
|
| 1799 |
}
|
1703 |
}
|
| 1800 |
|
1704 |
|
| - |
|
1705 |
public void sendQueuedResponse(){
|
| - |
|
1706 |
|
| - |
|
1707 |
List<List<NameValuePair>> postDataNameValuePair = new ArrayList<List<NameValuePair>>();
|
| - |
|
1708 |
postDataNameValuePair=orderDetails.readData1();
|
| - |
|
1709 |
for(List<NameValuePair> orderDetail : postDataNameValuePair) {
|
| - |
|
1710 |
orderDetail.add(new BasicNameValuePair("zip", "1"));
|
| - |
|
1711 |
orderDetail.add(new BasicNameValuePair("wifi",UtilityFunctions.checkWifi(getActivity())+""));
|
| - |
|
1712 |
orderDetail.add(new BasicNameValuePair("imeinumber",UtilityFunctions.getImeiNumber(getActivity())));
|
| - |
|
1713 |
orderDetail.add(new BasicNameValuePair("appversion",UtilityFunctions.getAppVersion(getActivity())));
|
| - |
|
1714 |
PushRawHTML pm =new PushRawHTML();
|
| - |
|
1715 |
pm.execute(orderDetail);
|
| - |
|
1716 |
}
|
| - |
|
1717 |
}
|
| - |
|
1718 |
|
| - |
|
1719 |
|
| - |
|
1720 |
class PaytmWebViewClient extends WebViewClient {
|
| 1801 |
@Override
|
1721 |
@Override
|
| - |
|
1722 |
public void onPageStarted(WebView view, String url, Bitmap favicon) {
|
| - |
|
1723 |
super.onPageStarted(view, url, favicon);
|
| - |
|
1724 |
}
|
| - |
|
1725 |
|
| - |
|
1726 |
@Override
|
| 1802 |
public void onDetach() {
|
1727 |
public void onPageFinished(WebView view, String url) {
|
| 1803 |
Log.d("Deals Home on Detach","Deals Home");
|
1728 |
super.onPageFinished(view, url);
|
| - |
|
1729 |
if(url.contains(apiData.getString("paytm.myorders.url","paytm.com/myorders"))){
|
| - |
|
1730 |
view.loadUrl("javascript:window.location='" + getPaytmUrl(url) + "';");
|
| 1804 |
super.onDetach();
|
1731 |
}else {
|
| - |
|
1732 |
view.loadUrl("javascript:window.HTMLOUT.showHTML(document.getElementsByTagName('html')[0].innerHTML);");
|
| - |
|
1733 |
}
|
| - |
|
1734 |
}
|
| 1805 |
}
|
1735 |
}
|
| 1806 |
*/
|
- |
|
| 1807 |
|
1736 |
|
| - |
|
1737 |
public String getPaytmUrl(String url){
|
| - |
|
1738 |
String returnUrl=null;
|
| - |
|
1739 |
//Pattern p = Pattern.compile("[/]myorders/(\\d+)");
|
| - |
|
1740 |
Pattern p = Pattern.compile(apiData.getString("paytm.myorders.pattern","[/]myorders/(\\d+)"));
|
| - |
|
1741 |
Matcher m = p.matcher(url);
|
| - |
|
1742 |
if (m.find()) {
|
| - |
|
1743 |
returnUrl=m.group(1);
|
| - |
|
1744 |
}
|
| - |
|
1745 |
System.out.println(apiData.getString("paytm.orderdetail.url","https://paytm.com/shop/orderdetail/") + returnUrl + "?actions=1&channel=web&version=2");
|
| - |
|
1746 |
return apiData.getString("paytm.orderdetail.url","https://paytm.com/shop/orderdetail/")+returnUrl+"?actions=1&channel=web&version=2";
|
| - |
|
1747 |
}
|
| - |
|
1748 |
|
| 1808 |
/*
|
1749 |
|
| - |
|
1750 |
public String getPaytmReferer(String url){
|
| - |
|
1751 |
String returnUrl=null;
|
| - |
|
1752 |
Pattern p = Pattern.compile(apiData.getString("paytm.summary.pattern","[/]summary/(\\d+)"));
|
| - |
|
1753 |
//Pattern p = Pattern.compile("[/]summary/(\\d+)");
|
| - |
|
1754 |
Matcher m = p.matcher(url);
|
| - |
|
1755 |
if (m.find()) {
|
| - |
|
1756 |
returnUrl=m.group(1);
|
| - |
|
1757 |
}
|
| - |
|
1758 |
System.out.println( "In paytm Referer" + apiData.getString("paytm.myorders.url","https://paytm.com/myorders/") +returnUrl);
|
| - |
|
1759 |
return apiData.getString("paytm.myorders.url","https://paytm.com/myorders/")+returnUrl;
|
| - |
|
1760 |
}
|
| - |
|
1761 |
|
| - |
|
1762 |
|
| 1809 |
class SnapdealSUPCCall extends AsyncTask<String, Integer, String> {
|
1763 |
class PaytmOrderURL extends AsyncTask<String, Integer, JSONObject> {
|
| 1810 |
|
1764 |
|
| 1811 |
@Override
|
1765 |
@Override
|
| 1812 |
protected void onPreExecute() {
|
1766 |
protected void onPreExecute() {
|
| 1813 |
Log.d("In Supc ","In supc Call");
|
- |
|
| 1814 |
super.onPreExecute();
|
1767 |
super.onPreExecute();
|
| 1815 |
}
|
1768 |
}
|
| 1816 |
|
1769 |
|
| 1817 |
@Override
|
1770 |
@Override
|
| 1818 |
protected String doInBackground(String... arg0) {
|
1771 |
protected JSONObject doInBackground(String... arg0) {
|
| 1819 |
HttpClient httpclient = new DefaultHttpClient();
|
1772 |
HttpClient httpclient = new DefaultHttpClient();
|
| 1820 |
try {
|
1773 |
try {
|
| 1821 |
String url = arg0[0];
|
1774 |
String fetchUrl = apiData.getString("amazon.order.tracking.get.url", null) + "?user_id=" + userData.getString("id", "") + "&store_id=" + UtilityFunctions.getNewStoreId(UtilityFunctions.generateStoreMap(apiData.getString("stores.code","")),"paytm");
|
| 1822 |
String supcUrl = apiData.getString("snapdeal.supc","");
|
1775 |
HttpGet httppost = new HttpGet(fetchUrl);
|
| 1823 |
HttpGet httppost = new HttpGet(supcUrl + Base64.encodeToString(url.getBytes(),Base64.NO_WRAP));
|
- |
|
| 1824 |
httppost.setHeader("Authorization", ProfitTillConstants.BASIC_AUTH);
|
1776 |
httppost.setHeader("Authorization", ProfitTillConstants.BASIC_AUTH);
|
| 1825 |
HttpResponse response = httpclient.execute(httppost);
|
1777 |
HttpResponse response = httpclient.execute(httppost);
|
| 1826 |
HttpEntity entity = response.getEntity();
|
1778 |
HttpEntity entity = response.getEntity();
|
| 1827 |
int status = response.getStatusLine().getStatusCode();
|
1779 |
int status = response.getStatusLine().getStatusCode();
|
| 1828 |
if (status == 200) {
|
- |
|
| 1829 |
System.out.println("ResponseCode While fetching URL: " + status + " is ");
|
- |
|
| 1830 |
} else {
|
- |
|
| 1831 |
Log.d("ResponseCode", status + "");
|
- |
|
| 1832 |
System.out.println(" NOT Transfered");
|
- |
|
| 1833 |
}
|
- |
|
| 1834 |
|
1780 |
|
| 1835 |
String jObjGmail = EntityUtils.toString(entity);
|
1781 |
JSONObject jObjGmail = new JSONObject(EntityUtils.toString(entity));
|
| 1836 |
System.out.println(jObjGmail);
|
- |
|
| 1837 |
return jObjGmail;
|
1782 |
return jObjGmail;
|
| 1838 |
|
- |
|
| - |
|
1783 |
} catch (JSONException e) {
|
| - |
|
1784 |
return null;
|
| 1839 |
} catch (ClientProtocolException e) {
|
1785 |
} catch (ClientProtocolException e) {
|
| 1840 |
Log.e("data FetchOrderURLS ", "data FetchOrderURLS " + e.getMessage());
|
- |
|
| 1841 |
return null;
|
1786 |
return null;
|
| 1842 |
} catch (IOException e) {
|
1787 |
} catch (IOException e) {
|
| 1843 |
Log.e("data FetchOrderURLS ", "data FetchOrderURLS " + e.getMessage());
|
- |
|
| 1844 |
return null;
|
1788 |
e.printStackTrace();
|
| 1845 |
} catch (Exception e) {
|
- |
|
| 1846 |
Log.e("data FetchOrderURLS ", "data FetchOrderURLS " + e.getMessage());
|
- |
|
| 1847 |
return null;
|
1789 |
return null;
|
| 1848 |
}
|
1790 |
}
|
| 1849 |
}
|
1791 |
}
|
| 1850 |
|
1792 |
|
| 1851 |
@Override
|
1793 |
@Override
|
| 1852 |
protected void onPostExecute(String result) {
|
1794 |
protected void onPostExecute(JSONObject result) {
|
| 1853 |
super.onPostExecute(result);
|
1795 |
super.onPostExecute(result);
|
| - |
|
1796 |
try {
|
| 1854 |
snapdealJavascriptUrl=result;
|
1797 |
if (result != null) {
|
| - |
|
1798 |
if (result.length() == 0) {
|
| - |
|
1799 |
userDataEditor.putString("paytmOrder", "false").commit();
|
| - |
|
1800 |
} else {
|
| 1855 |
Log.d("In Supc ","In supc Call post execute " + result);
|
1801 |
JSONArray js = result.getJSONArray("result");
|
| - |
|
1802 |
if(js.length()!=0) {
|
| - |
|
1803 |
strPaytmUrls = new ArrayList<>();
|
| - |
|
1804 |
strPaytmReferer = new ArrayList<>();
|
| - |
|
1805 |
for (int i = 0; i < js.length(); i++) {
|
| - |
|
1806 |
JSONObject paytmURLRef=js.getJSONObject(i);
|
| - |
|
1807 |
String url = paytmURLRef.getString("url");
|
| - |
|
1808 |
String referer = paytmURLRef.getString("referer");
|
| - |
|
1809 |
strPaytmUrls.add(url);
|
| - |
|
1810 |
strPaytmReferer.add(referer);
|
| - |
|
1811 |
}
|
| - |
|
1812 |
paytmOrderTracking(strPaytmUrls.get(0),strPaytmReferer.get(0));
|
| - |
|
1813 |
}else{
|
| - |
|
1814 |
userDataEditor.putString("paytmOrder", "false").commit();
|
| - |
|
1815 |
}
|
| - |
|
1816 |
}
|
| - |
|
1817 |
}
|
| - |
|
1818 |
}catch (Exception e){
|
| - |
|
1819 |
e.printStackTrace();
|
| - |
|
1820 |
}
|
| - |
|
1821 |
|
| 1856 |
}
|
1822 |
}
|
| 1857 |
}
|
1823 |
}
|
| - |
|
1824 |
|
| 1858 |
*/
|
1825 |
|
| 1859 |
public void redirectPage(final AlertDialog builder){
|
1826 |
class PaytmOrderCreation extends AsyncTask<List<NameValuePair>, Integer, JSONObject> {
|
| - |
|
1827 |
|
| - |
|
1828 |
@Override
|
| 1860 |
Handler h =new Handler();
|
1829 |
protected void onPreExecute() {
|
| 1861 |
h.postDelayed(new Runnable() {
|
1830 |
super.onPreExecute();
|
| - |
|
1831 |
}
|
| - |
|
1832 |
|
| 1862 |
@Override
|
1833 |
@Override
|
| - |
|
1834 |
protected JSONObject doInBackground(List<NameValuePair>... orderDetail) {
|
| - |
|
1835 |
|
| - |
|
1836 |
|
| 1863 |
public void run() {
|
1837 |
try {
|
| - |
|
1838 |
HttpClient httpclient = new DefaultHttpClient();
|
| - |
|
1839 |
HttpPost httppost = new HttpPost(apiData.getString("orderpagehtml.push.api", null));
|
| - |
|
1840 |
httppost.setHeader("Authorization", ProfitTillConstants.BASIC_AUTH);
|
| - |
|
1841 |
httppost.setEntity(new UrlEncodedFormEntity(orderDetail[0]));
|
| - |
|
1842 |
HttpResponse response = httpclient.execute(httppost);
|
| - |
|
1843 |
HttpEntity entity = response.getEntity();
|
| - |
|
1844 |
|
| - |
|
1845 |
int status = response.getStatusLine().getStatusCode();
|
| - |
|
1846 |
|
| 1864 |
if(builder!=null){
|
1847 |
if(status == 200){
|
| - |
|
1848 |
NameValuePair y = orderDetail[0].get(2);
|
| - |
|
1849 |
int z =orderDetails.deleteRecord(y.getName(),new String[]{y.getValue()});
|
| 1865 |
builder.dismiss();
|
1850 |
} else {
|
| 1866 |
}
|
1851 |
}
|
| 1867 |
userDataEditor.clear().commit();
|
1852 |
String getJSON = EntityUtils.toString(entity);
|
| - |
|
1853 |
if(getJSON==null){
|
| - |
|
1854 |
return null;
|
| - |
|
1855 |
}else {
|
| 1868 |
startActivity(new Intent(getActivity(), LoginActivity.class));
|
1856 |
JSONObject jObjGmail = new JSONObject(getJSON);
|
| - |
|
1857 |
return jObjGmail;
|
| - |
|
1858 |
}
|
| - |
|
1859 |
} catch (Exception e) {
|
| - |
|
1860 |
return null;
|
| 1869 |
}
|
1861 |
}
|
| 1870 |
},3000);
|
1862 |
}
|
| - |
|
1863 |
|
| - |
|
1864 |
|
| - |
|
1865 |
@Override
|
| - |
|
1866 |
protected void onPostExecute(JSONObject result) {
|
| - |
|
1867 |
if(result==null){
|
| 1871 |
|
1868 |
|
| - |
|
1869 |
}
|
| - |
|
1870 |
else {
|
| - |
|
1871 |
userDataEditor.putString("paytmOrder", "true").commit();
|
| - |
|
1872 |
userDataEditor.putLong("paytmNextFetchTime", System.currentTimeMillis()+ 21600000).commit();
|
| - |
|
1873 |
try {
|
| - |
|
1874 |
if (result.getString("message").equalsIgnoreCase("PROCESSED"))
|
| - |
|
1875 |
orderDetails.deleterecords();
|
| - |
|
1876 |
} catch (Exception e) {
|
| - |
|
1877 |
}
|
| - |
|
1878 |
}
|
| - |
|
1879 |
super.onPostExecute(result);
|
| - |
|
1880 |
}
|
| 1872 |
}
|
1881 |
}
|
| 1873 |
|
1882 |
|
| - |
|
1883 |
public void paytmOrderTracking(List<String> paytmUrls,List<String> paytmReferers){
|
| - |
|
1884 |
for(int i=1;i<paytmReferers.size();i++) {
|
| - |
|
1885 |
PaytmOrderTrackingClient paytmOrderTrackingClient = new PaytmOrderTrackingClient(paytmUrls.get(i));
|
| - |
|
1886 |
paytmWebView = new WebView(webView.getContext());
|
| - |
|
1887 |
paytmWebView.setVisibility(View.GONE);
|
| - |
|
1888 |
paytmWebView.addJavascriptInterface(new paytmInterface(getActivity()), "HTMLOUT");
|
| - |
|
1889 |
paytmWebView.getSettings().setJavaScriptEnabled(true);
|
| - |
|
1890 |
paytmWebView.loadUrl(paytmReferers.get(i));
|
| - |
|
1891 |
paytmWebView.setWebViewClient(paytmOrderTrackingClient);
|
| - |
|
1892 |
}
|
| - |
|
1893 |
userDataEditor.putLong("paytmNextFetchTime",System.currentTimeMillis()+21600000).commit();
|
| - |
|
1894 |
}
|
| - |
|
1895 |
|
| - |
|
1896 |
public void paytmOrderTracking(String paytmUrl,String paytmReferer){
|
| - |
|
1897 |
PaytmOrderTrackingClient paytmOrderTrackingClient = new PaytmOrderTrackingClient(paytmUrl);
|
| - |
|
1898 |
paytmWebView = new WebView(webView.getContext());
|
| - |
|
1899 |
paytmWebView.setVisibility(View.GONE);
|
| - |
|
1900 |
paytmWebView.addJavascriptInterface(new paytmInterface(getActivity()), "HTMLOUT");
|
| - |
|
1901 |
paytmWebView.getSettings().setJavaScriptEnabled(true);
|
| - |
|
1902 |
paytmWebView.loadUrl(paytmReferer);
|
| - |
|
1903 |
paytmWebView.setWebViewClient(paytmOrderTrackingClient);
|
| - |
|
1904 |
userDataEditor.putLong("paytmNextFetchTime",System.currentTimeMillis()+21600000).commit();
|
| - |
|
1905 |
}
|
| - |
|
1906 |
class PaytmOrderTrackingClient extends WebViewClient {
|
| - |
|
1907 |
String paytmUrlAfterReferer;
|
| - |
|
1908 |
public PaytmOrderTrackingClient(String paytmUrl){
|
| 1874 |
public void sendQueuedResponse(){
|
1909 |
paytmUrlAfterReferer=paytmUrl;
|
| - |
|
1910 |
}
|
| - |
|
1911 |
@Override
|
| - |
|
1912 |
public void onPageStarted(WebView view, String url, Bitmap favicon) {
|
| - |
|
1913 |
super.onPageStarted(view, url, favicon);
|
| - |
|
1914 |
}
|
| 1875 |
|
1915 |
|
| 1876 |
List<List<NameValuePair>> postDataNameValuePair = new ArrayList<List<NameValuePair>>();
|
- |
|
| 1877 |
postDataNameValuePair=orderDetails.readData1();
|
1916 |
@Override
|
| 1878 |
for(List<NameValuePair> orderDetail : postDataNameValuePair) {
|
1917 |
public void onPageFinished(WebView view, String url) {
|
| 1879 |
orderDetail.add(new BasicNameValuePair("zip", "1"));
|
1918 |
super.onPageFinished(view, url);
|
| 1880 |
orderDetail.add(new BasicNameValuePair("wifi",UtilityFunctions.checkWifi(getActivity())+""));
|
1919 |
if(url.contains(apiData.getString("paytm.myorders.url","paytm.com/myorders"))){
|
| 1881 |
orderDetail.add(new BasicNameValuePair("imeinumber",UtilityFunctions.getImeiNumber(getActivity())));
|
1920 |
view.loadUrl("javascript:window.location='"+ paytmUrlAfterReferer+ "';");
|
| - |
|
1921 |
}else {
|
| 1882 |
orderDetail.add(new BasicNameValuePair("appversion",UtilityFunctions.getAppVersion(getActivity())));
|
1922 |
view.loadUrl("javascript:window.HTMLOUT.paytmTracking(document.getElementsByTagName('html')[0].innerHTML);");
|
| 1883 |
PushRawHTML pm =new PushRawHTML();
|
- |
|
| 1884 |
pm.execute(orderDetail);
|
1923 |
}
|
| 1885 |
}
|
1924 |
}
|
| 1886 |
}
|
1925 |
}
|
| - |
|
1926 |
List<String> strPaytmUrls,strPaytmReferer;
|
| - |
|
1927 |
int paytmCounter=0;
|
| - |
|
1928 |
|
| - |
|
1929 |
class PaytmPushTrackingUrls extends AsyncTask<List<NameValuePair>, Integer, JSONObject> {
|
| - |
|
1930 |
@Override
|
| - |
|
1931 |
protected void onPreExecute() {
|
| - |
|
1932 |
super.onPreExecute();
|
| - |
|
1933 |
}
|
| - |
|
1934 |
|
| - |
|
1935 |
@Override
|
| - |
|
1936 |
protected JSONObject doInBackground(List<NameValuePair>... pushOrder) {
|
| - |
|
1937 |
|
| - |
|
1938 |
try {
|
| - |
|
1939 |
HttpClient httpclient = new DefaultHttpClient();
|
| 1887 |
}
|
1940 |
String fetchUrl = apiData.getString("amazon.order.tracking.post.url",null)+"?user_id="+ userData.getString("id","")+"&store_id=" + "&store_id=" + UtilityFunctions.getNewStoreId(UtilityFunctions.generateStoreMap(apiData.getString("stores.code","")),"paytm");
|
| - |
|
1941 |
HttpPost httppost = new HttpPost(fetchUrl);
|
| - |
|
1942 |
httppost.setHeader("Authorization", ProfitTillConstants.BASIC_AUTH);
|
| - |
|
1943 |
httppost.setEntity(new UrlEncodedFormEntity(pushOrder[0]));
|
| - |
|
1944 |
HttpResponse response = httpclient.execute(httppost);
|
| - |
|
1945 |
HttpEntity entity = response.getEntity();
|
| - |
|
1946 |
JSONObject jObjGmail = new JSONObject(EntityUtils.toString(entity));
|
| - |
|
1947 |
return jObjGmail;
|
| - |
|
1948 |
} catch (Exception e) {
|
| - |
|
1949 |
return null;
|
| - |
|
1950 |
}
|
| - |
|
1951 |
}
|
| - |
|
1952 |
|
| - |
|
1953 |
@Override
|
| - |
|
1954 |
protected void onPostExecute(JSONObject result) {
|
| - |
|
1955 |
super.onPostExecute(result);
|
| - |
|
1956 |
try {
|
| - |
|
1957 |
if (result == null) {
|
| - |
|
1958 |
|
| - |
|
1959 |
} else if (result.getString("result").equalsIgnoreCase("PARSE_ERROR")) {
|
| - |
|
1960 |
userDataEditor.putBoolean("paytmLoggedIn",false).commit();
|
| - |
|
1961 |
}else{
|
| - |
|
1962 |
paytmOrderTracking(strPaytmUrls,strPaytmReferer);
|
| - |
|
1963 |
}
|
| - |
|
1964 |
}catch(Exception e){
|
| - |
|
1965 |
e.printStackTrace();
|
| - |
|
1966 |
}
|
| - |
|
1967 |
}
|
| - |
|
1968 |
}
|
| - |
|
1969 |
|
| - |
|
1970 |
class paytmInterface {
|
| - |
|
1971 |
|
| - |
|
1972 |
Context mContext;
|
| - |
|
1973 |
|
| - |
|
1974 |
public paytmInterface(Context c) {
|
| - |
|
1975 |
mContext = c;
|
| - |
|
1976 |
}
|
| 1888 |
|
1977 |
|
| - |
|
1978 |
@JavascriptInterface
|
| - |
|
1979 |
public void showHTML(String html) {
|
| - |
|
1980 |
nameValuePairsRawHtml.add(new BasicNameValuePair("rawhtml", UtilityFunctions.compress(html)));
|
| - |
|
1981 |
long x = orderDetails.insertOrderDetails(nameValuePairsRawHtml);
|
| - |
|
1982 |
List<List<NameValuePair>> postDataNameValuePair = new ArrayList<List<NameValuePair>>();
|
| - |
|
1983 |
postDataNameValuePair = orderDetails.readData1();
|
| - |
|
1984 |
for (List<NameValuePair> orderDetail : postDataNameValuePair) {
|
| - |
|
1985 |
orderDetail.add(new BasicNameValuePair("zip", "1"));
|
| - |
|
1986 |
new PaytmOrderCreation().execute(orderDetail);
|
| - |
|
1987 |
}
|
| - |
|
1988 |
}
|
| 1889 |
|
1989 |
|
| 1890 |
//https://www.amazon.in/ap/forgotpassword?suppressSignInRadioButtons=0&openid.pape.max_auth_age=0&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.ns.pape=http%3A%2F%2Fspecs.openid.net%2Fextensions%2Fpape%2F1.0&prevRID=1JZA0HFF0Z954AGQ0HX2&pageId=anywhere_in&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&siteState=IMBMsgs.&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.mode=checkid_setup&openid.assoc_handle=anywhere_in&showRmrMe=1&openid.return_to=https%3A%2F%2Fwww.amazon.in%2Fgp%2Fcheckoutportal%2Fenter-checkout.html%3Fie%3DUTF8%26asin%3DB00GX9XFRM%26buyNow%3D1%26cartCustomerID%3DA36HI1A7IGU0T1%26fromSignIn%3D1%26offeringID%3DJh6%25252F3Ub%25252BpthAXjVfYxwB75kQiqEGByG9y2mMF1g%25252BhlBjgWsDLnX4sroH6dhJsVS9lMBaR%25252FW2m%25252FhYIqNkUAKNs97nPaxfPIbRsqftx5EseYCQWzJ45%25252F%25252BU3bW8p6PLoKGRkCg7s50jNROGKZHzSy3aBXT5iLQ1ALRG%26registryID%3D%26registryItemID%3D%26sessionID%3D276-7977280-3606555
|
1990 |
@JavascriptInterface
|
| - |
|
1991 |
public void paytmTracking(String html) {
|
| - |
|
1992 |
try {
|
| - |
|
1993 |
String url = strPaytmUrls.get(paytmCounter++);
|
| - |
|
1994 |
List<NameValuePair> amazonOrderHistory = new ArrayList<NameValuePair>();
|
| - |
|
1995 |
amazonOrderHistory.add(new BasicNameValuePair("url", url));
|
| - |
|
1996 |
amazonOrderHistory.add(new BasicNameValuePair("html", UtilityFunctions.compress(html)));
|
| - |
|
1997 |
amazonOrderHistory.add(new BasicNameValuePair("zip", "1"));
|
| - |
|
1998 |
if (isInternetOn()) {
|
| - |
|
1999 |
new PaytmPushTrackingUrls().execute(amazonOrderHistory);
|
| - |
|
2000 |
} else {
|
| 1891 |
|
2001 |
|
| - |
|
2002 |
}
|
| - |
|
2003 |
}catch(Exception e){
|
| - |
|
2004 |
e.printStackTrace();
|
| - |
|
2005 |
}
|
| - |
|
2006 |
|
| - |
|
2007 |
}
|
| - |
|
2008 |
}
|
| 1892 |
//https://www.amazon.in/ap/register?suppressSignInRadioButtons=0&openid.pape.max_auth_age=0&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.ns.pape=http%3A%2F%2Fspecs.openid.net%2Fextensions%2Fpape%2F1.0&prevRID=1JZA0HFF0Z954AGQ0HX2&pageId=anywhere_in&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&siteState=IMBMsgs.&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.mode=checkid_setup&openid.assoc_handle=anywhere_in&showRmrMe=1&openid.return_to=https%3A%2F%2Fwww.amazon.in%2Fgp%2Fcheckoutportal%2Fenter-checkout.html%3Fie%3DUTF8%26asin%3DB00GX9XFRM%26buyNow%3D1%26cartCustomerID%3DA36HI1A7IGU0T1%26fromSignIn%3D1%26offeringID%3DJh6%25252F3Ub%25252BpthAXjVfYxwB75kQiqEGByG9y2mMF1g%25252BhlBjgWsDLnX4sroH6dhJsVS9lMBaR%25252FW2m%25252FhYIqNkUAKNs97nPaxfPIbRsqftx5EseYCQWzJ45%25252F%25252BU3bW8p6PLoKGRkCg7s50jNROGKZHzSy3aBXT5iLQ1ALRG%26registryID%3D%26registryItemID%3D%26sessionID%3D276-7977280-3606555
|
2009 |
}
|