| Line 344... |
Line 344... |
| 344 |
return refundEbsPayment(payment, amount);
|
344 |
return refundEbsPayment(payment, amount);
|
| 345 |
}
|
345 |
}
|
| 346 |
else if (HDFC_EMI_GATEWAY_IDS.contains(gatewayId)){
|
346 |
else if (HDFC_EMI_GATEWAY_IDS.contains(gatewayId)){
|
| 347 |
//Capture and update the HDFC EMI payment
|
347 |
//Capture and update the HDFC EMI payment
|
| 348 |
return refundHdfcEmiPayment(payment, amount);
|
348 |
return refundHdfcEmiPayment(payment, amount);
|
| - |
|
349 |
}else if (gatewayId == PAYU_GATEWAY_ID) {
|
| - |
|
350 |
//Refund PayU
|
| - |
|
351 |
return refundPayUPayment(payment, amount);
|
| - |
|
352 |
|
| 349 |
}
|
353 |
}
|
| 350 |
|
354 |
|
| 351 |
logger.error("We have an captured payment from unknown gateway: " + gatewayId);
|
355 |
logger.error("We have an captured payment from unknown gateway: " + gatewayId);
|
| 352 |
return false;
|
356 |
return false;
|
| 353 |
}
|
357 |
}
|
| 354 |
|
358 |
|
| 355 |
|
359 |
|
| - |
|
360 |
private boolean refundPayUPayment (
|
| - |
|
361 |
in.shop2020.payment.domain.Payment payment, double amount) throws PaymentException{
|
| - |
|
362 |
Map<String, String> captureResult = PayuPaymentHandler.refundPayment(payment, amount);
|
| - |
|
363 |
if(captureResult.containsKey(IPaymentHandler.ERROR)){
|
| - |
|
364 |
payment.setDescription(captureResult.get(IPaymentHandler.ERROR));
|
| - |
|
365 |
payment.setErrorCode(captureResult.get(IPaymentHandler.ERR_CODE));
|
| - |
|
366 |
payment.setErrorTimestamp(new Date());
|
| - |
|
367 |
if(captureResult.get(IPaymentHandler.ERR_CODE).equals(Errors.CAPTURE_FAILURE)) {
|
| - |
|
368 |
payment.setStatus(PaymentStatus.FAILED.getValue());
|
| - |
|
369 |
paymentHandler.updatePayment(payment, captureResult);
|
| - |
|
370 |
persistPaymentRequiringExtraProcessing(payment, ExtraPaymentProcessingType.FAILED_PAYMENTS);
|
| - |
|
371 |
} else {
|
| - |
|
372 |
logger.error("Capture attempt failed for Payu payment with id: " + payment.getId());
|
| - |
|
373 |
payment.setStatus(PaymentStatus.CAPTURE_IN_PROCESS.getValue());
|
| - |
|
374 |
paymentHandler.updatePayment(payment, captureResult);
|
| - |
|
375 |
throw new PaymentException(106, captureResult.get(IPaymentHandler.ERROR));
|
| - |
|
376 |
}
|
| - |
|
377 |
return false;
|
| - |
|
378 |
} else {
|
| - |
|
379 |
|
| - |
|
380 |
payment.setGatewayTxnStatus("Refund initiated");
|
| - |
|
381 |
payment.setStatus(PaymentStatus.REFUNDED.getValue());
|
| - |
|
382 |
payment.setRefundAmount(amount);
|
| - |
|
383 |
|
| - |
|
384 |
SimpleDateFormat captureTimeDateFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
| - |
|
385 |
captureResult.put(IPaymentHandler.REFUND_TXN_ID, captureResult.get(IPaymentHandler.REFUND_TXN_ID));
|
| - |
|
386 |
captureResult.put(IPaymentHandler.REFUND_TIME, captureTimeDateFormatter.format(new Date()));
|
| - |
|
387 |
paymentHandler.updatePayment(payment, captureResult);
|
| - |
|
388 |
return true;
|
| - |
|
389 |
}
|
| - |
|
390 |
}
|
| - |
|
391 |
|
| 356 |
@Override
|
392 |
@Override
|
| 357 |
public long createRefund(long orderId, long merchantTxnId, double amount) throws PaymentException, TException{
|
393 |
public long createRefund(long orderId, long merchantTxnId, double amount) throws PaymentException, TException{
|
| 358 |
logger.info("Attempting to create a refund for order: " + orderId);
|
394 |
logger.info("Attempting to create a refund for order: " + orderId);
|
| 359 |
// if(!refundPayment(merchantTxnId, amount, false)){
|
395 |
// if(!refundPayment(merchantTxnId, amount, false)){
|
| 360 |
// logger.warn("Not able to refund corresponding to the merchant txn " + merchantTxnId);
|
396 |
// logger.warn("Not able to refund corresponding to the merchant txn " + merchantTxnId);
|
| Line 445... |
Line 481... |
| 445 |
if(captureResult.get(IPaymentHandler.ERR_CODE).equals(Errors.CAPTURE_FAILURE)) {
|
481 |
if(captureResult.get(IPaymentHandler.ERR_CODE).equals(Errors.CAPTURE_FAILURE)) {
|
| 446 |
payment.setStatus(PaymentStatus.FAILED.getValue());
|
482 |
payment.setStatus(PaymentStatus.FAILED.getValue());
|
| 447 |
paymentHandler.updatePayment(payment, attrMap);
|
483 |
paymentHandler.updatePayment(payment, attrMap);
|
| 448 |
persistPaymentRequiringExtraProcessing(payment, ExtraPaymentProcessingType.FAILED_PAYMENTS);
|
484 |
persistPaymentRequiringExtraProcessing(payment, ExtraPaymentProcessingType.FAILED_PAYMENTS);
|
| 449 |
} else {
|
485 |
} else {
|
| 450 |
logger.error("Capture attempt failed for HDFC payment with id: " + merchantPaymentId);
|
486 |
logger.error("Capture attempt failed for Payu payment with id: " + merchantPaymentId);
|
| 451 |
payment.setStatus(PaymentStatus.CAPTURE_IN_PROCESS.getValue());
|
487 |
payment.setStatus(PaymentStatus.CAPTURE_IN_PROCESS.getValue());
|
| 452 |
paymentHandler.updatePayment(payment, attrMap);
|
488 |
paymentHandler.updatePayment(payment, attrMap);
|
| 453 |
throw new PaymentException(106, captureResult.get(IPaymentHandler.ERROR));
|
489 |
throw new PaymentException(106, captureResult.get(IPaymentHandler.ERROR));
|
| 454 |
}
|
490 |
}
|
| 455 |
return false;
|
491 |
return false;
|