private void cmdAuthorize_Click(object sender, EventArgs e)
        {//The Authorize() operation is used to authorize transactions prior to capture.
            //Check to see if this transaction type is supported
            if (!SupportedTxnTypes.Authorize) { MessageBox.Show("Authorize Not Supported"); return; }
            //Check to see if the transaction is a PINDebit and that the AuthorizeAndCapture is used.
            if (chkProcessAsPINDebitTxn.Checked) { MessageBox.Show("A PINDebit transaction can only be processed as an AuthorizeAndCapture Transaction"); return; }

            Cursor = Cursors.WaitCursor;

            if (_bcs != null) //Process a BankCard Transaction
            {
                try
                {
                    BankcardTransaction BCtransaction = SetBankCardTxnData();
                    processResponse(Helper.ProcessBCPTransaction(TransactionType.Authorize, BCtransaction, null, null, null, null, null, null, null, ChkAcknowledge.Checked, ChkUserWorkflowId.Checked));
                }
                catch (Exception ex) { MessageBox.Show(ex.Message); }
                finally { Cursor = Cursors.Default; }

            }
            else if (_ecks != null) //Process as a Check transaction
            {
                try
                {
                    if (_queryAccountTxn == null) { MessageBox.Show("You must first perform a QuearyAccount() to verify that the account accepts ACH transactions"); return; }
                    if (!_queryAccountTxn.ACHCapable) { MessageBox.Show("Your previous QueryAccount() returned a response where the transaction is not ACHCapable"); return; }

                    ElectronicCheckingTransaction ECKTransaction = SetElectronicCheckTxnData();

                    //If a modified account or routing number is returned, those numbers should be used for the check transaction.  
                    //Good for verifying the info before running the charge – like when you initially set-up a recurring payment.
                    if (ECKTransaction.TenderData.CheckData.AccountNumber != _queryAccountTxn.ModifiedAccountNumber)
                        ECKTransaction.TenderData.CheckData.AccountNumber = _queryAccountTxn.ModifiedAccountNumber;
                    if (ECKTransaction.TenderData.CheckData.RoutingNumber != _queryAccountTxn.ModifiedRoutingNumber)
                        ECKTransaction.TenderData.CheckData.RoutingNumber = _queryAccountTxn.ModifiedRoutingNumber;

                    _queryAccountTxn = null; //Clear out the value as we're going to process a Check
                    //Let's Query a transaction
                    processResponse(Helper.ProcessECKTransaction(TransactionType.Authorize, ECKTransaction, null, null, null, ChkAcknowledge.Checked));
                }
                catch (Exception ex) { MessageBox.Show(ex.Message); }
                finally { Cursor = Cursors.Default; }
            }
            else if (_svas != null) //Process as a Check transaction
            {
                try
                {
                    StoredValueTransaction SVATransaction = SetStoredValueTxnData();
                    //Let's Query a transaction
                    processResponse(Helper.ProcessSVATransaction(TransactionType.Authorize, SVATransaction, null, null, null, null, ChkAcknowledge.Checked));
                }
                catch (Exception ex) { MessageBox.Show(ex.Message); }
                finally { Cursor = Cursors.Default; }
            }
        }
        private void cmdAuthorize_Click(object sender, EventArgs e)
        {
            //The Authorize() operation is used to authorize transactions prior to capture.
            //Check to see if this transaction type is supported
            if (!SupportedTxnTypes.Authorize) { MessageBox.Show("Authorize Not Supported"); return; }
            //Check to see if the transaction is a PINDebit and that the AuthorizeAndCapture is used.
            if (chkProcessAsPINDebitTxn.Checked) { MessageBox.Show("A PINDebit transaction can only be processed as an AuthorizeAndCapture Transaction"); return; }

            Cursor = Cursors.WaitCursor;

            if (_bcs != null) //Process a BankCard Transaction
            {
                try
                {
                    BankcardTransaction BCtransaction = dg.SetBankCardTxnData();// DataGenerator.SetBankCardTxnData();
                    processResponse(Helper.ProcessBCPTransaction(TransactionType.Authorize, BCtransaction, null, null, null, null, null, null, null, ChkAcknowledge.Checked, ChkUserWorkflowId.Checked));
                }
                catch (Exception ex) { MessageBox.Show(ex.Message); }
                finally { Cursor = Cursors.Default; }

            }
            else if (_ecks != null) //Process as a Check transaction
            {
                //First verify if all transactions selected are "Authorize" transactions
                List<ResponseDetails> txnsToProcess = new List<ResponseDetails>();
                foreach (object itemChecked in ChkLstTransactionsProcessed.CheckedItems)
                {
                    if (((ResponseDetails)(itemChecked)).TransactionType != TransactionType.QueryAccount.ToString() | ((ResponseDetails)(itemChecked)).TransactionType != TransactionType.QueryAccount.ToString())
                    {
                        MessageBox.Show("All selected messages must be of type QueryAccount or Authorize");
                        Cursor = Cursors.Default;
                        return;
                    }
                    txnsToProcess.Add(((ResponseDetails)(itemChecked)));
                }
                try
                {
                    if (txnsToProcess.Count == 0)
                    {
                        MessageBox.Show("You must select a QueryAccount transaction to use for the Authorize");
                        return;
                    }
                    //Now process each message selected
                    foreach (ResponseDetails _RD in txnsToProcess)
                    {
                        ElectronicCheckingTransaction ECKTransaction = dg.SetElectronicCheckTxnData();

                        _queryAccountTxn = (ElectronicCheckingTransactionResponse)_RD.Response;

                        if (_queryAccountTxn == null)
                        {
                            MessageBox.Show("You must first perform a QueryAccount() to verify that the account accepts ACH transactions");
                            return;
                        }
                        if (!_queryAccountTxn.ACHCapable)
                        {
                            MessageBox.Show("Your previous QueryAccount() returned a response where the transaction is not ACHCapable");
                            return;
                        }

                        //Let's Authorize the transaction
                        //If a modified account or routing number is returned, those numbers should be used for the check transaction.
                        //Good for verifying the info before running the charge – like when you initially set-up a recurring payment.
                        if (ECKTransaction.TenderData.CheckData.AccountNumber != _queryAccountTxn.ModifiedAccountNumber)
                            ECKTransaction.TenderData.CheckData.AccountNumber = _queryAccountTxn.ModifiedAccountNumber;
                        if (ECKTransaction.TenderData.CheckData.RoutingNumber != _queryAccountTxn.ModifiedRoutingNumber)
                            ECKTransaction.TenderData.CheckData.RoutingNumber = _queryAccountTxn.ModifiedRoutingNumber;

                        _queryAccountTxn = null; //Clear out the value as we're going to process a Check
                        //Let's Query a transaction
                        processResponse(Helper.ProcessECKTransaction(TransactionType.Authorize, ECKTransaction, null,
                                                                     null, null, ChkAcknowledge.Checked));

                    }

                }
                catch (Exception ex) { MessageBox.Show(ex.Message); }
                finally { Cursor = Cursors.Default; }
            }
            else if (_svas != null) //Process as a Check transaction
            {
                try
                {
                    StoredValueTransaction SVATransaction = dg.SetStoredValueTxnData();
                    //Let's Query a transaction
                    processResponse(Helper.ProcessSVATransaction(TransactionType.Authorize, SVATransaction, null, null, null, null, ChkAcknowledge.Checked));
                }
                catch (Exception ex) { MessageBox.Show(ex.Message); }
                finally { Cursor = Cursors.Default; }
            }
        }