public Task<DomainCharge> GetAsync(DomainCharge charge)
 {
     return Task.Run(() =>
     {
         try
         {
             StripeCharge c = _service.Get(charge.Id);
             return Task.FromResult(_mapper.Map<StripeCharge, DomainCharge>(c));
         }
         catch (StripeException e)
         {
             throw new BillingException(string.Format("Failed to get charge by id {0}: {1}", charge.Id, e));
         }
     });
 }
        public async Task SendPaymentNotificationAsync(DomainEvent billingEvent, DomainCompany company, DomainCharge charge)
        {
            if (billingEvent == null)
            {
                throw new ArgumentNullException("billingEvent");
            }

            if (company == null)
            {
                throw new ArgumentNullException("company");
            }

            if (charge == null)
            {
                throw new ArgumentNullException("charge");
            }

            if (!_settings.EmailNotifications)
            {
                return;
            }

            var email = new SendEmailDomain
            {
                Address = _settings.EmailAddressAlerts,
                DisplayName = Emails.SenderDisplayName,
                Emails = new List<string> { company.Email }
            };

            switch (billingEvent.Type)
            {
                case EventType.ChargeFailed:
                    email.Subject = Emails.SubjectPaymentFailed;
                    email.Body = string.Format(
                        PortalResources.PaymentFailed,
                        company.Name,
                        billingEvent.Id,
                        string.Format("{0} {1}", charge.AmountInCents*0.01, charge.Currency),
                        charge.Created);
                    break;

                case EventType.ChargeSucceeded:
                    email.Subject = Emails.SubjectPaymentCompleted;
                    email.Body = string.Format(
                        PortalResources.PaymentCompleted,
                        company.Name,
                        billingEvent.Id,
                        string.Format("{0} {1}", charge.AmountInCents*0.01, charge.Currency),
                        charge.Created);
                    break;

                case EventType.ChargeRefunded:
                    email.Subject = Emails.SubjectPaymentRefunded;
                    email.Body = string.Format(
                        PortalResources.PaymentRefunded,
                        company.Name,
                        billingEvent.Id,
                        string.Format("{0} {1}", charge.AmountInCents*0.01, charge.Currency),
                        charge.Created);
                    break;

                default:
                    return;
            }


            // Send email on user registration
            await _emailSenderService.SendEmailAsync(email);
        }