Exemple #1
0
    public static Money GetProperLimitValue(Member User, CustomPayoutProcessor PP)
    {
        if (PP.OverrideGlobalLimit)
        {
            return(PP.CashoutLimit);
        }

        return(GetGlobalLimitValue(User));
    }
Exemple #2
0
    protected void CashoutButtonConfirm_Click(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
            SuccMessagePanel.Visible     = false;
            ErrorMessagePanel.Visible    = false;
            CashoutButtonConfirm.Visible = false;

            try
            {
                //Parse amount
                Money Transferred;
                try
                {
                    Transferred = Money.Parse(AmountToCashoutTextBox.Text).FromMulticurrency();
                    Transferred = Money.Parse(Transferred.ToShortClearString());
                }
                catch (Exception ex)
                {
                    throw new MsgException(U2502.INVALIDMONEYFORMAT);
                }

                if (!AppSettings.Payments.WithdrawalEmailEnabled && AppSettings.Proxy.SMSType == ProxySMSType.EveryCashout)
                {
                    User.IsPhoneVerifiedBeforeCashout = true;
                    User.UnconfirmedSMSSent--;
                    User.Save();
                }

                //Lets process to cashout
                PayoutManager Manager = new PayoutManager(User, Transferred, RadioFrom.SelectedValue,
                                                          CustomPayoutProcessor.IsCustomPayoutProcessor(RadioFrom.SelectedValue), CustomPayoutProcessor.GetCustomPayoutProcessorId(RadioFrom.SelectedValue), Account.Text);

                SuccMessage.Text         = Manager.TryMakePayout();
                SuccMessagePanel.Visible = true;
            }
            catch (Exception ex)
            {
                ErrorMessagePanel.Visible = true;
                ErrorMessage.Text         = ex.Message;
            }
            finally
            {
                Account.Enabled = true;
                PIN.Enabled     = true;
                AmountToCashoutTextBox.Enabled       = true;
                CashoutButton.Visible                = true;
                ConfirmationCodePlaceHolder2.Visible = false;
                CashoutButtonConfirm.Visible         = false;
            }
        }
    }
Exemple #3
0
    private void LoadCustomProcessorsControls()
    {
        var customPayoutProcessorsList = CustomPayoutProcessor.GetAllActiveProcessors();

        foreach (var customPayoutProcessor in customPayoutProcessorsList)
        {
            var objControl    = (UserControl)Page.LoadControl("~/Controls/Payment/ProcessorSettings.ascx");
            var parsedControl = objControl as IProcessorSettingsObjectControl;

            parsedControl.Processor = customPayoutProcessor;
            parsedControl.UserId    = User.Id;
            parsedControl.DataBind();

            CustomPayoutProcessorsPlaceHolder.Controls.Add(objControl);
        }
    }
Exemple #4
0
    public static void CheckMaxPayout(PaymentProcessor processor, Member user, Money amountToPayout, int CustomPayoutProcessorId = -1)
    {
        var   errorNote = "";
        Money maxPayout = GetMaxPossiblePayout(processor, user, out errorNote);

        if (processor == PaymentProcessor.CustomPayoutProcessor && CustomPayoutProcessorId != -1)
        {
            var CustomProcessor = new CustomPayoutProcessor(CustomPayoutProcessorId);
            CustomProcessor.CheckMaxValueOfPendingRequestsPerDay(amountToPayout);
        }

        if (amountToPayout > maxPayout)
        {
            throw new MsgException(errorNote);
        }
    }
        protected override ApiResultMessage HandleRequest(object args)
        {
            string  token          = ((JObject)args)["token"].ToString();
            int     pin            = Convert.ToInt32(((JObject)args)["pin"]);
            decimal amount         = Convert.ToDecimal(((JObject)args)["amount"]);
            string  processorValue = ((JObject)args)["processor"].ToString();

            int    userId = ApiAccessToken.ValidateAndGetUserId(token);
            Member User   = new Member(userId);

            User.ValidatePIN(pin.ToString());

            Money Amount = new Money(amount);

            Amount = Money.Parse(Amount.ToShortClearString());

            var userAccountAddress = String.Empty;

            try
            {
                var CustomProcessor = new CustomPayoutProcessor(int.Parse(processorValue));
                userAccountAddress = User.GetPaymentAddress(CustomProcessor.Id);
            }
            catch (Exception)
            {
                var selectedProcessor            = processorValue;
                PaymentProcessor targetprocessor = PaymentAccountDetails.GetFromStringType(selectedProcessor);
                userAccountAddress = User.GetPaymentAddress(targetprocessor);
            }

            //Lets process to cashout
            PayoutManager Manager = new PayoutManager(User, Amount, processorValue,
                                                      CustomPayoutProcessor.IsCustomPayoutProcessor(processorValue), CustomPayoutProcessor.GetCustomPayoutProcessorId(processorValue), userAccountAddress);

            string successMessage = Manager.TryMakePayout();

            return(new ApiResultMessage
            {
                success = true,
                message = successMessage,
                data = null
            });
        }
Exemple #6
0
    protected void SetProcessorValues()
    {
        Account.Enabled             = true;
        ChangeAccountButton.Visible = false;
        AddNewAccount.Visible       = false;
        var   userAccountAddress = "";
        Money GlobalLimit        = PayoutLimit.GetGlobalLimitValue(User);
        var   errorNote          = "";

        try
        {
            //Custom Processor
            var CustomProcessor = new CustomPayoutProcessor(int.Parse(RadioFrom.SelectedValue));
            userAccountAddress = User.GetPaymentAddress(CustomProcessor.Id);
            Account.Text       = userAccountAddress;

            //Limits
            string limit     = (CustomProcessor.OverrideGlobalLimit ? CustomProcessor.CashoutLimit : GlobalLimit).ToShortString();
            Money  maxPayout = PayoutManager.GetMaxPossiblePayout(PaymentProcessor.CustomPayoutProcessor, User, out errorNote);

            if (maxPayout > User.MainBalance)
            {
                maxPayout = User.MainBalance;
            }

            MinLimitLabel.Text = limit;
            MaxLimitLabel.Text = maxPayout.ToShortString();
            InfoLabel.Text     = CustomProcessor.Description;
            FeesLabel.Text     = CustomProcessor.FeesToString();
        }
        catch (Exception)
        {
            //Automatic processor
            var selectedProcessor = RadioFrom.SelectedValue;

            if (!String.IsNullOrEmpty(selectedProcessor))
            {
                PaymentProcessor targetprocessor = PaymentAccountDetails.GetFromStringType(selectedProcessor);
                userAccountAddress = User.GetPaymentAddress(targetprocessor);
                var gateway = PaymentAccountDetails.GetFirstGateway(selectedProcessor);

                //Limits
                string limit     = (gateway.OverrideGlobalLimit ? gateway.CashoutLimit : GlobalLimit).ToShortString();
                Money  maxPayout = PayoutManager.GetMaxPossiblePayout(PaymentAccountDetails.GetFromStringType(gateway.AccountType), User, out errorNote);

                if (maxPayout > User.MainBalance)
                {
                    maxPayout = User.MainBalance;
                }

                MinLimitLabel.Text = limit;
                MaxLimitLabel.Text = maxPayout.ToShortString();
                FeesLabel.Text     = NumberUtils.FormatPercents(gateway.WithdrawalFeePercent.ToString());
            }
        }

        if (!string.IsNullOrWhiteSpace(userAccountAddress))
        {
            Account.Visible             = true;
            Account.Enabled             = false;
            Account.Text                = userAccountAddress;
            ChangeAccountButton.Text    = U6007.CHANGE;
            ChangeAccountButton.Visible = true;
        }
        else
        {
            Account.Visible       = false;
            AddNewAccount.Text    = L1.ADDNEW;
            AddNewAccount.Visible = true;
        }
    }
Exemple #7
0
    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()));
        }
    }
Exemple #8
0
    public string TryMakePayout()
    {
        Money withdrawalFee = Money.Zero;

        if (!IsCustomPayoutProcessor)
        {
            var processor = PaymentAccountDetails.GetFirstGateway(TargetPaymentProcessor);
            withdrawalFee = Money.MultiplyPercent(AmountToPayout, processor.WithdrawalFeePercent);

            var address = UsersPaymentProcessorsAddress.GetAddress(User.Id, new PaymentProcessorInfo((PaymentProcessor)Enum.Parse(typeof(PaymentProcessor), processor.AccountType)));
            if (address != null)
            {
                if (TargetAccount != address.PaymentAddress)
                {
                    throw new MsgException("Don't try to use account ID which is different from your current one. To change account ID go to user settings panel.");
                }

                if (address.LastChanged.AddDays(processor.DaysToBlockWithdrawalsAfterAccountChangename) > AppSettings.ServerTime)
                {
                    throw new MsgException(string.Format(U6007.CANTWITHDRAWDAYSLIMIT, (address.LastChanged.AddDays(processor.DaysToBlockWithdrawalsAfterAccountChangename).DayOfYear - AppSettings.ServerTime.DayOfYear)));
                }
            }
            else
            {
                User.SetPaymentAddress(processor.Id, TargetAccount);
            }
        }
        else
        {
            var blockingDays = new CustomPayoutProcessor(CustomPayoutProcessorId).DaysToBlockWithdrawalsAfterAccounChange;
            var address      = UsersPaymentProcessorsAddress.GetAddress(User.Id, new PaymentProcessorInfo(CustomPayoutProcessorId));
            if (address != null)
            {
                if (TargetAccount != address.PaymentAddress)
                {
                    throw new MsgException("Don't try to use account ID which is different from your current one. To change account ID go to user settings panel.");
                }

                if (address.LastChanged.AddDays(blockingDays) > AppSettings.ServerTime)
                {
                    throw new MsgException(string.Format(U6007.CANTWITHDRAWDAYSLIMIT, (address.LastChanged.AddDays(blockingDays).DayOfYear - AppSettings.ServerTime.DayOfYear)));
                }
            }
            else
            {
                User.SetPaymentAddress(CustomPayoutProcessorId, TargetAccount);
            }
        }

        ValidatePayout(User, AmountToPayout);

        //Check the gateway limit (global limit, pp custom limit)
        CheckBaseLimits();

        //CLP ---> extension for private client CLP
        User = Titan.CLP.CLPManager.CheckCashoutBonus(User, AmountToPayout);

        if (IsManualPayout()) //Decide if we go with automatic or manual
        {
            return(TryMakeManualPayout(withdrawalFee));
        }
        else
        {
            return(TryMakeInstantPayout(withdrawalFee));
        }

        return("");
    }