private void PayOrder(InvoicePaymentProvider invoicePaymentProvider) { InvoiceWebhook invoiceWebhook = _invoiceWebhookDomainService.CreateInvoiceWebhook(invoicePaymentProvider, DateTime.Now); try { Invoice invoice = _invoiceRepository.GetAllIncluding(x => x.Order).Single(x => x.Id == invoicePaymentProvider.InvoceId); if (invoice.Order.Status.Status == OrderStatus.OrderStatusValue.PaymentPending) { _orderDomainService.PayOrder(invoice.Order); switch (invoice.Order.Type.Type) { case OrderType.OrderTypeValue.Subscription: _eventBus.Trigger(new OrderSubscriptionPayedEventData(invoice.Order)); break; case OrderType.OrderTypeValue.RenewSubscription: _eventBus.Trigger(new OrderRenewSubscriptionPayedEventData(invoice.Order)); break; } } } catch (Exception ex) { Logger.Error("Ocurrio un error al Pagar una Orden.", ex); _invoiceWebhookDomainService.ChangeToError(invoiceWebhook); } finally { _invoiceWebhookRepository.Insert(invoiceWebhook); } }
public void ChangeToError(InvoiceWebhook invoiceWebhook) { invoiceWebhook.Status.Status = InvoiceWebhookStatus.InvoiceWebhookStatusValue.Error; }