Intershop 7.10. - fetching payment configuration

若如初见. 提交于 2021-02-10 03:17:55

问题


We would like to fetch the payment configuration from Order in Java class (OrderBO extension). So far we have managed to fetch the service like this:

final OrderBOPaymentExtension<OrderBO> paymentExtension = getExtendedObject().getExtension(OrderBOPaymentExtension.EXTENSION_ID);

final PaymentBO paymentBO = paymentExtension.getPaymentBOs().stream().findFirst().orElse(null);

PaymentServiceBO paymentServiceBO = paymentBO.getPaymentServiceBO();

Now we need to fetch the configuration, so we can read certain configuration parameters from the payment method. What is the best way to do that?

We know it is possible to fetch the payment configuration through the PO Factory like this:

PaymentConfigurationPOFactory f = (PaymentConfigurationPOFactory)NamingMgr.getInstance().lookupFactory(PaymentConfigurationPO.class);
PaymentConfigurationPO r = f.getConfigForIDAndDomain(iD, domain);

But we would like to avoid using deprecated code.

UPDATE: What we are trying to achieve is access these BO parameters in Java code:


回答1:


I'd suggest you write a PaymentServiceBO extension. Within that extension you can write getter methods to query for certain config values. The java code for accessing service configuration object is:

PaymentConfiguration paymentConfig = paymentServiceBO.getExtension(PersistentObjectBOExtension.class).getPersistentObject();
ServiceConfigurationBO serviceConfigurationBO = repository.getServiceConfigurationBOByID(paymentConfig.getManagedServiceConfiguration().getUUID());
ConfigurationProvider configProviderExtension = serviceConfigurationBO.getExtension(ConfigurationProvider.class);
Configuration configuration = configProviderExtension.getConfiguration();
Logger.debug(this, "payment service config keys = {}", configuration.getKeys());



回答2:


I believe PaymentConfiguration is deprecated. See PaymentConfigurationBO javadoc:

Deprecated since 7.6. Payment configurations are now represented via PaymentServiceBOs.

So you need to use PaymentServiceBO methods or write a business object extension that does what you want.



来源:https://stackoverflow.com/questions/54365374/intershop-7-10-fetching-payment-configuration

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!