Пример #1
0
        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);
            }
        }
Пример #2
0
        private void readMerchantCard()
        {
            if (nfc.InitReader())
            {
                if (nfc.ConnectReader())
                {
                    String CardId = "";
                    if (nfc.ReadTagID(ref CardId))
                    {
                        Program.MerchantCardId = CardId;
                        String PublicKey = "";
                        if (nfc.readPublicKey(ref PublicKey))
                        {
                            Program.MerchantPublicKey = PublicKey;
                            String EncryptedPrivateKey = "";

                            if (nfc.readPrivateKey(ref EncryptedPrivateKey))
                            {
                                Program.MerchantEncryptedPrivateKey = EncryptedPrivateKey;
                                this.Close();
                            }
                            else
                            {
                                lblStatus.Text = "Cannot read Private Key";
                            }
                        }
                        else
                        {
                            lblStatus.Text = "Cannot read Private Key";
                        }
                    }
                    else
                    {
                        lblStatus.Text = "Cannot read CardId";
                    }
                }
                else
                {
                    lblStatus.Text = "Card not Present on Reader";
                }
            }
            else
            {
                lblStatus.Text = "Cannot Initalise Reader";
            }
        }
Пример #3
0
        private void readCard()
        {
            nfc = DCPOS.Factory.GetNFC();
            if (nfc.InitReader())
            {
                if (nfc.ConnectReader())
                {
                    String CardId = "";
                    if (nfc.ReadTagID(ref CardId))
                    {
                        String PublicKey = "";
                        if (nfc.readPublicKey(ref PublicKey))
                        {
                            // Get Balance
                            ATM.AtmClient atm = new ATM.AtmClient();

                            decimal value = atm.GetBalance(PublicKey, 1);


                            lblBTCBalance.Text = value.ToString("0.000000 BTC");
                        }
                        else
                        {
                            lblStatus.Text = "Cannot read Public Key";
                        }
                    }
                    else
                    {
                        lblStatus.Text = "Cannot read CardId";
                    }
                }
                else
                {
                    lblStatus.Text = "Card not Present on Reader";
                }
            }
            else
            {
                lblStatus.Text = "Cannot Initalise Reader";
            }
        }
Пример #4
0
        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);
            }
        }
Пример #5
0
        private void btnActivate_Click(object sender, EventArgs e)
        {
            try
            {
                if (validate())
                {
                    String CardId = "";
                    String body   = "";
                    nfc = DCPOS.Factory.GetNFC();
                    Card.CardClient card = new Card.CardClient();
                    ATM.AtmClient   atm  = new ATM.AtmClient();
                    if (nfc.InitReader())
                    {
                        if (nfc.ConnectReader() && nfc.ReadTagID(ref CardId))
                        {
                            if (!card.IsCardOnFile(CardId))
                            {
                                ATM.Keys key               = atm.CreatePublicEncryptedPrivateKey();
                                String   Password          = key.Password.ToString();
                                String   PrivateKey        = key.PrivateKey;
                                String   PublicKey         = key.PublicKey;
                                String   modifiedpublicuri = String.Format("bitcoin:{0}", PublicKey);
                                if (nfc.WriteNFCTag(modifiedpublicuri, PrivateKey))
                                {
                                    body += Environment.NewLine;
                                    body += "Dear " + txtFirstName.Text + "," + Environment.NewLine;
                                    body += Environment.NewLine;
                                    body += Environment.NewLine;
                                    body += "Your Purchase" + Environment.NewLine;
                                    body += "From PC POS" + Environment.NewLine;
                                    body += Environment.NewLine;
                                    body += "Your Public Bitcoin Address is: https://blockchain.info/address/" + PublicKey + Environment.NewLine;
                                    body += Environment.NewLine;
                                    body += "LOSE THE FOLLOWING INFORMATION AND YOUR BITCOINS ARE LOST" + Environment.NewLine;
                                    body += "Your Private Key is: " + PrivateKey + Environment.NewLine;
                                    body += Environment.NewLine;
                                    body += Environment.NewLine;
                                    body += "Thank you" + Environment.NewLine;
                                    body += Environment.NewLine;
                                    body += "Diamond Circle Team" + Environment.NewLine;
                                    body += Environment.NewLine;
                                    body += "Allow for 6 Confirmations before balance appears." + Environment.NewLine;
                                    body += "See Terms and Conditions " + Environment.NewLine;
                                    atm.SendEmailAsync(txtEmail.Text, "Diamond Circle Private Key. CardId:" + CardId, body);
                                    // Write TagID to Database.
                                    Password = Convert.ToBase64String(key.Password);
                                    // card.AddCardWithPinLimit(CardId, PublicKey, Password, txtFirstName.Text, txtLastName.Text, txtAddress.Text, txtCity.Text, txtZip.Text, txtState.Text, cboCountry.SelectedItem, txtTelephone.Text, txtDOB.Text, txtEmail.Text, txtFirstName.Text + " " + txtLastName.Text, txtCCNumber.Text, txtExpiryDateMM.Text, txtExpiryDateYY.Text, txtCCNumber.Text, txtPIN.Text, cboCurrency.SelectedItem, Convert.ToInt32(txtLimit.Text), chkTopup);
                                }
                                else
                                {
                                    // Cannot write card.
                                }
                            }
                            else
                            {
                                // Card on file
                            }
                        }
                        else
                        {
                            lblStatusMessage.Text = "Hold Card on Reader";
                            this.Refresh();
                        }
                    }
                    else
                    {
                        lblStatusMessage.Text = "Cannot Initialse Reader";
                        this.Refresh();
                    }
                }
                else
                {
                    lblStatusMessage.Text = "Complete all Fields";
                }
            }

            catch (Exception ex)
            {
                // GeneralExceptions("Encode Tag", System.Diagnostics.TraceEventType.Critical, ex);
            }
        }