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
        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 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();
    }
Example #4
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()));
        }
    }
Example #5
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);
    }