private void DepositCryptocurrency(Member user, decimal amountInCryptocurrency) { Money moneyAmount = ConvertToMoney(amountInCryptocurrency); LogType LogType = ErrorLoggerHelper.GetTypeFromProcessor(DepositApiProcessor); user.Reload(); if (DepositTarget == DepositTargetBalance.PurchaseBalance) { user.AddToPurchaseBalance(moneyAmount, Code + " deposit", BalanceLogType.Other); user.SaveBalances(); } if (DepositTarget == DepositTargetBalance.CashBalance) { user.AddToCashBalance(moneyAmount, Code + " deposit", BalanceLogType.Other); user.SaveBalances(); //Referral commission for sponsors when user does Cash Balance deposit CashBalanceCrediter Crediter = (CashBalanceCrediter)CrediterFactory.Acquire(user, CreditType.CashBalanceDeposit); Crediter.TryCreditReferer(moneyAmount); } if (DepositTarget == DepositTargetBalance.Wallet) { user.AddToCryptocurrencyBalance(Type, amountInCryptocurrency, Code + " Wallet deposit", BalanceLogType.WalletDeposit); } PaymentProportionsManager.MemberPaidIn(moneyAmount, CryptocurrencyTypeHelper.ConvertToPaymentProcessor(Type), user); History.AddTransfer(user.Name, moneyAmount, Code + " deposit", DepositTarget.ToString()); ContestManager.IMadeAnAction(ContestType.Transfer, user.Name, moneyAmount, 0); }
public string ConfirmWithdrawal(ConversationMessage transactionMessage) { Money amount = transactionMessage.RepresentativeTransferAmount; //Lets validate //PayoutManager.ValidatePayout(User, amount); PayoutManager.CheckMaxPayout(PaymentProcessor.ViaRepresentative, User, amount); //Update payout proportions PaymentProportionsManager.MemberPaidOut(amount, PaymentProcessor.ViaRepresentative, User); History.AddCashout(User.Name, amount); User.MoneyCashout += amount; User.IsPhoneVerifiedBeforeCashout = false; User.CashoutsProceed++; User.Save(); //Add paymentproof PaymentProof.Add(User.Id, amount, PaymentType.Manual, PaymentProcessor.ViaRepresentative); //Send message to the user Member RepresentativeUser = new Member(RepresentativeUserId); RepresentativeUser.SendMessage(User.Id, U6010.WITHDRAWALCONFIRMED); return(U6010.WITHDRAWALCONFIRMED); }
protected void ProportionsGridView_RowDataBound(object sender, GridViewRowEventArgs e) { PaymentProportionsManager ppm = new PaymentProportionsManager(User); ProportionsGridView.Columns[0].HeaderText = U5004.PAYMENTPROCESSOR; ProportionsGridView.Columns[1].HeaderText = U5004.PAIDIN; ProportionsGridView.Columns[2].HeaderText = U5004.PAIDIN + " (%)"; ProportionsGridView.Columns[3].HeaderText = DEFAULT.TOTALCASHOUT; ProportionsGridView.Columns[4].HeaderText = U5004.MAXIMUMWITHDRAWAL + "*"; if (e.Row.RowType == DataControlRowType.DataRow) { PaymentProcessor processor = (PaymentProcessor)Convert.ToInt32(e.Row.Cells[0].Text); int percentage = ppm.GetPercentage(processor); //Processor e.Row.Cells[0].Text = processor.ToString(); //TotalIn e.Row.Cells[1].Text = Money.Parse(e.Row.Cells[1].Text).ToString(); e.Row.Cells[2].Text = percentage.ToString() + "%"; //TotalOut e.Row.Cells[3].Text = Money.Parse(e.Row.Cells[3].Text).ToString(); Money maximum = ppm.GetMaximum(processor); if (maximum > User.MainBalance) { maximum = User.MainBalance; } e.Row.Cells[4].Text = maximum.ToString(); } }
public void MakeWithdrawal(Money amount, string address, Member user, WithdrawalSourceBalance withdrawalSource) { decimal amountInCryptocurrency = Decimal.Zero; Money amountInMoney = Money.Zero; if (withdrawalSource == WithdrawalSourceBalance.MainBalance) { amountInCryptocurrency = ConvertFromMoney(amount); amountInMoney = amount; } else //Wallets { amountInCryptocurrency = amount.ToDecimal(); amountInMoney = ConvertToMoney(amountInCryptocurrency); } CryptocurrencyApiFactory.GetWithdrawalApi(this).TryWithDrawCryptocurrencyFromWallet(amountInCryptocurrency, address, Type); BitcoinIPNManager.AddIPNLog(AppSettings.ServerTime, OperationType.Withdrawal, null, user.Id, address, amountInCryptocurrency, amountInMoney, this.WithdrawalApiProcessor, true); if (withdrawalSource == WithdrawalSourceBalance.MainBalance) { PaymentProportionsManager.MemberPaidOut(amountInMoney, CryptocurrencyTypeHelper.ConvertToPaymentProcessor(Type), user); } AddPaymentProof(amount, user); }
public static void UndoMemberPaidOut(Money amount, PaymentProcessor processor, Member user) { if (amount == Money.Zero) //we don't want add 0 to tables { return; } PaymentProportionsManager ppm = new PaymentProportionsManager(user); ppm.UndoPaidOut(amount, processor); }
public static void MemberPaidOut(Money amount, PaymentProcessor processor, Member user, bool IsCustomPayoutProcessor = false) { if (amount == Money.Zero) //we don't want add 0 to tables { return; } if (!IsCustomPayoutProcessor) { PaymentProportionsManager ppm = new PaymentProportionsManager(user); ppm.PaidOut(amount, processor); } }
public void MarkAsPaid() { Status = WithdrawRequestStatus.Accepted; var user = new Member(UserId); if (WithdrawalSourceBalance == WithdrawalSourceBalance.MainBalance) { PaymentProportionsManager.MemberPaidOut(Amount, CryptocurrencyTypeHelper.ConvertToPaymentProcessor(Cryptocurrency), user); CryptocurrencyObject.AddPaymentProof(Amount, user); } else { CryptocurrencyObject.AddPaymentProof(CryptocurrencyObject.ConvertToMoney(Amount.ToDecimal()), user); } Save(); }
/// <summary> /// FROM AP /// </summary> /// <param name="request"></param> public static void RejectRequest(PayoutRequest request) { Member User = new Member(request.Username); try { PaymentProcessor processor = PaymentAccountDetails.GetFromStringType(request.PaymentProcessor); PaymentProportionsManager.UndoMemberPaidOut(request.Amount, processor, User); } catch { //processor = custom processor } request.IsPaid = true; request.PaymentProcessor = "REJECTED"; request.Save(); User.MoneyCashout -= request.Amount; User.AddToMainBalance(request.Amount, "Payout rejected"); User.Save(); History.AddCashoutRejection(User.Name, request.Amount.ToString()); }
public static void TransferToBalance(string username, Money money, string from, string transId, string targetBalance, bool isViaRepresentative = false, string cryptoCurrencyInfo = "") { Exceptions.HandleNonMsgEx(() => { //Add income to stats if (!isViaRepresentative) { Statistics.Statistics.AddToCashflow(money); } bool successful = (money >= AppSettings.Payments.MinimumTransferAmount); PaymentProcessor paymentProcessor = PaymentAccountDetails.GetFromStringType(from); Money moneyWithoutFee = money; if (!isViaRepresentative && (targetBalance == "Purchase Balance" || targetBalance == "Cash Balance" || targetBalance == "Marketplace Balance")) { moneyWithoutFee = PaymentAccountDetails.GetAmountWithoutFee(from, money); } if (successful) { Member user = new Member(username); if (targetBalance == "Purchase Balance") { user.AddToPurchaseBalance(moneyWithoutFee, from + " transfer"); } else if (targetBalance == "Cash Balance") { user.AddToCashBalance(moneyWithoutFee, from + " transfer"); } else if (targetBalance == "Traffic Balance") { user.AddToTrafficBalance(money, from + " transfer"); } else if (targetBalance == "Marketplace Balance") { user.AddToMarketplaceBalance(moneyWithoutFee, from + " transfer"); } else if (targetBalance == "Points Balance") { user.AddToPointsBalance(moneyWithoutFee.ConvertToPoints(), from + " transfer"); } user.SaveBalances(); if (targetBalance == "Purchase Balance" || targetBalance == "Cash Balance" || targetBalance == "Marketplace Balance") { //Update payment proportions PaymentProportionsManager.MemberPaidIn(moneyWithoutFee, paymentProcessor, user); } //Add history History.AddTransfer(username, moneyWithoutFee, from, targetBalance); //TryAchievement bool shouldBeSaved = user.TryToAddAchievements( Achievements.Achievement.GetProperAchievements( Achievements.AchievementType.AfterTransferringOnceAmount, moneyWithoutFee.GetTotals())); if (shouldBeSaved) { user.Save(); } //Check the contests Contests.ContestManager.IMadeAnAction(Contests.ContestType.Transfer, user.Name, moneyWithoutFee, 0); PurchasedItem.Create(user.Id, moneyWithoutFee, 1, "Transfer to " + targetBalance, PurchasedItemType.Transfer); //Referral commission for sponsors when user does Cash Balance deposit Titan.CashBalanceCrediter Crediter = (Titan.CashBalanceCrediter)Titan.CrediterFactory.Acquire(user, Titan.CreditType.CashBalanceDeposit); Crediter.TryCreditReferer(moneyWithoutFee); } //AddLog if (!isViaRepresentative) { CompletedPaymentLog.Create(paymentProcessor, "Transfer to " + targetBalance, transId, false, username, moneyWithoutFee, money - moneyWithoutFee, successful, cryptoCurrencyInfo); } }); }
protected void Page_Load(object sender, EventArgs e) { AccessManager.RedirectIfDisabled(AppSettings.TitanFeatures.MoneyPayoutEnabled); User = Member.Current; if (CreditLineManager.UserHasUnpaidLoans(User.Id)) { CashoutButton.Enabled = CashoutButtonConfirm.Enabled = WithdrawCryptocurrencyButton.Enabled = WithdrawCryptocurrencyConfirmButton.Enabled = CommissionCashoutButton.Enabled = false; UnpaidCreditLineInfo.Visible = true; } if (!Page.IsPostBack) { AppSettings.Reload(); #region Langs & Texts WithdrawCryptocurrencyButton.Text = L1.CASHOUT; WithdrawCryptocurrencyConfirmButton.Text = L1.CONFIRM; CashoutButtonConfirm.Text = L1.CONFIRM; SendWithdrawViaRepresentativeButton.Text = U6010.SENDTRANSFERMESSAGE; ProportionsGridView.EmptyDataText = U5004.NOPAYOUTHISTORY; MainBalanceButton.Text = L1.MAINBALANCE; MaxWithdrawalsButton.Text = U5004.MAXIMUMWITHDRAWAL; CommissionButton.Text = U5004.COMMISSIONBALANCE; WithdrawHistoryButton.Text = L1.HISTORY; CashoutButton.Text = CommissionCashoutButton.Text = L1.CASHOUT; MainBalanceLiteral.Text = User.MainBalance.ToString(); CommissionBalanceLiteral.Text = User.CommissionBalance.ToString(); WithdrawHistoryGridView.EmptyDataText = L1.NODATA; LangAdder.Add(RegularExpressionValidator3, L1.ER_BADPIN, true); LangAdder.Add(RegularExpressionValidator1, L1.ER_BADPIN, true); LangAdder.Add(RegularExpressionValidator2, L1.ER_BADPIN, true); LangAdder.Add(WithdrawViaRepresentativeButton, U6010.WITHDRAWVIAREPRESENTATIVE); LangAdder.Add(RequiredFieldValidator2, L1.REG_REQ_PIN, true); LangAdder.Add(RequiredFieldValidator4, L1.REG_REQ_PIN, true); LangAdder.Add(RequiredFieldValidator6, L1.REG_REQ_PIN, true); LangAdder.Add(RequiredFieldValidator1, L1.REQ_PP, true); LangAdder.Add(RequiredFieldValidator3, L1.REQ_PP, true); LangAdder.Add(RequiredFieldValidator7, U2502.INVALIDMONEYFORMAT, true); LangAdder.Add(BtcCodeValidator, U6000.INVALIDSECURITYCODE, true); LangAdder.Add(FiatCodeValidator, U6000.INVALIDSECURITYCODE, true); LangAdder.Add(REValidator, U3500.ILLEGALCHARS); #endregion PINDiv1.Visible = PINDiv2.Visible = BtcPinDiv.Visible = AppSettings.Registration.IsPINEnabled; var BtcCryptocurrency = CryptocurrencyFactory.Get <BitcoinCryptocurrency>(); var XrpCryptocurrency = CryptocurrencyFactory.Get <RippleCryptocurrency>(); var TokenCryptocurrency = CryptocurrencyFactory.Get <ERC20TokenCryptocurrency>(); //Check if user has some manual payouts waiting var UnpaidRequests = User.GetUnpaidPayoutRequests(); WarningPanel.Visible = UnpaidRequests.exists; WarningLiteral.Text = UnpaidRequests.text; //Generate proper Cashout options RadioFrom.Items.AddRange(GenerateHTMLButtons.CashoutFromItems); if (TitanFeatures.IsRofriqueWorkMines && !CryptocurrencyApiFactory.GetDepositApi(BtcCryptocurrency).AllowToUsePaymentButtons()) { RadioFrom.Items.Add(new ListItem("", "BTC")); } CommissionRadioFrom.Items.AddRange(GenerateHTMLButtons.CashoutFromItems); if (RadioFrom.Items.Count < 1) { PayoutPlaceHolder.Visible = false; WarningPanel.Visible = true; WarningLiteral.Text = U5006.PAYOUTUNAVAILABLE; } if (CommissionRadioFrom.Items.Count < 1) { CommissionPayoutPlaceHolder.Visible = false; CommissionWarningPanel.Visible = true; CommissionWarningLiteral.Text = U5006.PAYOUTUNAVAILABLE; } CommissionButton.Visible = AppSettings.Payments.CommissionBalanceWithdrawalEnabled; WithdrawViaRepresentativeButton.Visible = AppSettings.Representatives.RepresentativesHelpWithdrawalEnabled; //Lang CashoutButton.Text = CommissionCashoutButton.Text = L1.CASHOUT; LangAdder.Add(RegularExpressionValidator3, L1.ER_BADPIN, true); LangAdder.Add(RegularExpressionValidator1, L1.ER_BADPIN, true); LangAdder.Add(RegularExpressionValidator2, L1.ER_BADPIN, true); LangAdder.Add(WithdrawViaRepresentativeButton, U6010.WITHDRAWVIAREPRESENTATIVE); LangAdder.Add(RequiredFieldValidator2, L1.REG_REQ_PIN, true); LangAdder.Add(RequiredFieldValidator4, L1.REG_REQ_PIN, true); LangAdder.Add(RequiredFieldValidator6, L1.REG_REQ_PIN, true); LangAdder.Add(RequiredFieldValidator1, L1.REQ_PP, true); LangAdder.Add(RequiredFieldValidator3, L1.REQ_PP, true); LangAdder.Add(RequiredFieldValidator7, U2502.INVALIDMONEYFORMAT, true); LangAdder.Add(BtcCodeValidator, U6000.INVALIDSECURITYCODE, true); LangAdder.Add(FiatCodeValidator, U6000.INVALIDSECURITYCODE, true); //Pre-selected tab if (Request.QueryString["b"] != null) { var button = (Button)MenuButtonPlaceHolder.FindControl(Request.QueryString["b"] + "Button"); MenuButton_Click(button, null); } bool PercentOfInvestmentWIthdrawalEnabled = User.Membership.MaxWithdrawalAllowedPerInvestmentPercent < 1000000000; MaxWithdrawalsButton.Visible = AppSettings.Payments.ProportionalPayoutLimitsEnabled || PercentOfInvestmentWIthdrawalEnabled; if (PercentOfInvestmentWIthdrawalEnabled) { MaxWithdrawalAllowedPerInvestmentPercentPlaceHolder.Visible = true; PaymentProportionsManager ppm = new PaymentProportionsManager(User); Money invested = ppm.TotalPaidIn; Money withdrawn = ppm.TotalPaidOut; Money canwithdraw = Money.MultiplyPercent(invested, User.Membership.MaxWithdrawalAllowedPerInvestmentPercent); TotalPaidInLiteral.Text = invested.ToString(); TotalCashoutLiteral.Text = withdrawn.ToString(); HowmuchMoreCanBeWithdrawnLiteral.Text = String.Format(U6005.YOUCANWITHDRAWOFINVESTED, NumberUtils.FormatPercents(User.Membership.MaxWithdrawalAllowedPerInvestmentPercent), canwithdraw.ToString(), "<b>" + (canwithdraw - withdrawn).ToString() + "</b>"); } //Pre-selected tab if (Request.QueryString["b"] != null) { var button = (Button)MenuButtonPlaceHolder.FindControl(Request.QueryString["b"] + "Button"); MenuButton_Click(button, null); } BTCWithdrawalButton.Visible = BtcCryptocurrency.WithdrawalEnabled; XRPWithdrawalButton.Visible = XrpCryptocurrency.WithdrawalEnabled; ERC20TokenButton.Visible = TokenCryptocurrency.WithdrawalEnabled; BTCWithdrawalButton.Text = "BTC"; ERC20TokenButton.Text = String.Format("{0} ({1})", TokenCryptocurrency.Name, TokenCryptocurrency.Code); XRPWithdrawalButton.Text = "XRP"; if (RadioFrom.Items.Count < 1)//No payment processors, let's move to BTC/XRP/ETH tab on start { MainBalanceButton.Visible = false; if (BtcCryptocurrency.WithdrawalEnabled) { MenuButton_Click(BTCWithdrawalButton, null); } else if (XrpCryptocurrency.WithdrawalEnabled) { MenuButton_Click(XRPWithdrawalButton, null); } else if (TokenCryptocurrency.WithdrawalEnabled) { MenuButton_Click(ERC20TokenButton, null); } else { MainBalanceButton.Visible = true; } if (TitanFeatures.IsClickmyad) { MenuButton_Click(XRPWithdrawalButton, null); } } RadioFrom.SelectedIndex = 0; SetProcessorValues(); } SetDropdownItemsValues(RadioFrom); if (TitanFeatures.IsClickmyad) { BTCWithdrawalButton.Visible = false; } if (TitanFeatures.IsTrafficThunder) { MainBalanceButton.Visible = false; MaxWithdrawalsButton.Visible = false; } }
public static Money GetMaxPossiblePayout(PaymentProcessor processor, Member user, out string errorNote) { PaymentProportionsManager manager = new PaymentProportionsManager(user); decimal maxDailyPayout = user.Membership.MaxDailyCashout.ToDecimal() - user.PaidOutToday.ToDecimal(); if (maxDailyPayout < 0) { maxDailyPayout = 0; } decimal maxGlobalPayout = user.Membership.MaxGlobalCashout.ToDecimal() - user.MoneyCashout.ToDecimal(); decimal maxFromProcessor = 0m; decimal maxSinglePayout = 0m; decimal maxBasedOnAdPacks = 0m; if (AppSettings.Payments.MaximumPayoutPolicy == MaximumPayoutPolicy.Constant) { maxSinglePayout = AppSettings.Payments.MaximumPayoutConstant.ToDecimal(); } else if (AppSettings.Payments.MaximumPayoutPolicy == MaximumPayoutPolicy.Percentage) { maxSinglePayout = Money.MultiplyPercent(user.MainBalance, AppSettings.Payments.MaximumPayoutPercentage).ToDecimal(); } Dictionary <string, decimal> dic = new Dictionary <string, decimal>(); dic.Add(L1.MEMBERSHIP, maxDailyPayout); dic.Add(U6011.PAYMENTS, maxSinglePayout); dic.Add(U5002.YOUCANNOTCASHOUTLIMIT, maxGlobalPayout); if (AppSettings.Payments.ProportionalPayoutLimitsEnabled && processor != PaymentProcessor.CustomPayoutProcessor) { maxFromProcessor = manager.GetMaximum(processor).ToDecimal(); dic.Add(string.Format(U6011.PROPORTIONALLIMITSPROCESSOR), maxFromProcessor); } if (AppSettings.Payments.AdPackTypeWithdrawLimitEnabled) { maxBasedOnAdPacks = (AdPackTypeManager.GetWithdrawalLimit(user.Id) - user.MoneyCashout).ToDecimal(); if (maxBasedOnAdPacks < 0m) { maxBasedOnAdPacks = 0m; } dic.Add(AppSettings.RevShare.AdPack.AdPackNamePlural, maxBasedOnAdPacks); } //Maximum withdrawal of deposited amount % if (user.Membership.MaxWithdrawalAllowedPerInvestmentPercent < 1000000000) { PaymentProportionsManager ppm = new PaymentProportionsManager(user); Money invested = ppm.TotalPaidIn; Money withdrawn = ppm.TotalPaidOut; Money canwithdraw = Money.MultiplyPercent(invested, user.Membership.MaxWithdrawalAllowedPerInvestmentPercent); dic.Add(U6011.MEMBERSHIPMAXWITDRAWAL, (canwithdraw - withdrawn).ToDecimal()); } var min = dic.OrderBy(x => x.Value).First(); var money = new Money(min.Value); errorNote = string.Format(U6011.PAYOUTREQUESTTOOHIGH, money.ToString(), min.Key); if (money > user.MainBalance) { errorNote = string.Format(U6012.PAYOUTREQUESTBALANCEERROR, user.MainBalance.ToString()); money = user.MainBalance; } return(money > Money.Zero ? money : Money.Zero); }
private string TryMakeManualPayout(Money fee) { //Manual, add to payoutrequests PayoutRequest req = new PayoutRequest(); //Calculate fees for CustomPP Money Fees = fee; if (IsCustomPayoutProcessor) { CustomPayoutProcessor CPP = new CustomPayoutProcessor(CustomPayoutProcessorId); Fees = Fees + CPP.MoneyFee; Fees = Fees + (AmountToPayout * (CPP.PercentageFee * new Money(0.01))); if (string.IsNullOrWhiteSpace(TargetAccount)) { throw new MsgException(U4200.ACCOUNTFIELDNOTBLANK); } } req.Amount = AmountToPayout - Fees; req.IsPaid = false; req.RequestDate = DateTime.Now; req.Username = User.Name; req.IsRequest = true; req.BalanceType = BalanceType.MainBalance; if (IsCustomPayoutProcessor) { //CustomPP CustomPayoutProcessor CPP = new CustomPayoutProcessor(CustomPayoutProcessorId); req.PaymentAddress = TargetAccount; req.PaymentProcessor = CPP.Name; //MPesa check if (CPP.Name.ToLower() == "mpesa" && (TargetAccount.Length != 10 || !TargetAccount.StartsWith("07"))) { throw new MsgException("Check your phone number format. The number should be 07******** (10 length)"); } } else { string paymentAddress = PaymentAccountDetails.GetPaymentProcessorUserAccount(User, TargetPaymentProcessor); if (String.IsNullOrEmpty(paymentAddress)) { throw new MsgException(U5004.YOUMUST); } if (TargetPaymentProcessor == "Payeer" && paymentAddress.Contains("@")) { throw new MsgException(U6006.VALIDPAYEER); } req.PaymentAddress = paymentAddress; req.PaymentProcessor = TargetPaymentProcessor; } req.Save(); User.SubtractFromMainBalance(AmountToPayout, "Payout"); User.MoneyCashout += (AmountToPayout - Fees); User.IsPhoneVerifiedBeforeCashout = false; User.CashoutsProceed++; User.Save(); //Update payout proportions if (!IsCustomPayoutProcessor) { PaymentProportionsManager.MemberPaidOut(AmountToPayout - Fees, PaymentAccountDetails.GetFromStringType(TargetPaymentProcessor), User, IsCustomPayoutProcessor); } if (IsAutomaticButAvoveTheLimit) { return(U3501.CASHOUTSUCC + ": " + U3500.CASHOUT_APPROVE.Replace("%n%", TheLimit.ToString())); } else { return(U3501.CASHOUTSUCC + ": " + U3500.CASHOUT_MESSAGE.Replace("%n1%", (AmountToPayout - Fees).ToString()).Replace("%n2%", Fees.ToString())); } }
private string TryMakeInstantPayout(Money fee) { // payoutRequest --> change property to false (it isn't request) PayoutRequest req = new PayoutRequest(); req.Amount = AmountToPayout - fee; req.IsPaid = true; req.RequestDate = DateTime.Now; req.Username = User.Name; req.IsRequest = false; req.BalanceType = BalanceType.MainBalance; //Check if daily limit is not reached if (AppSettings.Payments.GlobalCashoutsToday + AmountToPayout - fee > AppSettings.Payments.GlobalCashoutLimitPerDay) { throw new MsgException(L1.TOOMANYCASHOUTS + " " + AppSettings.Payments.GlobalCashoutLimitPerDay.ToString()); } //User payment address string paymentAddress = PaymentAccountDetails.GetPaymentProcessorUserAccount(User, TargetPaymentProcessor); if (String.IsNullOrEmpty(paymentAddress)) { throw new MsgException(U5004.YOUMUST); } request = new TransactionRequest(User.Name, paymentAddress, AmountToPayout - fee); Transaction transaction = TransactionFactory.CreateTransaction(request, TargetPaymentProcessor); response = transaction.Commit(); req.PaymentAddress = paymentAddress; req.PaymentProcessor = TargetPaymentProcessor; if (!response.IsSuccess) { if (request != null && response != null) { PayoutManager.logPayout("Payout unsuccessful", request, response, req.PaymentProcessor); } throw new MsgException(response.Note); } req.Save(); History.AddCashout(User.Name, AmountToPayout); User.SubtractFromMainBalance(AmountToPayout, "Payout"); User.MoneyCashout += AmountToPayout - fee; User.IsPhoneVerifiedBeforeCashout = false; User.CashoutsProceed++; User.Save(); //Update payout proportions PaymentProportionsManager.MemberPaidOut(AmountToPayout - fee, PaymentAccountDetails.GetFromStringType(TargetPaymentProcessor), User, IsCustomPayoutProcessor); //Add to daily cashout AppSettings.Payments.GlobalCashoutsToday += AmountToPayout - fee; AppSettings.Payments.Save(); //Add outcome to stats (Data2); var stats = new Statistics(StatisticsType.Cashflow); stats.AddToData2(AmountToPayout); stats.Save(); //Add paymentproof PaymentProof.Add(User.Id, AmountToPayout, PaymentType.Instant, PaymentAccountDetails.GetFromStringType(TargetPaymentProcessor)); // Log because payment may have response status SuccessWithWarning // More on this: https://developer.paypal.com/webapps/developer/docs/classic/api/NVPAPIOverview/ logPayout("Payout successful", request, response, req.PaymentProcessor); return(U3501.AUTOMATICCASHOUTSUCC + ": " + response.Note); }