Ejemplo n.º 1
0
        ///<summary>Converts the XML string result from the EdgeExpress API to an XWebResponse.</summary>
        private static XWebResponse CreateEdgeExpressXWebResponse(string result, EdgeExpressTransactionType edgeExpressTransactionType)
        {
            XWebResponse xResponse = new XWebResponse();

            if (edgeExpressTransactionType.In(EdgeExpressTransactionType.CreditSale, EdgeExpressTransactionType.CreditAuth))
            {
                xResponse.OTK               = WebSerializer.DeserializeNode(result, "SESSIONTOKEN");
                xResponse.HpfUrl            = WebSerializer.DeserializeNode(result, "PAYPAGEURL");
                xResponse.TransactionStatus = XWebTransactionStatus.EdgeExpressPending;
            }
            if (edgeExpressTransactionType == EdgeExpressTransactionType.QueryPayment)
            {
                string            responseCode     = WebSerializer.DeserializeNode(result, "RESPONSECODE");
                XWebResponseCodes responseCodeEnum = PIn.Enum <XWebResponseCodes>(PIn.Int(responseCode, hasExceptions: false), XWebResponseCodes.Undefined);
                if (responseCodeEnum == XWebResponseCodes.InvalidReferenceError)
                {
                    //XWeb gives this code before the patient completes the transaction. They also give this code when the OrderId doesn't exist.
                    xResponse.XWebResponseCode = XWebResponseCodes.Pending;
                }
                else
                {
                    xResponse = ConvertEdgeExpressResponse(result);
                }
            }
            return(xResponse);
        }
Ejemplo n.º 2
0
 ///<summary>Adds additional parameters to the specified transaction type.</summary>
 private static void AddOtherEdgeExpressParams(XmlWriter xmlWriter, EdgeExpressTransactionType edgeExpressTransactionType, bool doCreateAlias,
                                               double amount, Patient pat)
 {
     if (edgeExpressTransactionType.In(EdgeExpressTransactionType.CreditSale, EdgeExpressTransactionType.CreditAuth))
     {
         xmlWriter.WriteElementString("AMOUNT", amount.ToString());
         xmlWriter.WriteElementString("CUSTOMERNAME", pat.GetNameFLnoPref());
         if (doCreateAlias)
         {
             xmlWriter.WriteElementString("CREATEALIAS", "true");
         }
         xmlWriter.WriteStartElement("HOSTPAYSETTING");
         xmlWriter.WriteStartElement("POSDEVICE");
         xmlWriter.WriteElementString("TYPE", "KEYED");
         xmlWriter.WriteEndElement();                //POSDEVICE
         xmlWriter.WriteStartElement("RETURNOPTION");
         if (ODBuild.IsDebug())
         {
             xmlWriter.WriteElementString("RETURNURL", "http://localhost/OpenDentalWebLander/PortalPayDone.aspx");
         }
         else
         {
             xmlWriter.WriteElementString("RETURNURL", "https://www.patientviewer.com/PortalPayDone.aspx");
         }
         xmlWriter.WriteElementString("RETURNTARGET", "_self");   //without this line, the top level window will be redirected to RETURNURL
         xmlWriter.WriteEndElement();                             //RETURNOPTION
         xmlWriter.WriteElementString("DISABLEFRAMING", "false"); //allows us to put the page in an iframe.
         xmlWriter.WriteStartElement("CUSTOMIZATION");
         xmlWriter.WriteStartElement("PAGE");
         xmlWriter.WriteStartElement("BILLINGFIRSTNAME");
         xmlWriter.WriteElementString("VISIBLE", "false"); //They've already entered their name
         xmlWriter.WriteEndElement();                      //BILLINGFIRSTNAME
         xmlWriter.WriteStartElement("BILLINGMIDDLENAME");
         xmlWriter.WriteElementString("VISIBLE", "false"); //They've already entered their name
         xmlWriter.WriteEndElement();                      //BILLINGMIDDLENAME
         xmlWriter.WriteStartElement("BILLINGLASTNAME");
         xmlWriter.WriteElementString("VISIBLE", "false"); //They've already entered their name
         xmlWriter.WriteEndElement();                      //BILLINGLASTNAME
         xmlWriter.WriteStartElement("BILLINGCOMPANY");
         xmlWriter.WriteElementString("VISIBLE", "false");
         xmlWriter.WriteEndElement();                //BILLINGCOMPANY
         xmlWriter.WriteStartElement("BILLINGCUSTOMERTITLE");
         xmlWriter.WriteElementString("VISIBLE", "false");
         xmlWriter.WriteEndElement();                //BILLINGCUSTOMERTITLE
         xmlWriter.WriteEndElement();                //PAGE
         xmlWriter.WriteEndElement();                //CUSTOMIZATION
         xmlWriter.WriteEndElement();                //HOSTPAYSETTING
     }
 }
Ejemplo n.º 3
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);
        }