Esempio n. 1
0
        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);
        }
Esempio n. 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);
        }
Esempio n. 3
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. 4
0
        public Money GetMaximumWithdrawalAmount(Member user, WithdrawalSourceBalance withdrawalSource, out string errorMessage)
        {
            errorMessage = U6012.PAYOUTREQUESTTOOHIGH;

            if (withdrawalSource == WithdrawalSourceBalance.MainBalance)
            {
                return(PayoutManager.GetMaxPossiblePayout(CryptocurrencyTypeHelper.ConvertToPaymentProcessor(this.CryptocurrencyType), user, out errorMessage));
            }
            else //Wallet
            {
                return(user.GetCryptocurrencyBalance(this.Type)); //No limit
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Use if you already have a Member object
        /// </summary>
        /// <param name="user"></param>
        /// <param name="amountInCryptocurrency"></param>
        /// <param name="transactionHash"></param>
        /// <param name="cryptoCurrencyInfo"></param>
        /// <param name="confirmations"></param>
        public void TryDepositCryptocurrency(Member user, decimal amountInCryptocurrency, string transactionHash,
                                             string cryptoCurrencyInfo, int confirmations = 100)
        {
            //Get transaction
            var transaction = CompletedPaymentLog.GetTransactionIfExistsCreateOtherwise(CryptocurrencyTypeHelper.ConvertToPaymentProcessor(Type),
                                                                                        transactionHash, "Deposit " + Code, user.Name, ConvertToMoney(amountInCryptocurrency), Money.Zero, cryptoCurrencyInfo);

            if (transaction.Successful)
            {
                throw new MsgException("This transaction has already been proceed.");
            }

            ValidateDeposit(amountInCryptocurrency, confirmations);
            DepositCryptocurrency(user, amountInCryptocurrency);

            transaction.Successful = true;
            transaction.Save();
        }
Esempio n. 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));
        }