| Line 153... |
Line 153... |
| 153 |
|
153 |
|
| 154 |
if (result != null && result.trim().equals(PaymentReturnStatus.APPROVED.value())) {
|
154 |
if (result != null && result.trim().equals(PaymentReturnStatus.APPROVED.value())) {
|
| 155 |
log.info("Payment " + merchantPaymentId + " authorized successfully. Updating the database.");
|
155 |
log.info("Payment " + merchantPaymentId + " authorized successfully. Updating the database.");
|
| 156 |
String description = "Payment authorized";
|
156 |
String description = "Payment authorized";
|
| 157 |
updatePaymentDetails(merchantPaymentId, description, PaymentStatus.AUTHORIZED, request, paymentClient);
|
157 |
updatePaymentDetails(merchantPaymentId, description, PaymentStatus.AUTHORIZED, request, paymentClient);
|
| 158 |
|
- |
|
| 159 |
log.info("Capturing payment with id: " + merchantPaymentId);
|
- |
|
| 160 |
Map<String, String> captureResult = HdfcPaymentService.capturePayment(payment, request.getParameter(TRANID));
|
- |
|
| 161 |
String captureStatus = captureResult.get(IPaymentService.STATUS);
|
- |
|
| 162 |
String gatewayStatus = captureResult.get(IPaymentService.GATEWAY_STATUS);
|
- |
|
| 163 |
|
- |
|
| 164 |
List<Attribute> attributes = new ArrayList<Attribute>();
|
- |
|
| 165 |
if(!captureStatus.trim().equals("0") || !PaymentReturnStatus.CAPTURED.value().equals(gatewayStatus)){
|
- |
|
| 166 |
//Failure
|
- |
|
| 167 |
log.info("Capture attempt failed for payment with id: " + merchantPaymentId);
|
- |
|
| 168 |
description = captureResult.get(IPaymentService.ERROR);
|
- |
|
| 169 |
String errorCode = captureResult.get(IPaymentService.ERR_CODE);
|
- |
|
| 170 |
|
- |
|
| 171 |
try {
|
- |
|
| 172 |
paymentServiceClient.getClient().updatePaymentDetails(merchantPaymentId, paymentId,
|
- |
|
| 173 |
null, null, description, null, null, null, errorCode, PaymentStatus.FAILED, null, attributes);
|
- |
|
| 174 |
} catch (PaymentException e) {
|
- |
|
| 175 |
log.error("Error while updating failed capture payment attempt: ", e);
|
- |
|
| 176 |
} catch (TException e) {
|
- |
|
| 177 |
log.error("Error while updating failed capture payment attempt: ", e);
|
- |
|
| 178 |
}
|
- |
|
| 179 |
//DataLogger.logData(EventType.PAYMENT_FAILURE.name(), session.getId(), Long.toString(userinfo.getUserId()), userinfo.getEmail(), Long.toString(merchantPaymentId), paymentId, gatewayTxnStatus, description, errorCode);
|
- |
|
| 180 |
this.redirectUrl = errorUrl + "?paymentId=" + merchantPaymentId;
|
- |
|
| 181 |
}else{
|
- |
|
| 182 |
//Success
|
- |
|
| 183 |
log.info("Capture attempt successful for payment with id: " + merchantPaymentId);
|
- |
|
| 184 |
description = "Payment Captured";
|
- |
|
| 185 |
attributes.add(new Attribute(IPaymentService.CAPTURE_TXN_ID, captureResult.get(IPaymentService.CAPTURE_TXN_ID)));
|
- |
|
| 186 |
attributes.add(new Attribute(IPaymentService.CAPTURE_REF_ID, captureResult.get(IPaymentService.CAPTURE_REF_ID)));
|
- |
|
| 187 |
attributes.add(new Attribute(IPaymentService.CAPTURE_AUTH_ID, captureResult.get(IPaymentService.CAPTURE_AUTH_ID)));
|
- |
|
| 188 |
|
- |
|
| 189 |
SimpleDateFormat captureTimeDateFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
- |
|
| 190 |
attributes.add(new Attribute(IPaymentService.CAPTURE_TIME, captureTimeDateFormatter.format(new Date())));
|
- |
|
| 191 |
|
- |
|
| 192 |
try {
|
- |
|
| 193 |
paymentServiceClient.getClient().updatePaymentDetails(merchantPaymentId, paymentId,
|
- |
|
| 194 |
null, gatewayStatus, null, null, null, null, null, PaymentStatus.SUCCESS, null, attributes);
|
- |
|
| 195 |
} catch (PaymentException e) {
|
- |
|
| 196 |
log.error("Error while updating successful capture payment attempt: ", e);
|
- |
|
| 197 |
} catch (TException e) {
|
- |
|
| 198 |
log.error("Error while updating successful capture payment attempt: ", e);
|
- |
|
| 199 |
}
|
- |
|
| 200 |
|
- |
|
| 201 |
CommonPaymentService.processSuccessfulTxn(txnId, userServiceClient, transactionServiceClient);
|
- |
|
| 202 |
|
158 |
|
| - |
|
159 |
CommonPaymentService.processSuccessfulTxn(txnId, userServiceClient, transactionServiceClient);
|
| - |
|
160 |
|
| 203 |
this.redirectUrl = successUrl + "?paymentId=" + merchantPaymentId;
|
161 |
this.redirectUrl = successUrl + "?paymentId=" + merchantPaymentId;
|
| - |
|
162 |
|
| - |
|
163 |
// log.info("Capturing payment with id: " + merchantPaymentId);
|
| - |
|
164 |
// Map<String, String> captureResult = HdfcPaymentService.capturePayment(payment);
|
| - |
|
165 |
// String captureStatus = captureResult.get(IPaymentService.STATUS);
|
| - |
|
166 |
// String gatewayStatus = captureResult.get(IPaymentService.GATEWAY_STATUS);
|
| - |
|
167 |
//
|
| - |
|
168 |
// List<Attribute> attributes = new ArrayList<Attribute>();
|
| - |
|
169 |
// if(!captureStatus.trim().equals("0") || !PaymentReturnStatus.CAPTURED.value().equals(gatewayStatus)){
|
| - |
|
170 |
// //Failure
|
| - |
|
171 |
// log.info("Capture attempt failed for payment with id: " + merchantPaymentId);
|
| - |
|
172 |
// description = captureResult.get(IPaymentService.ERROR);
|
| - |
|
173 |
// String errorCode = captureResult.get(IPaymentService.ERR_CODE);
|
| - |
|
174 |
//
|
| - |
|
175 |
// try {
|
| - |
|
176 |
// paymentServiceClient.getClient().updatePaymentDetails(merchantPaymentId, paymentId,
|
| - |
|
177 |
// null, null, description, null, null, null, errorCode, PaymentStatus.FAILED, null, attributes);
|
| - |
|
178 |
// } catch (PaymentException e) {
|
| - |
|
179 |
// log.error("Error while updating failed capture payment attempt: ", e);
|
| - |
|
180 |
// } catch (TException e) {
|
| - |
|
181 |
// log.error("Error while updating failed capture payment attempt: ", e);
|
| - |
|
182 |
// }
|
| 204 |
//DataLogger.logData(EventType.PAYMENT_SUCCESS.name(), session.getId(), Long.toString(userinfo.getUserId()), userinfo.getEmail(), Long.toString(merchantPaymentId), paymentId, gatewayTxnStatus, description, captureStatus);
|
183 |
// //DataLogger.logData(EventType.PAYMENT_FAILURE.name(), session.getId(), Long.toString(userinfo.getUserId()), userinfo.getEmail(), Long.toString(merchantPaymentId), paymentId, gatewayTxnStatus, description, errorCode);
|
| - |
|
184 |
// this.redirectUrl = errorUrl + "?paymentId=" + merchantPaymentId;
|
| - |
|
185 |
// }else{
|
| - |
|
186 |
// //Success
|
| - |
|
187 |
// log.info("Capture attempt successful for payment with id: " + merchantPaymentId);
|
| - |
|
188 |
// description = "Payment Captured";
|
| - |
|
189 |
// attributes.add(new Attribute(IPaymentService.CAPTURE_TXN_ID, captureResult.get(IPaymentService.CAPTURE_TXN_ID)));
|
| - |
|
190 |
// attributes.add(new Attribute(IPaymentService.CAPTURE_REF_ID, captureResult.get(IPaymentService.CAPTURE_REF_ID)));
|
| - |
|
191 |
// attributes.add(new Attribute(IPaymentService.CAPTURE_AUTH_ID, captureResult.get(IPaymentService.CAPTURE_AUTH_ID)));
|
| - |
|
192 |
//
|
| - |
|
193 |
// SimpleDateFormat captureTimeDateFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
| - |
|
194 |
// attributes.add(new Attribute(IPaymentService.CAPTURE_TIME, captureTimeDateFormatter.format(new Date())));
|
| - |
|
195 |
//
|
| - |
|
196 |
// try {
|
| - |
|
197 |
// paymentServiceClient.getClient().updatePaymentDetails(merchantPaymentId, paymentId,
|
| - |
|
198 |
// null, gatewayStatus, null, null, null, null, null, PaymentStatus.SUCCESS, null, attributes);
|
| - |
|
199 |
// } catch (PaymentException e) {
|
| - |
|
200 |
// log.error("Error while updating successful capture payment attempt: ", e);
|
| - |
|
201 |
// } catch (TException e) {
|
| - |
|
202 |
// log.error("Error while updating successful capture payment attempt: ", e);
|
| - |
|
203 |
// }
|
| - |
|
204 |
//
|
| - |
|
205 |
// CommonPaymentService.processSuccessfulTxn(txnId, userServiceClient, transactionServiceClient);
|
| - |
|
206 |
//
|
| - |
|
207 |
// this.redirectUrl = successUrl + "?paymentId=" + merchantPaymentId;
|
| 205 |
}
|
208 |
// }
|
| 206 |
} else {
|
209 |
} else {
|
| 207 |
updatePaymentDetails(merchantPaymentId, errorText, PaymentStatus.FAILED, request, paymentClient);
|
210 |
updatePaymentDetails(merchantPaymentId, errorText, PaymentStatus.FAILED, request, paymentClient);
|
| 208 |
|
211 |
|
| 209 |
CommonPaymentService.processFailedTxn(txnId, transactionServiceClient);
|
212 |
CommonPaymentService.processFailedTxn(txnId, transactionServiceClient);
|
| 210 |
|
213 |
|