Class DefaultTabbyPaymentModificationService
java.lang.Object
com.broadleafcommerce.tabby.service.DefaultTabbyPaymentModificationService
- All Implemented Interfaces:
com.broadleafcommerce.paymentgateway.service.PaymentGatewayPaymentModificationService
,com.broadleafcommerce.paymentgateway.service.PaymentGatewayTypeAware
,TabbyPaymentModificationService
public class DefaultTabbyPaymentModificationService
extends Object
implements TabbyPaymentModificationService
Reads the Order history for the authorized customer, and populates the Tabby payment with the
buyer and order history data, based on the result.
It updates the data only if it is not already provided.
- Author:
- Dima Myroniuk (dmyroniuk)
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultTabbyPaymentModificationService
(com.fasterxml.jackson.databind.ObjectMapper objectMapper, CustomerOrderInfoProvider<CustomerOrderInfo> customerOrderInfoProvider, ExternalOrderOperationProviderProperties properties, TabbyConfigurationProperties configurationProperties, com.broadleafcommerce.resource.security.utils.service.AuthenticationUtils authenticationUtils, com.broadleafcommerce.common.extension.TypeFactory typeFactory) -
Method Summary
Modifier and TypeMethodDescriptionprotected com.broadleafcommerce.data.tracking.core.context.ContextInfo
buildContextInfo
(String applicationId, String tenantId) protected TabbyBuyer
buildTabbyBuyer
(CustomerOrderInfo customerOrderInfo) protected List<TabbyOrderHistory>
buildTabbyOrderHistories
(@NonNull List<CustomerOrderInfo> orderHistories) protected TabbyShippingAddress
buildTabbyShippingAddress
(Address address) protected com.broadleafcommerce.resource.security.utils.service.AuthenticationUtils
protected int
Returns the batch size to read the orders.protected TabbyConfigurationProperties
protected List<CustomerOrderInfo>
getCustomerOrderInfoList
(@NonNull TabbyPayment tabbyPayment, String customerId, String applicationId, String tenantId) Reads the orders for the customer.protected CustomerOrderInfoProvider<CustomerOrderInfo>
protected int
Returns the max order history size.protected com.fasterxml.jackson.databind.ObjectMapper
protected Instant
getOldestOrderSubmitDate
(@NonNull List<CustomerOrderInfo> customerOrderInfoList) protected com.broadleafcommerce.paymentgateway.util.PaymentCallbackSecurityTokenUtil
protected ExternalOrderOperationProviderProperties
protected String
getTabbyOrderStatus
(@NonNull CustomerOrderInfo orderHistory) Returns the Tabby order status.protected com.broadleafcommerce.common.extension.TypeFactory
modifyPaymentMethodProperties
(@NonNull com.broadleafcommerce.paymentgateway.domain.PaymentInfo paymentInfo, String applicationId, String tenantId) protected TabbyPayment
populateBuyerHistory
(@NonNull TabbyPayment tabbyPayment, @NonNull List<CustomerOrderInfo> customerOrderInfoList) protected TabbyPayment
populateOrderAndBuyerHistory
(@NonNull TabbyPayment tabbyPayment, String applicationId, String tenantId) Reads the Order history from the Order Ops service and populatesTabbyPayment.getBuyerHistory()
andTabbyPayment.getOrderHistory()
based on it.protected TabbyPayment
populateOrderHistory
(@NonNull TabbyPayment tabbyPayment, @NonNull List<CustomerOrderInfo> customerOrderInfoList) protected TabbyPayment
readTabbyPayment
(@NonNull Map<String, String> paymentMethodProperties) Reads the Tabby payment specified in thePaymentInfo.getPaymentMethodProperties()
and converts it to theTabbyPayment
.void
setPaymentCallbackSecurityTokenUtil
(com.broadleafcommerce.paymentgateway.util.PaymentCallbackSecurityTokenUtil paymentCallbackSecurityTokenUtil) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.broadleafcommerce.paymentgateway.service.PaymentGatewayPaymentModificationService
getCallbackUrlKeys, modifyPaymentMethodProperties, updateGatewayPayment
-
Constructor Details
-
DefaultTabbyPaymentModificationService
public DefaultTabbyPaymentModificationService(com.fasterxml.jackson.databind.ObjectMapper objectMapper, CustomerOrderInfoProvider<CustomerOrderInfo> customerOrderInfoProvider, ExternalOrderOperationProviderProperties properties, TabbyConfigurationProperties configurationProperties, com.broadleafcommerce.resource.security.utils.service.AuthenticationUtils authenticationUtils, com.broadleafcommerce.common.extension.TypeFactory typeFactory)
-
-
Method Details
-
modifyPaymentMethodProperties
public Map<String,String> modifyPaymentMethodProperties(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentInfo paymentInfo, @Nullable String applicationId, @Nullable String tenantId) - Specified by:
modifyPaymentMethodProperties
in interfacecom.broadleafcommerce.paymentgateway.service.PaymentGatewayPaymentModificationService
-
readTabbyPayment
@Nullable protected TabbyPayment readTabbyPayment(@NonNull @NonNull Map<String, String> paymentMethodProperties) Reads the Tabby payment specified in thePaymentInfo.getPaymentMethodProperties()
and converts it to theTabbyPayment
.- Parameters:
paymentMethodProperties
- thePaymentInfo.getPaymentMethodProperties()
- Returns:
- the
TabbyPayment
-
populateOrderAndBuyerHistory
protected TabbyPayment populateOrderAndBuyerHistory(@NonNull @NonNull TabbyPayment tabbyPayment, @Nullable String applicationId, @Nullable String tenantId) Reads the Order history from the Order Ops service and populatesTabbyPayment.getBuyerHistory()
andTabbyPayment.getOrderHistory()
based on it.If
TabbyBuyerHistory.getRegisteredSince()
is not provided, it will be populated with the oldest order submit date. IfTabbyBuyerHistory.getLoyaltyLevel()
is not provided or equals to "0", it will be updated with the number of Orders in the of Order history. -
getCustomerOrderInfoList
protected List<CustomerOrderInfo> getCustomerOrderInfoList(@NonNull @NonNull TabbyPayment tabbyPayment, @Nullable String customerId, @Nullable String applicationId, @Nullable String tenantId) Reads the orders for the customer. If the customer is an anonymous user the orders will be fetched for the provided email in theTabbyBuyer.getEmail()
. -
getMaxOrderHistorySize
protected int getMaxOrderHistorySize()Returns the max order history size. The default value is 10 and the maximum is 100.- Returns:
- the max order history size
-
getBatchSize
protected int getBatchSize()Returns the batch size to read the orders. The default value is 10 and the maximum is 50.- Returns:
- the batch size to read the orders
-
buildContextInfo
-
populateOrderHistory
protected TabbyPayment populateOrderHistory(@NonNull @NonNull TabbyPayment tabbyPayment, @NonNull @NonNull List<CustomerOrderInfo> customerOrderInfoList) -
buildTabbyOrderHistories
protected List<TabbyOrderHistory> buildTabbyOrderHistories(@NonNull @NonNull List<CustomerOrderInfo> orderHistories) -
getTabbyOrderStatus
Returns the Tabby order status. The default is always "complete". -
buildTabbyBuyer
-
buildTabbyShippingAddress
-
populateBuyerHistory
protected TabbyPayment populateBuyerHistory(@NonNull @NonNull TabbyPayment tabbyPayment, @NonNull @NonNull List<CustomerOrderInfo> customerOrderInfoList) -
getOldestOrderSubmitDate
protected Instant getOldestOrderSubmitDate(@NonNull @NonNull List<CustomerOrderInfo> customerOrderInfoList) -
getGatewayType
- Specified by:
getGatewayType
in interfacecom.broadleafcommerce.paymentgateway.service.PaymentGatewayTypeAware
-
getObjectMapper
protected com.fasterxml.jackson.databind.ObjectMapper getObjectMapper() -
getCustomerOrderInfoProvider
-
getProperties
-
getConfigurationProperties
-
getAuthenticationUtils
protected com.broadleafcommerce.resource.security.utils.service.AuthenticationUtils getAuthenticationUtils() -
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory() -
setPaymentCallbackSecurityTokenUtil
@Autowired(required=false) @Qualifier("tabbyPaymentCallbackSecurityTokenUtil") public void setPaymentCallbackSecurityTokenUtil(@Nullable com.broadleafcommerce.paymentgateway.util.PaymentCallbackSecurityTokenUtil paymentCallbackSecurityTokenUtil) -
getPaymentCallbackSecurityTokenUtil
protected com.broadleafcommerce.paymentgateway.util.PaymentCallbackSecurityTokenUtil getPaymentCallbackSecurityTokenUtil()
-