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);
    }
Example #2
0
    /// <summary>
    /// FROM AP
    /// </summary>
    public static void MarkAsPaid(PayoutRequest request)
    {
        request.IsPaid = true;
        request.Save();

        //Add payment proof
        Member User = new Member(request.Username);

        PaymentProof.Add(User, request);

        //Add history
        History.AddCashout(request.Username, request.Amount);
    }
Example #3
0
    public string TryMakePayout()
    {
        ValidatePayout();

        string paymentAddress = PaymentAccountDetails.GetPaymentProcessorUserAccount(user, paymentProcessor);

        var         request     = new TransactionRequest(user.Name, paymentAddress, amountToPayout);
        Transaction transaction = TransactionFactory.CreateTransaction(request, paymentProcessor);
        var         response    = transaction.Commit();

        if (!response.IsSuccess)
        {
            if (request != null && response != null)
            {
                PayoutManager.logPayout("Commission Balance Payout unsuccessful", request, response, paymentProcessor);
            }
            throw new MsgException(response.Note);
        }

        PayoutRequest req = new PayoutRequest();

        req.Amount           = amountToPayout;
        req.IsPaid           = true;
        req.RequestDate      = DateTime.Now;
        req.Username         = user.Name;
        req.IsRequest        = false;
        req.BalanceType      = BalanceType.CommissionBalance;
        req.PaymentAddress   = paymentAddress;
        req.PaymentProcessor = paymentProcessor;
        req.Save();

        user.SubtractFromCommissionBalance(amountToPayout, "Payout");
        user.SaveBalances();

        History.AddCashout(user.Name, amountToPayout);
        PayoutManager.logPayout("Commission Balance Payout successful", request, response, paymentProcessor);
        PaymentProof.Add(user, req);

        return(U3501.AUTOMATICCASHOUTSUCC + ": " + response.Note);
    }
Example #4
0
    /// <summary>
    /// FROM AP
    /// </summary>
    /// <param name="request"></param>
    /// <param name="gateway"></param>
    /// <param name="transaction"></param>
    /// <returns></returns>
    public static bool MakePayout(PayoutRequest request, PaymentAccountDetails gateway, ref Transaction transaction)
    {
        transaction.Commit();
        if (transaction.Response.IsSuccess)
        {
            request.IsPaid    = true;
            request.IsRequest = false;
            request.Save();

            Member User = new Member(request.Username);

            //Add payment proof
            PaymentProof.Add(User, request);

            //Add statistics
            var stats = new Statistics(StatisticsType.Cashflow);
            stats.AddToData2(request.Amount);
            stats.Save();

            //Add history
            History.AddCashout(request.Username, request.Amount);


            if (gateway is PayPalAccountDetails)
            {
                // 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, transaction.Response, request.PaymentProcessor);
            }

            return(true);
        }
        else
        {
            logPayout("Payout unsuccessful", request, transaction.Response, request.PaymentProcessor);
            return(false);
        }
    }
Example #5
0
    protected void PayoutProofsGridView_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            PaymentProof proof = new PaymentProof(Convert.ToInt32(e.Row.Cells[0].Text));
            //Country
            int    userId = Convert.ToInt32(e.Row.Cells[2].Text);
            Member User   = new Member(userId);
            e.Row.Cells[2].Text = "<img src=\"Images/Flags/" + User.CountryCode.ToLower() + ".png\" class=\"imagemiddle\" /> " + User.Country;

            //Type
            PaymentType type = (PaymentType)Convert.ToInt32(e.Row.Cells[3].Text);
            if (type == PaymentType.Instant)
            {
                e.Row.Cells[3].Text = L1.INSTANT;
            }
            else if (type == PaymentType.Manual)
            {
                e.Row.Cells[3].Text = L1.MANUAL;
            }

            //Money
            e.Row.Cells[4].Text = Money.AddCurrencySign(e.Row.Cells[4].Text);

            //Via
            PaymentProcessor proc = (PaymentProcessor)Convert.ToInt32(e.Row.Cells[5].Text);

            if (proc == PaymentProcessor.CustomPayoutProcessor)
            {
                e.Row.Cells[5].Text = proof.ProcessorName;
            }
            else
            {
                e.Row.Cells[5].Text = proc.ToString();
            }
        }
    }
Example #6
0
        public void AddPaymentProof(Money amountInMoney, Member user)
        {
            var paymentType = IsAutomaticWithdrawal(user, amountInMoney) ? PaymentType.Instant : PaymentType.Manual;

            PaymentProof.Add(user.Id, amountInMoney, paymentType, CryptocurrencyTypeHelper.ConvertToPaymentProcessor(Type));
        }
Example #7
0
    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);
    }
Example #8
0
    public bool TryMakeInvestmentLevelsPayout()
    {
        // payoutRequest --> change property to false (it isn't request)
        var req = new PayoutRequest
        {
            Amount      = AmountToPayout,
            IsPaid      = true,
            RequestDate = DateTime.Now,
            Username    = User.Name,
            IsRequest   = false,
            BalanceType = BalanceType.InvestmentLevels
        };

        //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);
        Transaction transaction = TransactionFactory.CreateTransaction(request, TargetPaymentProcessor);

        response = transaction.Commit();

        req.PaymentAddress   = paymentAddress;
        req.PaymentProcessor = TargetPaymentProcessor;

        if (!response.IsSuccess)
        {
            if (request != null && response != null)
            {
                logPayout("Payout unsuccessful", request, response, req.PaymentProcessor);
            }
            return(false);
        }
        req.Save();

        History.AddInvestmentLevelCashout(User.Name, AmountToPayout);

        //Add to daily cashout
        AppSettings.Payments.GlobalCashoutsToday += AmountToPayout;
        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);

        ErrorLogger.Log(string.Format("{0}: {1}", U3501.AUTOMATICCASHOUTSUCC, response.Note));
        return(true);
    }