| Line 8... |
Line 8... |
| 8 |
|
8 |
|
| 9 |
import org.apache.thrift.TException;
|
9 |
import org.apache.thrift.TException;
|
| 10 |
import org.springframework.context.ApplicationContext;
|
10 |
import org.springframework.context.ApplicationContext;
|
| 11 |
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
11 |
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
| 12 |
|
12 |
|
| - |
|
13 |
import in.shop2020.payment.domain.Refund;
|
| 13 |
import in.shop2020.payment.handler.PaymentGatewayHandler;
|
14 |
import in.shop2020.payment.handler.PaymentGatewayHandler;
|
| 14 |
import in.shop2020.payment.handler.PaymentHandler;
|
15 |
import in.shop2020.payment.handler.PaymentHandler;
|
| - |
|
16 |
import in.shop2020.payment.handler.RefundHandler;
|
| 15 |
import in.shop2020.payments.Attribute;
|
17 |
import in.shop2020.payments.Attribute;
|
| 16 |
import in.shop2020.payments.Payment;
|
18 |
import in.shop2020.payments.Payment;
|
| 17 |
import in.shop2020.payments.PaymentException;
|
19 |
import in.shop2020.payments.PaymentException;
|
| 18 |
import in.shop2020.payments.PaymentGateway;
|
20 |
import in.shop2020.payments.PaymentGateway;
|
| 19 |
import in.shop2020.payments.PaymentService.Iface;
|
21 |
import in.shop2020.payments.PaymentService.Iface;
|
| Line 28... |
Line 30... |
| 28 |
private static final String CAPTURE_TIME = "CaptureTime";
|
30 |
private static final String CAPTURE_TIME = "CaptureTime";
|
| 29 |
|
31 |
|
| 30 |
ApplicationContext context = new ClassPathXmlApplicationContext("context.xml");
|
32 |
ApplicationContext context = new ClassPathXmlApplicationContext("context.xml");
|
| 31 |
PaymentHandler paymentHandler = (PaymentHandler) context.getBean("paymentHandler");
|
33 |
PaymentHandler paymentHandler = (PaymentHandler) context.getBean("paymentHandler");
|
| 32 |
PaymentGatewayHandler paymentGatewayHandler = (PaymentGatewayHandler) context.getBean("paymentGatewayHandler");
|
34 |
PaymentGatewayHandler paymentGatewayHandler = (PaymentGatewayHandler) context.getBean("paymentGatewayHandler");
|
| - |
|
35 |
RefundHandler refundHandler = (RefundHandler) context.getBean("refundHandler");
|
| 33 |
|
36 |
|
| 34 |
@Override
|
37 |
@Override
|
| 35 |
public void closeSession() throws TException {
|
38 |
public void closeSession() throws TException {
|
| 36 |
// TODO Auto-generated method stub
|
39 |
// TODO Auto-generated method stub
|
| 37 |
}
|
40 |
}
|
| Line 227... |
Line 230... |
| 227 |
|
230 |
|
| 228 |
payment = payments.get(0);
|
231 |
payment = payments.get(0);
|
| 229 |
if(payment.getStatus() != PaymentStatus.SUCCESS.getValue())
|
232 |
if(payment.getStatus() != PaymentStatus.SUCCESS.getValue())
|
| 230 |
throw new PaymentException(104, "No successful payments found corresponding to the merchant txn " + merchantTxnId);
|
233 |
throw new PaymentException(104, "No successful payments found corresponding to the merchant txn " + merchantTxnId);
|
| 231 |
|
234 |
|
| 232 |
//TODO: Create a refund and return its id.
|
235 |
Refund refund = new Refund();
|
| - |
|
236 |
refund.setOrderId(orderId);
|
| - |
|
237 |
refund.setPaymentId(payment.getId());
|
| - |
|
238 |
refund.setGatewayId(payment.getGatewayId());
|
| - |
|
239 |
refund.setAmount(amount);
|
| 233 |
return -1;
|
240 |
refund.setAttempts(0);
|
| - |
|
241 |
return refundHandler.createRefund(refund);
|
| 234 |
}
|
242 |
}
|
| 235 |
|
243 |
|
| 236 |
private boolean validatePaymentParams(double amount, Payment payment){
|
244 |
private boolean validatePaymentParams(double amount, Payment payment){
|
| 237 |
if(payment==null || payment.getAmount()!= amount){
|
245 |
if(payment==null || payment.getAmount()!= amount){
|
| 238 |
// We did not request this payment or the authorised amount is different.
|
246 |
// We did not request this payment or the authorised amount is different.
|