| Line 380... |
Line 380... |
| 380 |
List<UserWalletHistory> historyList = userWalletHistoryRepository.selectAllByreferenceIdandreferenceType(paymentId, WalletReferenceType.PAYMENT_GATEWAY);
|
380 |
List<UserWalletHistory> historyList = userWalletHistoryRepository.selectAllByreferenceIdandreferenceType(paymentId, WalletReferenceType.PAYMENT_GATEWAY);
|
| 381 |
if (fofoPayment.getStatus().equals(PaymentStatus.INIT) && historyList.size() == 0) {
|
381 |
if (fofoPayment.getStatus().equals(PaymentStatus.INIT) && historyList.size() == 0) {
|
| 382 |
String jsonString = mandiiService.getOrderStatus(gatewayReference);
|
382 |
String jsonString = mandiiService.getOrderStatus(gatewayReference);
|
| 383 |
JSONObject jsonOrder = new JSONObject(jsonString);
|
383 |
JSONObject jsonOrder = new JSONObject(jsonString);
|
| 384 |
double orderAmount = jsonOrder.getDouble("order_amount");
|
384 |
double orderAmount = jsonOrder.getDouble("order_amount");
|
| - |
|
385 |
double capturedAmount = jsonOrder.getDouble("captured_amount");
|
| 385 |
int merchantOrderId = jsonOrder.getInt("merchant_order_number");
|
386 |
int merchantOrderId = jsonOrder.getInt("merchant_order_number");
|
| 386 |
String status = jsonOrder.getString("status");
|
387 |
String status = jsonOrder.getString("status");
|
| - |
|
388 |
if(status.equals("SUCCESS") || status.equals("CAPTURED")) {
|
| 387 |
if(orderAmount == fofoPayment.getAmount() && merchantOrderId == fofoPayment.getId() && status.equals("SUCCESS")) {
|
389 |
if(orderAmount == fofoPayment.getAmount()) {
|
| 388 |
fofoPayment.setStatus(PaymentStatus.SUCCESS);
|
390 |
fofoPayment.setStatus(PaymentStatus.SUCCESS);
|
| - |
|
391 |
if(orderAmount == capturedAmount) {
|
| 389 |
walletService.addAmountToWallet(uc.getUserId(), paymentId, WalletReferenceType.PAYMENT_GATEWAY, "Amount added to wallet via SD Credit via Mandii", (float)fofoPayment.getAmount(), LocalDateTime.now());
|
392 |
walletService.addAmountToWallet(uc.getUserId(), paymentId, WalletReferenceType.PAYMENT_GATEWAY, "Amount added to wallet via SD Credit via Mandii", (float)fofoPayment.getAmount(), LocalDateTime.now());
|
| 390 |
return responseSender.ok(true);
|
393 |
return responseSender.ok(true);
|
| - |
|
394 |
} else {
|
| - |
|
395 |
walletService.addAmountToWallet(userId, userId, null, status, merchantOrderId, null)
|
| - |
|
396 |
}
|
| - |
|
397 |
}
|
| 391 |
}
|
398 |
}
|
| 392 |
}
|
399 |
}
|
| 393 |
return responseSender.ok(false);
|
400 |
return responseSender.ok(false);
|
| 394 |
}
|
401 |
}
|
| 395 |
}
|
402 |
}
|
| 396 |
|
403 |
|