public static DataAccessResponseType RefundPayment(string accountId, string chargeId, decimal refundAmount) { var account = AccountManager.GetAccount(accountId); if (account == null) { return(new DataAccessResponseType { isSuccess = false, ErrorMessage = "Can only makre refunds for valid accounts." }); } //Confirm that refund amount is greater than 0 if (refundAmount <= 0) { return(new DataAccessResponseType { isSuccess = false, ErrorMessage = "Refund amount must be greater than 0." }); } //Confirm that the refund amount is correctly formated if (Sahara.Core.Common.Methods.Billing.IsDecimalInTwoPlaces(refundAmount)) { //Submit the refund var stripeManager = new StripeManager(); var refundAmountStripeInteger = Sahara.Core.Common.Methods.Billing.ConvertDecimalToStripeAmount(refundAmount); StripeRefund refundedCharge; var refundResponse = stripeManager.RefundPayment(chargeId, refundAmountStripeInteger, out refundedCharge); if (refundResponse.isSuccess) { //Email all acount owners regarding the refund. //Get account ownerEmail(s): var ownerEmails = AccountManager.GetAccountOwnerEmails(account.AccountID.ToString()); string refundAmountDollars = string.Empty; if (refundAmount.ToString().Substring(0, 1) == ".") { refundAmountDollars = refundAmount + " cents."; } else { refundAmountDollars = "$" + refundAmount; } EmailManager.Send( ownerEmails, Settings.Endpoints.Emails.FromRefunds, Settings.Copy.EmailMessages.ChargeRefunded.FromName, Settings.Copy.EmailMessages.ChargeRefunded.Subject, String.Format(Settings.Copy.EmailMessages.ChargeRefunded.Body, account.AccountName, refundAmountDollars), true); } return(refundResponse); } else { return(new DataAccessResponseType { isSuccess = false, ErrorMessage = "Refund amount must be a monetary value with 2 decimal places. Examples: '2.25' or '.50'" }); } }