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);
    }
Esempio n. 2
0
        private void ValidateWithdrawal(Member user, string userAddress, decimal amount, WithdrawalSourceBalance withdrawalSource)
        {
            if (!WithdrawalEnabled)
            {
                throw new MsgException("Withdrawal is currently disabled by the administrator");
            }

            if (CryptocurrencyApi.IsAdministratorAddress(userAddress, WithdrawalApiProcessor))
            {
                throw new MsgException("You can't withdraw to administrator-generated address.");
            }

            Money  amountInCorrectType = Money.Zero;
            string errorMessage        = String.Empty;

            //General validation
            PayoutManager.ValidatePayoutNotConnectedToAmount(user);

            //Amounts & Balances
            if (withdrawalSource == WithdrawalSourceBalance.MainBalance)
            {
                amountInCorrectType = new Money(amount);

                //Check the balance
                if (amountInCorrectType > user.MainBalance)
                {
                    throw new MsgException(L1.NOTENOUGHFUNDS);
                }

                PayoutManager.ValidatePayout(user, amountInCorrectType);
                PayoutManager.CheckMaxPayout(CryptocurrencyTypeHelper.ConvertToPaymentProcessor(CryptocurrencyType), user, amountInCorrectType);
            }
            else //Wallets
            {
                amountInCorrectType = new CryptocurrencyMoney(this.Type, amount);

                //Check the balance
                if (amountInCorrectType > user.GetCryptocurrencyBalance(CryptocurrencyType))
                {
                    throw new MsgException(string.Format(U6012.NOFUNDSINWALLET, CryptocurrencyType.ToString()));
                }
            }

            //Check MIN withdrawal
            if (amountInCorrectType < GetMinimumWithdrawalAmount(user, withdrawalSource))
            {
                throw new MsgException(U5003.WITHDRAWALMUSTBEHIGHER);
            }

            //Check MAX withdrawals
            if (amountInCorrectType > GetMaximumWithdrawalAmount(user, withdrawalSource, out errorMessage))
            {
                throw new MsgException(errorMessage);
            }
        }
Esempio n. 3
0
    protected void SendWithdrawViaRepresentativeButtonConfirm_Click(object sender, EventArgs e)
    {
        RepresentativeErrorMessagePanel.Visible = false;
        try
        {
            string amount = Request.Form["price"].ToString();

            Money  Amount = Money.Parse(amount).FromMulticurrency();
            Member User   = Member.Current;

            //Anti-Injection Fix
            if (Amount <= new Money(0))
            {
                throw new MsgException(L1.ERROR);
            }

            if (string.IsNullOrEmpty(RepresentativeMessage.Text))
            {
                throw new MsgException(L1.REQ_TEXT);
            }

            //Lets validate
            PayoutManager.ValidatePayout(User, Amount);
            PayoutManager.CheckMaxPayout(PaymentProcessor.ViaRepresentative, User, Amount);

            string Message = InputChecker.HtmlEncode(RepresentativeMessage.Text, RepresentativeMessage.MaxLength, U5004.MESSAGE);

            var SelectedRepresentative = new Representative(Convert.ToInt32(AvaibleRepresentativeList.SelectedValue));

            if (ConversationMessage.CheckIfThisUserHavePendingActions(User.Id))
            {
                throw new MsgException(U6010.YOUHAVEPENDINGACTION);
            }

            //All OK, let's proceed
            RepresentativesTransferManager representativesTransferManager = new RepresentativesTransferManager(Member.CurrentId, SelectedRepresentative.UserId);
            representativesTransferManager.InvokeWithdrawal(Amount, Message);

            Response.Redirect("~/user/network/messenger.aspx");
        }
        catch (MsgException ex)
        {
            RepresentativeErrorMessagePanel.Visible = true;
            RepresentativeErrorMessage.Text         = ex.Message;
        }
        catch (Exception ex)
        {
            ErrorLogger.Log(ex);
            RepresentativeErrorMessagePanel.Visible = true;
            RepresentativeErrorMessage.Text         = ex.Message;
        }
    }