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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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>
|
||||
Reference in New Issue
Block a user