| Line 16... |
Line 16... |
| 16 |
import in.shop2020.payments.Payment;
|
16 |
import in.shop2020.payments.Payment;
|
| 17 |
import in.shop2020.payments.PaymentException;
|
17 |
import in.shop2020.payments.PaymentException;
|
| 18 |
import in.shop2020.payments.PaymentStatus;
|
18 |
import in.shop2020.payments.PaymentStatus;
|
| 19 |
import in.shop2020.serving.services.CommonPaymentService;
|
19 |
import in.shop2020.serving.services.CommonPaymentService;
|
| 20 |
import in.shop2020.serving.services.EbsPaymentService;
|
20 |
import in.shop2020.serving.services.EbsPaymentService;
|
| - |
|
21 |
import in.shop2020.serving.services.IPaymentService;
|
| 21 |
import in.shop2020.serving.utils.DataLogger;
|
22 |
import in.shop2020.serving.utils.DataLogger;
|
| 22 |
import in.shop2020.serving.utils.ebs.Base64;
|
23 |
import in.shop2020.serving.utils.ebs.Base64;
|
| 23 |
import in.shop2020.serving.utils.ebs.RC4;
|
24 |
import in.shop2020.serving.utils.ebs.RC4;
|
| 24 |
import in.shop2020.thrift.clients.PaymentServiceClient;
|
25 |
import in.shop2020.thrift.clients.PaymentServiceClient;
|
| 25 |
import in.shop2020.thrift.clients.TransactionServiceClient;
|
26 |
import in.shop2020.thrift.clients.TransactionServiceClient;
|
| Line 37... |
Line 38... |
| 37 |
private static Logger log = Logger.getLogger(Class.class);
|
38 |
private static Logger log = Logger.getLogger(Class.class);
|
| 38 |
|
39 |
|
| 39 |
private static final String FLAG_KEY = "IsFlagged";
|
40 |
private static final String FLAG_KEY = "IsFlagged";
|
| 40 |
private static final String TXN_KEY = "TransactionID";
|
41 |
private static final String TXN_KEY = "TransactionID";
|
| 41 |
private static final String AUTH_TXN_ID = "AuthTxnId";
|
42 |
private static final String AUTH_TXN_ID = "AuthTxnId";
|
| 42 |
private static final String CAPTURE_TXN_ID = "CaptureTxnId";
|
- |
|
| 43 |
private static final String CAPTURE_TIME = "CaptureTime";
|
- |
|
| 44 |
|
- |
|
| 45 |
|
43 |
|
| 46 |
private static String successUrl;
|
44 |
private static String successUrl;
|
| 47 |
private static String errorUrl;
|
45 |
private static String errorUrl;
|
| 48 |
|
46 |
|
| 49 |
/**
|
47 |
/**
|
| Line 104... |
Line 102... |
| 104 |
Long txnId = null;
|
102 |
Long txnId = null;
|
| 105 |
try {
|
103 |
try {
|
| 106 |
payment = paymentServiceClient.getClient().getPayment(merchantPaymentId);
|
104 |
payment = paymentServiceClient.getClient().getPayment(merchantPaymentId);
|
| 107 |
txnId = payment.getMerchantTxnId();
|
105 |
txnId = payment.getMerchantTxnId();
|
| 108 |
} catch (PaymentException e1) {
|
106 |
} catch (PaymentException e1) {
|
| 109 |
log.error("Payment exception. It is serious, check merchant payment id + " + merchantPaymentId);
|
107 |
log.error("Payment exception. It is serious, check merchant payment id + " + merchantPaymentId, e1);
|
| 110 |
e1.printStackTrace();
|
- |
|
| 111 |
} catch (TException e1) {
|
108 |
} catch (TException e1) {
|
| 112 |
log.error("Thrift exception. Check payment id "+ merchantPaymentId);
|
109 |
log.error("Thrift exception. Check payment id "+ merchantPaymentId, e1);
|
| 113 |
e1.printStackTrace();
|
- |
|
| 114 |
}
|
110 |
}
|
| 115 |
|
111 |
|
| 116 |
if(payment.getStatus() != PaymentStatus.INIT){
|
112 |
if(payment.getStatus() != PaymentStatus.INIT){
|
| 117 |
// We have already processed a response for this payment. Processing
|
113 |
// We have already processed a response for this payment. Processing
|
| 118 |
// it again may fail his orders. So, let's ask him to check his
|
114 |
// it again may fail his orders. So, let's ask him to check his
|
| Line 135... |
Line 131... |
| 135 |
} catch (TException e) {
|
131 |
} catch (TException e) {
|
| 136 |
e.printStackTrace();
|
132 |
e.printStackTrace();
|
| 137 |
}
|
133 |
}
|
| 138 |
|
134 |
|
| 139 |
Map<String, String> captureResult = EbsPaymentService.capturePayment(amount, gatewayPaymentId);
|
135 |
Map<String, String> captureResult = EbsPaymentService.capturePayment(amount, gatewayPaymentId);
|
| 140 |
String captureStatus = captureResult.get(EbsPaymentService.STATUS);
|
136 |
String captureStatus = captureResult.get(IPaymentService.STATUS);
|
| 141 |
|
137 |
|
| 142 |
if("".equals(captureStatus)){
|
138 |
if("".equals(captureStatus)){
|
| 143 |
//Failure
|
139 |
//Failure
|
| 144 |
description = captureResult.get(EbsPaymentService.ERROR);
|
140 |
description = captureResult.get(EbsPaymentService.ERROR);
|
| 145 |
String errorCode = captureResult.get(EbsPaymentService.ERR_CODE);
|
141 |
String errorCode = captureResult.get(EbsPaymentService.ERR_CODE);
|
| Line 155... |
Line 151... |
| 155 |
gatewayTxnStatus, description, errorCode);
|
151 |
gatewayTxnStatus, description, errorCode);
|
| 156 |
this.redirectUrl = errorUrl + "?paymentId=" + merchantPaymentId;
|
152 |
this.redirectUrl = errorUrl + "?paymentId=" + merchantPaymentId;
|
| 157 |
}else{
|
153 |
}else{
|
| 158 |
//Success
|
154 |
//Success
|
| 159 |
try {
|
155 |
try {
|
| 160 |
attributes.add(new Attribute(CAPTURE_TXN_ID, captureResult.get(EbsPaymentService.TXN_ID)));
|
156 |
attributes.add(new Attribute(IPaymentService.CAPTURE_TXN_ID, captureResult.get(IPaymentService.CAPTURE_TXN_ID)));
|
| 161 |
attributes.add(new Attribute(CAPTURE_TIME, captureResult.get(EbsPaymentService.DATE_TIME)));
|
157 |
attributes.add(new Attribute(IPaymentService.CAPTURE_TIME, captureResult.get(IPaymentService.CAPTURE_TIME)));
|
| 162 |
|
158 |
|
| 163 |
paymentServiceClient.getClient().updatePaymentDetails(merchantPaymentId, gatewayPaymentId,
|
159 |
paymentServiceClient.getClient().updatePaymentDetails(merchantPaymentId, gatewayPaymentId,
|
| 164 |
"", captureStatus, description, "", "", "", "", PaymentStatus.SUCCESS, "", attributes);
|
160 |
"", captureStatus, description, "", "", "", "", PaymentStatus.SUCCESS, "", attributes);
|
| 165 |
} catch (PaymentException e) {
|
161 |
} catch (PaymentException e) {
|
| 166 |
log.error("Error while updating successful capture payment attempt: ", e);
|
162 |
log.error("Error while updating successful capture payment attempt: ", e);
|