| Line 550... |
Line 550... |
| 550 |
double captureAmount = 0;
|
550 |
double captureAmount = 0;
|
| 551 |
String captureAmntStr = attrMap.get(IPaymentHandler.CAPTURE_AMNT);
|
551 |
String captureAmntStr = attrMap.get(IPaymentHandler.CAPTURE_AMNT);
|
| 552 |
if(captureAmntStr != null)
|
552 |
if(captureAmntStr != null)
|
| 553 |
captureAmount = Double.parseDouble(captureAmntStr);
|
553 |
captureAmount = Double.parseDouble(captureAmntStr);
|
| 554 |
captureAmount += amount;
|
554 |
captureAmount += amount;
|
| - |
|
555 |
// If capture amount higher than payment amount by more than 50 paisa,
|
| - |
|
556 |
// there is some issue and we should raise exception.
|
| 555 |
if(captureAmount > payment.getAmount())
|
557 |
if(captureAmount - payment.getAmount() > 0.5){
|
| 556 |
throw new PaymentException(105, "We've got a settlement request for an amount which is more than the transaction value.");
|
558 |
throw new PaymentException(105, "We've got a settlement request for an amount which is more than the transaction value.");
|
| - |
|
559 |
}
|
| 557 |
|
560 |
|
| - |
|
561 |
// If capture amount differs from payment amount by less than 50 paisa, lets mark the payment as successful.
|
| - |
|
562 |
// Else we can safely assume there will be some more orders for the payment, leading to make the payment as partially captured.
|
| 558 |
if(captureAmount < payment.getAmount()){
|
563 |
if(Math.abs(captureAmount - payment.getAmount()) < 0.5){
|
| 559 |
payment.setStatus(PaymentStatus.PARTIALLY_CAPTURED.getValue());
|
564 |
payment.setStatus(PaymentStatus.SUCCESS.getValue());
|
| 560 |
} else {
|
565 |
}else {
|
| 561 |
payment.setStatus(PaymentStatus.SUCCESS.getValue());
|
566 |
payment.setStatus(PaymentStatus.PARTIALLY_CAPTURED.getValue());
|
| 562 |
}
|
567 |
}
|
| 563 |
payment.setSuccessTimestamp(new Date());
|
568 |
payment.setSuccessTimestamp(new Date());
|
| 564 |
attrMap.put(IPaymentHandler.CAPTURE_AMNT, captureAmount + "");
|
569 |
attrMap.put(IPaymentHandler.CAPTURE_AMNT, captureAmount + "");
|
| 565 |
attrMap.put(IPaymentHandler.XFER_TXN_ID, xferTxnId);
|
570 |
attrMap.put(IPaymentHandler.XFER_TXN_ID, xferTxnId);
|
| 566 |
attrMap.put(IPaymentHandler.XFER_TXN_DATE, xferDateStr);
|
571 |
attrMap.put(IPaymentHandler.XFER_TXN_DATE, xferDateStr);
|