Exemplo n.º 1
0
 private void processReturnToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (!Security.IsAuthorized(Permissions.PaymentCreate))
     {
         return;
     }
     if (gridMain.SelectedIndices.Length < 1)
     {
         return;
     }
     if (IsXWebTransaction(gridMain.SelectedIndices[0]))
     {
         long              patNum    = PIn.Long(_tableTrans.Rows[gridMain.SelectedIndices[0]]["PatNum"].ToString());
         string            alias     = _tableTrans.Rows[gridMain.SelectedIndices[0]]["Alias"].ToString();
         List <CreditCard> listCards = CreditCards.GetCardsByToken(alias,
                                                                   new List <CreditCardSource> {
             CreditCardSource.XWeb, CreditCardSource.XWebPortalLogin
         });
         if (listCards.Count == 0)
         {
             MsgBox.Show(this, "This credit card is no longer stored in the database. Return cannot be processed.");
             return;
         }
         if (listCards.Count > 1)
         {
             MsgBox.Show(this, "There is more than one card in the database with this token. Return cannot be processed due to the risk of charging the " +
                         "incorrect card.");
             return;
         }
         FormXWeb FormXW = new FormXWeb(patNum, listCards.FirstOrDefault(), XWebTransactionType.CreditReturnTransaction, createPayment: true);
         FormXW.LockCardInfo = true;
         if (FormXW.ShowDialog() == DialogResult.OK)
         {
             FillGrid();
         }
     }
     else
     {
         Payment payment = Payments.GetPayment(PIn.Long(_tableTrans.Rows[gridMain.SelectedIndices[0]]["PaymentNum"].ToString()));
         PayConnectResponseWeb pcResponseWeb = PayConnectResponseWebs.GetOne(PIn.Long(_tableTrans.Rows[gridMain.SelectedIndices[0]]["ResponseNum"].ToString()));
         decimal amt    = PIn.Decimal(_tableTrans.Rows[gridMain.SelectedIndices[0]]["Amount"].ToString());
         string  refNum = _tableTrans.Rows[gridMain.SelectedIndices[0]]["TransactionID"].ToString();              //This is actually PayConnectResponseWeb.RefNumber, it's just stored in the TransactionID column
         if (!PayConnectL.VoidOrRefundPayConnectPortalTransaction(pcResponseWeb, payment, PayConnectService.transType.RETURN, refNum, amt))
         {
             return;
         }
         MsgBox.Show("Return successful.");
         FillGrid();
     }
 }
Exemplo n.º 2
0
 private void voidPaymentToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (!Security.IsAuthorized(Permissions.PaymentCreate))
     {
         return;
     }
     if (gridMain.SelectedIndices.Length < 1 ||
         !MsgBox.Show(this, MsgBoxButtons.YesNo, "Void this payment?"))
     {
         return;
     }
     try {
         Cursor = Cursors.WaitCursor;
         if (IsXWebTransaction(gridMain.SelectedIndices[0]))
         {
             long   patNum      = PIn.Long(_tableTrans.Rows[gridMain.SelectedIndices[0]]["PatNum"].ToString());
             long   responseNum = PIn.Long(_tableTrans.Rows[gridMain.SelectedIndices[0]]["ResponseNum"].ToString());
             string payNote     = Lan.g(this, "Void XWeb payment made from within Open Dental") + "\r\n"
                                  + Lan.g(this, "Amount:") + " " + PIn.Double(_tableTrans.Rows[gridMain.SelectedIndices[0]]["Amount"].ToString()).ToString("f") + "\r\n"
                                  + Lan.g(this, "Transaction ID:") + " " + _tableTrans.Rows[gridMain.SelectedIndices[0]]["TransactionID"].ToString() + "\r\n"
                                  + Lan.g(this, "Card Number:") + " " + _tableTrans.Rows[gridMain.SelectedIndices[0]]["MaskedAcctNum"].ToString() + "\r\n"
                                  + Lan.g(this, "Processed:") + " " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString();
             XWebs.VoidPayment(patNum, payNote, responseNum);
         }
         else
         {
             Payment payment = Payments.GetPayment(PIn.Long(_tableTrans.Rows[gridMain.SelectedIndices[0]]["PaymentNum"].ToString()));
             PayConnectResponseWeb pcResponseWeb = PayConnectResponseWebs.GetOne(PIn.Long(_tableTrans.Rows[gridMain.SelectedIndices[0]]["ResponseNum"].ToString()));
             decimal amt    = PIn.Decimal(_tableTrans.Rows[gridMain.SelectedIndices[0]]["Amount"].ToString());
             string  refNum = _tableTrans.Rows[gridMain.SelectedIndices[0]]["TransactionID"].ToString();                  //This is actually PayConnectResponseWeb.RefNumber, it's just stored in the TransactionID column
             if (!PayConnectL.VoidOrRefundPayConnectPortalTransaction(pcResponseWeb, payment, PayConnectService.transType.VOID, refNum, amt))
             {
                 Cursor = Cursors.Default;
                 return;
             }
         }
         Cursor = Cursors.Default;
         MsgBox.Show(this, "Void successful");
         FillGrid();
     }
     catch (ODException ex) {
         Cursor = Cursors.Default;
         MessageBox.Show(ex.Message);
     }
 }