Ejemplo n.º 1
0
        /// <summary>
        /// ATM calls this service to send BTC
        /// </summary>
        /// <param name="address"></param>
        /// <param name="btcAmount"></param>
        /// <returns></returns>
        public DC.Common.Models.Order CreateOrder(String address, Decimal btcAmount)
        {
            if (btcAmount > 0 && BitcoinHelper.IsValidAddress(address))
            {
                //Providers.IWallet wallet = Helpers.Factory.GetWallet();
                Providers.IWallet wallet = new Providers.BlockChainInfo()
                {
                    MerchantId = "4ea10592-e7cb-4170-9b5b-6e94e3236bb1", Password = "******"
                };                                                                                                                                         //ADD YOUR BLOCK CHAIN INFO CREDS HERE!

                //Move to a factory to spit out order model.
                DC.Common.Models.Order order = new DC.Common.Models.Order()
                {
                    Address = address,
                    BTC     = btcAmount
                };

                order.Txn = wallet.Send(address, btcAmount);
                return(order);
            }
            else
            {
                throw new ArgumentOutOfRangeException("Check the bitcoin address is valid and amount is greater than zero.");
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// ATM calls this service to send BTC
        /// </summary>
        /// <param name="address"></param>
        /// <param name="btcAmount"></param>
        /// <returns></returns>
        public DC.Common.Models.Order CreateOrder(String address, Decimal btcAmount)
        {
            if (btcAmount > 0 && BitcoinHelper.IsValidAddress(address))
            {
                // Buy  Bitcoin- https://blockchain.info/address/1QJQMFhgyoiLLUZXpr913T2TaEaX7pNFaF
                DigitalBTC digitalbtc = new DigitalBTC();
                PriceData  pricedata  = digitalbtc.GetSpotPrice2(btcAmount, "USD");
                if (pricedata.Price > 0)
                {
                    pricedata.Price += 1M;


                    float     price          = (float)pricedata.Price;
                    float     btcorderamount = (float)btcAmount;
                    OrderData orderdata      = digitalbtc.Order(price, btcorderamount);
                }

                // Sell Bitcoin
                //Providers.IWallet wallet = Helpers.Factory.GetWallet();
                Providers.IWallet wallet = new Providers.BlockChainInfo()
                {
                    MerchantId = "4ea10592-e7cb-4170-9b5b-6e94e3236bb1", Password = "******"
                };                                                                                                                                          //ADD YOUR BLOCK CHAIN INFO CREDS HERE!

                //Move to a factory to spit out order model.
                DC.Common.Models.Order order = new DC.Common.Models.Order()
                {
                    Address = address,
                    BTC     = btcAmount
                };

                order.Txn = wallet.Send(address, btcAmount);



                return(order);
            }
            else
            {
                throw new ArgumentOutOfRangeException("Check the bitcoin address is valid and amount is greater than zero.");
            }
        }