| Line 14... |
Line 14... |
| 14 |
import org.springframework.beans.factory.annotation.Autowired;
|
14 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 15 |
import org.springframework.http.HttpStatus;
|
15 |
import org.springframework.http.HttpStatus;
|
| 16 |
import org.springframework.http.MediaType;
|
16 |
import org.springframework.http.MediaType;
|
| 17 |
import org.springframework.http.ResponseEntity;
|
17 |
import org.springframework.http.ResponseEntity;
|
| 18 |
import org.springframework.stereotype.Controller;
|
18 |
import org.springframework.stereotype.Controller;
|
| - |
|
19 |
import org.springframework.web.bind.annotation.RequestBody;
|
| 19 |
import org.springframework.web.bind.annotation.RequestMapping;
|
20 |
import org.springframework.web.bind.annotation.RequestMapping;
|
| 20 |
import org.springframework.web.bind.annotation.RequestMethod;
|
21 |
import org.springframework.web.bind.annotation.RequestMethod;
|
| 21 |
import org.springframework.web.bind.annotation.RequestParam;
|
22 |
import org.springframework.web.bind.annotation.RequestParam;
|
| 22 |
|
23 |
|
| 23 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
24 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 24 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
25 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 25 |
import com.spice.profitmandi.common.util.Utils;
|
26 |
import com.spice.profitmandi.common.util.Utils;
|
| - |
|
27 |
import com.spice.profitmandi.dao.entity.User;
|
| 26 |
import com.spice.profitmandi.dao.entity.UserAccounts;
|
28 |
import com.spice.profitmandi.dao.entity.UserAccounts;
|
| 27 |
import com.spice.profitmandi.dao.enumuration.AccountType;
|
29 |
import com.spice.profitmandi.dao.enumuration.AccountType;
|
| 28 |
import com.spice.profitmandi.dao.repository.UserAccountRepository;
|
30 |
import com.spice.profitmandi.dao.repository.UserAccountRepository;
|
| - |
|
31 |
import com.spice.profitmandi.dao.repository.UserRepository;
|
| 29 |
import com.spice.profitmandi.thrift.clients.TransactionClient;
|
32 |
import com.spice.profitmandi.thrift.clients.TransactionClient;
|
| - |
|
33 |
import com.spice.profitmandi.thrift.clients.PaymentClient;
|
| 30 |
import com.spice.profitmandi.web.model.ProfitMandiResponse;
|
34 |
import com.spice.profitmandi.web.model.ProfitMandiResponse;
|
| 31 |
import com.spice.profitmandi.web.model.ResponseStatus;
|
35 |
import com.spice.profitmandi.web.model.ResponseStatus;
|
| - |
|
36 |
import com.spice.profitmandi.web.req.CreateRechargeRequest;
|
| 32 |
import com.spice.profitmandi.web.res.ConfirmRechargeResponse;
|
37 |
import com.spice.profitmandi.web.res.ConfirmRechargeResponse;
|
| 33 |
import com.spice.profitmandi.web.util.ResponseSender;
|
38 |
import com.spice.profitmandi.web.res.CreateRechargeResponse;
|
| 34 |
|
39 |
|
| 35 |
import in.shop2020.model.v1.order.DenominationType;
|
40 |
import in.shop2020.model.v1.order.DenominationType;
|
| 36 |
import in.shop2020.model.v1.order.DeviceNumberInfo;
|
41 |
import in.shop2020.model.v1.order.DeviceNumberInfo;
|
| - |
|
42 |
import in.shop2020.model.v1.order.OrderType;
|
| 37 |
import in.shop2020.model.v1.order.RechargeDenomination;
|
43 |
import in.shop2020.model.v1.order.RechargeDenomination;
|
| - |
|
44 |
import in.shop2020.model.v1.order.RechargeOrder;
|
| - |
|
45 |
import in.shop2020.model.v1.order.RechargeOrderStatus;
|
| 38 |
import in.shop2020.model.v1.order.RechargeType;
|
46 |
import in.shop2020.model.v1.order.RechargeType;
|
| - |
|
47 |
import in.shop2020.model.v1.order.TransactionServiceException;
|
| 39 |
import in.shop2020.model.v1.order.UserWallet;
|
48 |
import in.shop2020.model.v1.order.UserWallet;
|
| - |
|
49 |
import in.shop2020.payments.Payment;
|
| - |
|
50 |
import in.shop2020.payments.PaymentException;
|
| - |
|
51 |
import in.shop2020.payments.PaymentStatus;
|
| 40 |
import io.swagger.annotations.ApiImplicitParam;
|
52 |
import io.swagger.annotations.ApiImplicitParam;
|
| 41 |
import io.swagger.annotations.ApiImplicitParams;
|
53 |
import io.swagger.annotations.ApiImplicitParams;
|
| 42 |
import io.swagger.annotations.ApiOperation;
|
54 |
import io.swagger.annotations.ApiOperation;
|
| 43 |
|
55 |
|
| 44 |
@Controller
|
56 |
@Controller
|
| 45 |
public class RechargeController {
|
57 |
public class RechargeController {
|
| 46 |
|
58 |
|
| 47 |
private static final Logger log=LoggerFactory.getLogger(RechargeController.class);
|
59 |
private static final Logger log=LoggerFactory.getLogger(RechargeController.class);
|
| - |
|
60 |
private static final String HEADER_X_FORWARDED_FOR = "X-FORWARDED-FOR";
|
| 48 |
|
61 |
|
| 49 |
@Autowired
|
62 |
@Autowired
|
| 50 |
UserAccountRepository userAccountRepository;
|
63 |
UserAccountRepository userAccountRepository;
|
| - |
|
64 |
|
| - |
|
65 |
@Autowired
|
| - |
|
66 |
UserRepository userRepository;
|
| 51 |
|
67 |
|
| 52 |
@RequestMapping(value = ProfitMandiConstants.URL_GET_SERVICE_PROVIDER, method=RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE)
|
68 |
@RequestMapping(value = ProfitMandiConstants.URL_GET_SERVICE_PROVIDER, method=RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE)
|
| 53 |
@ApiImplicitParams({
|
69 |
@ApiImplicitParams({
|
| 54 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token",
|
70 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token",
|
| 55 |
required = true, dataType = "string", paramType = "header")
|
71 |
required = true, dataType = "string", paramType = "header")
|
| 56 |
})
|
72 |
})
|
| Line 123... |
Line 139... |
| 123 |
UserWallet wallet = null;
|
139 |
UserWallet wallet = null;
|
| 124 |
if (rechargeAmount <=0){
|
140 |
if (rechargeAmount <=0){
|
| 125 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString() , HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.SUCCESS, null);
|
141 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString() , HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.SUCCESS, null);
|
| 126 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.BAD_REQUEST);
|
142 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.BAD_REQUEST);
|
| 127 |
}
|
143 |
}
|
| 128 |
|
144 |
|
| 129 |
try {
|
145 |
try {
|
| 130 |
userAccount = userAccountRepository.getUserAccountByType(userId, AccountType.saholic);
|
146 |
userAccount = userAccountRepository.getUserAccountByType(userId, AccountType.saholic);
|
| 131 |
} catch (ProfitMandiBusinessException e) {
|
147 |
} catch (ProfitMandiBusinessException e) {
|
| 132 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString() , HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.SUCCESS, null);
|
148 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString() , HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.SUCCESS, null);
|
| 133 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
149 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
| Line 137... |
Line 153... |
| 137 |
wallet = tc.getClient().getUserWallet(Long.valueOf(userAccount.getAccount_key()));
|
153 |
wallet = tc.getClient().getUserWallet(Long.valueOf(userAccount.getAccount_key()));
|
| 138 |
} catch (NumberFormatException | TException e) {
|
154 |
} catch (NumberFormatException | TException e) {
|
| 139 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString() , HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.SUCCESS, null);
|
155 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString() , HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.SUCCESS, null);
|
| 140 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
156 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
| 141 |
}
|
157 |
}
|
| 142 |
|
158 |
|
| 143 |
ConfirmRechargeResponse crr = new ConfirmRechargeResponse();
|
159 |
ConfirmRechargeResponse crr = new ConfirmRechargeResponse();
|
| 144 |
crr.setWalletAmount(wallet.getAmount());
|
160 |
crr.setWalletAmount(wallet.getAmount());
|
| 145 |
crr.setWalletAmountLeft(wallet.getAmount() - rechargeAmount);
|
161 |
crr.setWalletAmountLeft(wallet.getAmount() - rechargeAmount);
|
| 146 |
crr.setCanProceed(true);
|
162 |
crr.setCanProceed(true);
|
| 147 |
if (crr.getWalletAmountLeft() < 0){
|
163 |
if (crr.getWalletAmountLeft() < 0){
|
| Line 149... |
Line 165... |
| 149 |
crr.setReason("You don't have sufficient wallet balance");
|
165 |
crr.setReason("You don't have sufficient wallet balance");
|
| 150 |
}
|
166 |
}
|
| 151 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString() , HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, crr);
|
167 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString() , HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, crr);
|
| 152 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
168 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
| 153 |
}
|
169 |
}
|
| 154 |
|
170 |
|
| 155 |
@RequestMapping(value = ProfitMandiConstants.URL_CREATE_RECHARGE , method=RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE)
|
171 |
@RequestMapping(value = ProfitMandiConstants.URL_CREATE_RECHARGE , method=RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE)
|
| 156 |
@ApiImplicitParams({
|
172 |
@ApiImplicitParams({
|
| 157 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token",
|
173 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token",
|
| 158 |
required = true, dataType = "string", paramType = "header")
|
174 |
required = true, dataType = "string", paramType = "header")
|
| 159 |
})
|
175 |
})
|
| - |
|
176 |
public ResponseEntity<?> createRecharge(HttpServletRequest request, @RequestBody CreateRechargeRequest createRechargeRequest){
|
| - |
|
177 |
String ipAddress = remoteAddr(request);
|
| - |
|
178 |
String errorMessage = validateRecharge(RechargeType.valueOf(createRechargeRequest.getRechargeType()), createRechargeRequest.getNumber(), createRechargeRequest.getOperatorId(), ipAddress);
|
| - |
|
179 |
CreateRechargeResponse crr = new CreateRechargeResponse();
|
| - |
|
180 |
if(!errorMessage.equals("SUCCESS")){
|
| - |
|
181 |
crr.setReason(errorMessage);
|
| - |
|
182 |
crr.setResult(false);
|
| - |
|
183 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString() , HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.SUCCESS, crr);
|
| - |
|
184 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.BAD_REQUEST);
|
| - |
|
185 |
}
|
| - |
|
186 |
int userId = (int)request.getAttribute("userId");
|
| - |
|
187 |
UserAccounts userAccount = null;
|
| - |
|
188 |
UserWallet wallet = null;
|
| - |
|
189 |
if (createRechargeRequest.getRechargeAmount() <=0){
|
| - |
|
190 |
crr.setReason("Illegal recharge amount");
|
| - |
|
191 |
crr.setResult(false);
|
| - |
|
192 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString() , HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.SUCCESS, crr);
|
| - |
|
193 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.BAD_REQUEST);
|
| - |
|
194 |
}
|
| - |
|
195 |
|
| - |
|
196 |
try {
|
| - |
|
197 |
userAccount = userAccountRepository.getUserAccountByType(userId, AccountType.saholic);
|
| - |
|
198 |
} catch (ProfitMandiBusinessException e) {
|
| - |
|
199 |
log.error("Unable to get user account ",e);
|
| - |
|
200 |
crr.setReason("We are experiencing some problem right now.");
|
| - |
|
201 |
crr.setResult(false);
|
| - |
|
202 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString() , HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.SUCCESS, crr);
|
| - |
|
203 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
| - |
|
204 |
}
|
| - |
|
205 |
try {
|
| - |
|
206 |
TransactionClient tc = new TransactionClient();
|
| - |
|
207 |
wallet = tc.getClient().getUserWallet(Long.valueOf(userAccount.getAccount_key()));
|
| - |
|
208 |
} catch (NumberFormatException | TException e) {
|
| - |
|
209 |
log.error("Unable to get user wallet ",e);
|
| - |
|
210 |
crr.setReason("We are experiencing some problem right now.");
|
| - |
|
211 |
crr.setResult(false);
|
| - |
|
212 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString() , HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.SUCCESS, crr);
|
| - |
|
213 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
| - |
|
214 |
}
|
| - |
|
215 |
|
| - |
|
216 |
if (wallet.getAmount() < createRechargeRequest.getRechargeAmount()){
|
| - |
|
217 |
crr.setReason("You don't have sufficient wallet balance.");
|
| - |
|
218 |
crr.setResult(false);
|
| - |
|
219 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString() , HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.SUCCESS, crr);
|
| - |
|
220 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.BAD_REQUEST);
|
| - |
|
221 |
}
|
| - |
|
222 |
|
| - |
|
223 |
User user = null;
|
| - |
|
224 |
try {
|
| - |
|
225 |
user = userRepository.selectById(userId);
|
| - |
|
226 |
} catch (ProfitMandiBusinessException e) {
|
| - |
|
227 |
log.error("Unable to get user",e);
|
| - |
|
228 |
crr.setReason("We are experiencing some problem right now.");
|
| - |
|
229 |
crr.setResult(false);
|
| - |
|
230 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString() , HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.SUCCESS, crr);
|
| - |
|
231 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
| - |
|
232 |
}
|
| - |
|
233 |
|
| - |
|
234 |
|
| - |
|
235 |
RechargeOrder t_rechargeOrder = new RechargeOrder();
|
| - |
|
236 |
t_rechargeOrder.setTotalAmount(createRechargeRequest.getRechargeAmount());
|
| - |
|
237 |
t_rechargeOrder.setUserEmailId(user.getEmailId());
|
| - |
|
238 |
t_rechargeOrder.setUserId(userId);
|
| - |
|
239 |
t_rechargeOrder.setDeviceNumber(createRechargeRequest.getNumber());
|
| - |
|
240 |
t_rechargeOrder.setPlan(createRechargeRequest.getPlan()==null?"":createRechargeRequest.getPlan());
|
| - |
|
241 |
t_rechargeOrder.setOperatorId(createRechargeRequest.getOperatorId());
|
| - |
|
242 |
t_rechargeOrder.setRechargeType(RechargeType.valueOf(createRechargeRequest.getRechargeType()));
|
| - |
|
243 |
t_rechargeOrder.setStatus(RechargeOrderStatus.PAYMENT_PENDING);
|
| - |
|
244 |
t_rechargeOrder.setOrderType(OrderType.B2C);
|
| - |
|
245 |
t_rechargeOrder.setWalletAmount(createRechargeRequest.getRechargeAmount());
|
| - |
|
246 |
t_rechargeOrder.setCouponAmount(0);
|
| - |
|
247 |
t_rechargeOrder.setCouponCode("");
|
| - |
|
248 |
t_rechargeOrder.setIpAddress(ipAddress);
|
| - |
|
249 |
TransactionClient tc = null;
|
| - |
|
250 |
RechargeOrder rechargeOrder;
|
| - |
|
251 |
try {
|
| - |
|
252 |
tc = new TransactionClient();
|
| - |
|
253 |
rechargeOrder = tc.getClient().createRechargeOrder(t_rechargeOrder);
|
| - |
|
254 |
} catch (TransactionServiceException | TException e) {
|
| - |
|
255 |
log.error("Unable to create recharge order",e);
|
| - |
|
256 |
crr.setReason("We are experiencing some problem right now.");
|
| - |
|
257 |
crr.setResult(false);
|
| - |
|
258 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString() , HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.SUCCESS, crr);
|
| - |
|
259 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
| - |
|
260 |
}
|
| - |
|
261 |
|
| - |
|
262 |
log.info("Recharge Order:" + rechargeOrder);
|
| - |
|
263 |
PaymentClient paymentServiceClient = null;
|
| - |
|
264 |
try {
|
| - |
|
265 |
paymentServiceClient = new PaymentClient();
|
| - |
|
266 |
} catch (TTransportException e) {
|
| - |
|
267 |
log.error("Unable to create payment client",e);
|
| - |
|
268 |
crr.setReason("We are experiencing some problem right now.");
|
| - |
|
269 |
crr.setResult(false);
|
| - |
|
270 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString() , HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.SUCCESS, crr);
|
| - |
|
271 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
| - |
|
272 |
}
|
| - |
|
273 |
try {
|
| - |
|
274 |
RechargeOrder d_rechargeOrder = tc.getClient().getRechargeOrder(rechargeOrder.getId());
|
| - |
|
275 |
List<Payment> payments = paymentServiceClient.getClient().getPaymentForRechargeTxnId(d_rechargeOrder.getTransactionId());
|
| - |
|
276 |
if(payments.size() > 0) {
|
| - |
|
277 |
throw new PaymentException(d_rechargeOrder.getId(), "Payment already exists for recharge");
|
| - |
|
278 |
}
|
| - |
|
279 |
Long merchantPaymentId = 0l;
|
| - |
|
280 |
if (d_rechargeOrder.getWalletAmount() + d_rechargeOrder.getCouponAmount() != d_rechargeOrder.getTotalAmount()) {
|
| - |
|
281 |
log.error("Wallet amount : " + d_rechargeOrder.getWalletAmount() + ", coupon amount : " + d_rechargeOrder.getCouponAmount() + " and total amount : " + d_rechargeOrder.getTotalAmount());
|
| - |
|
282 |
merchantPaymentId = paymentServiceClient.getClient().createPayment(d_rechargeOrder.getUserId(), d_rechargeOrder.getTotalAmount(), 8, d_rechargeOrder.getTransactionId(), true);
|
| - |
|
283 |
paymentServiceClient.getClient().updatePaymentDetails(merchantPaymentId, "","", "0", "", "", "", "", "", PaymentStatus.FAILED, "", null);
|
| - |
|
284 |
tc.getClient().updateRechargeOrderStatus(d_rechargeOrder.getId(), RechargeOrderStatus.PAYMENT_FAILED);
|
| - |
|
285 |
} else {
|
| - |
|
286 |
merchantPaymentId = paymentServiceClient.getClient().createPayment(d_rechargeOrder.getUserId(), d_rechargeOrder.getTotalAmount(), 8, d_rechargeOrder.getTransactionId(), true);
|
| - |
|
287 |
//Update payment status as authorized
|
| - |
|
288 |
paymentServiceClient.getClient().updatePaymentDetails(merchantPaymentId, "","", "0", "", "", "", "", "", PaymentStatus.SUCCESS, "", null);
|
| - |
|
289 |
tc.getClient().updateRechargeOrderStatus(d_rechargeOrder.getId(), RechargeOrderStatus.PAYMENT_SUCCESSFUL);
|
| - |
|
290 |
}
|
| - |
|
291 |
crr.setRechargeOrderId(d_rechargeOrder.getId());
|
| - |
|
292 |
crr.setResult(true);
|
| - |
|
293 |
} catch (Exception e) {
|
| - |
|
294 |
log.error("Unable to mark the payment as authorized", e);
|
| - |
|
295 |
crr.setReason("We are experiencing some problem right now.");
|
| - |
|
296 |
crr.setResult(false);
|
| - |
|
297 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString() , HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.SUCCESS, crr);
|
| - |
|
298 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
| - |
|
299 |
}
|
| - |
|
300 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString() , HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, crr);
|
| - |
|
301 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
| - |
|
302 |
}
|
| - |
|
303 |
|
| - |
|
304 |
|
| 160 |
public ResponseEntity<?> createRecharge(HttpServletRequest request){
|
305 |
private String remoteAddr(HttpServletRequest request) {
|
| - |
|
306 |
String remoteAddr = "";
|
| - |
|
307 |
String x;
|
| - |
|
308 |
x = request.getHeader(HEADER_X_FORWARDED_FOR);
|
| - |
|
309 |
if (x != null && !x.isEmpty()) {
|
| - |
|
310 |
remoteAddr = x;
|
| - |
|
311 |
int idx = remoteAddr.lastIndexOf(',');
|
| - |
|
312 |
if (idx > -1) {
|
| - |
|
313 |
remoteAddr = remoteAddr.substring(idx + 1).trim();
|
| - |
|
314 |
}
|
| - |
|
315 |
} else {
|
| - |
|
316 |
remoteAddr = request.getRemoteAddr();
|
| - |
|
317 |
}
|
| 161 |
return null;
|
318 |
return remoteAddr;
|
| 162 |
}
|
319 |
}
|
| - |
|
320 |
|
| - |
|
321 |
private String validateRecharge(RechargeType rechargeType, String number, long operatorId, String ipAddress){
|
| - |
|
322 |
TransactionClient tcl;
|
| - |
|
323 |
try {
|
| - |
|
324 |
tcl = new TransactionClient();
|
| - |
|
325 |
String result = tcl.getClient().validateRecharge(rechargeType, number, operatorId, ipAddress);
|
| - |
|
326 |
log.info("validateRecharge Called" + number + " and rechargeType : " + rechargeType + ", IP:" + ipAddress + ", Operator:" + operatorId + ", Result:" + result);
|
| - |
|
327 |
return result;
|
| - |
|
328 |
} catch (Exception e) {
|
| - |
|
329 |
log.error("Unable to get service provider for Device number " + number + " and rechargeType : " + rechargeType, e);
|
| - |
|
330 |
}
|
| - |
|
331 |
return "Oops! There seems to be a problem. Please try after some time";
|
| 163 |
|
332 |
}
|
| - |
|
333 |
|
| - |
|
334 |
|
| 164 |
}
|
335 |
}
|
| 165 |
|
336 |
|
| 166 |
|
337 |
|
| 167 |
|
338 |
|