/// <summary> /// Value to pass to the notification monitors /// </summary> /// <param name="model"> /// The model. /// </param> /// <param name="contacts"> /// An additional list of contacts /// </param> protected override void Notify(IPaymentResult model, IEnumerable <string> contacts) { var symbol = string.Empty; IShipment shipment = null; IShipMethod shipMethod = null; if (model.Invoice != null) { if (model.Invoice.Items.Any()) { var currencyCode = model.Invoice.Items.First().ExtendedData.GetValue(Core.Constants.ExtendedDataKeys.CurrencyCode); var currency = _storeSettingService.GetCurrencyByCode(currencyCode); symbol = currency.Symbol; } // get shipping information if any var shippingLineItems = model.Invoice.ShippingLineItems().ToArray(); if (shippingLineItems.Any()) { // just use the first one shipment = shippingLineItems.First().ExtendedData.GetShipment <InvoiceLineItem>(); // get the shipmethod information if (shipment != null && shipment.ShipMethodKey.HasValue) { shipMethod = _shipMethodService.GetByKey(shipment.ShipMethodKey.Value); } } } NotifyMonitors(model.ToOrderConfirmationNotification(contacts, shipment, shipMethod, symbol)); }
public ShipMethodDisplay GetShipMethod(OrderDisplay order) { var invoice = _invoiceService.GetByKey(order.InvoiceKey); if (invoice == null) { throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound)); } var shipmentLineItem = invoice.Items.FirstOrDefault(x => x.LineItemType == LineItemType.Shipping); if (shipmentLineItem == null) { throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound)); } var shipment = shipmentLineItem.ExtendedData.GetShipment<InvoiceLineItem>(); if (shipment == null) { throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound)); } if (shipment.ShipMethodKey != null) { var shipMethod = _shipMethodService.GetByKey(shipment.ShipMethodKey.Value); if (shipMethod == null) return new ShipMethodDisplay() { Name = "Not Found" }; return shipMethod.ToShipMethodDisplay(); } return new ShipMethodDisplay() { Name = "Not Found" }; }
/// <summary> /// Gets a <see cref="IShipMethod"/> by it's unique key /// </summary> /// <param name="shipMethodKey">The <see cref="IShipMethod"/> key</param> /// <returns>A <see cref="IShipMethod"/></returns> public IShipMethod GetShipMethodByKey(Guid shipMethodKey) { return(_shipMethodService.GetByKey(shipMethodKey)); }