private void btnPurchase_Click(object sender, EventArgs e) { String CardId = ""; nfc = DCPOS.Factory.GetNFC(); if (nfc.InitReader()) { if (nfc.ConnectReader()) { if (nfc.ReadTagID(ref CardId)) { Decimal FiatAmount = Convert.ToInt32(txtAmount.Text); Decimal Bitcoins = Convert.ToDecimal(txtBitcoins.Text); String DestinationAddress = ""; if (nfc.readPublicKey(ref DestinationAddress)) { if (ChkPINLimit(CardId, FiatAmount, cboCurrency.SelectedItem.ToString()) == "01") { PinPad pinform = new PinPad(); pinform.ShowDialog(); if (checkPin(CardId, Program.Pin) == "00") { DCCommon common = new DCCommon(); common.PurchaseBitcoins(CardId, DestinationAddress, FiatAmount, cboCurrency.SelectedItem.ToString()); } } else { DCCommon common = new DCCommon(); common.PurchaseBitcoins(CardId, DestinationAddress, FiatAmount, cboCurrency.SelectedItem.ToString()); // MessageBox.Show(result); } } else { MessageBox.Show("Cannot read Public Key", "DC PC POS", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk); } } else { MessageBox.Show("Card not on Reader or cannot read card ", "DC PC POS", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk); } } else { MessageBox.Show("The Reader cannot be Initalised", "DC PC POS", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk); } } else { MessageBox.Show("The Reader cannot be Initalised", "DC PC POS", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk); } }
private void btnRefund_Click(object sender, EventArgs e) { String CardId = ""; nfc = DCPOS.Factory.GetNFC(); if (nfc.InitReader()) { if (nfc.ConnectReader()) { if (nfc.ReadTagID(ref CardId)) { Decimal FiatAmount = Convert.ToInt32(txtAmount.Text); Decimal Bitcoins = Convert.ToDecimal(txtBitcoins.Text); MerchantCard ReadMerchantCard = new MerchantCard(); ReadMerchantCard.ShowDialog(); DCCommon common = new DCCommon(); String result = common.SendBitcoins(Program.MerchantCardId, Program.MerchantPublicKey, Program.MerchantEncryptedPrivateKey, CardId, Bitcoins, FiatAmount, cboCurrency.SelectedItem.ToString()); MessageBox.Show(result); } else { MessageBox.Show("Cannot Read CardId", "DC PC POS", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk); } } else { MessageBox.Show("The Card is not Present", "DC PC POS", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk); } } else { MessageBox.Show("The Reader cannot be Initalised", "DC PC POS", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk); } }