Subversion Repositories SmartDukaan

Rev

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

Rev 25703 Rev 26228
Line 77... Line 77...
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> UNBLOCKED_RECHARGE_EMAILS = Arrays.asList("pgautam84@gmail.com");
80
	private List<String> UNBLOCKED_RECHARGE_EMAILS = Arrays.asList("pgautam84@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}")
-
 
83
	private String oxigenRechargeTransactionUrl;
-
 
84
 
-
 
85
	@Value("${oxigen.recharge.enquiry.url}")
-
 
86
	private String oxigenRechargeEnquiryUrl;
-
 
87
 
-
 
88
	@Value("${oxigen.recharge.auth.key}")
-
 
89
	private String oxigenRechargeAuthKey;
-
 
90
 
-
 
91
	@Value("${oxigen.recharge.validation.url}")
-
 
92
	private String oxigenRechargeValidationUrl;
-
 
93
 
-
 
94
	@Value("${oxigen.recharge.validation.auth.key}")
-
 
95
	private String oxigenRechargeValidationAuthKey;
-
 
96
 
82
 
97
	@Value("${think.walnut.digital.recharge.transaction.mobile.url}")
83
	@Value("${think.walnut.digital.recharge.transaction.mobile.url}")
98
	private String thinkWalnutDigitalRechargeTransactionMobileUrl;
84
	private String thinkWalnutDigitalRechargeTransactionMobileUrl;
99
 
85
 
100
	@Value("${think.walnut.digital.recharge.transaction.mobile.username}")
86
	@Value("${think.walnut.digital.recharge.transaction.mobile.username}")
Line 338... Line 324...
338
 
324
 
339
	public ResponseEntity<?> createRecharge(HttpServletRequest request,
325
	public ResponseEntity<?> createRecharge(HttpServletRequest request,
340
			@RequestBody CreateRechargeRequest createRechargeRequest) throws ProfitMandiBusinessException {
326
			@RequestBody CreateRechargeRequest createRechargeRequest) throws ProfitMandiBusinessException {
341
		int userId = (int) request.getAttribute(ProfitMandiConstants.USER_ID);
327
		int userId = (int) request.getAttribute(ProfitMandiConstants.USER_ID);
342
		int retailerId = userAccountRepository.selectRetailerIdByUserId(userId);
328
		int retailerId = userAccountRepository.selectRetailerIdByUserId(userId);
343
		
329
 
344
		String ipAddress = remoteAddr(request);
330
		String ipAddress = remoteAddr(request);
345
 
331
 
346
		CreateRechargeResponse crr = new CreateRechargeResponse();
332
		CreateRechargeResponse crr = new CreateRechargeResponse();
347
 
333
 
348
		UserAccount userAccount = null;
334
		UserAccount userAccount = null;
Line 373... Line 359...
373
		RechargeRequest rechargeRequest = convertRechargeRequest(createRechargeRequest);
359
		RechargeRequest rechargeRequest = convertRechargeRequest(createRechargeRequest);
374
		if (!UNBLOCKED_RECHARGE_EMAILS.contains(saholicUser.getEmailId())) {
360
		if (!UNBLOCKED_RECHARGE_EMAILS.contains(saholicUser.getEmailId())) {
375
			throw new ProfitMandiBusinessException("Recharge Provider", createRechargeRequest.getOperatorId(),
361
			throw new ProfitMandiBusinessException("Recharge Provider", createRechargeRequest.getOperatorId(),
376
					"We are experiencing some problem right now.");
362
					"We are experiencing some problem right now.");
377
		}
363
		}
378
		RechargeResponse rechargeResponse = rechargeService.doRecharge(oxigenRechargeTransactionUrl,
364
		RechargeResponse rechargeResponse = rechargeService.doRecharge(rechargeTransactionMobileCredential,
379
				oxigenRechargeAuthKey, oxigenRechargeValidationUrl, oxigenRechargeValidationAuthKey,
-
 
380
				rechargeTransactionMobileCredential, rechargeTransactionDthCredential, retailerId, rechargeRequest);
365
				rechargeTransactionDthCredential, retailerId, rechargeRequest);
381
 
366
 
382
		crr.setResult(rechargeResponse.getStatus().equals(RechargeStatus.SUCCESS));
367
		crr.setResult(rechargeResponse.getStatus().equals(RechargeStatus.SUCCESS));
383
		crr.setRequestId(rechargeResponse.getRequestId());
368
		crr.setRequestId(rechargeResponse.getRequestId());
384
 
369
 
385
		if (RechargeType.valueOf(rechargeRequest.getRechargeType()) == RechargeType.MOBILE) {
370
		if (RechargeType.valueOf(rechargeRequest.getRechargeType()) == RechargeType.MOBILE) {
Line 462... Line 447...
462
		// RechargeResponse rr = new RechargeResponse();
447
		// RechargeResponse rr = new RechargeResponse();
463
		// String requestId = rr.getRequestId();
448
		// String requestId = rr.getRequestId();
464
		int userId = (int) request.getAttribute(ProfitMandiConstants.USER_ID);
449
		int userId = (int) request.getAttribute(ProfitMandiConstants.USER_ID);
465
		int retailerId = userAccountRepository.selectRetailerIdByUserId(userId);
450
		int retailerId = userAccountRepository.selectRetailerIdByUserId(userId);
466
 
451
 
467
		RechargeResponse rechargeResponse = rechargeService.checkStatus(oxigenRechargeEnquiryUrl, oxigenRechargeAuthKey,
452
		RechargeResponse rechargeResponse = rechargeService.checkStatus(thinkWalnutDigitalRechargeEnquiryCredential,
468
				thinkWalnutDigitalRechargeEnquiryCredential, retailerId, requestId);
453
				retailerId, requestId);
469
		return responseSender.ok(rechargeResponse);
454
		return responseSender.ok(rechargeResponse);
470
	}
455
	}
471
 
456
 
472
	@RequestMapping(value = ProfitMandiConstants.URL_POLL_RECHARGE, method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
457
	@RequestMapping(value = ProfitMandiConstants.URL_POLL_RECHARGE, method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
473
	@ApiImplicitParams({
458
	@ApiImplicitParams({