Пример #1
0
        private void btnRefund_Click(object sender, EventArgs e)
        {
            try
            {
                UseWaitCursor = true;
                if (!IsValid())
                {
                    return;
                }

                String CardId = "";

                if (common.nfc.InitReader())
                {
                    if (common.nfc.ConnectReader())
                    {
                        if (common.nfc.ReadTagID(ref CardId))
                        {
                            Decimal FiatAmount = Convert.ToInt32(txtAmount.Text);
                            Decimal Bitcoins   = Convert.ToDecimal(txtBitcoins.Text);


                            String result = common.SendBitcoins(Program.MerchantCardId, Program.MerchantPublicKey, Program.MerchantEncryptedPrivateKey, CardId, Bitcoins, FiatAmount, cboCurrency.SelectedItem.ToString());
                            MessageBox.Show(result);
                        }
                        else
                        {
                            _errorMessageButton = "Cannot Read CardId";
                            this.Refresh();
                        }
                    }
                    else
                    {
                        _errorMessageButton = "The Card is not Present";
                        this.Refresh();
                    }
                }

                else
                {
                    _errorMessageButton = "The Reader cannot be Initalised";
                    this.Refresh();
                }
            }
            catch (Exception ex)
            {
                _errorMessageButton = "Error:" + ex.ToString();
                this.Refresh();
            }
            finally
            {
                UseWaitCursor = false;
                ShowValidationMessages();
            }
        }
Пример #2
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);
            }
        }
Пример #3
0
        private void btnSell_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  encryptedPrivateKey = "";

                        if (nfc.readPrivateKey(ref encryptedPrivateKey))
                        {
                            String FromCardPublicAddress = "";
                            if (nfc.readPublicKey(ref FromCardPublicAddress))
                            {
                                if (ChkPINLimit(CardId, FiatAmount, cboCurrency.SelectedItem.ToString()) == "01")
                                {
                                    PinPad pinform = new PinPad();
                                    pinform.ShowDialog();

                                    if (checkPin(CardId, Program.Pin) == "00")
                                    {
                                        DCCommon common = new DCCommon();

                                        MerchantCard ReadMerchantCard = new MerchantCard();
                                        ReadMerchantCard.ShowDialog();

                                        String result = common.SendBitcoins(CardId, FromCardPublicAddress, encryptedPrivateKey, Program.MerchantCardId, Bitcoins, FiatAmount, cboCurrency.SelectedItem.ToString());
                                        MessageBox.Show(result);
                                    }
                                }
                                else
                                {
                                    DCCommon     common           = new DCCommon();
                                    MerchantCard ReadMerchantCard = new MerchantCard();
                                    ReadMerchantCard.ShowDialog();
                                    String result = common.SendBitcoins(CardId, FromCardPublicAddress, encryptedPrivateKey, Program.MerchantCardId, Bitcoins, FiatAmount, cboCurrency.SelectedItem.ToString());
                                    MessageBox.Show(result);
                                }
                            }
                            else
                            {
                                MessageBox.Show("Cannot read Public Key", "DC PC POS", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk);
                            }
                        }
                        else
                        {
                            MessageBox.Show("Cannot read Private 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);
            }
        }
Пример #4
0
        private void btnSell_Click(object sender, EventArgs e)
        {
            try
            {
                UseWaitCursor = false;
                if (!IsValid())
                {
                    return;
                }

                String CardId = "";

                if (common.nfc.InitReader())
                {
                    if (common.nfc.ConnectReader())
                    {
                        if (common.nfc.ReadTagID(ref CardId))
                        {
                            Decimal FiatAmount          = Convert.ToInt32(txtAmount.Text);
                            Decimal Bitcoins            = Convert.ToDecimal(txtBitcoins.Text);
                            String  encryptedPrivateKey = "";

                            if (common.nfc.readPrivateKey(ref encryptedPrivateKey))
                            {
                                String FromCardPublicAddress = "";
                                if (common.nfc.readPublicKey(ref FromCardPublicAddress))
                                {
                                    if (common.ChkPINLimit(CardId, FiatAmount, cboCurrency.SelectedItem.ToString()) == "01")
                                    {
                                        PinPad pinform = new PinPad();
                                        pinform.ShowDialog();

                                        if (common.checkPin(CardId, Program.Pin) == "00")
                                        {
                                            String result = common.SendBitcoins(CardId, FromCardPublicAddress, encryptedPrivateKey, Program.MerchantCardId, Bitcoins, FiatAmount, cboCurrency.SelectedItem.ToString());
                                            MessageBox.Show(result);
                                        }
                                        else
                                        {
                                            MessageBox.Show("Pin Invalid");
                                        }
                                    }
                                    else
                                    {
                                        String result = common.SendBitcoins(CardId, FromCardPublicAddress, encryptedPrivateKey, Program.MerchantCardId, Bitcoins, FiatAmount, cboCurrency.SelectedItem.ToString());
                                        MessageBox.Show(result);
                                    }
                                }
                                else
                                {
                                    _errorMessageButton = "Cannot read Public Key";
                                    this.Refresh();
                                }
                            }
                            else
                            {
                                _errorMessageButton = "Cannot read Private Key";
                                this.Refresh();
                            }
                        }
                        else
                        {
                            _errorMessageButton = "Card not on Reader or cannot read card ";
                            this.Refresh();
                        }
                    }
                    else
                    {
                        _errorMessageButton = "The Reader cannot be Connected ";
                        this.Refresh();
                    }
                }
                else
                {
                    _errorMessageButton = "The Reader cannot be Initalised ";
                    this.Refresh();
                }
            }
            catch (Exception ex)
            {
                //TODO: log error
                _errorMessageButton = "Error:" + ex.ToString();
                this.Refresh();
            }
            finally
            {
                ShowValidationMessages();
                UseWaitCursor = false;
            }
        }