updates to wallet functionality

This commit is contained in:
Prince
2026-06-11 23:52:20 +02:00
parent 0dce7f51dc
commit 8a9d58fe05
13 changed files with 17 additions and 101 deletions

View File

@@ -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();

View File

@@ -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;
}

View File

@@ -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);
}

View File

@@ -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) {

View File

@@ -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();
}

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -28,7 +28,7 @@ sbz.aggregator.encryption-key=91b5b3c7-860f-473c-ac5c-b12d9121819b
steward.payment.processor.url=${sbz.merchant.url}
mpgs.return-url=https://vdt.co.zw/#/return
mpgs.return-url=https://pay.velocityafrica.net/return
# JWT Configuration
jwt.secret=your-super-secret-jwt-key-here-make-it-very-long-and-secure-in-production

View File

@@ -1,18 +0,0 @@
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:pro="http://www.liquibase.org/xml/ns/pro" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/pro http://www.liquibase.org/xml/ns/pro/liquibase-pro-latest.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd">
<changeSet author="khoza (generated)" id="1781189342457-3">
<addColumn tableName="transaction">
<column name="order_transaction_id" type="varchar(255)"/>
</addColumn>
</changeSet>
<changeSet author="khoza (generated)" id="1781189342457-4">
<addColumn tableName="transaction">
<column name="retries" type="integer"/>
</addColumn>
</changeSet>
<changeSet author="khoza (generated)" id="1781189342457-5">
<addColumn tableName="transaction">
<column name="verification_code" type="varchar(255)"/>
</addColumn>
</changeSet>
</databaseChangeLog>