Платежметодапийсервник : stripe
и он используется bylupifproperty
@slf4j
@applicationscoped
@lookupifproperty (имя = "cm.ext-payment-gw.gw-selected", stringvalue = "stripe")
public Class StripePaymentGatewayservice реализует платежметодапийсвейс {< /p>
Теперь мне нужно несколько платежных платежей, чтобы выбрать В том же развертывании
ext-payment-gw:
gw selected:
-paypal
- stripe < /p>
Так что @lookupifproperty не может инициировать Bean из списка, который он может сделать только один < /p>
, следовательно, нам нужно сделать пользовательский отбор, чтобы выбрать бобы с матчем Значение API < /p>
@ConfigProperty(name = "cm.ext-payment-gw.gw-selected")
Map configuredGateways;
@Inject
ServiceProviderService serviceProviderService;
@Inject
Instance paymentMethodApiServiceProvider;
private PaymentMethodApiService getPaymentGatewayForRequest() {
var paymentGateway = serviceProviderService.retrievePaymentGatewayConfig().getProvider().toLowerCase();
logger.info("Looking for gateway implementation: {}", paymentGateway);
logger.info("Configured gateways: {}", configuredGateways.keySet());
if (!Boolean.TRUE.equals(configuredGateways.get(paymentGateway))) {
throw new IllegalStateException("Payment gateway " + paymentGateway +
" is not enabled in the configuration: " + configuredGateways);
}
for (PaymentMethodApiService service : paymentMethodApiServiceProvider) {
Class beanClass = service.getClass();
logger.info("Discovered service: {}", beanClass.getSimpleName());
// Handle proxies correctly by using the superclass if needed
if (beanClass.getName().contains("_ClientProxy")) {
beanClass = beanClass.getSuperclass(); // Get the actual class of the bean
}
SupportedPaymentGateway annotation = beanClass.getAnnotation(SupportedPaymentGateway.class);
if (annotation != null) {
logger.info("Service: {} has gateway: {}", beanClass.getSimpleName(), annotation.value());
if (annotation.value().equalsIgnoreCase(paymentGateway)) {
return service;
}
} else {
logger.info("Service: {} has no @SupportedPaymentGateway annotation", beanClass.getSimpleName());
}
}
throw new IllegalStateException("No implementation found for gateway: " + paymentGateway);
}```
I have made @SupportedPaymentGateway("stripe") for stripe service
@SupportedPaymentGateway("paypal") for paypal service
but its straight away picking expection, that means there is no Instamces of PaymentMethodServiceProvider
2025-02-21 14:32:18,683 ERROR [com.obp.cms.exc.GenericExceptionMapper] (executor-thread-0) Exception occurred No implementation found for gateway: telus: java.lang.Illeg
alStateException: No implementation found for gateway: stripe
Подробнее здесь: https://stackoverflow.com/questions/794 ... -api-value