| Line 2... |
Line 2... |
| 2 |
|
2 |
|
| 3 |
import in.shop2020.datalogger.EventType;
|
3 |
import in.shop2020.datalogger.EventType;
|
| 4 |
import in.shop2020.model.v1.order.Order;
|
4 |
import in.shop2020.model.v1.order.Order;
|
| 5 |
import in.shop2020.model.v1.order.TransactionServiceException;
|
5 |
import in.shop2020.model.v1.order.TransactionServiceException;
|
| 6 |
import in.shop2020.model.v1.user.Address;
|
6 |
import in.shop2020.model.v1.user.Address;
|
| - |
|
7 |
import in.shop2020.model.v1.user.Cart;
|
| 7 |
import in.shop2020.model.v1.user.ShoppingCartException;
|
8 |
import in.shop2020.model.v1.user.ShoppingCartException;
|
| 8 |
import in.shop2020.serving.interceptors.TrackingInterceptor;
|
9 |
import in.shop2020.serving.interceptors.TrackingInterceptor;
|
| 9 |
import in.shop2020.serving.services.CodPaymentService;
|
10 |
import in.shop2020.serving.services.CodPaymentService;
|
| 10 |
import in.shop2020.serving.services.CommonPaymentService;
|
11 |
import in.shop2020.serving.services.CommonPaymentService;
|
| 11 |
import in.shop2020.serving.services.CouponPaymentService;
|
12 |
import in.shop2020.serving.services.CouponPaymentService;
|
| Line 141... |
Line 142... |
| 141 |
if(!verifyCaptcha()){
|
142 |
if(!verifyCaptcha()){
|
| 142 |
addActionError("Invalid captcha");
|
143 |
addActionError("Invalid captcha");
|
| 143 |
log.info("Invalid captcha error msg has been added");
|
144 |
log.info("Invalid captcha error msg has been added");
|
| 144 |
return "proceed-to-pay-redirect";
|
145 |
return "proceed-to-pay-redirect";
|
| 145 |
}
|
146 |
}
|
| - |
|
147 |
UserClient userServiceClient = null;
|
| - |
|
148 |
try {
|
| - |
|
149 |
userServiceClient = new UserClient();
|
| - |
|
150 |
in.shop2020.model.v1.user.UserContextService.Client userClient = userServiceClient.getClient();
|
| - |
|
151 |
Cart cart = userClient.getCart(currentCartId);
|
| - |
|
152 |
if(!isCouponValid(cart)){
|
| - |
|
153 |
addActionError("Cart amount is not zero.");
|
| - |
|
154 |
log.info("Cart amount is not zero.");
|
| - |
|
155 |
return "proceed-to-pay-redirect";
|
| - |
|
156 |
}
|
| - |
|
157 |
} catch (Exception e) {
|
| - |
|
158 |
log.error("Unable to talk to the user context service.", e);
|
| - |
|
159 |
addActionError("We are experiencing some problems. Please try later.");
|
| - |
|
160 |
return "proceed-to-pay-redirect";
|
| - |
|
161 |
}
|
| 146 |
}
|
162 |
}
|
| 147 |
|
163 |
|
| 148 |
try {
|
164 |
try {
|
| 149 |
if(!createOrders(addressId, currentCartId, currentUserId, Long.parseLong(paymentOption))) {
|
165 |
if(!createOrders(addressId, currentCartId, currentUserId, Long.parseLong(paymentOption))) {
|
| 150 |
addActionError("We are experiencing some problems. Please try later.");
|
166 |
addActionError("We are experiencing some problems. Please try later.");
|
| Line 199... |
Line 215... |
| 199 |
} else {
|
215 |
} else {
|
| 200 |
log.info("Successfully created payment for Innoviti to process. Redirecting to /innoviti-pay/" + paymentId);
|
216 |
log.info("Successfully created payment for Innoviti to process. Redirecting to /innoviti-pay/" + paymentId);
|
| 201 |
return "innoviti-pay-redirect";
|
217 |
return "innoviti-pay-redirect";
|
| 202 |
}
|
218 |
}
|
| 203 |
|
219 |
|
| 204 |
case 16:
|
220 |
case 17:
|
| 205 |
IPaymentService couponPaymentService = new CouponPaymentService();
|
221 |
IPaymentService couponPaymentService = new CouponPaymentService();
|
| 206 |
paymentId = couponPaymentService.createPayment(userinfo.getUserId(), txnId, paymentOption, 16);
|
222 |
paymentId = couponPaymentService.createPayment(userinfo.getUserId(), txnId, paymentOption, 17);
|
| 207 |
if (paymentId == IPaymentService.PAYMENT_NOT_CREATED) {
|
223 |
if (paymentId == IPaymentService.PAYMENT_NOT_CREATED) {
|
| 208 |
//Very unlikely. The only possible reason can be that the payment service is down.
|
224 |
//Very unlikely. The only possible reason can be that the payment service is down.
|
| 209 |
log.error("Unable to process the Coupon payment.");
|
225 |
log.error("Unable to process the Coupon payment.");
|
| 210 |
addActionError("We are experiencing some problems. Please try later.");
|
226 |
addActionError("We are experiencing some problems. Please try later.");
|
| 211 |
return "proceed-to-pay-redirect";
|
227 |
return "proceed-to-pay-redirect";
|
| Line 256... |
Line 272... |
| 256 |
log.info("Successfully created payment for EBS to process. Redirecting to /ebs-pay/" + paymentId);
|
272 |
log.info("Successfully created payment for EBS to process. Redirecting to /ebs-pay/" + paymentId);
|
| 257 |
return "ebs-pay-redirect";
|
273 |
return "ebs-pay-redirect";
|
| 258 |
}
|
274 |
}
|
| 259 |
}
|
275 |
}
|
| 260 |
|
276 |
|
| - |
|
277 |
private boolean isCouponValid(Cart cart) {
|
| - |
|
278 |
String couponCode = cart.getCouponCode();
|
| - |
|
279 |
double totalAmountD;
|
| - |
|
280 |
if(couponCode == null || "".equals(couponCode))
|
| - |
|
281 |
totalAmountD = cart.getTotalPrice();
|
| - |
|
282 |
else
|
| - |
|
283 |
totalAmountD = cart.getDiscountedPrice();
|
| - |
|
284 |
if(totalAmountD == 0) {
|
| - |
|
285 |
return true;
|
| - |
|
286 |
}else{
|
| - |
|
287 |
return false;
|
| - |
|
288 |
}
|
| - |
|
289 |
}
|
| - |
|
290 |
|
| 261 |
private long findGatewayId(String paymentOption){
|
291 |
private long findGatewayId(String paymentOption){
|
| 262 |
long gatewayId = 0;
|
292 |
long gatewayId = 0;
|
| 263 |
gatewayId = ProceedToPayController.getGatewayId(Long.parseLong(paymentOption));
|
293 |
gatewayId = ProceedToPayController.getGatewayId(Long.parseLong(paymentOption));
|
| 264 |
if(gatewayId==0){
|
294 |
if(gatewayId==0){
|
| 265 |
if(paymentOption.equals(IPaymentService.COD)){
|
295 |
if(paymentOption.equals(IPaymentService.COD)){
|
| 266 |
gatewayId = 4;
|
296 |
gatewayId = 4;
|
| 267 |
}
|
297 |
}
|
| 268 |
if(paymentOption.equals(IPaymentService.COUPON)){
|
298 |
if(paymentOption.equals(IPaymentService.COUPON)){
|
| 269 |
gatewayId = 16;
|
299 |
gatewayId = 17;
|
| 270 |
}
|
300 |
}
|
| 271 |
}
|
301 |
}
|
| 272 |
return gatewayId;
|
302 |
return gatewayId;
|
| 273 |
}
|
303 |
}
|
| 274 |
|
304 |
|