Workflows and Activities
Existing workflows
The following document describes the changes made to existing workflows required for the Subscription module.
Note: With the inclusion of the following new activities, you will want to verify the activity ordering of these workflows if you have made any custom changes to the ordering.
CreateSubscriptionActivity
The CreateSubscriptionActivity
was added to the blCheckoutWorkflow
with the given order of 6500
. This activity creates
a Subscription for any Subscription Product that makes it through checkout.
<bean id="blCheckoutWorkflow" class="org.broadleafcommerce.core.workflow.SequenceProcessor">
<property name="activities">
<list>
<bean p:order="6500" class="com.broadleafcommerce.subscription.service.workflow.CreateSubscriptionActivity" />
</list>
</property>
</bean>
SubscriptionAvailabilityActivity
The SubscriptionAvailability
was added to both the blAddItemWorkflow
and the blUpdateItemWorkflow
. This activity
verifies that the Customer isn't already subscribed to a Subscription that is being added to the cart.
<bean id="blAddItemWorkflow" class="org.broadleafcommerce.core.workflow.SequenceProcessor">
<property name="activities">
<list>
<bean p:order="1500" class="com.broadleafcommerce.subscription.service.workflow.SubscriptionAvailabilityActivity" />
</list>
</property>
</bean>
<bean id="blUpdateItemWorkflow" class="org.broadleafcommerce.core.workflow.SequenceProcessor">
<property name="activities">
<list>
<bean p:order="1500" class="com.broadleafcommerce.subscription.service.workflow.SubscriptionAvailabilityActivity" />
</list>
</property>
</bean>
Subscription Payment Workflow
This is based on the payment workflow that occurs during regular checkout, but adapted to be run periodically and in the background, without user interaction.
The activities that constitute this workflow can be seen in the workflow's declaration in blc-subscription-base-applicationContext.xml
:
...
<bean id="blSubscriptionPaymentWorkflow" class="org.broadleafcommerce.core.workflow.SequenceProcessor">
<property name="processContextFactory">
<bean class="com.broadleafcommerce.subscription.service.workflow.SubscriptionPaymentProcessContextFactory"/>
</property>
<property name="defaultErrorHandler">
<bean class="org.broadleafcommerce.core.workflow.DefaultErrorHandler">
<property name="unloggedExceptionClasses">
<list>
<value>org.hibernate.exception.LockAcquisitionException</value>
</list>
</property>
</bean>
</property>
<property name="activities">
<list>
<bean p:order="7000" class="com.broadleafcommerce.subscription.service.workflow.CreateSecondaryOrderForSubscriptionActivity" />
<bean p:order="7100" class="com.broadleafcommerce.subscription.service.workflow.CalculateSubscriptionTaxActivity" />
<bean p:order="7200" class="com.broadleafcommerce.subscription.service.workflow.TotalSubscriptionTaxActivity" />
<bean p:order="7300" class="com.broadleafcommerce.subscription.service.workflow.CreateSecondaryOrderPaymentForSubscriptionActivity" />
<bean p:order="7500" class="com.broadleafcommerce.subscription.service.workflow.ValidateAndConfirmSubscriptionPaymentActivity">
<property name="rollbackHandler" ref="blConfirmSubscriptionPaymentsRollbackHandler" />
</bean>
<bean p:order="7600" class="com.broadleafcommerce.subscription.service.workflow.CompleteSubscriptionOrderActivity" />
</list>
</property>
</bean>
...
A brief description of each of the activities:
- CreateSecondaryOrderForSubscriptionActivity: Starts the internal "cloning" process of an order, within the subscription. Deep-copies order item and fulfillment groups.
- CalculateSubscriptionTaxActivity: calculate tax rates on the order item(s), based on fulfillment information
- TotalSubscriptionTaxActivity: calculates and adds subtotals and tax totals for the secondary order.
- CreateSecondaryOrderPaymentForSubscriptionActivity: completes the cloning of the order into the secondary order, adding Order Payment child objects.
- ValidateAndConfirmSubscriptionPaymentActivity: interacts with the payment gateway
- CompleteSubscriptionOrderActivity: marks the payment process as completed, and stages necessary values for the next billing period.