public void SendOrderConfirmationToVendor(IECommerceConfiguration shop, Order order) { string orderConfirmationVendorText = _messageBuilder.Transform("OrderConfirmationVendor", new { order = order }); _mailSender.Send(shop.ConfirmationEmailFrom, shop.VendorEmail, "Order Confirmation", orderConfirmationVendorText); }
public Order PlaceOrder(IECommerceConfiguration configuration, string cardNumber, string cardVerificationCode, DeliveryMethod deliveryMethod, decimal deliveryPrice, Address billingAddress, Address shippingAddress, PaymentCard paymentCard, string emailAddress, string telephoneNumber, string mobileTelephoneNumber, IEnumerable<OrderItem> items, decimal totalVatPrice, decimal totalPrice) { // Convert shopping basket into order, with unpaid status. Order order = new Order { User = (_webContext.User != null && (_webContext.User is WebPrincipal)) ? ((WebPrincipal) _webContext.User).MembershipUser : null, DeliveryMethod = deliveryMethod, BillingAddress = billingAddress, ShippingAddress = shippingAddress, PaymentCard = paymentCard, EmailAddress = emailAddress, TelephoneNumber = telephoneNumber, MobileTelephoneNumber = mobileTelephoneNumber, Status = OrderStatus.Unpaid, TotalDeliveryPrice = deliveryPrice, TotalVatPrice = totalVatPrice, TotalPrice = totalPrice }; foreach (OrderItem orderItem in items) orderItem.AddTo(order); order.AddTo(configuration.Orders); _persister.Save(order); order.Title = "Order #" + order.ID; _persister.Save(order); // Process payment. PaymentRequest paymentRequest = new PaymentRequest( PaymentTransactionType.Payment, order.ID.ToString(), order.TotalPrice, order.Title, order.BillingAddress, order.ShippingAddress, order.PaymentCard, cardNumber, cardVerificationCode, order.TelephoneNumber, order.EmailAddress, _webContext.Request.UserHostAddress); PaymentResponse paymentResponse = _paymentGateway.TakePayment(paymentRequest); if (paymentResponse.Success) { // Update order status to Paid. order.Status = OrderStatus.Paid; _persister.Save(order); // Send email to customer and vendor. //commented out by Dave - why would this be a centralised library - like we don't need to change this for project to project? //_orderMailService.SendOrderConfirmationToCustomer(configuration, order); //_orderMailService.SendOrderConfirmationToVendor(configuration, order); } else { throw new ZeusECommerceException(paymentResponse.Message); } return order; }
public void SendOrderConfirmationToCustomer(IECommerceConfiguration shop, Order order) { string orderConfirmationCustomerText = _messageBuilder.Transform("OrderConfirmationCustomer", new { order = order, text = shop.ConfirmationEmailText }); _mailSender.Send(shop.ConfirmationEmailFrom, order.EmailAddress, "Order Confirmation", orderConfirmationCustomerText); }
public Order PlaceOrderWithoutPayment(IECommerceConfiguration configuration, DeliveryMethod deliveryMethod, decimal deliveryPrice, Address billingAddress, Address shippingAddress, PaymentCard paymentCard, string emailAddress, string telephoneNumber, string mobileTelephoneNumber, IEnumerable<OrderItem> items, decimal totalVatPrice, decimal totalPrice) { try { // Convert shopping basket into order, with unpaid status. Order order = new Order { User = (_webContext.User != null && (_webContext.User is WebPrincipal)) ? ((WebPrincipal)_webContext.User).MembershipUser : null, DeliveryMethod = deliveryMethod, BillingAddress = billingAddress, ShippingAddress = shippingAddress, PaymentCard = paymentCard, EmailAddress = emailAddress, TelephoneNumber = telephoneNumber, MobileTelephoneNumber = mobileTelephoneNumber, Status = OrderStatus.Unpaid, TotalDeliveryPrice = deliveryPrice, TotalVatPrice = totalVatPrice, TotalPrice = totalPrice }; foreach (OrderItem orderItem in items) orderItem.AddTo(order); order.AddTo(configuration.Orders); order.Status = OrderStatus.Unpaid; _persister.Save(order); if (_webContext.User != null && !string.IsNullOrEmpty(_webContext.User.Identity.Name)) { order.Title = _webContext.User.Identity.Name + " for " + items.First().Title; } else { order.Title = "Order #" + order.ID; } _persister.Save(order); return order; } catch (System.Exception ex) { throw(new System.Exception("Error creating order: \n" + ex.Message + "\n" + ex.StackTrace)); } }