private void SetRadioItemsValues(DropDownList dropDownList) { var TokenCryptocurrency = CryptocurrencyFactory.Get <ERC20TokenCryptocurrency>(); foreach (ListItem item in dropDownList.Items) { item.Text = item.Value; string ImageIconName = String.Format("../Images/OneSite/TransferMoney/{0}.png", item.Value); if (item.Value == (String.Format("{0} Wallet", TokenCryptocurrency.Code))) { ImageIconName = AppSettings.Ethereum.ERC20TokenImageUrl; } if (TitanFeatures.IsClickmyad && item.Text == CryptocurrencyAPIProvider.CoinPayments.ToString()) { item.Attributes.Add("data-content", String.Format("<img src='{0}' />", ImageIconName)); } else { item.Attributes.Add("data-content", String.Format("<img src='{0}' style='height:40px' /> {1}", ImageIconName, item.Text)); } } }
protected override object GetDataFromSource() { var gateways = PaymentAccountDetails.AllGateways; var availableGateways = new HashSet <PaymentProcessor>(); foreach (var gateway in gateways) { if (gateway.IsActive && (gateway.Cashflow == GatewayCashflowDirection.ToGate || gateway.Cashflow == GatewayCashflowDirection.Both)) { availableGateways.Add(gateway.GetProcessorType()); } } var cryptocurrencies = CryptocurrencyFactory.GetAllAvailable(); foreach (var crypto in cryptocurrencies) { if (crypto.DepositApiProcessor != 0 && CryptocurrencyApiFactory.Get(crypto.DepositApiProcessor).AllowToUsePaymentButtons()) { if (crypto.DepositApiProcessor == CryptocurrencyAPIProvider.CoinPayments) { availableGateways.Add(PaymentProcessor.CoinPayments); } if (crypto.DepositApiProcessor == CryptocurrencyAPIProvider.Coinbase) { availableGateways.Add(PaymentProcessor.Coinbase); } } } return(availableGateways.Distinct().ToList()); }
public static string GetPaymentButtons(BaseButtonGenerator bg) { var BtcCryptocurrency = CryptocurrencyFactory.Get(CryptocurrencyType.BTC); int buttonsPresent = 0; StringBuilder sb = new StringBuilder(); foreach (var t in PaymentAccountDetails.PaymentAccountDetailsClasses) { var instance = Activator.CreateInstance(t); var gateway = (PaymentAccountDetails)PaymentAccountDetails.RunStaticMethod(t, "GetFirstIncomeGateway"); if (gateway != null && gateway.AccountType != "MPesaAgent") //MPesaAgent do not support payment buttons { bg.Strategy = gateway.GetStrategy(); sb.Append(bg.Generate()); buttonsPresent++; } } if (BtcCryptocurrency.DepositEnabled && CryptocurrencyApiFactory.Get(BtcCryptocurrency.DepositApiProcessor).AllowToUsePaymentButtons()) { sb.Append(GetBtcButton(bg)); buttonsPresent++; } if (buttonsPresent == 0) { return(U6011.NOACTIVEPAYMENTPROCESSORS); } return(sb.ToString()); }
public void InitControls() { currentStage = ICOStage.GetCurrentStage(); var TokenCryptocurrency = CryptocurrencyFactory.Get(CryptocurrencyType.ERC20Token); if (currentStage == null) { StagePlaceHolder.Visible = false; NoStageLiteral.Text = U6012.NOSTAGEINFO; var nextStage = ICOStage.GetNextStage(); if (nextStage == null) { NextStageLiteral.Visible = false; } else { NextStageLiteral.Text = string.Format(U6012.NEXTSTAGEINFO, "<b>" + nextStage.StartDate + "</b>"); } } else { decimal ProgressBarValue = ((decimal)currentStage.GetAvailableTokens() / (decimal)currentStage.TotalAvailableTokens) * 100; int availableTokens = currentStage.GetAvailableTokens(); NoStagePlaceHolder.Visible = false; ProgressBarLiteral.Text = string.Format("<div class='progress-bar' style='width: {0}%'>{1}: <b>{2}</b> {3} ({0}%)</div>", ProgressBarValue.ToString("#.#"), U6012.TOKENSLEFT, availableTokens, TokenCryptocurrency.Code); NameTextBox.Text = string.Format(U6012.ISLIVE, currentStage.Name); } }
public static void TryBuyAdPackForTokens(int numberOfPacks, int advertId, Member user, AdPackType adPackType, int?userGroupIdNullable = null, int?groupIdNullable = null, bool forcePurchaseWithoutDeducingFunds = false, Member adPackOwner = null) { var TokenCryptocurrency = CryptocurrencyFactory.Get(CryptocurrencyType.ERC20Token); //Check all basic values Money TotalPriceForAdPacks = AdPackManager.GetAdPacksPrice(adPackType, numberOfPacks); Money TokenValue = TokenCryptocurrency.GetValue(); Decimal TokenNumberNeeded = TotalPriceForAdPacks.ToDecimal() / TokenValue.ToDecimal(); if (TokenValue <= Money.Zero) { throw new MsgException("Amount of tokens can not be <= 0"); } if (TokenNumberNeeded > user.GetCryptocurrencyBalance(CryptocurrencyType.ERC20Token).ToDecimal()) { throw new MsgException(String.Format(U6012.NOFUNDSINWALLET, TokenCryptocurrency.Code)); } try { //Funds ok, lets proceed with tokens transfer user.SubtractFromCryptocurrencyBalance(CryptocurrencyType.ERC20Token, TokenNumberNeeded, "Purchase transfer", BalanceLogType.PurchaseTransfer); user.AddToPurchaseBalance(TotalPriceForAdPacks, "Purchase transfer", BalanceLogType.PurchaseTransfer); AdPackManager.BuyPacks(numberOfPacks, advertId, user, adPackType, PurchaseBalances.Purchase, adPackOwner: adPackOwner); } catch (MsgException ex) { user.AddToCryptocurrencyBalance(CryptocurrencyType.ERC20Token, TokenNumberNeeded, "Reversed Purchase transfer", BalanceLogType.ReversedPurchaseTransfer); user.SubtractFromPurchaseBalance(TotalPriceForAdPacks, "Reversed Purchase transfer", BalanceLogType.ReversedPurchaseTransfer); throw new MsgException("<br />" + ex.Message); } }
private static decimal GetCurrentRate(string currencyCode) { if (Money.IsCryptoCurrency(currencyCode)) { return(CryptocurrencyFactory.Get(currencyCode).GetOriginalValue(AppSettings.Site.CurrencyCode).ToDecimal()); //1BTC = X USD } return(ExchangeRatesFactory.Get().GetRate(currencyCode).ToDecimal()); //1USD = X PLN }
protected void WithdrawCryptocurrencyButton_Click(object sender, EventArgs e) { if (Page.IsValid) { CryptocurrencySuccessMessagePanel.Visible = false; CryptocurrencyErrorMessagePanel.Visible = false; try { var Cryptocurrency = CryptocurrencyFactory.Get(SelectedCryptocurrency); User.ValidatePIN(CryptoPINTextBox.Text); string address = TryGetWithdrawalAddress(Cryptocurrency); Money moneyAmount = Money.Zero; Money moneyFee = Money.Zero; Money totalAmount = Money.Zero; decimal amountInCryptocurrency = Decimal.Zero; if (Cryptocurrency.WithdrawalFeePolicy == WithdrawalFeePolicy.Packs) { WithdrawalPacksPlaceHolder.Visible = true; WithdrawalPacksLiteral.Text = BitcoinWithdrawalFeePacks.GetPacksText(User.Id); } moneyAmount = new Money(Convert.ToDecimal(WithdrawCryptocurrencyAmountTextBox.Text)).FromMulticurrency(); moneyFee = Cryptocurrency.EstimatedWithdrawalFee(amountInCryptocurrency, address, User.Id, Cryptocurrency.WithdrawalSource); totalAmount = moneyAmount - moneyFee; amountInCryptocurrency = Cryptocurrency.ConvertFromMoney(moneyAmount); if (Cryptocurrency.WithdrawalSource == WithdrawalSourceBalance.Wallet) { amountInCryptocurrency = Convert.ToDecimal(WithdrawCryptocurrencyAmountTextBox.Text); moneyAmount = new CryptocurrencyMoney(Cryptocurrency.Type, amountInCryptocurrency); moneyFee = Cryptocurrency.EstimatedWithdrawalFee(amountInCryptocurrency, address, User.Id, Cryptocurrency.WithdrawalSource); totalAmount = new CryptocurrencyMoney(SelectedCryptocurrency, moneyAmount.ToDecimal() - moneyFee.ToDecimal()); } TryValidateCryptocurrencyWithdrawalByEmailOrPhone(); CryptocurrencyFeeLiteral.Visible = WithdrawTotalCryptocurrencyLiteral.Visible = true; CryptocurrencyFeeLiteral.Text = "</br>" + U3500.CASHOUT_FEES + ": " + moneyFee.ToString() + "</br>"; WithdrawTotalCryptocurrencyLiteral.Text = "<b>" + U5001.TOTAL + ": " + totalAmount + "</b>"; WithdrawCryptocurrencyButton.Visible = false; WithdrawCryptocurrencyConfirmButton.Visible = true; WithdrawCryptocurrencyAmountTextBox.Enabled = false; CryptoPINTextBox.Enabled = false; } catch (Exception ex) { CryptocurrencyErrorMessagePanel.Visible = true; CryptocurrencyErrorMessageLiteral.Text = ex.Message; } } }
public static String GetName(BalanceType balanceType) { switch (balanceType) { case BalanceType.MainBalance: if (TitanFeatures.IsTrafficThunder) { return(String.Format(U6012.WALLET, String.Format("{0} {1}", AppSettings.Site.CurrencyCode, U5004.MAIN))); } return(L1.MAINBALANCE); case BalanceType.PurchaseBalance: if (TitanFeatures.IsTrafficThunder) { return(String.Format(U6012.WALLET, AppSettings.Site.CurrencyCode)); } return(U6012.PURCHASEBALANCE); case BalanceType.TrafficBalance: return(U4200.TRAFFICBALANCE); case BalanceType.PointsBalance: return(String.Format("{0}", AppSettings.PointsName)); case BalanceType.CommissionBalance: return(U5004.COMMISSIONBALANCE); case BalanceType.PTCCredits: return(String.Format("{0} {1}", U6003.PTC, U6012.CREDITS)); case BalanceType.CashBalance: return(U5008.CASHBALANCE); case BalanceType.InvestmentBalance: return(U6006.INVESTMENTBALANCE); case BalanceType.MarketplaceBalance: return(U6008.MARKETPLACEBALANCE); case BalanceType.BTC: case BalanceType.ETH: case BalanceType.XRP: return(String.Format(U6012.WALLET, balanceType.ToString())); case BalanceType.Token: return(String.Format(U6012.WALLET, CryptocurrencyFactory.Get(CryptocurrencyType.ERC20Token).Code)); case BalanceType.FreezedToken: return(String.Format(U6012.WALLET, CryptocurrencyFactory.Get(CryptocurrencyType.ERCFreezed).Code)); case BalanceType.LoginAdsCredits: return(U5008.LOGINADSCREDITS); default: return(String.Empty); } }
protected void Page_Load(object sender, EventArgs e) { AccessManager.RedirectIfDisabled(AppSettings.TitanFeatures.ICOBuyEnabled); TokenCryptocurrency = CryptocurrencyFactory.Get(CryptocurrencyType.ERC20Token); BtcCryptocurrency = CryptocurrencyFactory.Get(CryptocurrencyType.BTC); if (!Page.IsPostBack) { SetupLanguagesAndTexts(); } }
public static String GetBalanceCode(bool isStock) { BalanceType targetBalance = isStock == true ? AppSettings.InternalExchange.InternalExchangeStockType : AppSettings.InternalExchange.InternalExchangePurchaseVia; if (BalanceTypeHelper.IsCryptoBalance(targetBalance)) { return(CryptocurrencyFactory.Get(CryptocurrencyTypeHelper.ConvertToCryptocurrencyType(targetBalance)).Code); } return(AppSettings.Site.CurrencyCode); }
protected override object GetDataFromSource() { Dictionary <CryptocurrencyType, Cryptocurrency> data = new Dictionary <CryptocurrencyType, Cryptocurrency>(); foreach (Type cryptocurrencyType in CryptocurrencyFactory.GetArrayOfSupportedTypes()) { Cryptocurrency cryptocurrency = (Cryptocurrency)Activator.CreateInstance(cryptocurrencyType); data.Add(cryptocurrency.CryptocurrencyType, cryptocurrency); } return(data); }
public static string GetPaymentButton(BaseButtonGenerator bg, CryptocurrencyType t) { var cryptocurrency = CryptocurrencyFactory.Get(t); var sb = new StringBuilder(); if (cryptocurrency.DepositEnabled && CryptocurrencyApiFactory.Get(cryptocurrency.DepositApiProcessor).AllowToUsePaymentButtons()) { sb.Append(GetBtcButton(bg)); } return(string.IsNullOrEmpty(sb.ToString()) ? U6011.NOACTIVEPAYMENTPROCESSORS : sb.ToString()); }
public CryptocurrencyWithdrawRequest(int userId, string address, Money amount, Money amountWithFee, CryptocurrencyType cryptocurrency, WithdrawalSourceBalance sourceBalance) { this.CryptocurrencyCode = cryptocurrency.ToString(); this.UserId = userId; this.Address = address; this.RequestDate = AppSettings.ServerTime; this.Status = WithdrawRequestStatus.Pending; this.Amount = amount; this.AmountWithFee = amountWithFee; this.WithdrawalSourceBalance = sourceBalance; this.CryptocurrencyObject = CryptocurrencyFactory.Get(Cryptocurrency); }
protected void Page_Load(object sender, EventArgs e) { if (Member.IsLogged) { var user = Member.CurrentInCache; TokenCryptocurrency = CryptocurrencyFactory.Get(CryptocurrencyType.ERC20Token); BtcCryptocurrency = CryptocurrencyFactory.Get(CryptocurrencyType.BTC); if (TitanFeatures.PurchaseBalanceDisabled) { AdBalancePlaceHolder.Visible = false; } PointsPlaceHolder.Visible = AppSettings.Points.PointsEnabled; CashBalancePlaceHolder.Visible = AppSettings.Payments.CashBalanceEnabled; CommissionBalancePlaceHolder.Visible = AppSettings.Payments.CommissionBalanceEnabled; TrafficBalancePlaceHolder.Visible = AppSettings.TitanFeatures.EarnTrafficExchangeEnabled; MarketPlaceBalancePlaceHolder.Visible = AppSettings.Payments.MarketplaceBalanceEnabled; InvestmentBalancePlaceHolder.Visible = AppSettings.InvestmentPlatform.InvestmentBalanceEnabled; BTCWalletPlaceHolder.Visible = BtcCryptocurrency.WalletEnabled; ERC20TokenPlaceHolder.Visible = TokenCryptocurrency.WalletEnabled; ERC20FreezedWalletPlaceHolder.Visible = TokenCryptocurrency.WalletEnabled && AppSettings.Ethereum.ERC20TokensFreezeSystemEnabled; MainBalanceLiteral.Text = string.Format("<td class='text-success'>{0}:</td><td class='text-success'><b>{1}</b></td>", U5004.MAIN, user.MainBalance.ToString()); AdBalanceLiteral.Text = string.Format("<td>{0}:</td><td><b>{1}</b></td>", U6012.PURCHASE, user.PurchaseBalance.ToString()); PointsLiteral.Text = string.Format("<td>{0}:</td><td><b>{1}</b></td>", AppSettings.PointsName, user.PointsBalance.ToString()); CashBalanceLiteral.Text = string.Format("<td>{0}:</td><td><b>{1}</b></td>", !TitanFeatures.IsRofriqueWorkMines ? U6002.CASH : "Funds Deposited", user.CashBalance.ToString()); CommissionBalanceLiteral.Text = string.Format("<td>{0}:</td><td><b>{1}</b></td>", U5004.COMMISSION, user.CommissionBalance.ToString()); TrafficBalanceLiteral.Text = string.Format("<td>{0}:</td><td><b>{1}</b></td>", U5004.TRAFFIC, user.TrafficBalance.ToString()); MarketPlaceBalanceLiteral.Text = string.Format("<td>{0}:</td><td><b>{1}</b></td>", U5006.MARKETPLACE, user.MarketplaceBalance.ToString()); InvestmentBalanceLiteral.Text = string.Format("<td>{0}:</td><td><b>{1}</b></td>", U6006.INVESTMENT, user.InvestmentBalance.ToString()); if (BtcCryptocurrency.WalletEnabled) { BTCWalletLiteral.Text = string.Format("<td class='text-warning'>{0}:</td><td class='text-warning'><b>{1}</b></td>", String.Format(U6012.WALLET, "BTC"), user.GetCryptocurrencyBalance(CryptocurrencyType.BTC)); } if (TokenCryptocurrency.WalletEnabled) { ERC20WalletLiteral.Text = string.Format("<td>{0}:</td><td><b>{1}</b></td>", String.Format(U6012.WALLET, TokenCryptocurrency.Code), user.GetCryptocurrencyBalance(CryptocurrencyType.ERC20Token)); } if (TokenCryptocurrency.WalletEnabled && AppSettings.Ethereum.ERC20TokensFreezeSystemEnabled) { ERC20FreezedTokensWalletLiteral.Text = string.Format("<td>{0}:</td><td><b>{1}</b></td>", TokenCryptocurrency.Code + " Freezed", user.GetCryptocurrencyBalance(CryptocurrencyType.ERCFreezed)); } } }
protected void Page_Load(object sender, EventArgs e) { AccessManager.RedirectIfDisabled(AppSettings.TitanFeatures.ICOHistoryEnabled); TokenCryptocurrency = CryptocurrencyFactory.Get(CryptocurrencyType.ERC20Token); if (!IsPostBack) { MainDescriptionLiteral.Text = String.Format(U6012.PURCHASEHISTORY, TokenCryptocurrency.Code); PurchasesGridView.EmptyDataText = L1.NODATA; PurchasesGridView.DataBind(); } }
public static string GetBtcButton(BaseButtonGenerator bg) { StringBuilder sb = new StringBuilder(); var BtcCryptocurrency = CryptocurrencyFactory.Get(CryptocurrencyType.BTC); if (BtcCryptocurrency.DepositEnabled && CryptocurrencyApiFactory.Get(BtcCryptocurrency.DepositApiProcessor).AllowToUsePaymentButtons()) { bg.Strategy = CryptocurrencyApiFactory.Get(BtcCryptocurrency.DepositApiProcessor).GetStrategy(); sb.Append(bg.Generate()); } return(sb.ToString()); }
public static String GetBalanceSign(bool isStock) { BalanceType targetBalance = isStock == true ? AppSettings.InternalExchange.InternalExchangeStockType : AppSettings.InternalExchange.InternalExchangePurchaseVia; if (BalanceTypeHelper.IsCryptoBalance(targetBalance)) { Cryptocurrency crypto = CryptocurrencyFactory.Get(CryptocurrencyTypeHelper.ConvertToCryptocurrencyType(targetBalance)); if (String.IsNullOrEmpty(crypto.CurrencyDisplaySignBefore)) { return(crypto.CurrencyDisplaySignAfter.Trim()); } return(crypto.CurrencyDisplaySignBefore.Trim()); } return(AppSettings.Site.CurrencySign.Trim()); }
/// <summary> /// Exchanges from currecny passed as parameter to Main currency /// </summary> /// <param name="currencyCode"></param> /// <returns></returns> public Money ExchangeFrom(string currencyCode) { Money output = Money.Zero; if (AppSettings.Payments.CurrencyMode == CurrencyMode.Fiat) { output = CurrencyExchangeHelper.FromCalculate(this, currencyCode); } else if (AppSettings.Payments.CurrencyMode == CurrencyMode.Cryptocurrency) { var cryptocurrencyExchange = CryptocurrencyFactory.Get(AppSettings.Site.CurrencyCode); output = new Money(cryptocurrencyExchange.ConvertFromMoney(this, currencyCode)); } return(output); }
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>"); } } }
protected void WithdrawCryptocurrencyConfirmButton_Click(object sender, EventArgs e) { if (Page.IsValid) { CryptocurrencySuccessMessagePanel.Visible = false; CryptocurrencyErrorMessagePanel.Visible = false; WithdrawCryptocurrencyConfirmButton.Visible = false; try { var Cryptocurrency = CryptocurrencyFactory.Get(SelectedCryptocurrency); string address = TryGetWithdrawalAddress(Cryptocurrency); User = Member.Current; decimal amount = Convert.ToDecimal(WithdrawCryptocurrencyAmountTextBox.Text); string successMessage = Cryptocurrency.TryMakeWithdrawal(User.Id, address, amount, Cryptocurrency.WithdrawalSource); CryptocurrencySuccessMessagePanel.Visible = true; CryptocurrencySuccessMessageLiteral.Text = successMessage; WithdrawCryptocurrencyAmountTextBox.Text = string.Empty; CryptocurrencyFeeLiteral.Visible = WithdrawTotalCryptocurrencyLiteral.Visible = false; if (!AppSettings.Payments.WithdrawalEmailEnabled && AppSettings.Proxy.SMSType == ProxySMSType.EveryCashout) { User.IsPhoneVerifiedBeforeCashout = true; User.UnconfirmedSMSSent--; User.Save(); } } catch (Exception ex) { CryptocurrencyErrorMessagePanel.Visible = true; CryptocurrencyErrorMessageLiteral.Text = ex.Message; } finally { WithdrawCryptocurrencyAmountTextBox.Enabled = true; WithdrawCryptocurrencyButton.Visible = true; ConfirmationCodePlaceHolder.Visible = false; } } }
protected void SetupLanguagesAndTexts() { var currentStage = ICOStage.GetCurrentStage(); var priceStage = currentStage; BuyFromBTCWalletButton.Visible = BtcCryptocurrency.WalletEnabled; if (currentStage == null) { priceStage = ICOStage.GetNextStage(); BuyFromPurchaseBalanceButton.Visible = BuyFromBTCWalletButton.Visible = false; } Money tokenPrice = Money.Zero; if (priceStage == null) //No next stage coming { tokenPrice = AppSettings.Ethereum.ERC20TokenRate; } else { tokenPrice = priceStage.TokenPrice; } BTCValueLabel.Visible = BtcCryptocurrency.WalletEnabled; BTCValueLiteral.Text = String.Format("1 {0} = <b id='BTCPrice'>{1}</b> BTC", TokenCryptocurrency.Code, (tokenPrice.ToDecimal() / CryptocurrencyFactory.Get(CryptocurrencyType.BTC).GetValue().ToDecimal()).TruncateDecimals(8)); USDValueLiteral.Text = String.Format("1 {0} = <b>{1}</b><span id='tokenPrice' style='display:none'>{2}</span>", TokenCryptocurrency.Code, tokenPrice.ToString(), tokenPrice.ToDecimal()); MaxVolumeLiteral.Text = String.Format(U6012.MAXPER14MIN, "<b>" + AppSettings.ICO.ICOPurchaseLimitPerUserPer15mins + "</b>", TokenCryptocurrency.Code); LangAdder.Add(BuyFromPurchaseBalanceButton, U6012.PAYVIAPURCHASEBALANCE); LangAdder.Add(BuyFromBTCWalletButton, String.Format(U6012.PAYVIAWALLET, "BTC")); LangAdder.Add(RequiredFieldValidator4, L1.ER_ALLFIELDSREQUIRED); NumberOfTokensTextBox.Attributes["placeholder"] = String.Format("{0}", L1.AMOUNT); if (TitanFeatures.IsTrafficThunder) { BuyFromPurchaseBalanceButton.Visible = false; } }
protected void Page_Load(object sender, EventArgs e) { TokenCryptocurrency = CryptocurrencyFactory.Get <BitcoinCryptocurrency>(); ERC20TokenCryptocurrency = CryptocurrencyFactory.Get <ERC20TokenCryptocurrency>(); if (!IsPostBack) { HideMessages(); var PurchaseOptions = PurchaseOption.Get(PurchaseOption.Features.AdPack); BindDataToTypesDDL(); CustomCampaignsDropDownManagement(); CustomPurchaseViaTokenPlaceHolder.Visible = false; CustomPurchaseViaMainBalancePlaceHolder.Visible = TitanFeatures.IsTrafficThunder; CustomPurchaseViaCommissionBalancePlaceHolder.Visible = AppSettings.RevShare.AdPackPurchasesViaCommissionBalanceEnabled; CustomPurchaseViaPurchaseBalancePlaceHolder.Visible = PurchaseOptions.PurchaseBalanceEnabled && !TitanFeatures.PurchaseBalanceDisabled; CustomPurchaseViaCashBalancePlaceHolder.Visible = PurchaseOptions.CashBalanceEnabled; CustomPurchaseForReferralPlaceHolder.Visible = AppSettings.RevShare.AdPack.BuyAdPacksForReferralsEnabled; CustomPurchaseViaERC20TokensButton.Enabled = false; CustomPurchaseViaCommissionBalanceButton.Enabled = false; CustomPurchaseViaCashBalanceButton.Enabled = false; CustomPurchaseViaPurchaseBalanceButton.Enabled = false; CustomPurchaseViaMainBalanceButton.Enabled = false; TOSAgreement.Checked = false; if (TitanFeatures.IsTrafficThunder) { CustomTypesDDLPlaceHolder.Visible = false; } LangAdders(); } var adPackType = new AdPackType(Convert.ToInt32(CustomTypesDropDown.SelectedValue)); CustomPackPriceLabel.Text = adPackType.Price.ToClearString(); ScriptManager.RegisterStartupScript(CustomAdPackPurchaseUpdatePanel, GetType(), "AdPacksTBChanged", "AdPacksTBChanged();", true); }
protected void SetupSpecialTransfersProperties() { AdditionalInformationLiteralPlaceHolder.Visible = false; RequestedBTCCryptocurrencyTransfer = false; CurrencyTransferSignLiteral.Text = AppSettings.Site.MulticurrencySign; TransferFromTextBox.Text = "100.00"; if (RadioFrom.SelectedValue == "Main balance" && RadioTo.SelectedValue == TokenCryptocurrency.Code + " Wallet") { AdditionalInformationLiteralPlaceHolder.Visible = true; AdditionalInformationLiteral.Text = string.Format("1 {0} = <b>{1}</b>", TokenCryptocurrency.Code, TokenCryptocurrency.GetValue().ToString()); if (TitanFeatures.IsTrafficThunder) { AdditionalInformationLiteral.Text = string.Format("1 {0} = <b>${1}</b>", TokenCryptocurrency.Code, TokenCryptocurrency.GetValue().ToShortClearString()); } } if (RadioTo.SelectedValue == "BTC Wallet" || RadioTo.SelectedValue == "BTC" || RadioFrom.SelectedValue == "CoinPayments" || RadioFrom.SelectedValue == "CoinBase" || RadioFrom.SelectedValue == "Blocktrail") { AdditionalInformationLiteralPlaceHolder.Visible = true; AdditionalInformationLiteral.Text = string.Format("1 BTC = <b>{0}</b>", CryptocurrencyFactory.Get(CryptocurrencyType.BTC).GetValue().ToString()); if (BtcCryptocurrency.DepositEnabled && BtcCryptocurrency.DepositMinimum > 0) { AdditionalInformationLiteral.Text += "<br /><br />" + String.Format(U6012.WARNINGMINBTCDEPOSIT, CryptocurrencyMoney.Parse(BtcCryptocurrency.DepositMinimum.ToString(), CryptocurrencyType.BTC).ToString()); } if (RadioFrom.SelectedValue == "CoinPayments") { AdditionalInformationLiteral.Text += " " + U6012.BTCDEPOSITLIMITINFO; } } if (RadioTo.SelectedValue == "BTC Wallet") { RequestedBTCCryptocurrencyTransfer = true; CurrencyTransferSignLiteral.Text = "฿"; TransferFromTextBox.Text = "0.1"; } }
private static string GetAndUseBTCWallet(int userId) { var BtcCryptocurrency = CryptocurrencyFactory.Get(CryptocurrencyType.BTC); var daysToActivate = BtcCryptocurrency.ActivateUserAddressAfterDays; var btcAddress = CryptocurrencyWithdrawalAddress.GetAddress(userId, CryptocurrencyType.BTC); if (btcAddress == null) { throw new MsgException(U6000.ADDBTCADDRESSFIRST); } if (!btcAddress.IsNew && btcAddress.DateAdded.AddDays(daysToActivate) > AppSettings.ServerTime) { throw new MsgException(string.Format(U6000.CANTWITHDRAWBTCUNTIL, (btcAddress.DateAdded.AddDays(daysToActivate) - AppSettings.ServerTime).ToFriendlyDisplay(2))); } return(btcAddress.Address.Replace(" ", String.Empty)); }
private static string GetAndUseEmail(int userId) { var BtcCryptocurrency = CryptocurrencyFactory.Get(CryptocurrencyType.BTC); var daysToActivate = BtcCryptocurrency.ActivateUserAddressAfterDays; var coinbaseAddress = GetEmailAddress(userId); if (coinbaseAddress == null) { throw new MsgException(U6000.ADDBTCADDRESSFIRST); } if (coinbaseAddress.LastChanged.AddDays(daysToActivate) > AppSettings.ServerTime) { throw new MsgException(string.Format(U6000.CANTWITHDRAWBTCUNTIL, (coinbaseAddress.LastChanged.AddDays(daysToActivate) - AppSettings.ServerTime).ToFriendlyDisplay(2))); } return(coinbaseAddress.PaymentAddress); }
protected override object GetDataFromSource() { var gateways = PaymentAccountDetails.AllGateways; foreach (var gateway in gateways) { if (gateway.IsActive && (gateway.Cashflow == GatewayCashflowDirection.ToGate || gateway.Cashflow == GatewayCashflowDirection.Both)) { return(true); } } var BtcCryptocurrency = CryptocurrencyFactory.Get(CryptocurrencyType.BTC); if (BtcCryptocurrency.DepositEnabled && CryptocurrencyApiFactory.Get(BtcCryptocurrency.DepositApiProcessor).AllowToUsePaymentButtons()) { return(true); } return(false); }
/// <summary> /// Returns Transaction Id /// </summary> /// <param name="senderAddress"></param> /// <param name="senderParityPassword"></param> /// <param name="destinationAddress"></param> /// <param name="amount"></param> /// <returns></returns> public static string SendTokens(string senderAddress, string senderParityPassword, string destinationAddress, decimal amount) { var TokenCryprocurrency = CryptocurrencyFactory.Get(CryptocurrencyType.ERC20Token); var TokenAmountAsInteger = new BigInteger(amount * TokenCryprocurrency.DecimalPlaces); var web3 = new Web3("http://localhost:8545"); var targetContract = web3.Eth.GetContract(GetTokenAbi(), AppSettings.Ethereum.ERC20TokenContract); var balanceFunction = targetContract.GetFunction("balanceOf"); var balanceFunctionAsyncCall = balanceFunction.CallAsync <BigInteger>("0x1480a8ddbab23081b88a404461333154ef961999"); balanceFunctionAsyncCall.Wait(); var availableBalance = balanceFunctionAsyncCall.Result; if (availableBalance < TokenAmountAsInteger) { throw new MsgException("You don't have sufficient amount of tokens on this account."); } //If you get 'Method not found' message, it means that you did not configured parity to run with RPC API: Personal //parity --warp --rpcapi "eth,net,web3,personal,parity" var unlockResult = web3.Personal.UnlockAccount.SendRequestAsync(senderAddress, senderParityPassword, new HexBigInteger(120)); unlockResult.Wait(); var transferFunction = targetContract.GetFunction("transferFrom"); var transferFunctionAsyncCall = transferFunction.SendTransactionAsync( senderAddress, new HexBigInteger(50000), new HexBigInteger(0), senderAddress, destinationAddress, TokenAmountAsInteger); transferFunctionAsyncCall.Wait(); return(transferFunctionAsyncCall.Result); }
public string GenerateBTCAddress() { string adminAddress = string.Empty; using (MyWebClient client = new MyWebClient()) { var BtcCryptocurrency = CryptocurrencyFactory.Get(CryptocurrencyType.BTC); //We have a Blocktrail SDK installed on apis.usetitan.com string requestUrl = String.Format("https://apis.usetitan.com/btg.php?command=generate&key={0}&secret={1}&walletName={2}&walletPass={3}&confirmations={4}", ApiKey, ApiSecret, AppSettings.Cryptocurrencies.BlocktrailWalletIdentifier, AppSettings.Cryptocurrencies.BlocktrailWalletPassword, BtcCryptocurrency.DepositMinimumConfirmations); var responseString = client.DownloadString(requestUrl); if (!responseString.StartsWith("OK")) { throw new MsgException(responseString); } adminAddress = responseString.Split(':')[1]; } return(adminAddress); }
public static void TryBuyAdPackFromAnotherBalance(int numberOfPacks, int advertId, Member user, AdPackType adPackType, BalanceType targetType, int?userGroupIdNullable = null, int?groupIdNullable = null, bool forcePurchaseWithoutDeducingFunds = false, Member adPackOwner = null) { Money TotalPriceForAdPacks = AdPackManager.GetAdPacksPrice(adPackType, numberOfPacks); if (TotalPriceForAdPacks <= Money.Zero) { throw new MsgException("Value can not be <= 0"); } if (targetType == BalanceType.CommissionBalance) { if (TotalPriceForAdPacks > user.CommissionBalance) { throw new MsgException(L1.NOTENOUGHFUNDS); } try { //Funds ok, lets proceed with tokens transfer user.SubtractFromCommissionBalance(TotalPriceForAdPacks, "Purchase transfer", BalanceLogType.PurchaseTransfer); user.AddToPurchaseBalance(TotalPriceForAdPacks, "Purchase transfer", BalanceLogType.PurchaseTransfer); AdPackManager.BuyPacks(numberOfPacks, advertId, user, adPackType, PurchaseBalances.Purchase, adPackOwner: adPackOwner); } catch (MsgException ex) { user.SubtractFromPurchaseBalance(TotalPriceForAdPacks, "Reversed Purchase transfer", BalanceLogType.ReversedPurchaseTransfer); user.AddToPurchaseBalance(TotalPriceForAdPacks, "Purchase transfer", BalanceLogType.PurchaseTransfer); throw new MsgException("<br />" + ex.Message); } } else if (targetType == BalanceType.MainBalance) { if (TotalPriceForAdPacks > user.MainBalance) { throw new MsgException(L1.NOTENOUGHFUNDS); } try { //Funds ok, lets proceed with tokens transfer user.SubtractFromMainBalance(TotalPriceForAdPacks, "Purchase transfer", BalanceLogType.PurchaseTransfer); user.AddToPurchaseBalance(TotalPriceForAdPacks, "Purchase transfer", BalanceLogType.PurchaseTransfer); AdPackManager.BuyPacks(numberOfPacks, advertId, user, adPackType, PurchaseBalances.Purchase, adPackOwner: adPackOwner); } catch (MsgException ex) { user.SubtractFromPurchaseBalance(TotalPriceForAdPacks, "Reversed Purchase transfer", BalanceLogType.ReversedPurchaseTransfer); user.AddToMainBalance(TotalPriceForAdPacks, "Purchase transfer", BalanceLogType.PurchaseTransfer); throw new MsgException("<br />" + ex.Message); } } else if (targetType == BalanceType.BTC) { Money BTCValue = CryptocurrencyFactory.Get(CryptocurrencyType.BTC).GetValue(); Decimal BTCAmountNeeded = TotalPriceForAdPacks.ToDecimal() / BTCValue.ToDecimal(); if (BTCAmountNeeded > user.GetCryptocurrencyBalance(CryptocurrencyType.BTC).ToDecimal()) { throw new MsgException(String.Format(U6012.NOFUNDSINWALLET, "BTC")); } try { //Funds ok, lets proceed with tokens transfer user.SubtractFromCryptocurrencyBalance(CryptocurrencyType.BTC, BTCAmountNeeded, "Purchase transfer", BalanceLogType.PurchaseTransfer); user.AddToPurchaseBalance(TotalPriceForAdPacks, "Purchase transfer", BalanceLogType.PurchaseTransfer); AdPackManager.BuyPacks(numberOfPacks, advertId, user, adPackType, PurchaseBalances.Purchase, adPackOwner: adPackOwner); } catch (MsgException ex) { user.SubtractFromPurchaseBalance(TotalPriceForAdPacks, "Reversed Purchase transfer", BalanceLogType.ReversedPurchaseTransfer); user.AddToCryptocurrencyBalance(CryptocurrencyType.BTC, BTCAmountNeeded, "Purchase transfer", BalanceLogType.PurchaseTransfer); throw new MsgException("<br />" + ex.Message); } } else { throw new MsgException("Not implemented transaction"); } }
public override void ProcessRequest() { try { CoinbaseApi api = new CoinbaseApi(AppSettings.Cryptocurrencies.CoinbaseAPIKey, AppSettings.Cryptocurrencies.CoinbaseAPISecret, false); if (!IP.IsIpInRange(IP.Current, "54.175.255.192/27")) { throw new MsgException("Bad request IP."); } var json = JObject.Parse(context.Request.GetFromBodyString()); string merchant = json["account"]["id"].ToString(); if (String.IsNullOrEmpty(merchant)) { throw new MsgException("No Account ID passed"); } if (merchant != CoinbaseCryptocurrencyApi.GetAccountId(api)) { throw new MsgException("Invalid account ID."); } //IPN process string operationType = json["type"].ToString(); if (AppSettings.Cryptocurrencies.IsCoinbaseMerchant) { string transactionId = json["data"]["transaction"]["id"].ToString(); string currency = json["data"]["amount"]["currency"].ToString(); string amount = json["data"]["amount"]["amount"].ToString(); string args = json["data"]["metadata"]["all"].ToString(); string[] argsSplit = args.Split(ButtonGenerationStrategy.ArgsDelimeter); CheckIfNotDoneYet(transactionId); if (operationType == "wallet:orders:paid" || operationType == "wallet:orders:mispaid") { string commandName = json["data"]["description"].ToString(); string buyerCurrency = json["data"]["bitcoin_amount"]["currency"].ToString(); string buyerCurrencyAmount = json["data"]["bitcoin_amount"]["amount"].ToString(); string cryptocurrencyInfo = string.Format("{0}{1}", buyerCurrencyAmount, buyerCurrency); var assembly = Assembly.GetAssembly(typeof(IIpnHandler)); var type = assembly.GetType(commandName, true, true); var command = Activator.CreateInstance(type) as IIpnHandler; var Cryptocurrency = CryptocurrencyFactory.Get(buyerCurrency); //Wallet deposit, sent in BTC if (command is WalletDepositCryptocurrencyIpnHandler && Cryptocurrency.DepositTarget == DepositTargetBalance.Wallet && currency == "BTC" && AppSettings.Site.CurrencyCode != "BTC") { Cryptocurrency.TryDepositCryptocurrency(new Member(argsSplit[0]), Decimal.Parse(amount), transactionId, cryptocurrencyInfo); } CheckCurrency(currency); command.HandleCoinbase(args, transactionId, amount, cryptocurrencyInfo); } } else { string transactionId = json["additional_data"]["transaction"]["id"].ToString(); string currency = json["additional_data"]["amount"]["currency"].ToString(); string amount = json["additional_data"]["amount"]["amount"].ToString(); string currencyInfo = string.Format("{0}{1}", amount, currency); string address = json["data"]["address"].ToString(); CheckIfNotDoneYet(transactionId); if (currency != "BTC") { throw new MsgException("This is not BTC."); } if (operationType == "wallet:addresses:new-payment") { var bitcoinAmount = Convert.ToDecimal(amount); var TargetAddress = json["data"]["address"].ToString(); var Cryptocurrency = CryptocurrencyFactory.Get(currency); Cryptocurrency.TryDepositCryptocurrency(CryptocurrencyAPIProvider.Coinbase, address, bitcoinAmount, transactionId, currencyInfo); } } } catch (Exception ex) { ErrorLogger.Log(ex); } }