| Line 8... |
Line 8... |
| 8 |
import org.apache.log4j.Logger;
|
8 |
import org.apache.log4j.Logger;
|
| 9 |
import org.apache.struts2.convention.annotation.InterceptorRef;
|
9 |
import org.apache.struts2.convention.annotation.InterceptorRef;
|
| 10 |
import org.apache.struts2.convention.annotation.InterceptorRefs;
|
10 |
import org.apache.struts2.convention.annotation.InterceptorRefs;
|
| 11 |
import org.apache.struts2.convention.annotation.Result;
|
11 |
import org.apache.struts2.convention.annotation.Result;
|
| 12 |
import org.apache.struts2.convention.annotation.Results;
|
12 |
import org.apache.struts2.convention.annotation.Results;
|
| - |
|
13 |
import org.apache.thrift.transport.TTransportException;
|
| 13 |
|
14 |
|
| 14 |
import com.opensymphony.xwork2.ValidationAwareSupport;
|
15 |
import com.opensymphony.xwork2.ValidationAwareSupport;
|
| 15 |
|
16 |
|
| 16 |
import in.shop2020.config.ConfigException;
|
17 |
import in.shop2020.config.ConfigException;
|
| 17 |
import in.shop2020.model.v1.order.LineItem;
|
18 |
import in.shop2020.model.v1.order.LineItem;
|
| 18 |
import in.shop2020.model.v1.order.Order;
|
19 |
import in.shop2020.model.v1.order.Order;
|
| - |
|
20 |
import in.shop2020.model.v1.order.RechargeOrder;
|
| 19 |
import in.shop2020.model.v1.order.Transaction;
|
21 |
import in.shop2020.model.v1.order.Transaction;
|
| 20 |
import in.shop2020.payments.Attribute;
|
22 |
import in.shop2020.payments.Attribute;
|
| 21 |
import in.shop2020.payments.Payment;
|
23 |
import in.shop2020.payments.Payment;
|
| 22 |
import in.shop2020.serving.services.IPaymentService;
|
24 |
import in.shop2020.serving.services.IPaymentService;
|
| - |
|
25 |
import in.shop2020.test.Address;
|
| 23 |
import in.shop2020.thrift.clients.PaymentClient;
|
26 |
import in.shop2020.thrift.clients.PaymentClient;
|
| 24 |
import in.shop2020.thrift.clients.TransactionClient;
|
27 |
import in.shop2020.thrift.clients.TransactionClient;
|
| - |
|
28 |
import in.shop2020.thrift.clients.UserClient;
|
| 25 |
import in.shop2020.thrift.clients.config.ConfigClient;
|
29 |
import in.shop2020.thrift.clients.config.ConfigClient;
|
| 26 |
|
30 |
|
| 27 |
@SuppressWarnings("serial")
|
31 |
@SuppressWarnings("serial")
|
| 28 |
@InterceptorRefs({
|
32 |
@InterceptorRefs({
|
| 29 |
@InterceptorRef("myDefault"),
|
33 |
@InterceptorRef("myDefault"),
|
| Line 105... |
Line 109... |
| 105 |
|
109 |
|
| 106 |
log.info(billingDetails);
|
110 |
log.info(billingDetails);
|
| 107 |
|
111 |
|
| 108 |
return "show";
|
112 |
return "show";
|
| 109 |
}
|
113 |
}
|
| - |
|
114 |
|
| - |
|
115 |
|
| - |
|
116 |
/**
|
| - |
|
117 |
* This method is used for Recharge payments. It is being called by RechargePaymentController.
|
| - |
|
118 |
* @return
|
| - |
|
119 |
*/
|
| - |
|
120 |
public String edit(){
|
| - |
|
121 |
PaymentClient paymentServiceClient = null;
|
| - |
|
122 |
Payment payment = null;
|
| - |
|
123 |
try {
|
| - |
|
124 |
long paymentId = Long.parseLong(this.id);
|
| - |
|
125 |
paymentServiceClient = new PaymentClient();
|
| - |
|
126 |
payment = paymentServiceClient.getClient().getPayment(paymentId);
|
| - |
|
127 |
} catch (Exception e) {
|
| - |
|
128 |
log.error("Error while getting payment client", e);
|
| - |
|
129 |
addActionError("We are experiencing some problems. Please try later.");
|
| - |
|
130 |
return "shipping-redirect";
|
| - |
|
131 |
}
|
| - |
|
132 |
|
| - |
|
133 |
RechargeOrder rechargeOrder = null;
|
| - |
|
134 |
try {
|
| - |
|
135 |
long txnId = payment.getMerchantTxnId();
|
| - |
|
136 |
TransactionClient transactionServiceClient = new TransactionClient();
|
| - |
|
137 |
in.shop2020.model.v1.order.TransactionService.Client txnClient = transactionServiceClient.getClient();
|
| - |
|
138 |
rechargeOrder = txnClient.getRechargeOrdersForTransaction(txnId);
|
| - |
|
139 |
} catch (Exception e) {
|
| - |
|
140 |
log.error("Error while getting transaction information", e);
|
| - |
|
141 |
addActionError("We are experiencing some problems. Please try later.");
|
| - |
|
142 |
return "shipping-redirect";
|
| - |
|
143 |
}
|
| - |
|
144 |
|
| - |
|
145 |
String desc = "Recharge for Rs. " + rechargeOrder.getTotalAmount() + ", operator : " + rechargeOrder.getOperatorId();
|
| - |
|
146 |
this.description = new StringBuilder(desc);
|
| - |
|
147 |
setPaymentOption(payment);
|
| - |
|
148 |
|
| - |
|
149 |
this.amount = payment.getAmount();
|
| - |
|
150 |
UserClient userClient;
|
| - |
|
151 |
in.shop2020.model.v1.user.Address address = null;
|
| - |
|
152 |
try {
|
| - |
|
153 |
userClient = new UserClient();
|
| - |
|
154 |
long addressId = userClient.getClient().getDefaultAddressId(rechargeOrder.getUserId());
|
| - |
|
155 |
address = userClient.getClient().getAddressById(addressId);
|
| - |
|
156 |
} catch (Exception e) {
|
| - |
|
157 |
log.error("Unable to get address to put in billing details");
|
| - |
|
158 |
e.printStackTrace();
|
| - |
|
159 |
}
|
| - |
|
160 |
this.billingDetails = new ContactDetails(address.getName(),
|
| - |
|
161 |
rechargeOrder.getUserEmailId(), address.getLine1(),
|
| - |
|
162 |
address.getCity(), address.getState(),
|
| - |
|
163 |
address.getPin(), "IND",
|
| - |
|
164 |
address.getPhone());
|
| - |
|
165 |
|
| - |
|
166 |
log.info(billingDetails);
|
| - |
|
167 |
|
| - |
|
168 |
return "show";
|
| - |
|
169 |
}
|
| 110 |
|
170 |
|
| 111 |
public String getDescription(){
|
171 |
public String getDescription(){
|
| 112 |
if(this.description.length() >= 255)
|
172 |
if(this.description.length() >= 255)
|
| 113 |
return this.description.substring(0, 255);
|
173 |
return this.description.substring(0, 255);
|
| 114 |
else
|
174 |
else
|