| Line 1... |
Line 1... |
| 1 |
package in.shop2020.serving.controllers;
|
1 |
package in.shop2020.serving.controllers;
|
| 2 |
|
2 |
|
| - |
|
3 |
import java.util.List;
|
| - |
|
4 |
|
| 3 |
import in.shop2020.model.v1.order.RechargeOrder;
|
5 |
import in.shop2020.model.v1.order.RechargeOrder;
|
| 4 |
import in.shop2020.model.v1.user.Address;
|
6 |
import in.shop2020.model.v1.user.Address;
|
| - |
|
7 |
import in.shop2020.payments.Payment;
|
| - |
|
8 |
import in.shop2020.payments.PaymentException;
|
| 5 |
import in.shop2020.serving.services.EbsPaymentService;
|
9 |
import in.shop2020.serving.services.EbsPaymentService;
|
| 6 |
import in.shop2020.serving.services.HdfcPaymentService;
|
10 |
import in.shop2020.serving.services.HdfcPaymentService;
|
| 7 |
import in.shop2020.serving.services.IPaymentService;
|
11 |
import in.shop2020.serving.services.IPaymentService;
|
| - |
|
12 |
import in.shop2020.thrift.clients.PaymentClient;
|
| 8 |
import in.shop2020.thrift.clients.TransactionClient;
|
13 |
import in.shop2020.thrift.clients.TransactionClient;
|
| 9 |
import in.shop2020.thrift.clients.UserClient;
|
14 |
import in.shop2020.thrift.clients.UserClient;
|
| 10 |
|
15 |
|
| 11 |
import org.apache.log4j.Logger;
|
16 |
import org.apache.log4j.Logger;
|
| 12 |
import org.apache.struts2.convention.annotation.Result;
|
17 |
import org.apache.struts2.convention.annotation.Result;
|
| 13 |
import org.apache.struts2.convention.annotation.Results;
|
18 |
import org.apache.struts2.convention.annotation.Results;
|
| 14 |
|
19 |
|
| 15 |
|
20 |
|
| 16 |
@Results({
|
21 |
@Results({
|
| 17 |
@Result(name="recharge-redirect", type="redirectAction", params = {"actionName" , "recharge"}),
|
22 |
@Result(name="recharge-redirect", type="redirectAction", params = {"actionName" , "recharge", "error", "${errorMessage}"}),
|
| 18 |
@Result(name="recharge-pay-options-redirect", type="redirectAction", params = {"actionName" , "recharge-pay-options", "rechargeOrderId", "${rechargeOrderId}"}),
|
23 |
@Result(name="recharge-pay-options-redirect", type="redirectAction", params = {"actionName" , "recharge-pay-options", "rechargeOrderId", "${rechargeOrderId}"}),
|
| 19 |
@Result(name="ebs-pay-redirect", type="redirectAction", params = {"actionName", "/ebs-pay/${paymentId}/edit", "phone", "${phone}"}),
|
24 |
@Result(name="ebs-pay-redirect", type="redirectAction", params = {"actionName", "/ebs-pay/${paymentId}/edit", "phone", "${phone}"}),
|
| 20 |
@Result(name="cod-redirect", type="redirect", location="/pay-success?paymentId=${paymentId}")
|
25 |
@Result(name="cod-redirect", type="redirect", location="/pay-success?paymentId=${paymentId}")
|
| 21 |
})
|
26 |
})
|
| 22 |
|
27 |
|
| Line 57... |
Line 62... |
| 57 |
|
62 |
|
| 58 |
private String id;
|
63 |
private String id;
|
| 59 |
private long txnId = 0;
|
64 |
private long txnId = 0;
|
| 60 |
|
65 |
|
| 61 |
private long paymentId;
|
66 |
private long paymentId;
|
| - |
|
67 |
private String errorMessage;
|
| 62 |
|
68 |
|
| 63 |
private String redirectURL;
|
69 |
private String redirectURL;
|
| 64 |
private RechargeOrder rechargeOrder;
|
70 |
private RechargeOrder rechargeOrder;
|
| 65 |
|
71 |
|
| 66 |
// GET /order/ orderid
|
72 |
// GET /order/ orderid
|
| Line 73... |
Line 79... |
| 73 |
|
79 |
|
| 74 |
// POST /order/
|
80 |
// POST /order/
|
| 75 |
public String create(){
|
81 |
public String create(){
|
| 76 |
|
82 |
|
| 77 |
if(rechargeOrderId == null){
|
83 |
if(rechargeOrderId == null){
|
| - |
|
84 |
setErrorMessage("There was some problem. Please try again.");
|
| 78 |
return "recharge-redirect";
|
85 |
return "recharge-redirect";
|
| 79 |
}
|
86 |
}
|
| 80 |
try {
|
87 |
try {
|
| 81 |
TransactionClient tc = new TransactionClient();
|
88 |
TransactionClient tc = new TransactionClient();
|
| 82 |
rechargeOrder = tc.getClient().getRechargeOrder(Long.parseLong(rechargeOrderId));
|
89 |
rechargeOrder = tc.getClient().getRechargeOrder(Long.parseLong(rechargeOrderId));
|
| 83 |
} catch (Exception ee) {
|
90 |
} catch (Exception ee) {
|
| 84 |
log.error("problem fetching rechargeOrder : " + rechargeOrderId);
|
91 |
log.error("problem fetching rechargeOrder : " + rechargeOrderId);
|
| - |
|
92 |
setErrorMessage("There was some problem. Please try again.");
|
| - |
|
93 |
return "recharge-redirect";
|
| - |
|
94 |
}
|
| - |
|
95 |
|
| - |
|
96 |
try {
|
| - |
|
97 |
PaymentClient paymentServiceClient = new PaymentClient();
|
| - |
|
98 |
List<Payment> payments = paymentServiceClient.getClient().getPaymentForRechargeTxnId(rechargeOrder.getTransactionId());
|
| - |
|
99 |
if(payments.size() > 0) {
|
| - |
|
100 |
setErrorMessage("There was some problem. Please try again.");
|
| - |
|
101 |
return "recharge-redirect";
|
| - |
|
102 |
}
|
| - |
|
103 |
} catch (Exception ee) {
|
| - |
|
104 |
log.error("problem fetching payment for rechargeId : " + rechargeOrderId);
|
| - |
|
105 |
setErrorMessage("There was some problem. Please try again.");
|
| 85 |
return "recharge-redirect";
|
106 |
return "recharge-redirect";
|
| 86 |
}
|
107 |
}
|
| - |
|
108 |
|
| 87 |
try {
|
109 |
try {
|
| 88 |
UserClient uc = new UserClient();
|
110 |
UserClient uc = new UserClient();
|
| 89 |
if(!name.isEmpty() && !phone.isEmpty()) {
|
111 |
if(!name.isEmpty() && !phone.isEmpty()) {
|
| 90 |
Address address = new Address();
|
112 |
Address address = new Address();
|
| 91 |
address.setName(name);
|
113 |
address.setName(name);
|
| Line 145... |
Line 167... |
| 145 |
EbsPaymentService ebsPaymentService = new EbsPaymentService();
|
167 |
EbsPaymentService ebsPaymentService = new EbsPaymentService();
|
| 146 |
paymentId = ebsPaymentService.createPayment(rechargeOrder, paymentOption);
|
168 |
paymentId = ebsPaymentService.createPayment(rechargeOrder, paymentOption);
|
| 147 |
if(paymentId == IPaymentService.PAYMENT_NOT_CREATED){
|
169 |
if(paymentId == IPaymentService.PAYMENT_NOT_CREATED){
|
| 148 |
addActionError("We are experiencing some problems. Please try later.");
|
170 |
addActionError("We are experiencing some problems. Please try later.");
|
| 149 |
log.error("Unable to process payment through EBS.");
|
171 |
log.error("Unable to process payment through EBS.");
|
| - |
|
172 |
setErrorMessage("There was some problem. Please try again.");
|
| 150 |
return "recharge-redirect";
|
173 |
return "recharge-redirect";
|
| 151 |
} else {
|
174 |
} else {
|
| 152 |
log.info("Successfully created payment for EBS to process. Redirecting to /ebs-pay/" + paymentId);
|
175 |
log.info("Successfully created payment for EBS to process. Redirecting to /ebs-pay/" + paymentId);
|
| 153 |
return "ebs-pay-redirect";
|
176 |
return "ebs-pay-redirect";
|
| 154 |
}
|
177 |
}
|
| Line 231... |
Line 254... |
| 231 |
}
|
254 |
}
|
| 232 |
|
255 |
|
| 233 |
public void setPincode(String pincode) {
|
256 |
public void setPincode(String pincode) {
|
| 234 |
this.pincode = pincode;
|
257 |
this.pincode = pincode;
|
| 235 |
}
|
258 |
}
|
| - |
|
259 |
|
| - |
|
260 |
public void setErrorMessage(String errorMessage) {
|
| - |
|
261 |
this.errorMessage = errorMessage;
|
| - |
|
262 |
}
|
| - |
|
263 |
|
| - |
|
264 |
public String getErrorMessage() {
|
| - |
|
265 |
return errorMessage;
|
| - |
|
266 |
}
|
| 236 |
}
|
267 |
}
|
| 237 |
|
268 |
|