here's the checkout workflow modification:
Code: Select all
<bean id="blCheckoutWorkflow" class="org.broadleafcommerce.core.workflow.SequenceProcessor">
<property name="processContextFactory">
<bean class="org.broadleafcommerce.core.checkout.service.workflow.CheckoutProcessContextFactory"/>
</property>
<property name="activities">
<list>
<ref bean="blVerifyCustomerMaxOfferUsesActivity" />
<ref bean="blPaymentServiceActivity" />
<ref bean="blRecordOfferUsageActivity" />
<ref bean="blCommitTaxActivity" />
<ref bean="blCompleteOrderActivity" />
<ref bean="ServiceCreateOrderActivity" />
<ref bean="ServiceValidateOrderActivity" />
</list>
</property>
<property name="defaultErrorHandler" ref="blDefaultErrorHandler"/>
</bean>
I have added two activities that performs Create/Validate order from broadleaf to an external web service.
Code: Select all
public class ServiceCreateOrderActivity extends BaseActivity<CheckoutContext> {
@Override
public CheckoutContext execute(CheckoutContext context) throws Exception {
CheckoutSeed seed = context.getSeedData();
Order cart = seed.getOrder();
try {
// perform the create order to be sent to a webservice
} catch(AxisFault e) {
e.printStackTrace();
context.stopProcess();
throw new MyOrderResponseFailedException("Unable to process request. Service Response failed.");
}
}
when an exception has occured, it will just throw the Exception I created and handle it on the site project.
under CheckoutController
Code: Select all
@RequestMapping(value = "/complete", method = RequestMethod.POST)
public ModelAndView completeSecureCreditCardCheckout(@Context HttpServletRequest request, HttpServletResponse response, Model model,
@ModelAttribute("orderInfoForm") OrderInfoForm orderInfoForm,
@ModelAttribute("shippingInfoForm") ShippingInfoForm shippingForm,
@ModelAttribute("billingInfoForm") BillingInfoForm billingForm,
BindingResult result) throws CheckoutException, PricingException, ServiceException {
prepopulateCheckoutForms(CartState.getCart(), null, shippingForm, billingForm);
System.out.println("complete secure card checkout");
String csCCC = "";
try {
csCCC = super.completeSecureCreditCardCheckout(request, response, model, billingForm, result);
} catch (CheckoutException e) {
System.out.println(e.getCause().getMessage());
model.addAttribute("hasActivityError", true);
model.addAttribute("error", e.getCause().getMessage());
csCCC = getCheckoutPageRedirect();
}
return new ModelAndView(csCCC);
}
The main problem I am encountering is that, It has no more cart items coz it redirects to cart complete.
How will I make it "not" discard the cart items? Is there some kind of rollback functionality? Because I think broadleaf handles the rollback state part but im not sure how to do it.
Thanks