| Line 1... |
Line 1... |
| 1 |
package in.shop2020.payment.service.handler;
|
1 |
package in.shop2020.payment.service.handler;
|
| 2 |
|
2 |
|
| - |
|
3 |
import in.shop2020.model.v1.order.RechargeOrder;
|
| - |
|
4 |
import in.shop2020.model.v1.order.TransactionServiceException;
|
| 3 |
import in.shop2020.payment.domain.Refund;
|
5 |
import in.shop2020.payment.domain.Refund;
|
| 4 |
import in.shop2020.payment.handler.PaymentGatewayHandler;
|
6 |
import in.shop2020.payment.handler.PaymentGatewayHandler;
|
| 5 |
import in.shop2020.payment.handler.PaymentHandler;
|
7 |
import in.shop2020.payment.handler.PaymentHandler;
|
| 6 |
import in.shop2020.payment.handler.PaymentRequiringExtraProcessingHandler;
|
8 |
import in.shop2020.payment.handler.PaymentRequiringExtraProcessingHandler;
|
| 7 |
import in.shop2020.payment.handler.RefundHandler;
|
9 |
import in.shop2020.payment.handler.RefundHandler;
|
| Line 10... |
Line 12... |
| 10 |
import in.shop2020.payments.Payment;
|
12 |
import in.shop2020.payments.Payment;
|
| 11 |
import in.shop2020.payments.PaymentException;
|
13 |
import in.shop2020.payments.PaymentException;
|
| 12 |
import in.shop2020.payments.PaymentGateway;
|
14 |
import in.shop2020.payments.PaymentGateway;
|
| 13 |
import in.shop2020.payments.PaymentService.Iface;
|
15 |
import in.shop2020.payments.PaymentService.Iface;
|
| 14 |
import in.shop2020.payments.PaymentStatus;
|
16 |
import in.shop2020.payments.PaymentStatus;
|
| - |
|
17 |
import in.shop2020.thrift.clients.TransactionClient;
|
| 15 |
|
18 |
|
| 16 |
import java.text.SimpleDateFormat;
|
19 |
import java.text.SimpleDateFormat;
|
| 17 |
import java.util.ArrayList;
|
20 |
import java.util.ArrayList;
|
| 18 |
import java.util.Date;
|
21 |
import java.util.Date;
|
| 19 |
import java.util.HashMap;
|
22 |
import java.util.HashMap;
|
| Line 76... |
Line 79... |
| 76 |
org.apache.commons.dbcp.BasicDataSource ds = (org.apache.commons.dbcp.BasicDataSource)context.getBean("dataSource");
|
79 |
org.apache.commons.dbcp.BasicDataSource ds = (org.apache.commons.dbcp.BasicDataSource)context.getBean("dataSource");
|
| 77 |
return ds.getUrl();
|
80 |
return ds.getUrl();
|
| 78 |
}
|
81 |
}
|
| 79 |
|
82 |
|
| 80 |
@Override
|
83 |
@Override
|
| 81 |
public long createPayment(long userId, double amount, long gatewayId, long txnId) throws PaymentException, TException {
|
84 |
public long createPayment(long userId, double amount, long gatewayId, long txnId, boolean isDigital) throws PaymentException, TException {
|
| 82 |
logger.info("Creating payment corresponding to our txn id:" + txnId);
|
85 |
logger.info("Creating payment corresponding to our txn id:" + txnId);
|
| 83 |
in.shop2020.payment.domain.Payment payment = new in.shop2020.payment.domain.Payment();
|
86 |
in.shop2020.payment.domain.Payment payment = new in.shop2020.payment.domain.Payment();
|
| 84 |
payment.setUserId(userId);
|
87 |
payment.setUserId(userId);
|
| 85 |
payment.setAmount(amount);
|
88 |
payment.setAmount(amount);
|
| 86 |
payment.setGatewayId(gatewayId);
|
89 |
payment.setGatewayId(gatewayId);
|
| 87 |
payment.setMerchantTxnId(txnId);
|
90 |
payment.setMerchantTxnId(txnId);
|
| 88 |
payment.setStatus(PaymentStatus.INIT.getValue());
|
91 |
payment.setStatus(PaymentStatus.INIT.getValue());
|
| - |
|
92 |
payment.setDigital(isDigital);
|
| 89 |
|
93 |
|
| 90 |
return paymentHandler.insertPayment(payment);
|
94 |
return paymentHandler.insertPayment(payment);
|
| 91 |
}
|
95 |
}
|
| 92 |
|
96 |
|
| 93 |
@Override
|
97 |
@Override
|
| Line 222... |
Line 226... |
| 222 |
minMaxAmounts.add(Double.parseDouble(Float.toString(minMax.get("MIN"))));
|
226 |
minMaxAmounts.add(Double.parseDouble(Float.toString(minMax.get("MIN"))));
|
| 223 |
minMaxAmounts.add(Double.parseDouble(Float.toString(minMax.get("MAX"))));
|
227 |
minMaxAmounts.add(Double.parseDouble(Float.toString(minMax.get("MAX"))));
|
| 224 |
return minMaxAmounts;
|
228 |
return minMaxAmounts;
|
| 225 |
}
|
229 |
}
|
| 226 |
|
230 |
|
| 227 |
@Override
|
231 |
@Override
|
| 228 |
public String initializeHdfcPayment(long merchantPaymentId) throws PaymentException, TException {
|
232 |
public String initializeHdfcPayment(long merchantPaymentId) throws PaymentException, TException {
|
| 229 |
logger.info("Initializing HDFC payment with id: " + merchantPaymentId);
|
233 |
logger.info("Initializing HDFC payment with id: " + merchantPaymentId);
|
| 230 |
in.shop2020.payment.domain.Payment payment = paymentHandler.getPayment(merchantPaymentId);
|
234 |
in.shop2020.payment.domain.Payment payment = paymentHandler.getPayment(merchantPaymentId);
|
| 231 |
String redirectURL;
|
235 |
String redirectURL;
|
| 232 |
try {
|
236 |
try {
|
| 233 |
redirectURL = HdfcPaymentHandler.initializeHdfcPayment(payment, this);
|
237 |
redirectURL = HdfcPaymentHandler.initializeHdfcPayment(payment, this);
|
| 234 |
} catch (Exception e) {
|
238 |
} catch (Exception e) {
|
| 235 |
throw new PaymentException(102, "Error while initiliazing payment. Check service log for more details.");
|
239 |
throw new PaymentException(102, "Error while initiliazing payment. Check service log for more details.");
|
| - |
|
240 |
}
|
| - |
|
241 |
return redirectURL;
|
| 236 |
}
|
242 |
}
|
| - |
|
243 |
|
| - |
|
244 |
@Override
|
| - |
|
245 |
public String doHdfcPaymentForDigitalOrder(long merchantPaymentId, long rechargeOrderId) throws PaymentException, TException {
|
| - |
|
246 |
logger.info("Initializing HDFC payment with id: " + merchantPaymentId);
|
| - |
|
247 |
in.shop2020.payment.domain.Payment payment = paymentHandler.getPayment(merchantPaymentId);
|
| - |
|
248 |
TransactionClient tc = new TransactionClient();
|
| - |
|
249 |
String redirectURL;
|
| - |
|
250 |
RechargeOrder rechargeOrder;
|
| - |
|
251 |
try {
|
| - |
|
252 |
rechargeOrder = tc.getClient().getRechargeOrder(rechargeOrderId);
|
| - |
|
253 |
redirectURL = HdfcPaymentHandler.initializeHdfcPayment(payment, rechargeOrder, this);
|
| - |
|
254 |
} catch (Exception e) {
|
| - |
|
255 |
throw new PaymentException(102, "Error while initiliazing payment. Check service log for more details.");
|
| - |
|
256 |
}
|
| - |
|
257 |
|
| 237 |
return redirectURL;
|
258 |
return redirectURL;
|
| 238 |
}
|
259 |
}
|
| 239 |
|
260 |
|
| 240 |
@Override
|
261 |
@Override
|
| 241 |
public String initializeHdfcEmiPayment(long merchantPaymentId) throws PaymentException, TException {
|
262 |
public String initializeHdfcEmiPayment(long merchantPaymentId) throws PaymentException, TException {
|
| 242 |
logger.info("Initializing HDFC payment with id: " + merchantPaymentId);
|
263 |
logger.info("Initializing HDFC payment with id: " + merchantPaymentId);
|
| 243 |
in.shop2020.payment.domain.Payment payment = paymentHandler.getPayment(merchantPaymentId);
|
264 |
in.shop2020.payment.domain.Payment payment = paymentHandler.getPayment(merchantPaymentId);
|