Exemplo n.º 1
0
        protected void BuyJackpotTickets(Member user, Money amount, int tickets, Jackpot jackpot, string from, string transId, string cryptoCurrencyInfo)
        {
            bool successful = false;

            try
            {
                if (amount < (jackpot.TicketPrice * tickets))
                {
                    throw new MsgException("Not enough money sent!");
                }

                JackpotManager.GiveTickets(jackpot, user, tickets);

                successful = true;
            }
            catch (Exception ex)
            {
                successful = false;
                ErrorLogger.Log(ex);
            }

            PaymentProcessor PP = PaymentAccountDetails.GetFromStringType(from);

            CompletedPaymentLog.Create(PP, "Jackpot Tickets", transId, false, user.Name, amount, Money.Zero, successful, cryptoCurrencyInfo);
        }
Exemplo n.º 2
0
        private void buyAdvert(string advertTypeName, int advertId, Money money, string from, string transId, string cryptoCurrencyInfo)
        {
            var advert = (Advert)Activator.CreateInstance(Type.GetType(advertTypeName), new object[] { advertId });

            //Prevent fraud transactions (GET price modifications)c
            //NOTE: {X}.XXX cost = {X}.XX received (1.051 = 1.05, 1.059 = 1.05)
            //That is why we add 0.009

            bool successful = false;

            if ((money + new Money(0.009)) >= advert.Price)
            {
                successful    = true;
                advert.Status = AdvertStatus.WaitingForAcceptance;
                advert.SaveStatus();
            }

            //Earnings stats
            if (advert is BannerAdvert)
            {
                BannerAdvert thisAdvert = (BannerAdvert)advert;
                EarningsStatsManager.Add(EarningsStatsType.Banner, money);
                PoolDistributionManager.AddProfit(ProfitSource.Banners, money);
            }

            //AddLog
            PaymentProcessor PP = PaymentAccountDetails.GetFromStringType(from);

            CompletedPaymentLog.Create(PP, "Purchase Advertisement pack", transId, advert.Advertiser.CreatedBy == Advertiser.Creator.Stranger, advert.Advertiser.MemberUsername, money, Money.Zero, successful, cryptoCurrencyInfo);
        }
Exemplo n.º 3
0
    public static CompletedPaymentLog Create(PaymentProcessor PP, string PaidFor, string TransactionId, bool IsGuest, string Username,
                                             Money Amount, Money fees, bool successful, string cryptoCurrencyInfo = "")
    {
        CompletedPaymentLog ol = new CompletedPaymentLog();

        ol.When             = DateTime.Now;
        ol.PaymentProcessor = PP;

        if (IsGuest)
        {
            ol.UserId   = -1;
            ol.Username = "******";
        }
        else
        {
            ol.UserId   = new Member(Username).Id;
            ol.Username = Username;
        }

        ol.IsGuest            = IsGuest;
        ol.PaidFor            = PaidFor;
        ol.TransactionId      = TransactionId;
        ol.Amount             = Amount;
        ol.Fees               = fees;
        ol.Successful         = successful;
        ol.CryptoCurrencyInfo = cryptoCurrencyInfo;
        ol.Save();

        return(ol);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        this.Visible = false;
        var BtcCryptocurrency = CryptocurrencyFactory.Get(CryptocurrencyType.BTC);

        if (Member.IsLogged && BtcCryptocurrency.DepositEnabled)
        {
            var pendingBtcDeposit = CompletedPaymentLog.GetPendingBTCDeposits(Member.CurrentId);

            if (pendingBtcDeposit != null)
            {
                this.Visible        = true;
                MessageLiteral.Text =
                    String.Format(U6011.AWAITINGBTCCONFIRMATION, "<b>" + BtcCryptocurrency.DepositMinimumConfirmations + "</b> ",
                                  "<b>" + pendingBtcDeposit.TransactionId + "</b>");
            }
        }
    }
Exemplo 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();
        }
Exemplo n.º 6
0
        protected void BuyInvestmentPlatformPlan(Member user, Money amount, InvestmentPlatformPlan plan, string from, string transId, string cryptoCurrencyInfo)
        {
            bool successful = false;

            try
            {
                if (plan.MaxPrice > Money.Zero)
                {
                    if (!plan.CheckPlanPrice(amount))
                    {
                        throw new MsgException("Not enough money sent!");
                    }

                    InvestmentPlatformManager.BuyOrUpgradePlan(user, PurchaseBalances.PaymentProcessor, plan, amount);
                    successful = true;
                }
                else
                {
                    var price = plan.Price;

                    if (AppSettings.InvestmentPlatform.LevelsEnabled)
                    {
                        price += plan.LevelFee;
                    }

                    if (amount < price)
                    {
                        throw new MsgException("Not enough money sent!");
                    }

                    InvestmentPlatformManager.BuyOrUpgradePlan(user, PurchaseBalances.PaymentProcessor, plan);
                    successful = true;
                }
            }
            catch (Exception ex)
            {
                successful = false;
                ErrorLogger.Log(ex);
            }

            PaymentProcessor PP = PaymentAccountDetails.GetFromStringType(from);

            CompletedPaymentLog.Create(PP, "Investment Plan", transId, false, user.Name, amount, Money.Zero, successful, cryptoCurrencyInfo);
        }
Exemplo n.º 7
0
        protected void UpgradeMembership(Member user, Money amount, MembershipPack pack, string from, string transId, string cryptoCurrencyInfo)
        {
            bool successful = false;

            try
            {
                Membership.AddPack(user, pack, amount);
                successful = true;
            }
            catch (Exception ex)
            {
                successful = false;
                ErrorLogger.Log(ex);
            }

            PaymentProcessor PP = PaymentAccountDetails.GetFromStringType(from);

            CompletedPaymentLog.Create(PP, "Upgrade", transId, false, user.Name, amount, Money.Zero, successful, cryptoCurrencyInfo);
        }
Exemplo n.º 8
0
        protected void BuyMarketplaceProduct(string username, Money amount, string from, string transId,
                                             int productId, int quantity, string deliveryAddress, string email, int?promotorId, string cryptoCurrencyInfo)
        {
            MarketplaceProduct product = new MarketplaceProduct(productId);

            bool successful = false;

            try
            {
                product.BuyViaProcessor(username, quantity, email, deliveryAddress, amount, promotorId);
                successful = true;
            }
            catch
            {
                successful = false;
            }

            PaymentProcessor PP = PaymentAccountDetails.GetFromStringType(from);

            CompletedPaymentLog.Create(PP, "Marketplace Purchase", transId, false, username, amount, Money.Zero, successful, cryptoCurrencyInfo);
        }
Exemplo n.º 9
0
    public static void TryMarkAccountActivationFeeAsPaid(Member user, Money amount, string from, string transId, string cryptoCurrencyInfo)
    {
        bool Successful = false;

        try
        {
            String Message = String.Format(" {0} money for account activation. ", amount);

            if (amount < AppSettings.Registration.AccountActivationFee)
            {
                Message += "Amount is lower than expected! Account not activated.";
                History.AddEntry(Member.CurrentName, HistoryType.Transfer, Message);

                PoolDistributionManager.AddProfit(ProfitSource.AccountActivationFee, amount);
                throw new Exception(String.Format("Account activation fee is lower than expected! ({0})", amount));
            }

            AccountActivationFeeCrediter Crediter = (AccountActivationFeeCrediter)CrediterFactory.Acquire(user, CreditType.AccountActivationFee);
            var moneyLeftForPools = Crediter.CreditReferer(amount);

            //Pools
            PoolDistributionManager.AddProfit(ProfitSource.AccountActivationFee, moneyLeftForPools);

            user.IsAccountActivationFeePaid = true;
            user.Save();

            Message += "Account activated.";
            History.AddEntry(Member.CurrentName, HistoryType.Transfer, Message);

            Successful = true;
        }
        catch (Exception ex)
        {
            ErrorLogger.Log(ex);
        }

        PaymentProcessor PP = PaymentAccountDetails.GetFromStringType(from);

        CompletedPaymentLog.Create(PP, "Activation Fee", transId, false, user.Name, amount, Money.Zero, Successful, cryptoCurrencyInfo);
    }
Exemplo n.º 10
0
        public static void TransferToBalance(string username, Money money, string from, string transId, string targetBalance,
                                             bool isViaRepresentative = false, string cryptoCurrencyInfo = "")
        {
            Exceptions.HandleNonMsgEx(() =>
            {
                //Add income to stats
                if (!isViaRepresentative)
                {
                    Statistics.Statistics.AddToCashflow(money);
                }

                bool successful = (money >= AppSettings.Payments.MinimumTransferAmount);

                PaymentProcessor paymentProcessor = PaymentAccountDetails.GetFromStringType(from);
                Money moneyWithoutFee             = money;

                if (!isViaRepresentative &&
                    (targetBalance == "Purchase Balance" || targetBalance == "Cash Balance" || targetBalance == "Marketplace Balance"))
                {
                    moneyWithoutFee = PaymentAccountDetails.GetAmountWithoutFee(from, money);
                }

                if (successful)
                {
                    Member user = new Member(username);
                    if (targetBalance == "Purchase Balance")
                    {
                        user.AddToPurchaseBalance(moneyWithoutFee, from + " transfer");
                    }
                    else if (targetBalance == "Cash Balance")
                    {
                        user.AddToCashBalance(moneyWithoutFee, from + " transfer");
                    }
                    else if (targetBalance == "Traffic Balance")
                    {
                        user.AddToTrafficBalance(money, from + " transfer");
                    }
                    else if (targetBalance == "Marketplace Balance")
                    {
                        user.AddToMarketplaceBalance(moneyWithoutFee, from + " transfer");
                    }
                    else if (targetBalance == "Points Balance")
                    {
                        user.AddToPointsBalance(moneyWithoutFee.ConvertToPoints(), from + " transfer");
                    }
                    user.SaveBalances();

                    if (targetBalance == "Purchase Balance" || targetBalance == "Cash Balance" || targetBalance == "Marketplace Balance")
                    {
                        //Update payment proportions
                        PaymentProportionsManager.MemberPaidIn(moneyWithoutFee, paymentProcessor, user);
                    }

                    //Add history
                    History.AddTransfer(username, moneyWithoutFee, from, targetBalance);

                    //TryAchievement
                    bool shouldBeSaved = user.TryToAddAchievements(
                        Achievements.Achievement.GetProperAchievements(
                            Achievements.AchievementType.AfterTransferringOnceAmount, moneyWithoutFee.GetTotals()));

                    if (shouldBeSaved)
                    {
                        user.Save();
                    }

                    //Check the contests
                    Contests.ContestManager.IMadeAnAction(Contests.ContestType.Transfer, user.Name, moneyWithoutFee, 0);
                    PurchasedItem.Create(user.Id, moneyWithoutFee, 1, "Transfer to " + targetBalance, PurchasedItemType.Transfer);

                    //Referral commission for sponsors when user does Cash Balance deposit
                    Titan.CashBalanceCrediter Crediter = (Titan.CashBalanceCrediter)Titan.CrediterFactory.Acquire(user, Titan.CreditType.CashBalanceDeposit);
                    Crediter.TryCreditReferer(moneyWithoutFee);
                }

                //AddLog
                if (!isViaRepresentative)
                {
                    CompletedPaymentLog.Create(paymentProcessor, "Transfer to " + targetBalance, transId, false, username, moneyWithoutFee,
                                               money - moneyWithoutFee, successful, cryptoCurrencyInfo);
                }
            });
        }