customer creation now pointing to velocity
This commit is contained in:
@@ -1,20 +1,12 @@
|
||||
package zw.qantra.tm.domain.controllers;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.cache.CacheManager;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import zw.qantra.tm.domain.enums.ChargeConditionType;
|
||||
import zw.qantra.tm.domain.enums.ChargeLabelEnum;
|
||||
import zw.qantra.tm.domain.enums.CurrencyType;
|
||||
import zw.qantra.tm.domain.models.Category;
|
||||
import zw.qantra.tm.domain.models.Charge;
|
||||
import zw.qantra.tm.domain.models.ChargeCondition;
|
||||
import zw.qantra.tm.domain.models.IntegrationProcessor;
|
||||
import zw.qantra.tm.domain.models.PaymentProcessor;
|
||||
import zw.qantra.tm.domain.models.Provider;
|
||||
import zw.qantra.tm.domain.services.ChargeConditionService;
|
||||
import zw.qantra.tm.domain.services.ChargeService;
|
||||
import zw.qantra.tm.domain.services.IntegrationProcessorService;
|
||||
@@ -22,11 +14,7 @@ import zw.qantra.tm.domain.services.CategoryService;
|
||||
import zw.qantra.tm.domain.services.PaymentProcessorService;
|
||||
import zw.qantra.tm.domain.services.ProviderService;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/configs")
|
||||
@RequiredArgsConstructor
|
||||
@@ -45,333 +33,4 @@ public class ConfigController {
|
||||
return ResponseEntity.ok("Cache cleared");
|
||||
}
|
||||
|
||||
@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")
|
||||
.percentageCommission(6)
|
||||
.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")
|
||||
.percentageCommission(5.5)
|
||||
.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")
|
||||
.percentageCommission(1.5)
|
||||
.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")
|
||||
.percentageCommission(6)
|
||||
.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(){
|
||||
|
||||
// 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("powertel_zesa")
|
||||
.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));
|
||||
add(chargeConditions.get(1));
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user