| Line 48... |
Line 48... |
| 48 |
* The secret key used to decode RC4 encoded data.
|
48 |
* The secret key used to decode RC4 encoded data.
|
| 49 |
*/
|
49 |
*/
|
| 50 |
private static String accountKey;
|
50 |
private static String accountKey;
|
| 51 |
|
51 |
|
| 52 |
private String redirectUrl;
|
52 |
private String redirectUrl;
|
| 53 |
private String id;
|
- |
|
| 54 |
|
53 |
|
| 55 |
static{
|
54 |
static{
|
| 56 |
try {
|
55 |
try {
|
| 57 |
successUrl = ConfigClient.getClient().get("ebs_success_url");
|
56 |
successUrl = ConfigClient.getClient().get("ebs_success_url");
|
| 58 |
errorUrl = ConfigClient.getClient().get("ebs_error_url");
|
57 |
errorUrl = ConfigClient.getClient().get("ebs_error_url");
|
| Line 78... |
Line 77... |
| 78 |
try {
|
77 |
try {
|
| 79 |
paymentServiceClient = new PaymentServiceClient();
|
78 |
paymentServiceClient = new PaymentServiceClient();
|
| 80 |
transactionServiceClient = new TransactionServiceClient();
|
79 |
transactionServiceClient = new TransactionServiceClient();
|
| 81 |
userServiceClient = new UserContextServiceClient();
|
80 |
userServiceClient = new UserContextServiceClient();
|
| 82 |
} catch (Exception e) {
|
81 |
} catch (Exception e) {
|
| 83 |
log.error("Unable to initialize one of the clients");
|
82 |
log.error("Unable to initialize one of the clients", e);
|
| 84 |
e.printStackTrace();
|
- |
|
| 85 |
}
|
83 |
}
|
| 86 |
|
84 |
|
| 87 |
|
85 |
|
| 88 |
long merchantPaymentId = Long.parseLong(paymentParams.get("MerchantRefNo"));
|
86 |
long merchantPaymentId = Long.parseLong(paymentParams.get("MerchantRefNo"));
|
| 89 |
String gatewayPaymentId = paymentParams.get("PaymentID");
|
87 |
String gatewayPaymentId = paymentParams.get("PaymentID");
|
| Line 125... |
Line 123... |
| 125 |
//Update payment status as authorized
|
123 |
//Update payment status as authorized
|
| 126 |
try {
|
124 |
try {
|
| 127 |
paymentServiceClient.getClient().updatePaymentDetails(merchantPaymentId, gatewayPaymentId,
|
125 |
paymentServiceClient.getClient().updatePaymentDetails(merchantPaymentId, gatewayPaymentId,
|
| 128 |
"", gatewayTxnStatus, description, "", "", "", "", PaymentStatus.AUTHORIZED, "", attributes);
|
126 |
"", gatewayTxnStatus, description, "", "", "", "", PaymentStatus.AUTHORIZED, "", attributes);
|
| 129 |
} catch (PaymentException e) {
|
127 |
} catch (PaymentException e) {
|
| 130 |
e.printStackTrace();
|
128 |
log.error("Unable to mark the payment as authorized", e);
|
| 131 |
} catch (TException e) {
|
129 |
} catch (TException e) {
|
| 132 |
e.printStackTrace();
|
130 |
log.error("Unable to mark the payment as authorized", e);
|
| 133 |
}
|
131 |
}
|
| 134 |
|
132 |
|
| 135 |
Map<String, String> captureResult = EbsPaymentService.capturePayment(payment, gatewayPaymentId);
|
133 |
Map<String, String> captureResult = EbsPaymentService.capturePayment(payment, gatewayPaymentId);
|
| 136 |
String captureStatus = captureResult.get(IPaymentService.STATUS);
|
134 |
String captureStatus = captureResult.get(IPaymentService.STATUS);
|
| 137 |
|
135 |
|
| Line 173... |
Line 171... |
| 173 |
}else{
|
171 |
}else{
|
| 174 |
try {
|
172 |
try {
|
| 175 |
paymentServiceClient.getClient().updatePaymentDetails(merchantPaymentId, gatewayPaymentId,
|
173 |
paymentServiceClient.getClient().updatePaymentDetails(merchantPaymentId, gatewayPaymentId,
|
| 176 |
"", gatewayTxnStatus, description, "", "", "", "", PaymentStatus.FAILED, "", attributes);
|
174 |
"", gatewayTxnStatus, description, "", "", "", "", PaymentStatus.FAILED, "", attributes);
|
| 177 |
} catch (PaymentException e) {
|
175 |
} catch (PaymentException e) {
|
| 178 |
e.printStackTrace();
|
176 |
log.error("Unable to mark the payment as failed", e);
|
| 179 |
} catch (TException e) {
|
177 |
} catch (TException e) {
|
| 180 |
e.printStackTrace();
|
178 |
log.error("Unable to mark the payment as failed", e);
|
| 181 |
}
|
179 |
}
|
| 182 |
|
180 |
|
| 183 |
CommonPaymentService.processFailedTxn(txnId, transactionServiceClient);
|
181 |
CommonPaymentService.processFailedTxn(txnId, transactionServiceClient);
|
| 184 |
DataLogger.logData(EventType.PAYMENT_FAILURE, session.getId(), userinfo.getUserId(), userinfo.getEmail(), Long.toString(merchantPaymentId), gatewayPaymentId,
|
182 |
DataLogger.logData(EventType.PAYMENT_FAILURE, session.getId(), userinfo.getUserId(), userinfo.getEmail(), Long.toString(merchantPaymentId), gatewayPaymentId,
|
| 185 |
gatewayTxnStatus, description);
|
183 |
gatewayTxnStatus, description);
|
| Line 189... |
Line 187... |
| 189 |
|
187 |
|
| 190 |
log.info("User will be redirected to: " + this.redirectUrl);
|
188 |
log.info("User will be redirected to: " + this.redirectUrl);
|
| 191 |
return "index";
|
189 |
return "index";
|
| 192 |
}
|
190 |
}
|
| 193 |
|
191 |
|
| 194 |
public String getId() {
|
- |
|
| 195 |
return id;
|
- |
|
| 196 |
}
|
- |
|
| 197 |
|
- |
|
| 198 |
private boolean validatePaymentParams(double returnedAmount, Payment payment){
|
192 |
private boolean validatePaymentParams(double returnedAmount, Payment payment){
|
| 199 |
if(!(payment != null && Math.abs(payment.getAmount() - returnedAmount) <= 0.50)){
|
193 |
if(!(payment != null && Math.abs(payment.getAmount() - returnedAmount) <= 0.50)){
|
| 200 |
// We did not request this payment or the authorised amount is different.
|
194 |
// We did not request this payment or the authorised amount is different.
|
| 201 |
log.error("Checks and balance failed on returned data");
|
195 |
log.error("Checks and balance failed on returned data");
|
| 202 |
return false;
|
196 |
return false;
|
| Line 231... |
Line 225... |
| 231 |
break;
|
225 |
break;
|
| 232 |
recvString += recvString1 + "\n";
|
226 |
recvString += recvString1 + "\n";
|
| 233 |
recvString1 = reader.readLine();
|
227 |
recvString1 = reader.readLine();
|
| 234 |
}
|
228 |
}
|
| 235 |
} catch (IOException e) {
|
229 |
} catch (IOException e) {
|
| 236 |
e.printStackTrace();
|
230 |
log.error("Unable to read from Ebs response", e);
|
| 237 |
}
|
231 |
}
|
| 238 |
recvString = recvString.replace("=&", "=--&");
|
232 |
recvString = recvString.replace("=&", "=--&");
|
| 239 |
return recvString;
|
233 |
return recvString;
|
| 240 |
}
|
234 |
}
|
| 241 |
|
235 |
|