updates to wallet functionality
This commit is contained in:
@@ -8,8 +8,6 @@ import zw.qantra.tm.domain.dtos.erp.VelocityAccountDto;
|
||||
import zw.qantra.tm.domain.dtos.erp.VelocityStatementDto;
|
||||
import zw.qantra.tm.domain.services.VelocityAccountService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/accounts")
|
||||
@RequiredArgsConstructor
|
||||
@@ -19,10 +17,10 @@ public class AccountController {
|
||||
|
||||
@GetMapping("/phone/{currencyPhoneConcat}")
|
||||
@PreAuthorize("hasRole('ACCOUNT_READ')")
|
||||
public ResponseEntity<Object> getAccountByPhone(
|
||||
public ResponseEntity<VelocityAccountDto> getAccountByPhone(
|
||||
@PathVariable String currencyPhoneConcat) {
|
||||
try {
|
||||
Object account = velocityAccountService.getAccountByPhone(currencyPhoneConcat);
|
||||
VelocityAccountDto account = velocityAccountService.getAccountByPhone(currencyPhoneConcat);
|
||||
return ResponseEntity.ok(account);
|
||||
} catch (Exception e) {
|
||||
return ResponseEntity.badRequest().build();
|
||||
|
||||
@@ -2,15 +2,12 @@ package zw.qantra.tm.domain.dtos.erp;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import jakarta.persistence.*;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@@ -27,11 +24,10 @@ public class VelocityAccountDto {
|
||||
private String type;
|
||||
private String category;
|
||||
private String ledger;
|
||||
private Timestamp deactivatedAt;
|
||||
private BigDecimal balance;
|
||||
private String partyType;
|
||||
private String party;
|
||||
private String currency;
|
||||
private Object currency;
|
||||
private String customerStringId;
|
||||
private String companyStringId;
|
||||
}
|
||||
@@ -253,8 +253,10 @@ public class GroupBatchService {
|
||||
CompletableFuture<Object> future = workflowUtils
|
||||
.waitForState(batch.getWorkflowId(), new String[]{"done", "failed"},
|
||||
15000, 50);
|
||||
future.get();
|
||||
return getBatch(batchId, userId);
|
||||
StateResponse response = (StateResponse) future.get();
|
||||
String id = response.getBody().toString(); // this returns Batch Transaction ID
|
||||
String cleaned = id.replaceAll("^\"|\"$", "");
|
||||
return transactionService.findById(UUID.fromString(cleaned));
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
@@ -133,7 +133,6 @@ public class GroupBatchWorkflowService {
|
||||
return groupBatchRepository.save(batch);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public GroupBatch processPoll(UUID batchId) throws Exception {
|
||||
GroupBatch batch = getBatchById(batchId);
|
||||
if (batch.getStatus() != GroupBatchStatus.REQUESTED && batch.getStatus() != GroupBatchStatus.POLL_FAILED) {
|
||||
|
||||
@@ -102,7 +102,7 @@ public class ProviderService {
|
||||
try {
|
||||
response = restService.getAs(stockUrl, headers, LinkedHashMap.class);
|
||||
} catch (Exception e) {
|
||||
log.error("Error fetching products for provider " + providerId, e);
|
||||
log.error("Error fetching products for provider " + providerId);
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ public class VelocityAccountService {
|
||||
* @param currencyPhoneConcat The concatenation of currency and phone (e.g. "USD+263771234567").
|
||||
* @return VelocityAccountDto with account details.
|
||||
*/
|
||||
public Object getAccountByPhone(String currencyPhoneConcat) {
|
||||
public VelocityAccountDto getAccountByPhone(String currencyPhoneConcat) {
|
||||
try {
|
||||
LinkedHashMap responseMap = velocityPaymentService.makeRequest(
|
||||
HttpMethod.GET,
|
||||
@@ -37,7 +37,7 @@ public class VelocityAccountService {
|
||||
log.error("Error fetching account");
|
||||
throw new IllegalStateException("Error fetching account");
|
||||
}
|
||||
return responseMap;
|
||||
return Utils.deepCopy(responseMap, VelocityAccountDto.class);
|
||||
} catch (Exception e) {
|
||||
log.error("Error fetching account by phone {}: {}", currencyPhoneConcat, e.getMessage(), e);
|
||||
throw new IllegalStateException("Error fetching account: " + e.getMessage(), e);
|
||||
|
||||
@@ -205,8 +205,10 @@ public class VelocityPaymentService {
|
||||
int maxRetries = settingService.getIntegerSetting("MAX_RETRIES");
|
||||
int retries = transaction.getRetries() == null ? 0 : transaction.getRetries();
|
||||
|
||||
if (retries >= maxRetries)
|
||||
if (retries >= maxRetries) {
|
||||
transaction.setErrorMessage("Maximum retries reached");
|
||||
return transaction;
|
||||
}
|
||||
|
||||
transaction.setRetries(retries + 1);
|
||||
|
||||
|
||||
@@ -70,7 +70,6 @@ public class CityWalletRemotePaymentProcessor implements TransactionProcessorInt
|
||||
|
||||
try {
|
||||
transaction = velocityPaymentService.pollPaymentStatus(transaction);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("Network error during payment processing: {}", e.getMessage(), e);
|
||||
@@ -88,6 +87,7 @@ public class CityWalletRemotePaymentProcessor implements TransactionProcessorInt
|
||||
|
||||
try {
|
||||
velocityPaymentService.updateTransaction(transaction.getOrderTransactionId(), code);
|
||||
transaction.setStatus(Status.SUCCESS);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("Network error during payment update: {}", e.getMessage(), e);
|
||||
|
||||
Reference in New Issue
Block a user