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 Details

  • 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 interface com.broadleafcommerce.paymentgateway.service.PaymentGatewayPaymentModificationService
    • readTabbyPayment

      @Nullable protected TabbyPayment readTabbyPayment(@NonNull @NonNull Map<String,String> paymentMethodProperties)
      Reads the Tabby payment specified in the PaymentInfo.getPaymentMethodProperties() and converts it to the TabbyPayment.
      Parameters:
      paymentMethodProperties - the PaymentInfo.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 populates TabbyPayment.getBuyerHistory() and TabbyPayment.getOrderHistory() based on it.

      If TabbyBuyerHistory.getRegisteredSince() is not provided, it will be populated with the oldest order submit date. If TabbyBuyerHistory.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 the TabbyBuyer.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

      protected com.broadleafcommerce.data.tracking.core.context.ContextInfo buildContextInfo(@Nullable String applicationId, @Nullable String tenantId)
    • populateOrderHistory

      protected TabbyPayment populateOrderHistory(@NonNull @NonNull TabbyPayment tabbyPayment, @NonNull @NonNull List<CustomerOrderInfo> customerOrderInfoList)
    • buildTabbyOrderHistories

      protected List<TabbyOrderHistory> buildTabbyOrderHistories(@NonNull @NonNull List<CustomerOrderInfo> orderHistories)
    • getTabbyOrderStatus

      protected String getTabbyOrderStatus(@NonNull @NonNull CustomerOrderInfo orderHistory)
      Returns the Tabby order status. The default is always "complete".
    • buildTabbyBuyer

      protected TabbyBuyer buildTabbyBuyer(CustomerOrderInfo customerOrderInfo)
    • buildTabbyShippingAddress

      protected TabbyShippingAddress buildTabbyShippingAddress(Address address)
    • populateBuyerHistory

      protected TabbyPayment populateBuyerHistory(@NonNull @NonNull TabbyPayment tabbyPayment, @NonNull @NonNull List<CustomerOrderInfo> customerOrderInfoList)
    • getOldestOrderSubmitDate

      protected Instant getOldestOrderSubmitDate(@NonNull @NonNull List<CustomerOrderInfo> customerOrderInfoList)
    • getGatewayType

      public String getGatewayType()
      Specified by:
      getGatewayType in interface com.broadleafcommerce.paymentgateway.service.PaymentGatewayTypeAware
    • getObjectMapper

      protected com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
    • getCustomerOrderInfoProvider

      protected CustomerOrderInfoProvider<CustomerOrderInfo> getCustomerOrderInfoProvider()
    • getProperties

      protected ExternalOrderOperationProviderProperties getProperties()
    • getConfigurationProperties

      protected TabbyConfigurationProperties 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()