updating ci

This commit is contained in:
2025-10-17 20:46:42 +02:00
parent d6439b8845
commit b7558c18d6
3 changed files with 186 additions and 27 deletions

View File

@@ -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<Category> 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<Provider> 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<ChargeCondition> 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<Charge> 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(){