protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext) { //Capture the payment if (CustomerOrder.Transactions == null) { CustomerOrder.Transactions = new LazyList <Transaction>(); } //pull this order and make sure it's not already transacted/charged Order orderCheck = OrderServiceInterface.GetOrder(CustomerOrder.ID); decimal amountPaid = 0; if (orderCheck.Transactions.Count > 0) { amountPaid = orderCheck.Transactions.Sum(x => x.Amount); } if (amountPaid > 0) { throw new InvalidOperationException("A transaction already exists for this order: " + CustomerOrder.OrderNumber); } CustomerOrder.Transactions.Add(PaymentGateway.Capture(CustomerOrder)); return(ActivityExecutionStatus.Closed); }