Subversion Repositories SmartDukaan

Rev

Rev 13548 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 13548 Rev 13549
Line 92... Line 92...
92
		log.info("postResponse====" + postResponse);
92
		log.info("postResponse====" + postResponse);
93
		JSONObject postMap = null;
93
		JSONObject postMap = null;
94
		try {
94
		try {
95
			postMap = new JSONObject(postResponse);
95
			postMap = new JSONObject(postResponse);
96
		
96
		
97
			log.info("postMap.get(\"status\")=======" + postMap.get("status"));
-
 
98
			if (0 == ((Integer)postMap.get("status")).intValue()) {
97
			if (0 == ((Integer)postMap.get("status")).intValue()) {
99
				log.info("Some error occurred at Payu");
98
				log.info("Some error occurred at Payu");
100
				resultMap.put(ERR_CODE, Errors.CAPTURE_FAILURE.code);
99
				resultMap.put(ERR_CODE, Errors.CAPTURE_FAILURE.code);
101
				resultMap.put(ERROR, (String)postMap.get("msg"));
100
				resultMap.put(ERROR, (String)postMap.get("msg"));
102
			} else if (1 == ((Integer)postMap.get("status")).intValue()){
101
			} else if (1 == ((Integer)postMap.get("status")).intValue()){
103
				System.out.println("in io block"); 
102
				if(!postMap.isNull("txn_update_id")) {
104
				if(!JSONObject.NULL.equals(postMap.get("bank_ref_num"))){ 
-
 
105
					resultMap.put(REF_NO, (String) postMap.get("bank_ref_num"));
103
					resultMap.put("txn_update_id", postMap.optString("txn_update_id"));
106
				}
104
				}
107
				System.out.println("after bankrefnum"); 
-
 
108
				if(postMap.get("txn_update_id")!= null) {
-
 
109
					resultMap.put("txn_update_id", (String)postMap.get("txn_update_id"));
-
 
110
				}
-
 
111
				System.out.println("after txn update"); 
-
 
112
				if(postMap.get("request_id")!=null){
105
				if(!postMap.isNull("request_id")){
113
					resultMap.put("txn_update_id", (String)postMap.get("request_id"));
106
					resultMap.put("txn_update_id", postMap.optString("request_id"));
114
				}
107
				}
115
				System.out.println("after request_id"); 
-
 
116
				resultMap.put("mihpayid", ((Integer)postMap.get("mihpayid")).toString());
108
				resultMap.put("mihpayid", postMap.optString("mihpayid"));
117
				System.out.println("after mihpayid"); 
-
 
118
				resultMap.put("msg", (String)postMap.get("msg"));
109
				resultMap.put("msg", postMap.optString("msg"));
119
			}
110
			}
120
		} catch (JSONException e) {
111
		} catch (JSONException e) {
121
			log.error("Could not Parse json");
112
			log.error("Could not Parse json");
122
			resultMap.put(ERR_CODE, Errors.CAPTURE_FAILURE.code);
113
			resultMap.put(ERR_CODE, Errors.CAPTURE_FAILURE.code);
123
			resultMap.put(ERROR, "Could not parse refund");
114
			resultMap.put(ERROR, "Could not parse refund");
Line 268... Line 259...
268
						context.deserialize(entry.getValue(), Object.class));
259
						context.deserialize(entry.getValue(), Object.class));
269
			return map;
260
			return map;
270
		}
261
		}
271
	}
262
	}
272
	
263
	
273
	public static void main (String arg[]){
264
	public static void main (String arg[]) throws Exception{
274
		String jsonText = "{\"amit\":0, \"babu\":{\"a\":null}, \"Raka\": null}";
265
		String jsonText = "{\"amit\":0, \"babu\":{\"a\":null}, \"Raka\": null}";
275
/*		System.out.println(jsonText);
266
/*		System.out.println(jsonText);
276
		GsonBuilder gsonBuilder = new GsonBuilder();
267
		GsonBuilder gsonBuilder = new GsonBuilder();
277
		gsonBuilder
268
		gsonBuilder
278
				.registerTypeAdapter(Object.class, new NaturalDeserializer());
269
				.registerTypeAdapter(Object.class, new NaturalDeserializer());
Line 281... Line 272...
281
		Map<String, Object> postMap =  gson.fromJson(jsonText, t);
272
		Map<String, Object> postMap =  gson.fromJson(jsonText, t);
282
		Map<String, Object> postMap = (Map<String, Object>) gson.fromJson(
273
		Map<String, Object> postMap = (Map<String, Object>) gson.fromJson(
283
				jsonText, Object.class);
274
				jsonText, Object.class);
284
		System.out.println(postMap);
275
		System.out.println(postMap);
285
		System.out.println(0 == ((Integer)postMap.get("amit")).intValue());*/
276
		System.out.println(0 == ((Integer)postMap.get("amit")).intValue());*/
286
		try {
-
 
287
			String postResponse = "{\"status\":1,\"msg\":\"Refund Request Queued\",\"request_id\":\"172046358\",\"bank_ref_num\":null,\"mihpayid\":251494242,\"error_code\":102}";
277
			String postResponse = "{\"status\":1,\"msg\":\"Refund Request Queued\",\"request_id\":\"172046358\",\"bank_ref_num\":null,\"mihpayid\":251494242,\"error_code\":102}";
288
			JSONObject postMap = new JSONObject(postResponse);
278
			JSONObject postMap = new JSONObject(postResponse);
289
			String a = "";
279
			String a = "";
290
			log.info("postMap.get(\"status\")=======" + postMap.get("status"));
280
			log.info("postMap.get(\"status\")=======" + postMap.get("status"));
291
			if (0 == ((Integer)postMap.get("status")).intValue()) {
281
			if (0 == ((Integer)postMap.get("status")).intValue()) {
292
				log.info("Some error occurred at Payu");
282
				log.info("Some error occurred at Payu");
293
				a= (String)postMap.get("msg");
283
				a= (String)postMap.get("msg");	
294
			} else if (1 == ((Integer)postMap.get("status")).intValue()){
284
			} else if (1 == ((Integer)postMap.get("status")).intValue()){
295
				System.out.println("in io block"); 
285
				System.out.println("in io block"); 
296
				System.out.println(postMap.get("bank_ref_num").getClass());
-
 
297
				if(postMap.get("bank_ref_num")!=null){ 
286
				if(!postMap.isNull("bank_ref_num")){ 
298
					a = (String) postMap.get("bank_ref_num");
287
					a = (String) postMap.get("bank_ref_num");
299
				}
288
				}
300
				System.out.println("after bankrefnum"); 
289
				System.out.println("after bankrefnum"); 
301
				if(postMap.get("txn_update_id")!= null) {
290
				if(!postMap.isNull("txn_update_id")) {
302
					a = (String)postMap.get("txn_update_id");
291
					a = (String)postMap.get("txn_update_id");
303
				}
292
				}
304
				System.out.println("after txn update"); 
293
				System.out.println("after txn update"); 
305
				if(JSONObject.NULL.equals(postMap.get("request_id"))){
294
				if(!JSONObject.NULL.equals(postMap.get("request_id"))){
306
					a = (String)postMap.get("request_id");
295
					a = (String)postMap.get("request_id");
307
				}
296
				}
308
				System.out.println("after request_id"); 
297
				System.out.println("after request_id"); 
309
				((Integer)postMap.get("mihpayid")).toString();
298
				((Integer)postMap.get("mihpayid")).toString();
310
				System.out.println("after mihpayid"); 
299
				System.out.println("after mihpayid"); 
311
				a = (String)postMap.get("msg");
300
				a = (String)postMap.get("msg");
312
			}
301
			}
313
		} catch (JSONException e) {
-
 
314
			System.out.println("in catch");
302
			System.out.println(postMap.optString("mihpayid"));
315
		}
-
 
316
	}
303
	}
317
}
304
}