Interface TaxProvider<T1 extends TaxRequest,​T2 extends TaxResponse>

  • All Superinterfaces:
    org.springframework.core.Ordered, TaxAccessor<T1,​T2>
    All Known Implementing Classes:
    SimpleTaxProvider

    public interface TaxProvider<T1 extends TaxRequest,​T2 extends TaxResponse>
    extends TaxAccessor<T1,​T2>, org.springframework.core.Ordered
    Represents a component that is tasked with calculating taxes, or calling a 1st or 3rd party service to calculate taxes.
    Author:
    Chad Harchar (charchar), Kelly Tisdell (ktisdell)
    • Method Detail

      • getProviderId

        @NonNull
        default String getProviderId()
        This returns a string that is unique to identify each TaxProvider. Broadleaf implementations will use "BLC_" as a prefix. Custom implementations should NOT use this prefix.
        Returns:
      • isEstimator

        default boolean isEstimator()
        Indicates (or hints) if this provider estimates taxes. This is similar to (or could be the same as) calculating taxes. This is usually a consideration where a provider prefers not to make a remote call, or where the provider can operate on limited info (e.g. just a state or province or country and not a full address).

        The default is false.

        Returns:
      • validate

        default void validate​(@Nullable
                              com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        This can be used to determine if configurations, credential, and connections are correct and working properly together. This should be called by the Admin UI or other methods to simply validate whether connection and credential details are correct. If everything is working, this is a pass-through method. If something is not working, then a RuntimeException should be thrown, typically an IllegalStateException, IllegalArgumentException, or UnsupportedOperationException. This method may be invoked by a call from the Admin or other systems to ensure that the configuration is correct.
        Parameters:
        contextInfo -
      • canHandle

        default <R extends TaxCalculationRequest> boolean canHandle​(@NonNull
                                                                    R request,
                                                                    @Nullable
                                                                    com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Indicates if this TaxProvider can handle requests for the given TaxCalculationRequest and ContextInfo, which can be null.
        Parameters:
        request - the tax request being
        contextInfo -
        Returns:
      • getOrder

        default int getOrder()
        Allows for ordering of priority or precedence for various TaxProvider implementations. By default, this returns 0. Implementations that want to affect ordering, should return a value ' less than zero for higher priorities and greater than zero for lower priorities. Note that these are global orderings. Ordering only matters when you have multiple TaxProvider implementations and more than one may be able to handle the request. Ordering ensures you select the the highest priority first. This is typically the case in DefaultTaxDelegate, which attempts to resolve the best TaxProvider for a given request.
        Specified by:
        getOrder in interface org.springframework.core.Ordered
        Returns: