diff --git a/src/main/java/zw/qantra/tm/domain/controllers/ConfigController.java b/src/main/java/zw/qantra/tm/domain/controllers/ConfigController.java index 7dc8989..5e79c31 100644 --- a/src/main/java/zw/qantra/tm/domain/controllers/ConfigController.java +++ b/src/main/java/zw/qantra/tm/domain/controllers/ConfigController.java @@ -36,7 +36,174 @@ public class ConfigController { private final ProviderService providerService; private final CategoryService categoryService; private final IntegrationProcessorService integrationProcessorService; - + + @GetMapping("/seed/live") + public ResponseEntity seedLiveConfig(){ + + // clear existing payment processors before seeding + paymentProcessorService.getPaymentProcessorRepository().deleteAll(); + paymentProcessorService.getPaymentProcessorRepository().saveAll(Arrays.asList( + PaymentProcessor.builder() + .name("Ecocash") + .label("ECOCASH") + .type("GATEWAY") + .image("ecocash.png") + .accountFieldName("phoneNumber") + .accountFieldLabel("EcoCash Phone Number") + .description("Pay using your mobile wallet") + .authType("REMOTE") + .build(), + PaymentProcessor.builder() + .name("Visa/MasterCard") + .label("MPGS") + .type("GATEWAY") + .image("visa-mastercard.png") + .accountFieldName("cardNumber") + .accountFieldLabel("Card Number") + .description("Pay using your international card") + .authType("WEB") + .build() + )); + + + + integrationProcessorService.getIntegrationProcessorRepository().deleteAll(); + integrationProcessorService.getIntegrationProcessorRepository().saveAll(Arrays.asList( + IntegrationProcessor.builder() + .name("STEWARD") + .label("STEWARD") + .description("Steward Integration Processor") + .build() + )); + + // clear existing categories before seeding + categoryService.getCategoryRepository().deleteAll(); + // seed categories + List categories = Arrays.asList( + Category.builder() + .name("Airtime") + .description("Airtime for local mobile networks") + .label("AIRTIME") + .build(), + Category.builder() + .name("Utilities") + .description("Council bills & rates") + .label("UTILITIES") + .build() + ); + categoryService.getCategoryRepository().saveAll(categories); + + // clear existing providers before seeding + providerService.getProviderRepository().deleteAll(); + + // seed providers + List providers = Arrays.asList( + Provider.builder() + .description("Econet Airtime") + .clientId("econet_airtime") + .label("ECONET") + .category("AIRTIME") + .image("econet.png") + .externalId("78f1f497-c9eb-401c-b22c-884756e68e40") + .integrationProcessorLabel("STEWARD") + .accountFieldName("Phone Number") + .build(), + Provider.builder() + .description("NetOne Airtime") + .clientId("netone_usd_airtime") + .label("NETONE") + .category("AIRTIME") + .image("netone.png") + .externalId("95d485a7-39c9-4559-8a27-6521969abe8f") + .integrationProcessorLabel("STEWARD") + .accountFieldName("Phone Number") + .build(), + Provider.builder() + .description("Prepaid Zesa") + .clientId("zesa_prepaid_usd") + .label("ZESA") + .category("UTILITIES") + .image("zesa.png") + .externalId("0f67f7cc-b62b-4fb5-915f-6740b2afdba6") + .integrationProcessorLabel("STEWARD") + .accountFieldName("Meter Number") + .build(), + Provider.builder() + .description("Econet Broadband") + .clientId("econet_broadband_usd") + .label("ECONET_BROADBAND") + .category("AIRTIME") + .image("econet.png") + .externalId("287863e2-a791-4106-b629-79dadc9a6779") + .integrationProcessorLabel("STEWARD") + .accountFieldName("Phone Number") + .build() + ); + providerService.getProviderRepository().saveAll(providers); + + // Clear existing charges and charge conditions before seeding + List chargeConditions = Arrays.asList( + ChargeCondition.builder() + .name("Ecocash Gateway") + .type(ChargeConditionType.GATEWAY) + .codes("ECOCASH") + .build(), + ChargeCondition.builder() + .name("Steward Gateway") + .type(ChargeConditionType.GATEWAY) + .codes("STEWARD") + .build(), + ChargeCondition.builder() + .name("Mastercard Gateway") + .type(ChargeConditionType.GATEWAY) + .codes("MPGS") + .build() + ); + chargeService.getChargeRepository().deleteAll(); + chargeConditionService.getChargeConditionRepository().deleteAll(); + chargeConditionService.getChargeConditionRepository().saveAll(chargeConditions); + + List charges = Arrays.asList( + Charge.builder() + .description("Gateway fee") + .chargeLabel(ChargeLabelEnum.GATEWAY_FEE) + .currency(CurrencyType.USD) + .percentageRate(new BigDecimal("1")) + .includes(new HashSet<>() {{ + add(chargeConditions.get(0)); + }}) + .build(), + Charge.builder() + .description("Gateway fee") + .chargeLabel(ChargeLabelEnum.GATEWAY_FEE) + .currency(CurrencyType.USD) + .percentageRate(new BigDecimal("2")) + .min(new BigDecimal("0.55")) + .includes(new HashSet<>() {{ + add(chargeConditions.get(2)); + }}) + .build() +// Charge.builder() +// .description("Tax") +// .chargeLabel(ChargeLabelEnum.TAX) +// .currency(CurrencyType.USD) +// .percentageRate(new BigDecimal("2")) +// .max(new BigDecimal("10150")) +// .minimumAmount(new BigDecimal("5")) +// .maximumAmount(new BigDecimal("500000")) +// .includes(new HashSet<>() {{ +// add(chargeConditions.get(0)); +// add(chargeConditions.get(1)); +// add(chargeConditions.get(2)); +// }}) +// .build() + ); + + chargeService.getChargeRepository().saveAll(charges); + + return ResponseEntity.ok("Project configuration seeding complete"); + } + @GetMapping("/seed") public ResponseEntity seedConfig(){ diff --git a/src/main/resources/application-vusa.properties b/src/main/resources/application-vusa.properties index 0924579..a7af74a 100644 --- a/src/main/resources/application-vusa.properties +++ b/src/main/resources/application-vusa.properties @@ -1,10 +1,2 @@ # sbz.merchant.url=http://localhost:24000/v1 sbz.merchant.url=https://api.stewardpay.co.zw/lab/v2 - -spring.datasource.url=jdbc:postgresql://localhost:5432/qpay?useLegacyDatetimeCode=false -spring.datasource.username=postgres -spring.datasource.password=example - -nflow.db.postgresql.url=jdbc:postgresql://localhost:5432/qpay -nflow.db.postgresql.user=postgres -nflow.db.postgresql.password=example diff --git a/src/main/resources/liquibase-diff-changeLog.xml b/src/main/resources/liquibase-diff-changeLog.xml index f47fc2b..e7fa546 100644 --- a/src/main/resources/liquibase-diff-changeLog.xml +++ b/src/main/resources/liquibase-diff-changeLog.xml @@ -2,7 +2,7 @@ - + @@ -14,7 +14,7 @@ - + @@ -27,7 +27,7 @@ - + @@ -55,7 +55,7 @@ - + @@ -67,27 +67,27 @@ - + - + - + - + - + @@ -99,7 +99,7 @@ - + @@ -111,7 +111,7 @@ - + @@ -124,7 +124,7 @@ - + @@ -141,7 +141,7 @@ - + @@ -161,7 +161,7 @@ - + @@ -178,7 +178,7 @@ - + @@ -189,7 +189,7 @@ - + @@ -256,7 +256,7 @@ - + @@ -270,7 +270,7 @@ - +