///<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>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()); }