| Line 3... |
Line 3... |
| 3 |
import in.shop2020.model.v1.catalog.Item;
|
3 |
import in.shop2020.model.v1.catalog.Item;
|
| 4 |
import in.shop2020.model.v1.user.Address;
|
4 |
import in.shop2020.model.v1.user.Address;
|
| 5 |
import in.shop2020.model.v1.user.Cart;
|
5 |
import in.shop2020.model.v1.user.Cart;
|
| 6 |
import in.shop2020.model.v1.user.Line;
|
6 |
import in.shop2020.model.v1.user.Line;
|
| 7 |
import in.shop2020.serving.utils.FormattingUtils;
|
7 |
import in.shop2020.serving.utils.FormattingUtils;
|
| 8 |
import in.shop2020.thrift.clients.CatalogServiceClient;
|
8 |
import in.shop2020.thrift.clients.CatalogClient;
|
| 9 |
import in.shop2020.thrift.clients.LogisticsServiceClient;
|
9 |
import in.shop2020.thrift.clients.LogisticsClient;
|
| 10 |
import in.shop2020.thrift.clients.UserContextServiceClient;
|
10 |
import in.shop2020.thrift.clients.UserClient;
|
| 11 |
|
11 |
|
| 12 |
import java.util.Collection;
|
12 |
import java.util.Collection;
|
| 13 |
import java.util.List;
|
13 |
import java.util.List;
|
| 14 |
import java.util.ResourceBundle;
|
14 |
import java.util.ResourceBundle;
|
| 15 |
|
15 |
|
| Line 63... |
Line 63... |
| 63 |
}
|
63 |
}
|
| 64 |
return processPaymentOptions();
|
64 |
return processPaymentOptions();
|
| 65 |
}
|
65 |
}
|
| 66 |
|
66 |
|
| 67 |
private String processPaymentOptions() {
|
67 |
private String processPaymentOptions() {
|
| 68 |
UserContextServiceClient userContextServiceClient = null;
|
68 |
UserClient userContextServiceClient = null;
|
| 69 |
in.shop2020.model.v1.user.UserContextService.Client userClient = null;
|
69 |
in.shop2020.model.v1.user.UserContextService.Client userClient = null;
|
| 70 |
|
70 |
|
| 71 |
Address address;
|
71 |
Address address;
|
| 72 |
List<Line> lineItems;
|
72 |
List<Line> lineItems;
|
| 73 |
|
73 |
|
| 74 |
try {
|
74 |
try {
|
| 75 |
userContextServiceClient = new UserContextServiceClient();
|
75 |
userContextServiceClient = new UserClient();
|
| 76 |
userClient = userContextServiceClient.getClient();
|
76 |
userClient = userContextServiceClient.getClient();
|
| 77 |
|
77 |
|
| 78 |
long cartId = userinfo.getCartId();
|
78 |
long cartId = userinfo.getCartId();
|
| 79 |
|
79 |
|
| 80 |
// Validate the cart to ensure that we are not accepting payment for
|
80 |
// Validate the cart to ensure that we are not accepting payment for
|
| Line 99... |
Line 99... |
| 99 |
addActionError("We are experiencing some problem. Please try again.");
|
99 |
addActionError("We are experiencing some problem. Please try again.");
|
| 100 |
return "shipping-redirect";
|
100 |
return "shipping-redirect";
|
| 101 |
}
|
101 |
}
|
| 102 |
|
102 |
|
| 103 |
try {
|
103 |
try {
|
| 104 |
CatalogServiceClient catalogServiceClient = new CatalogServiceClient();
|
104 |
CatalogClient catalogServiceClient = new CatalogClient();
|
| 105 |
in.shop2020.model.v1.catalog.InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
105 |
in.shop2020.model.v1.catalog.InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
| 106 |
for (Line line : lineItems) {
|
106 |
for (Line line : lineItems) {
|
| 107 |
Item item = catalogClient.getItem(line.getItemId());
|
107 |
Item item = catalogClient.getItem(line.getItemId());
|
| 108 |
if(item.getSellingPrice() > COD_CUTOFF_AMOUNT)
|
108 |
if(item.getSellingPrice() > COD_CUTOFF_AMOUNT)
|
| 109 |
showCodOption = false;
|
109 |
showCodOption = false;
|
| Line 113... |
Line 113... |
| 113 |
addActionError("We are experiencing some problem. Please try again.");
|
113 |
addActionError("We are experiencing some problem. Please try again.");
|
| 114 |
return "shipping-redirect";
|
114 |
return "shipping-redirect";
|
| 115 |
}
|
115 |
}
|
| 116 |
|
116 |
|
| 117 |
try {
|
117 |
try {
|
| 118 |
LogisticsServiceClient lClient = new LogisticsServiceClient();
|
118 |
LogisticsClient lClient = new LogisticsClient();
|
| 119 |
showCodOption = showCodOption && lClient.getClient().isCodAllowed(address.getPin());
|
119 |
showCodOption = showCodOption && lClient.getClient().isCodAllowed(address.getPin());
|
| 120 |
} catch(Exception e) {
|
120 |
} catch(Exception e) {
|
| 121 |
logger.error("Error while checking if COD is available for: " + showCodOption, e);
|
121 |
logger.error("Error while checking if COD is available for: " + showCodOption, e);
|
| 122 |
showCodOption = false; //Not a critical error, proceeding with defensive behaviour.
|
122 |
showCodOption = false; //Not a critical error, proceeding with defensive behaviour.
|
| 123 |
}
|
123 |
}
|