public virtual void run(Payment payment) { Order order = payment.Order; LineItem[] lineItems = order.LineItems; Customer customer = order.Customer; foreach (LineItem lineItem in lineItems) { if (!lineItem.hasCategory(ProductCategory.Membership)) { continue; } Membership membership = _service.findBySku(lineItem.Sku); if (membership != null) { customer.addMembership(membership, _notificationService); } } }
public virtual void run(Payment payment) { Order order = payment.Order; Customer customer = order.Customer; LineItem[] lineItems = order.LineItems; foreach (LineItem lineItem in lineItems) { if (!lineItem.hasCategory(ProductCategory.Membership)) { continue; } Membership membership = _repo.findBySku(lineItem.Sku); Membership previousLevel = membership.PreviousLevel; if (customer.hasMembership(previousLevel)) { customer.addMembership(membership, _notificationService); } } }