| Line 1... |
Line 1... |
| 1 |
package in.shop2020.serving.controllers;
|
1 |
package in.shop2020.serving.controllers;
|
| 2 |
|
2 |
|
| 3 |
import in.shop2020.config.ConfigException;
|
3 |
import in.shop2020.config.ConfigException;
|
| 4 |
import in.shop2020.datalogger.EventType;
|
4 |
import in.shop2020.datalogger.EventType;
|
| - |
|
5 |
import in.shop2020.model.v1.order.RechargeOrderStatus;
|
| - |
|
6 |
import in.shop2020.model.v1.order.TransactionServiceException;
|
| 5 |
import in.shop2020.payments.Attribute;
|
7 |
import in.shop2020.payments.Attribute;
|
| 6 |
import in.shop2020.payments.Payment;
|
8 |
import in.shop2020.payments.Payment;
|
| 7 |
import in.shop2020.payments.PaymentException;
|
9 |
import in.shop2020.payments.PaymentException;
|
| 8 |
import in.shop2020.payments.PaymentStatus;
|
10 |
import in.shop2020.payments.PaymentStatus;
|
| 9 |
import in.shop2020.serving.services.CommonPaymentService;
|
11 |
import in.shop2020.serving.services.CommonPaymentService;
|
| Line 39... |
Line 41... |
| 39 |
private static final String TXN_KEY = "TransactionID";
|
41 |
private static final String TXN_KEY = "TransactionID";
|
| 40 |
private static final String AUTH_TXN_ID = "AuthTxnId";
|
42 |
private static final String AUTH_TXN_ID = "AuthTxnId";
|
| 41 |
|
43 |
|
| 42 |
private static String successUrl;
|
44 |
private static String successUrl;
|
| 43 |
private static String errorUrl;
|
45 |
private static String errorUrl;
|
| - |
|
46 |
private static String rechargeResultUri;
|
| 44 |
|
47 |
|
| 45 |
/**
|
48 |
/**
|
| 46 |
* The secret key used to decode RC4 encoded data.
|
49 |
* The secret key used to decode RC4 encoded data.
|
| 47 |
*/
|
50 |
*/
|
| 48 |
private static String accountKey;
|
51 |
private static String accountKey;
|
| Line 51... |
Line 54... |
| 51 |
|
54 |
|
| 52 |
static{
|
55 |
static{
|
| 53 |
try {
|
56 |
try {
|
| 54 |
successUrl = ConfigClient.getClient().get("ebs_success_url");
|
57 |
successUrl = ConfigClient.getClient().get("ebs_success_url");
|
| 55 |
errorUrl = ConfigClient.getClient().get("ebs_error_url");
|
58 |
errorUrl = ConfigClient.getClient().get("ebs_error_url");
|
| - |
|
59 |
setRechargeResultUri(ConfigClient.getClient().get("recharge_success_url"));
|
| 56 |
accountKey = ConfigClient.getClient().get("ebs_secret_key");
|
60 |
accountKey = ConfigClient.getClient().get("ebs_secret_key");
|
| 57 |
} catch (ConfigException e) {
|
61 |
} catch (ConfigException e) {
|
| 58 |
log.error("Unable to get success and error usr info from config server.");
|
62 |
log.error("Unable to get success and error usr info from config server.");
|
| 59 |
}
|
63 |
}
|
| 60 |
}
|
64 |
}
|
| Line 125... |
Line 129... |
| 125 |
} catch (PaymentException e) {
|
129 |
} catch (PaymentException e) {
|
| 126 |
log.error("Unable to mark the payment as authorized", e);
|
130 |
log.error("Unable to mark the payment as authorized", e);
|
| 127 |
} catch (TException e) {
|
131 |
} catch (TException e) {
|
| 128 |
log.error("Unable to mark the payment as authorized", e);
|
132 |
log.error("Unable to mark the payment as authorized", e);
|
| 129 |
}
|
133 |
}
|
| - |
|
134 |
|
| - |
|
135 |
if(payment.isIsDigital()) {
|
| - |
|
136 |
try {
|
| - |
|
137 |
transactionServiceClient.getClient().updateRechargeOrderStatus(txnId, RechargeOrderStatus.PAYMENT_SUCCESSFUL);
|
| - |
|
138 |
} catch (Exception e) {
|
| - |
|
139 |
// TODO Auto-generated catch block
|
| - |
|
140 |
e.printStackTrace();
|
| - |
|
141 |
}
|
| - |
|
142 |
this.redirectUrl = rechargeResultUri + "?paymentId=" + merchantPaymentId;
|
| - |
|
143 |
} else {
|
| 130 |
|
144 |
|
| 131 |
if(isFlagged.equals("YES")){
|
145 |
if(isFlagged.equals("YES")){
|
| 132 |
CommonPaymentService.processSuccessfulTxn(txnId, userServiceClient, transactionServiceClient, true);
|
146 |
CommonPaymentService.processSuccessfulTxn(txnId, userServiceClient, transactionServiceClient, true);
|
| 133 |
this.redirectUrl = successUrl + "?paymentId=" + merchantPaymentId;
|
147 |
this.redirectUrl = successUrl + "?paymentId=" + merchantPaymentId;
|
| 134 |
}else{
|
148 |
}else{
|
| 135 |
CommonPaymentService.processSuccessfulTxn(txnId, userServiceClient, transactionServiceClient, false);
|
149 |
CommonPaymentService.processSuccessfulTxn(txnId, userServiceClient, transactionServiceClient, false);
|
| 136 |
this.redirectUrl = successUrl + "?paymentId=" + merchantPaymentId;
|
150 |
this.redirectUrl = successUrl + "?paymentId=" + merchantPaymentId;
|
| - |
|
151 |
}
|
| 137 |
}
|
152 |
}
|
| 138 |
|
- |
|
| 139 |
|
153 |
|
| 140 |
|
154 |
|
| 141 |
// Map<String, String> captureResult = EbsPaymentService.capturePayment(payment, gatewayPaymentId);
|
155 |
// Map<String, String> captureResult = EbsPaymentService.capturePayment(payment, gatewayPaymentId);
|
| 142 |
// String captureStatus = captureResult.get(IPaymentService.STATUS);
|
156 |
// String captureStatus = captureResult.get(IPaymentService.STATUS);
|
| 143 |
//
|
157 |
//
|
| Line 181... |
Line 195... |
| 181 |
} catch (PaymentException e) {
|
195 |
} catch (PaymentException e) {
|
| 182 |
log.error("Unable to mark the payment as failed", e);
|
196 |
log.error("Unable to mark the payment as failed", e);
|
| 183 |
} catch (TException e) {
|
197 |
} catch (TException e) {
|
| 184 |
log.error("Unable to mark the payment as failed", e);
|
198 |
log.error("Unable to mark the payment as failed", e);
|
| 185 |
}
|
199 |
}
|
| 186 |
|
- |
|
| - |
|
200 |
if(!payment.isIsDigital()) {
|
| 187 |
CommonPaymentService.processFailedTxn(txnId, transactionServiceClient);
|
201 |
CommonPaymentService.processFailedTxn(txnId, transactionServiceClient);
|
| 188 |
DataLogger.logData(EventType.PAYMENT_FAILURE, getSessionId(), userinfo.getUserId(), userinfo.getEmail(), Long.toString(merchantPaymentId), gatewayPaymentId,
|
202 |
DataLogger.logData(EventType.PAYMENT_FAILURE, getSessionId(), userinfo.getUserId(), userinfo.getEmail(), Long.toString(merchantPaymentId), gatewayPaymentId,
|
| 189 |
gatewayTxnStatus, description);
|
203 |
gatewayTxnStatus, description);
|
| 190 |
|
204 |
|
| 191 |
this.redirectUrl = errorUrl + "?paymentId=" + merchantPaymentId;
|
205 |
this.redirectUrl = errorUrl + "?paymentId=" + merchantPaymentId;
|
| - |
|
206 |
} else {
|
| - |
|
207 |
this.redirectUrl = rechargeResultUri + "?paymentId=" + merchantPaymentId;
|
| - |
|
208 |
}
|
| 192 |
}
|
209 |
}
|
| 193 |
|
210 |
|
| 194 |
log.info("User will be redirected to: " + this.redirectUrl);
|
211 |
log.info("User will be redirected to: " + this.redirectUrl);
|
| 195 |
return "index";
|
212 |
return "index";
|
| 196 |
}
|
213 |
}
|
| Line 260... |
Line 277... |
| 260 |
}
|
277 |
}
|
| 261 |
|
278 |
|
| 262 |
public Map<String, String> getPaymentParams() {
|
279 |
public Map<String, String> getPaymentParams() {
|
| 263 |
return paymentParams;
|
280 |
return paymentParams;
|
| 264 |
}
|
281 |
}
|
| - |
|
282 |
|
| - |
|
283 |
public static void setRechargeResultUri(String rechargeResultUri) {
|
| - |
|
284 |
EbsPayResponseController.rechargeResultUri = rechargeResultUri;
|
| - |
|
285 |
}
|
| - |
|
286 |
|
| - |
|
287 |
public static String getRechargeResultUri() {
|
| - |
|
288 |
return rechargeResultUri;
|
| - |
|
289 |
}
|
| 265 |
}
|
290 |
}
|