public XWebInputDTGPaymentVoid(long patNum, string payNote, long xWebResponseNum) : base(XWebTransactionType.CreditVoidTransaction, patNum, payNote) { XWebResponse xwr = XWebResponses.GetOne(xWebResponseNum); if (xwr == null) { throw new ODException("XWebResponseNum not found: " + xWebResponseNum.ToString(), ODException.ErrorCodes.OtkArgsInvalid); } if (xwr.PatNum != _patNum) { throw new ODException("XWebResponse does not belong to this patient. XWebResponseNum: " + xWebResponseNum.ToString() + " - PatNum: " + _patNum.ToString() + ".", ODException.ErrorCodes.OtkArgsInvalid); } //We currently only support CreditSaleTransaction and CreditReturnTransaction. switch (xwr.XTransactionType) { case XWebTransactionType.CreditSaleTransaction: _insertPositivePayment = false; break; case XWebTransactionType.CreditReturnTransaction: _insertPositivePayment = true; break; default: throw new ODException("Voiding invalid transaction type: " + xwr.TransactionType, ODException.ErrorCodes.OtkArgsInvalid); } _transactionID = xwr.TransactionID; if (string.IsNullOrEmpty(_transactionID)) { throw new ODException("Invalid TransactionID", ODException.ErrorCodes.OtkArgsInvalid); } }
///<summary>Interface the XWeb Gateway and return an instance of XWebResponse. Goes to db and/or cache to get patient info and ProgramProperties for XWeb.</summary> public XWebResponse GenerateOutput() { Patient pat = OpenDentBusiness.Patients.GetPat(_patNum); if (pat == null) { throw new ODException("Patient not found for PatNum: " + _patNum.ToString(), ODException.ErrorCodes.XWebProgramProperties); } _patNum = pat.PatNum; _provNum = pat.PriProv; //Explicitly set ClinicNum=0, since a pat's ClinicNum will remain set if the user enabled clinics, assigned patients to clinics, and then //disabled clinics because we use the ClinicNum to determine which PayConnect or XCharge/XWeb credentials to use for payments. _clinicNum = 0; if (PrefC.HasClinicsEnabled) { _clinicNum = pat.ClinicNum; } if (!OpenDentBusiness.PrefC.HasClinicsEnabled) //Patient.ClinicNum is unreliable if clinics have been turned off. { _clinicNum = 0; } OpenDentBusiness.WebTypes.Shared.XWeb.WebPaymentProperties xwebProperties; ProgramProperties.GetXWebCreds(_clinicNum, out xwebProperties); if (ChargeSource == ChargeSource.PatientPortal && !xwebProperties.IsPaymentsAllowed) { throw new ODException("Clinic or Practice has online payments disabled", ODException.ErrorCodes.XWebProgramProperties); } _xWebID = xwebProperties.XWebID; _authKey = xwebProperties.AuthKey; _terminalID = xwebProperties.TerminalID; XWebResponse response = CreateGatewayResponse(UploadData(GatewayInput, _gatewayUrl)); response.PatNum = _patNum; response.ProvNum = _provNum; response.ClinicNum = _clinicNum; response.DateTUpdate = DateTime.Now; response.TransactionType = _transactionType.ToString(); response.TransactionStatus = XWebTransactionStatus.HpfPending; PostProcessOutput(response); if (InsertResponseIntoDb) { XWebResponses.Insert(response); } if (WakeupMonitorThread) { OnWakeupMonitor(response, new EventArgs()); } return(response); }
///<summary>Sends a web request to the XWeb EdgeExpress API.</summary> private static XWebResponse SendEdgeExpressRequest(long patNum, EdgeExpressTransactionType edgeExpressTransactionType, string url, double amount = 0, string orderId = "", bool doCreateAlias = false) { Patient pat = Patients.GetPat(patNum); if (pat == null) { throw new ODException("Patient not found for PatNum: " + patNum.ToString(), ODException.ErrorCodes.XWebProgramProperties); } long clinicNum = 0; if (PrefC.HasClinicsEnabled) { clinicNum = pat.ClinicNum; } ProgramProperties.GetXWebCreds(clinicNum, out WebPaymentProperties xwebProperties); if (!xwebProperties.IsPaymentsAllowed) { throw new ODException("Clinic or Practice has online payments disabled", ODException.ErrorCodes.XWebProgramProperties); } orderId = string.IsNullOrEmpty(orderId) ? XWebResponses.CreateOrderId() : orderId; StringBuilder strBldXml = new StringBuilder(); using (XmlWriter xmlWriter = XmlWriter.Create(strBldXml)) { xmlWriter.WriteStartElement("REQUEST"); xmlWriter.WriteElementString("XWEBID", xwebProperties.XWebID); xmlWriter.WriteElementString("XWEBTERMINALID", xwebProperties.TerminalID); xmlWriter.WriteElementString("XWEBAUTHKEY", xwebProperties.AuthKey); xmlWriter.WriteElementString("TRANSACTIONTYPE", edgeExpressTransactionType.ToString().ToUpper()); xmlWriter.WriteElementString("ORDERID", orderId); AddOtherEdgeExpressParams(xmlWriter, edgeExpressTransactionType, doCreateAlias, amount, pat); xmlWriter.WriteEndElement(); //REQUEST } string result = XWebInputAbs.UploadData(strBldXml.ToString(), url); XWebResponse xResponse = CreateEdgeExpressXWebResponse(result, edgeExpressTransactionType); xResponse.OrderId = orderId; xResponse.PatNum = patNum; xResponse.ProvNum = pat.PriProv; xResponse.ClinicNum = clinicNum; xResponse.DateTUpdate = DateTime.Now; xResponse.TransactionType = edgeExpressTransactionType.ToString(); OnWakeupMonitor(xResponse, new EventArgs()); return(xResponse); }
///<summary>Inserts the response to the db and wakes up the monitor thread.</summary> private static void FinishEdgeExpressUrlRequest(XWebResponse response) { response.HpfExpiration = DateTime.Now.Add(_formTimeout); XWebResponses.Insert(response); OnWakeupMonitor(response, new EventArgs()); }
private void FillGrid() { List <long> listClinicNums = new List <long>(); if (PrefC.HasClinicsEnabled && comboClinic.SelectedIndex != 0) //Not 'All' selected { if (Security.CurUser.ClinicIsRestricted) { listClinicNums.Add(_listClinics[comboClinic.SelectedIndex - 1].ClinicNum); //Minus 1 for 'All' } else { if (comboClinic.SelectedIndex == 1) //'Unassigned' selected { listClinicNums.Add(0); } else if (comboClinic.SelectedIndex > 1) { listClinicNums.Add(_listClinics[comboClinic.SelectedIndex - 2].ClinicNum); //Minus 2 for 'All' and 'Unassigned' } } } else { //Send an empty list of clinics to get all transactions } DateTime dateFrom = PIn.Date(textDateFrom.Text); DateTime dateTo = PIn.Date(textDateTo.Text); _tableTrans = XWebResponses.GetApprovedTransactions(listClinicNums, dateFrom, dateTo); gridMain.BeginUpdate(); gridMain.Columns.Clear(); ODGridColumn col; col = new ODGridColumn(Lan.g(this, "Patient"), 120); gridMain.Columns.Add(col); col = new ODGridColumn(Lan.g(this, "Amount"), 60, HorizontalAlignment.Right); gridMain.Columns.Add(col); col = new ODGridColumn(Lan.g(this, "Date"), 80); gridMain.Columns.Add(col); col = new ODGridColumn(Lan.g(this, "Tran Type"), 80); gridMain.Columns.Add(col); col = new ODGridColumn(Lan.g(this, "Card Number"), 140); gridMain.Columns.Add(col); col = new ODGridColumn(Lan.g(this, "Expiration"), 70); gridMain.Columns.Add(col); if (PrefC.HasClinicsEnabled) { col = new ODGridColumn(Lan.g(this, "Clinic"), 100); gridMain.Columns.Add(col); } col = new ODGridColumn(Lan.g(this, "Transaction ID"), 110); gridMain.Columns.Add(col); gridMain.Rows.Clear(); ODGridRow row; for (int i = 0; i < _tableTrans.Rows.Count; i++) { row = new ODGridRow(); row.Cells.Add(_tableTrans.Rows[i]["Patient"].ToString()); row.Cells.Add(PIn.Double(_tableTrans.Rows[i]["Amount"].ToString()).ToString("f")); row.Cells.Add(PIn.Date(_tableTrans.Rows[i]["DateTUpdate"].ToString()).ToShortDateString()); XWebTransactionStatus tranStatus = (XWebTransactionStatus)PIn.Int(_tableTrans.Rows[i]["TransactionStatus"].ToString()); string tranStatusStr; switch (tranStatus) { case XWebTransactionStatus.DtgPaymentApproved: case XWebTransactionStatus.HpfCompletePaymentApproved: case XWebTransactionStatus.HpfCompletePaymentApprovedPartial: tranStatusStr = "Sale"; break; case XWebTransactionStatus.DtgPaymentReturned: tranStatusStr = "Return"; break; case XWebTransactionStatus.DtgPaymentVoided: tranStatusStr = "Void"; break; default: //These other values should not be returned from the query. tranStatusStr = tranStatus.ToString(); break; } row.Cells.Add(tranStatusStr); row.Cells.Add(_tableTrans.Rows[i]["MaskedAcctNum"].ToString()); string expiration = _tableTrans.Rows[i]["ExpDate"].ToString(); if (expiration.Length > 2) { expiration = expiration.Substring(0, 2) + "/" + expiration.Substring(2); } row.Cells.Add(expiration); if (PrefC.HasClinicsEnabled) { row.Cells.Add(_tableTrans.Rows[i]["Clinic"].ToString()); } row.Cells.Add(_tableTrans.Rows[i]["TransactionID"].ToString()); gridMain.Rows.Add(row); } gridMain.EndUpdate(); }
private void FillGrid() { List <long> listClinicNums = new List <long>(); if (PrefC.HasClinicsEnabled && comboClinic.SelectedIndex != 0) //Not 'All' selected { if (Security.CurUser.ClinicIsRestricted) { listClinicNums.Add(_listClinics[comboClinic.SelectedIndex - 1].ClinicNum); //Minus 1 for 'All' } else { if (comboClinic.SelectedIndex == 1) //'Unassigned' selected { listClinicNums.Add(0); } else if (comboClinic.SelectedIndex > 1) { listClinicNums.Add(_listClinics[comboClinic.SelectedIndex - 2].ClinicNum); //Minus 2 for 'All' and 'Unassigned' } } } else { //Send an empty list of clinics to get all transactions } DateTime dateFrom = PIn.Date(textDateFrom.Text); DateTime dateTo = PIn.Date(textDateTo.Text); _tableTrans = XWebResponses.GetApprovedTransactions(listClinicNums, dateFrom, dateTo); gridMain.BeginUpdate(); gridMain.ListGridColumns.Clear(); GridColumn col; col = new GridColumn(Lan.g(this, "Patient"), 120); gridMain.ListGridColumns.Add(col); col = new GridColumn(Lan.g(this, "Amount"), 60, HorizontalAlignment.Right); gridMain.ListGridColumns.Add(col); col = new GridColumn(Lan.g(this, "Date"), 80); gridMain.ListGridColumns.Add(col); col = new GridColumn(Lan.g(this, "Tran Type"), 80); gridMain.ListGridColumns.Add(col); col = new GridColumn(Lan.g(this, "Card Number"), 140); gridMain.ListGridColumns.Add(col); col = new GridColumn(Lan.g(this, "Expiration"), 70); gridMain.ListGridColumns.Add(col); if (PrefC.HasClinicsEnabled) { col = new GridColumn(Lan.g(this, "Clinic"), 100); gridMain.ListGridColumns.Add(col); } col = new GridColumn(Lan.g(this, "Transaction ID"), 110); gridMain.ListGridColumns.Add(col); gridMain.ListGridRows.Clear(); GridRow row; for (int i = 0; i < _tableTrans.Rows.Count; i++) { bool isXWeb = IsXWebTransaction(i); //Only other option at the moment is PayConnect. This will need to be refactored if we add more payment options row = new GridRow(); row.Cells.Add(_tableTrans.Rows[i]["Patient"].ToString()); row.Cells.Add(PIn.Double(_tableTrans.Rows[i]["Amount"].ToString()).ToString("f")); row.Cells.Add(PIn.Date(_tableTrans.Rows[i]["DateTUpdate"].ToString()).ToShortDateString()); if (isXWeb) { XWebTransactionStatus tranStatus = (XWebTransactionStatus)PIn.Int(_tableTrans.Rows[i]["TransactionStatus"].ToString()); row.Cells.Add(GetXWebTranTypeByStatus(tranStatus)); } else { //This is actually the PayConnectResponseWeb.TransType row.Cells.Add(_tableTrans.Rows[i]["TransactionStatus"].ToString()); } row.Cells.Add(_tableTrans.Rows[i]["MaskedAcctNum"].ToString()); row.Cells.Add(_tableTrans.Rows[i]["ExpDate"].ToString()); if (PrefC.HasClinicsEnabled) { row.Cells.Add(_tableTrans.Rows[i]["Clinic"].ToString()); } row.Cells.Add(_tableTrans.Rows[i]["TransactionID"].ToString()); gridMain.ListGridRows.Add(row); } gridMain.EndUpdate(); }