Class DefaultSubscriptionGenerationService<O extends com.broadleafcommerce.order.client.domain.Order,F extends com.broadleafcommerce.order.client.domain.OrderFulfillment,SWI extends SubscriptionWithItems>

java.lang.Object
com.broadleafcommerce.orderoperation.service.generate.subscription.DefaultSubscriptionGenerationService<O,F,SWI>
All Implemented Interfaces:
SubscriptionGenerationService<O,F,SWI>

public class DefaultSubscriptionGenerationService<O extends com.broadleafcommerce.order.client.domain.Order,F extends com.broadleafcommerce.order.client.domain.OrderFulfillment,SWI extends SubscriptionWithItems> extends Object implements SubscriptionGenerationService<O,F,SWI>
  • Constructor Details

    • DefaultSubscriptionGenerationService

      public DefaultSubscriptionGenerationService(SubscriptionOpsProvider<SWI> subscriptionOpsProvider, com.broadleafcommerce.common.extension.TypeFactory typeFactory)
  • Method Details

    • createNewSubscriptions

      public List<SWI> createNewSubscriptions(@NonNull O order, @NonNull @NonNull Collection<F> fulfillments, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: SubscriptionGenerationService
      Given the provided Order and its items, creates a Subscription, if one is required. Returns already existed Subscription if any.
      Specified by:
      createNewSubscriptions in interface SubscriptionGenerationService<O extends com.broadleafcommerce.order.client.domain.Order,F extends com.broadleafcommerce.order.client.domain.OrderFulfillment,SWI extends SubscriptionWithItems>
      Parameters:
      order - a completed order
      fulfillments - the order's collection of fulfillments
      contextInfo - context information around the multi-tenant state
      Returns:
      the list of the Subscriptions & SubscriptionItems that were created
    • lockSubscription

      public LockStatus lockSubscription(String subscriptionId, @Nullable List<String> reservations)
      Specified by:
      lockSubscription in interface SubscriptionGenerationService<O extends com.broadleafcommerce.order.client.domain.Order,F extends com.broadleafcommerce.order.client.domain.OrderFulfillment,SWI extends SubscriptionWithItems>
    • clearLock

      public LockStatus clearLock(String subscriptionId, boolean isRevert)
      Specified by:
      clearLock in interface SubscriptionGenerationService<O extends com.broadleafcommerce.order.client.domain.Order,F extends com.broadleafcommerce.order.client.domain.OrderFulfillment,SWI extends SubscriptionWithItems>
    • unlockToken

      public LockStatus unlockToken(String subscriptionId, String token, boolean propagate)
      Specified by:
      unlockToken in interface SubscriptionGenerationService<O extends com.broadleafcommerce.order.client.domain.Order,F extends com.broadleafcommerce.order.client.domain.OrderFulfillment,SWI extends SubscriptionWithItems>
    • createToken

      public LockStatus createToken(String subscriptionId, String tokenIdentifier)
      Specified by:
      createToken in interface SubscriptionGenerationService<O extends com.broadleafcommerce.order.client.domain.Order,F extends com.broadleafcommerce.order.client.domain.OrderFulfillment,SWI extends SubscriptionWithItems>
    • buildRequest

      protected CreateSubscriptionFromOrderRequest buildRequest(@NonNull O order, @NonNull @NonNull Collection<F> fulfillments, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • shouldCreateAnyNewSubscriptions

      protected boolean shouldCreateAnyNewSubscriptions(O order, @NonNull @NonNull Collection<F> fulfillments, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Hook point to determine whether a given Order has any items representing a Subscription that should be created. By default, a subscription is only created for items that need to be billed recurringly. This method checks whether OrderItem.getRecurringPrice() is not null to determine that for each item.

      IMPORTANT: By default, this method assumes that if any of the dependent OrderItems are subscriptions, then their parent (i.e., the root items on the Order) are also subscriptions.

      Parameters:
      order - The Order with OrderItems representing Subscriptions to create
      fulfillments - The OrderFulfillments created for order
      contextInfo - Additional sandbox and multitenant info
      Returns:
      whether a subscription should be created for the given orderItem
    • isSubscriptionItem

      protected boolean isSubscriptionItem(@NonNull @NonNull com.broadleafcommerce.order.client.domain.OrderItem orderItem)
    • orderItemRepresentsActionToExistingSubscription

      protected boolean orderItemRepresentsActionToExistingSubscription(@NonNull O order, @NonNull @NonNull com.broadleafcommerce.order.client.domain.OrderItem orderItem)
    • getSubscriptionOpsProvider

      protected SubscriptionOpsProvider<SWI> getSubscriptionOpsProvider()
    • getTypeFactory

      protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()