/// <summary> /// Charges the FiatAmount to the customer's credit card, /// then buys the Bitcoin amount, /// the records the transaction. /// //TODO: Store a log of the transaction steps so that refunds or rollback can occur since proper transactions are impossible here /// </summary> /// <param name="CardId"></param> /// <param name="BitcoinAmount"></param> /// <param name="Currency"></param> /// <param name="Amount"></param> /// <param name="TerminalId"></param> /// <returns></returns> public bool PayForAndBuyBitcoin(string CardId, string ToCardPublicAddress, decimal BitcoinAmount, string Currency, decimal FiatAmount, int TerminalId) { if (MakeFiatPayment(CardId, Currency, FiatAmount, TerminalId)) { if (ToCardPublicAddress != "") { DC.Data.Card card; using (var db = new DiamondCircle_dbEntities()) { card = db.Cards.Where(c => c.CardId == CardId).ToList().First(); ToCardPublicAddress = card.PublicKey; } } DC.Node.atm atmsvc = new Node.atm(); var order = atmsvc.CreateOrder(ToCardPublicAddress, BitcoinAmount); WriteTransaction(CardId, "BUY", TerminalId, Currency, "Bitcoin", BitcoinAmount, FiatAmount, order.Txn.ToString(), 1); return(true); } else { return(false); } }
public void SendCoinTest() { var atmsvc = new Node.atm(); // This code passed. var order = atmsvc.CreateOrder("1MR8RpE2v2yq6ZS6s9x79HTrxdzZZumt3B", 0.01M); Assert.IsNotNull(order); }
public void SendCoinTest() { var atmsvc = new Node.atm(); // This code passed. Decimal btcAmount = 0.5M; var order = atmsvc.CreateOrder("1EckcwV6Szv4UndFq4PkNHBrZaMnnJXGgj", btcAmount); Assert.IsNotNull(order); }