示例#1
0
    protected void btnDepositBTC_Click(object sender, EventArgs e)
    {
        try
        {
            if (BtcCryptocurrency.DepositEnabled)
            {
                if (CryptocurrencyApiFactory.GetDepositApi(BtcCryptocurrency).AllowToUsePaymentButtons())
                {
                    BTCDepositInfopanel.Visible = false;

                    var amount = Money.Parse(BTCAmountTextBox.Text).FromMulticurrency();
                    var bg     = new DepositCryptocurrencyButtonGenerator(user, amount);
                    BTCPaymentButton.Text = GenerateHTMLButtons.GetBtcButton(bg);
                }

                else
                {
                    classicbtcDepositBTC.Visible = false;
                    BTCValuePanel.Visible        = true;

                    string adminAddress = CryptocurrencyApiFactory.Get(BtcCryptocurrency.DepositApiProcessor).TryGetAdminAddress();

                    WalletToBTCPanel.Visible = true;
                    ClassicBTCPanel.Visible  = true;

                    if (!string.IsNullOrWhiteSpace(adminAddress))
                    {
                        multipleDepositWarningLiteral.Visible = true;
                        multipleDepositWarningLiteral.Text    = "<p class='alert alert-warning'>" + U5005.MUSTWAITTODEPOSIT + "</p>";

                        BitcoinQRCode.ImageUrl = "~/Handlers/Utils/BitcoinQRCode.ashx?address=" + adminAddress;

                        depositBTCLabel.Text = adminAddress;

                        DepositBTCInfoPanel.Visible = true;
                        DepositBTCInfoLabel.Text    = string.Format(U4200.DEPOSITBTCDESCRIPTION, "<b>" + adminAddress + "</b>", "<br/>", BtcCryptocurrency.DepositMinimumConfirmations.ToString());
                    }
                    else
                    {
                        depositBTCLabel.Text = "<p class='alert alert-danger'>" + U4200.DEPOSITUNAVAILABLE + "</p>";
                    }
                }
            }
            else
            {
                throw new MsgException(U4200.DEPOSITUNAVAILABLE);
            }
        }
        catch (MsgException ex)
        {
            ErrorMessagePanelBTC.Visible = true;
            ErrorMessageBTC.Text         = ex.Message;
        }
        catch (Exception ex)
        {
            ErrorLogger.Log(ex);
            ErrorMessagePanelBTC.Visible = true;
            ErrorMessageBTC.Text         = ex.Message;
        }
    }
示例#2
0
    protected static string TryInvokeProcessorTransfer(string transferFrom, string transferTo, Money amount, Member user)
    {
        var BtcCryptocurrency = CryptocurrencyFactory.Get(CryptocurrencyType.BTC);

        if (transferFrom == BtcCryptocurrency.DepositApiProcessor.ToString() && amount is CryptocurrencyMoney)
        {
            //We have BTC direct transfer
            var cryptoAmount = (CryptocurrencyMoney)amount;
            var bg           = new DepositToWalletCryptocurrencyButtonGenerator(user, cryptoAmount);
            return(GenerateHTMLButtons.GetBtcButton(bg));
        }

        if (transferFrom == BtcCryptocurrency.DepositApiProcessor.ToString())
        {
            var bg = new DepositCryptocurrencyButtonGenerator(user, amount);
            return(GenerateHTMLButtons.GetBtcButton(bg));
        }

        if (amount < AppSettings.Payments.MinimumTransferAmount)
        {
            throw new MsgException(U3000.ITSLOWERTHANMINIMUM);
        }

        var thegateway = PaymentAccountDetails.GetFirstGateway(transferFrom, true);

        if (thegateway == null)
        {
            throw new MsgException("No specified gateway installed.");
        }

        amount = thegateway.CalculateAmountWithFee(amount);

        if (transferTo == "Traffic balance")
        {
            var bg = new TransferToRentalBalanceButtonGenerator(user, amount);
            bg.Strategy = thegateway.GetStrategy();
            return(bg.Generate());
        }
        else if (transferTo == "Purchase balance")
        {
            var bg = new TransferToAdvertisingBalanceButtonGenerator(user, amount);
            bg.Strategy = thegateway.GetStrategy();
            return(bg.Generate());
        }
        else if (transferTo == "Cash balance")
        {
            var bg = new TransferToCashBalanceButtonGenerator(user, amount);
            bg.Strategy = thegateway.GetStrategy();
            return(bg.Generate());
        }
        else if (transferTo == "Marketplace balance")
        {
            var bg = new TransferToMarketplaceBalanceButtonGenerator(user, amount);
            bg.Strategy = thegateway.GetStrategy();
            return(bg.Generate());
        }
        else if (transferTo == TransferOptionConst.PointsTransfer)
        {
            var bg = new TransferToPointsBalanceButtonGenerator(user, amount);
            bg.Strategy = thegateway.GetStrategy();
            return(bg.Generate());
        }

        return(String.Empty);
    }