Subversion Repositories SmartDukaan

Rev

Rev 24893 | Rev 25048 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 24893 Rev 25007
Line 75... Line 75...
75
public class RechargeController {
75
public class RechargeController {
76
 
76
 
77
	private static final Logger log = LoggerFactory.getLogger(RechargeController.class);
77
	private static final Logger log = LoggerFactory.getLogger(RechargeController.class);
78
	private static final String HEADER_X_FORWARDED_FOR = "X-FORWARDED-FOR";
78
	private static final String HEADER_X_FORWARDED_FOR = "X-FORWARDED-FOR";
79
 
79
 
80
	private List<String> blockedRecharge = Arrays.asList();
80
	private List<String> UNBLOCKED_RECHARGE_EMAILS = Arrays.asList("themobileplanet03@gmail.com");
81
	private static final String X_REAL_IP = "X-Real-IP";
81
	private static final String X_REAL_IP = "X-Real-IP";
82
	@Value("${oxigen.recharge.transaction.url}")
82
	@Value("${oxigen.recharge.transaction.url}")
83
	private String oxigenRechargeTransactionUrl;
83
	private String oxigenRechargeTransactionUrl;
84
 
84
 
85
	@Value("${oxigen.recharge.enquiry.url}")
85
	@Value("${oxigen.recharge.enquiry.url}")
Line 317... Line 317...
317
 
317
 
318
	public ResponseEntity<?> createRechargeDown(HttpServletRequest request,
318
	public ResponseEntity<?> createRechargeDown(HttpServletRequest request,
319
			@RequestBody CreateRechargeRequest createRechargeRequest) throws ProfitMandiBusinessException {
319
			@RequestBody CreateRechargeRequest createRechargeRequest) throws ProfitMandiBusinessException {
320
 
320
 
321
		int userId = (int) request.getAttribute(ProfitMandiConstants.USER_ID);
321
		int userId = (int) request.getAttribute(ProfitMandiConstants.USER_ID);
-
 
322
		User user = null;
-
 
323
		try {
322
		int retailerId = userAccountRepository.selectRetailerIdByUserId(userId);
324
			user = userRepository.selectById(userId);
-
 
325
			if (UNBLOCKED_RECHARGE_EMAILS.contains(user.getEmailId())) {
-
 
326
				return createRecharge(request, createRechargeRequest);
-
 
327
			}
-
 
328
		} catch (ProfitMandiBusinessException e) {
-
 
329
			log.error("Unable to get user", e);
-
 
330
		}
323
 
331
		
-
 
332
		
324
		CreateRechargeResponse crr = new CreateRechargeResponse();
333
		CreateRechargeResponse crr = new CreateRechargeResponse();
325
		String ipAddress = remoteAddr(request);
334
		String ipAddress = remoteAddr(request);
326
		log.info("IP Address is {}", ipAddress);
335
		log.info("IP Address is {}", ipAddress);
327
 
336
 
328
		crr.setResult(true);
337
		crr.setResult(true);
Line 333... Line 342...
333
 
342
 
334
	public ResponseEntity<?> createRecharge(HttpServletRequest request,
343
	public ResponseEntity<?> createRecharge(HttpServletRequest request,
335
			@RequestBody CreateRechargeRequest createRechargeRequest) throws ProfitMandiBusinessException {
344
			@RequestBody CreateRechargeRequest createRechargeRequest) throws ProfitMandiBusinessException {
336
		int userId = (int) request.getAttribute(ProfitMandiConstants.USER_ID);
345
		int userId = (int) request.getAttribute(ProfitMandiConstants.USER_ID);
337
		int retailerId = userAccountRepository.selectRetailerIdByUserId(userId);
346
		int retailerId = userAccountRepository.selectRetailerIdByUserId(userId);
-
 
347
		
338
		String ipAddress = remoteAddr(request);
348
		String ipAddress = remoteAddr(request);
339
 
349
 
340
		CreateRechargeResponse crr = new CreateRechargeResponse();
350
		CreateRechargeResponse crr = new CreateRechargeResponse();
341
 
351
 
342
		UserAccount userAccount = null;
352
		UserAccount userAccount = null;
Line 364... Line 374...
364
			crr.setResult(false);
374
			crr.setResult(false);
365
			return responseSender.internalServerError(e);
375
			return responseSender.internalServerError(e);
366
		}
376
		}
367
 
377
 
368
		RechargeRequest rechargeRequest = convertRechargeRequest(createRechargeRequest);
378
		RechargeRequest rechargeRequest = convertRechargeRequest(createRechargeRequest);
369
		if (blockedRecharge.contains(user.getEmailId())) {
379
		if (!UNBLOCKED_RECHARGE_EMAILS.contains(user.getEmailId())) {
370
			throw new ProfitMandiBusinessException("Recharge Provider", createRechargeRequest.getOperatorId(),
380
			throw new ProfitMandiBusinessException("Recharge Provider", createRechargeRequest.getOperatorId(),
371
					"We are experiencing some problem right now.");
381
					"We are experiencing some problem right now.");
372
		}
382
		}
373
		RechargeResponse rechargeResponse = rechargeService.doRecharge(oxigenRechargeTransactionUrl,
383
		RechargeResponse rechargeResponse = rechargeService.doRecharge(oxigenRechargeTransactionUrl,
374
				oxigenRechargeAuthKey, oxigenRechargeValidationUrl, oxigenRechargeValidationAuthKey,
384
				oxigenRechargeAuthKey, oxigenRechargeValidationUrl, oxigenRechargeValidationAuthKey,