Esempio n. 1
0
            ///<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);
            }
Esempio n. 2
0
        ///<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);
        }