コード例 #1
0
            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);
                }
            }
コード例 #2
0
ファイル: XWebs.cs プロジェクト: ChemBrain/OpenDental
        ///<summary>Creates and returns the EdgeExpress URL and validation OTK which can be used to make a payment for an unspecified credit card.
        ///</summary>
        public static XWebResponse GetEdgeExpressUrlForPayment(long patNum, string payNote, double amount, bool createAlias, CreditCardSource ccSource)
        {
            //No need to check RemotingRole;no call to db.
            if (ccSource != CreditCardSource.XWeb && ccSource != CreditCardSource.XWebPortalLogin)
            {
                throw new ODException("Invalid CreditCardSource: " + ccSource.ToString(), ODException.ErrorCodes.OtkArgsInvalid);
            }
            //Validate the amount.
            if (amount < 0.00 || amount > 99999.99)
            {
                throw new ODException("Invalid Amount", ODException.ErrorCodes.OtkArgsInvalid);
            }
            if (string.IsNullOrEmpty(payNote))
            {
                throw new ODException("Invalid PayNote", ODException.ErrorCodes.OtkArgsInvalid);
            }
            XWebResponse response = SendEdgeExpressRequest(patNum, EdgeExpressTransactionType.CreditSale, _edgeExpressHostPayUrl, amount,
                                                           doCreateAlias: createAlias);

            response.Amount   = amount;
            response.PayNote  = payNote;
            response.CCSource = ccSource;
            FinishEdgeExpressUrlRequest(response);
            return(response);
        }
コード例 #3
0
            ///<summary>Performs base XWebInputDTGForPayment behavior and creates PaymentWeb row.</summary>
            protected override void PostProcessOutput(XWebResponse response)
            {
                //Verify result and set response.PayNote.
                base.PostProcessOutput(response);
                response.Alias = _cc.XChargeToken;
                if (InsertPaymentOnApproval)                  //Insert Payment, PaySplit, and set FK.
                {
                    response.PaymentNum = Payments.InsertFromXWeb(
                        _patNum, _provNum, _clinicNum,
                        (InsertPositivePayment ? _amount : -_amount),
                        response.GetFormattedNote(InsertPositivePayment), "", CreditCardSource.XWeb);                      //todo: create a formatted receipt to show the web user after the payment has been accepted
                }
                //XWeb's Decline Minimizer will pass us back updated card information. Update our copy when necessary.
                bool update = false;

                if (_cc.CCExpiration != response.AccountExpirationDate)
                {
                    _cc.CCExpiration = response.AccountExpirationDate;
                    update           = true;
                }
                if (_cc.CCNumberMasked != response.MaskedAcctNum)
                {
                    _cc.CCNumberMasked = response.MaskedAcctNum;
                    update             = true;
                }
                if (update)
                {
                    CreditCards.Update(_cc);
                }
            }
コード例 #4
0
ファイル: XWebs.cs プロジェクト: ChemBrain/OpenDental
        ///<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);
        }
コード例 #5
0
ファイル: XWebs.cs プロジェクト: ChemBrain/OpenDental
        ///<summary>Converts the XML string result from the EdgeExpress API for a QueryPayment to an XWebResponse.</summary>
        private static XWebResponse ConvertEdgeExpressResponse(string result)
        {
            EdgeExpressResponse eeResponse;

            using (StringReader sr = new StringReader(result)) {
                //XWeb's xml references this class as RESULT but OD wants to deserialize to a class called EdgeExpressResponse.
                //We must explicitly specific the XmlRoot node name here to make that conversion.
                eeResponse = (EdgeExpressResponse) new XmlSerializer(typeof(EdgeExpressResponse), new XmlRootAttribute("RESULT")).Deserialize(sr);
            }
            XWebResponse xResponse = new XWebResponse {
                AccountExpirationDate = new DateTime(2000 + eeResponse.EXPYEAR, eeResponse.EXPMONTH, 1),
                Alias               = eeResponse.ALIAS,
                Amount              = (double)eeResponse.APPROVEDAMOUNT,
                ApprovalCode        = eeResponse.APPROVALCODE,
                BatchNum            = eeResponse.BATCHNO,
                CardBrand           = eeResponse.CARDBRAND,
                CardCodeResponse    = eeResponse.CARDCODERESPONSE,
                CardType            = eeResponse.CARDTYPE,
                MaskedAcctNum       = eeResponse.MASKEDCARDNUMBER,
                ProcessorResponse   = eeResponse.PROCESSORRESPONSE,
                ReceiptID           = eeResponse.RECEIPTID,
                ResponseCode        = eeResponse.RESPONSECODE,
                ResponseDescription = eeResponse.RESPONSEDESCRIPTION,
                TransactionID       = eeResponse.TRANSACTIONID,
                TransactionType     = eeResponse.TRANSACTIONTYPE,
                XWebResponseCode    = XWebResponse.ConvertResponseCode(eeResponse.RESPONSECODE),
            };

            return(xResponse);
        }
コード例 #6
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <XWebResponse> TableToList(DataTable table)
        {
            List <XWebResponse> retVal = new List <XWebResponse>();
            XWebResponse        xWebResponse;

            foreach (DataRow row in table.Rows)
            {
                xWebResponse = new XWebResponse();
                xWebResponse.XWebResponseNum   = PIn.Long(row["XWebResponseNum"].ToString());
                xWebResponse.PatNum            = PIn.Long(row["PatNum"].ToString());
                xWebResponse.ProvNum           = PIn.Long(row["ProvNum"].ToString());
                xWebResponse.ClinicNum         = PIn.Long(row["ClinicNum"].ToString());
                xWebResponse.PaymentNum        = PIn.Long(row["PaymentNum"].ToString());
                xWebResponse.DateTEntry        = PIn.DateT(row["DateTEntry"].ToString());
                xWebResponse.DateTUpdate       = PIn.DateT(row["DateTUpdate"].ToString());
                xWebResponse.TransactionStatus = (OpenDentBusiness.XWebTransactionStatus)PIn.Int(row["TransactionStatus"].ToString());
                xWebResponse.ResponseCode      = PIn.Int(row["ResponseCode"].ToString());
                string xWebResponseCode = row["XWebResponseCode"].ToString();
                if (xWebResponseCode == "")
                {
                    xWebResponse.XWebResponseCode = (OpenDentBusiness.XWebResponseCodes) 0;
                }
                else
                {
                    try{
                        xWebResponse.XWebResponseCode = (OpenDentBusiness.XWebResponseCodes)Enum.Parse(typeof(OpenDentBusiness.XWebResponseCodes), xWebResponseCode);
                    }
                    catch {
                        xWebResponse.XWebResponseCode = (OpenDentBusiness.XWebResponseCodes) 0;
                    }
                }
                xWebResponse.ResponseDescription = PIn.String(row["ResponseDescription"].ToString());
                xWebResponse.OTK                   = PIn.String(row["OTK"].ToString());
                xWebResponse.HpfUrl                = PIn.String(row["HpfUrl"].ToString());
                xWebResponse.HpfExpiration         = PIn.DateT(row["HpfExpiration"].ToString());
                xWebResponse.TransactionID         = PIn.String(row["TransactionID"].ToString());
                xWebResponse.TransactionType       = PIn.String(row["TransactionType"].ToString());
                xWebResponse.Alias                 = PIn.String(row["Alias"].ToString());
                xWebResponse.CardType              = PIn.String(row["CardType"].ToString());
                xWebResponse.CardBrand             = PIn.String(row["CardBrand"].ToString());
                xWebResponse.CardBrandShort        = PIn.String(row["CardBrandShort"].ToString());
                xWebResponse.MaskedAcctNum         = PIn.String(row["MaskedAcctNum"].ToString());
                xWebResponse.Amount                = PIn.Double(row["Amount"].ToString());
                xWebResponse.ApprovalCode          = PIn.String(row["ApprovalCode"].ToString());
                xWebResponse.CardCodeResponse      = PIn.String(row["CardCodeResponse"].ToString());
                xWebResponse.ReceiptID             = PIn.Int(row["ReceiptID"].ToString());
                xWebResponse.ExpDate               = PIn.String(row["ExpDate"].ToString());
                xWebResponse.EntryMethod           = PIn.String(row["EntryMethod"].ToString());
                xWebResponse.ProcessorResponse     = PIn.String(row["ProcessorResponse"].ToString());
                xWebResponse.BatchNum              = PIn.Int(row["BatchNum"].ToString());
                xWebResponse.BatchAmount           = PIn.Double(row["BatchAmount"].ToString());
                xWebResponse.AccountExpirationDate = PIn.Date(row["AccountExpirationDate"].ToString());
                xWebResponse.DebugError            = PIn.String(row["DebugError"].ToString());
                xWebResponse.PayNote               = PIn.String(row["PayNote"].ToString());
                xWebResponse.CCSource              = (OpenDentBusiness.CreditCardSource)PIn.Int(row["CCSource"].ToString());
                xWebResponse.OrderId               = PIn.String(row["OrderId"].ToString());
                retVal.Add(xWebResponse);
            }
            return(retVal);
        }
コード例 #7
0
ファイル: XWebResponseCrud.cs プロジェクト: royedwards/DRDNet
 ///<summary>Inserts one XWebResponse into the database.  Returns the new priKey.</summary>
 public static long Insert(XWebResponse xWebResponse)
 {
     if (DataConnection.DBtype == DatabaseType.Oracle)
     {
         xWebResponse.XWebResponseNum = DbHelper.GetNextOracleKey("xwebresponse", "XWebResponseNum");
         int loopcount = 0;
         while (loopcount < 100)
         {
             try {
                 return(Insert(xWebResponse, true));
             }
             catch (Oracle.ManagedDataAccess.Client.OracleException ex) {
                 if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated"))
                 {
                     xWebResponse.XWebResponseNum++;
                     loopcount++;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else
     {
         return(Insert(xWebResponse, false));
     }
 }
コード例 #8
0
 ///<summary>Adds amount to response.</summary>
 protected override void PostProcessOutput(XWebResponse response)
 {
     base.PostProcessOutput(response);
     response.Amount   = _amount;
     response.PayNote  = _payNote;
     response.CCSource = _ccSource;
 }
コード例 #9
0
        ///<summary>Updates one XWebResponse in the database.</summary>
        public static void Update(XWebResponse xWebResponse)
        {
            string command = "UPDATE xwebresponse SET "
                             + "PatNum               =  " + POut.Long(xWebResponse.PatNum) + ", "
                             + "ProvNum              =  " + POut.Long(xWebResponse.ProvNum) + ", "
                             + "ClinicNum            =  " + POut.Long(xWebResponse.ClinicNum) + ", "
                             + "PaymentNum           =  " + POut.Long(xWebResponse.PaymentNum) + ", "
                             //DateTEntry not allowed to change
                             + "DateTUpdate          =  " + POut.DateT(xWebResponse.DateTUpdate) + ", "
                             + "TransactionStatus    =  " + POut.Int((int)xWebResponse.TransactionStatus) + ", "
                             + "ResponseCode         =  " + POut.Int(xWebResponse.ResponseCode) + ", "
                             + "XWebResponseCode     = '" + POut.String(xWebResponse.XWebResponseCode.ToString()) + "', "
                             + "ResponseDescription  = '" + POut.String(xWebResponse.ResponseDescription) + "', "
                             + "OTK                  = '" + POut.String(xWebResponse.OTK) + "', "
                             + "HpfUrl               =  " + DbHelper.ParamChar + "paramHpfUrl, "
                             + "HpfExpiration        =  " + POut.DateT(xWebResponse.HpfExpiration) + ", "
                             + "TransactionID        = '" + POut.String(xWebResponse.TransactionID) + "', "
                             + "TransactionType      = '" + POut.String(xWebResponse.TransactionType) + "', "
                             + "Alias                = '" + POut.String(xWebResponse.Alias) + "', "
                             + "CardType             = '" + POut.String(xWebResponse.CardType) + "', "
                             + "CardBrand            = '" + POut.String(xWebResponse.CardBrand) + "', "
                             + "CardBrandShort       = '" + POut.String(xWebResponse.CardBrandShort) + "', "
                             + "MaskedAcctNum        = '" + POut.String(xWebResponse.MaskedAcctNum) + "', "
                             + "Amount               = '" + POut.Double(xWebResponse.Amount) + "', "
                             + "ApprovalCode         = '" + POut.String(xWebResponse.ApprovalCode) + "', "
                             + "CardCodeResponse     = '" + POut.String(xWebResponse.CardCodeResponse) + "', "
                             + "ReceiptID            =  " + POut.Int(xWebResponse.ReceiptID) + ", "
                             + "ExpDate              = '" + POut.String(xWebResponse.ExpDate) + "', "
                             + "EntryMethod          = '" + POut.String(xWebResponse.EntryMethod) + "', "
                             + "ProcessorResponse    = '" + POut.String(xWebResponse.ProcessorResponse) + "', "
                             + "BatchNum             =  " + POut.Int(xWebResponse.BatchNum) + ", "
                             + "BatchAmount          = '" + POut.Double(xWebResponse.BatchAmount) + "', "
                             + "AccountExpirationDate=  " + POut.Date(xWebResponse.AccountExpirationDate) + ", "
                             + "DebugError           =  " + DbHelper.ParamChar + "paramDebugError, "
                             + "PayNote              =  " + DbHelper.ParamChar + "paramPayNote, "
                             + "CCSource             =  " + POut.Int((int)xWebResponse.CCSource) + ", "
                             + "OrderId              = '" + POut.String(xWebResponse.OrderId) + "' "
                             + "WHERE XWebResponseNum = " + POut.Long(xWebResponse.XWebResponseNum);

            if (xWebResponse.HpfUrl == null)
            {
                xWebResponse.HpfUrl = "";
            }
            OdSqlParameter paramHpfUrl = new OdSqlParameter("paramHpfUrl", OdDbType.Text, POut.StringParam(xWebResponse.HpfUrl));

            if (xWebResponse.DebugError == null)
            {
                xWebResponse.DebugError = "";
            }
            OdSqlParameter paramDebugError = new OdSqlParameter("paramDebugError", OdDbType.Text, POut.StringParam(xWebResponse.DebugError));

            if (xWebResponse.PayNote == null)
            {
                xWebResponse.PayNote = "";
            }
            OdSqlParameter paramPayNote = new OdSqlParameter("paramPayNote", OdDbType.Text, POut.StringParam(xWebResponse.PayNote));

            Db.NonQ(command, paramHpfUrl, paramDebugError, paramPayNote);
        }
コード例 #10
0
ファイル: XWebs.cs プロジェクト: ChemBrain/OpenDental
        ///<summary>Creates and returns the EdgeExpress URL and validation OTK which can be used to create a credit card alias.</summary>
        public static XWebResponse GetEdgeExpressUrlForCreditCardAlias(long patNum)
        {
            //No need to check RemotingRole;no call to db.
            XWebResponse response = SendEdgeExpressRequest(patNum, EdgeExpressTransactionType.CreditAuth, _edgeExpressHostPayUrl, amount: 0, doCreateAlias: true);

            FinishEdgeExpressUrlRequest(response);
            return(response);
        }
コード例 #11
0
 ///<summary>Verifies approval and sets response.PatNote.</summary>
 protected override void PostProcessOutput(XWebResponse response)
 {
     if (response.XWebResponseCode != XWebResponseCodes.Approval && response.XWebResponseCode != XWebResponseCodes.AliasSuccess)
     {
         throw new ODException("DTG failed (" + response.ResponseCode.ToString() + "): " + response.ResponseDescription);
     }
     response.PayNote           = _payNote;
     response.TransactionStatus = ApprovalStatus;
 }
コード例 #12
0
 protected override void PostProcessOutput(XWebResponse response)
 {
     //Verify result and set response.PayNote.
     base.PostProcessOutput(response);
     //Insert Payment, PaySplit, and set FK.
     response.PaymentNum = Payments.InsertFromXWeb(
         _patNum, _provNum, _clinicNum,
         (_insertPositivePayment ? response.Amount : -response.Amount),
         response.GetFormattedNote(_insertPositivePayment), "", CreditCardSource.XWeb);
 }
コード例 #13
0
 ///<summary>Convert output (in xml) from the XWeb gateway to GatewayResponse.</summary>
 private static XWebResponse CreateGatewayResponse(string xml)
 {
     using (StringReader sr = new StringReader(xml)) {
         //XWeb's xml references this class as GatewayResponse but OD wants to deserialize to a class called XWebResponse.
         //We must explicitly specific the XmlRoot node name here to make that conversion.
         XWebResponse ret = (XWebResponse)(new XmlSerializer(typeof(XWebResponse), new XmlRootAttribute("GatewayResponse")).Deserialize(sr));
         //Convert int to XWebStatus.
         ret.XWebResponseCode      = XWebResponse.ConvertResponseCode(ret.ResponseCode);
         ret.AccountExpirationDate = XWebResponse.ConvertExpDate(ret.ExpDate);
         return(ret);
     }
 }
コード例 #14
0
ファイル: XWebs.cs プロジェクト: ChemBrain/OpenDental
            ///<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);
            }
コード例 #15
0
            ///<summary>Performs base XWebInputDTGForPayment behavior and deletes CreditCard row.</summary>
            protected override void PostProcessOutput(XWebResponse response)
            {
                //Verify result and set response.PayNote.
                base.PostProcessOutput(response);
                response.Alias = _cc.XChargeToken;
                try { response.PayNote = "Deleted CreditCard: " + JsonConvert.SerializeObject(_cc); } catch { }
                CreditCards.Delete(_cc.CreditCardNum);
                List <CreditCard> creditCards = CreditCards.Refresh(_patNum);

                for (int i = 0; i < creditCards.Count; i++)
                {
                    creditCards[i].ItemOrder = creditCards.Count - (i + 1);
                    CreditCards.Update(creditCards[i]);                    //Resets ItemOrder.
                }
            }
コード例 #16
0
ファイル: XWebResponseCrud.cs プロジェクト: royedwards/DRDNet
 ///<summary>Inserts one XWebResponse into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(XWebResponse xWebResponse)
 {
     if (DataConnection.DBtype == DatabaseType.MySql)
     {
         return(InsertNoCache(xWebResponse, false));
     }
     else
     {
         if (DataConnection.DBtype == DatabaseType.Oracle)
         {
             xWebResponse.XWebResponseNum = DbHelper.GetNextOracleKey("xwebresponse", "XWebResponseNum");                  //Cacheless method
         }
         return(InsertNoCache(xWebResponse, true));
     }
 }
コード例 #17
0
ファイル: XWebs.cs プロジェクト: ChemBrain/OpenDental
        ///<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);
        }
コード例 #18
0
ファイル: FormXWeb.cs プロジェクト: royedwards/DRDNet
        ///<summary>Processes the selected XWeb transaction. Returns true if the payment was successful, false otherwise.</summary>
        private bool ProcessSelectedTransaction()
        {
            double amount = PIn.Double(textAmount.Text);

            try {
                Cursor = Cursors.WaitCursor;
                if (_tranType == XWebTransactionType.CreditReturnTransaction)
                {
                    ResponseResult = XWebs.ReturnPayment(_creditCard.PatNum, textPayNote.Text, amount, _creditCard.CreditCardNum, _createPayment);
                }
            }
            catch (ODException ex) {
                Cursor = Cursors.Default;
                MessageBox.Show(ex.Message);
                return(false);
            }
            Cursor = Cursors.Default;
            return(true);
        }
コード例 #19
0
            ///<summary>Verifies OTK creation and creates HpfUrl.</summary>
            protected override void PostProcessOutput(XWebResponse response)
            {
                //Create a One Time Key (OTK) for the desired amount.
                if (response.XWebResponseCode != XWebResponseCodes.OtkSuccess)
                {
                    throw new ODException("OTK creation failed: " + response.ResponseDescription);
                }
                //Build the HPF URL that will be used by the browser.
                response.HpfUrl = _hpfUrlBase + "?otk=" + response.OTK;
                Dictionary <string, string> dictHpfParams = QueryStringArgs;

                foreach (KeyValuePair <string, string> param in dictHpfParams)
                {
                    response.HpfUrl += "&" + param.Key + "=" + param.Value;
                }
                //Get the status of the OTK we just created.
                XWebResponseCodes status = new XWebInputOtkStatus(_patNum, response.OTK, false).GenerateOutput().XWebResponseCode;

                if (status != XWebResponseCodes.Pending)                //Should be pending. If not, there is a problem.
                {
                    throw new ODException("New OTK status invalid: " + status.ToString());
                }
                response.HpfExpiration = DateTime.Now.Add(_formTimeout);
            }
コード例 #20
0
ファイル: XWebResponseCrud.cs プロジェクト: royedwards/DRDNet
        ///<summary>Inserts one XWebResponse into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
        public static long InsertNoCache(XWebResponse xWebResponse, bool useExistingPK)
        {
            bool   isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys);
            string command      = "INSERT INTO xwebresponse (";

            if (!useExistingPK && isRandomKeys)
            {
                xWebResponse.XWebResponseNum = ReplicationServers.GetKeyNoCache("xwebresponse", "XWebResponseNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "XWebResponseNum,";
            }
            command += "PatNum,ProvNum,ClinicNum,PaymentNum,DateTEntry,DateTUpdate,TransactionStatus,ResponseCode,XWebResponseCode,ResponseDescription,OTK,HpfUrl,HpfExpiration,TransactionID,TransactionType,Alias,CardType,CardBrand,CardBrandShort,MaskedAcctNum,Amount,ApprovalCode,CardCodeResponse,ReceiptID,ExpDate,EntryMethod,ProcessorResponse,BatchNum,BatchAmount,AccountExpirationDate,DebugError,PayNote,CCSource) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(xWebResponse.XWebResponseNum) + ",";
            }
            command +=
                POut.Long(xWebResponse.PatNum) + ","
                + POut.Long(xWebResponse.ProvNum) + ","
                + POut.Long(xWebResponse.ClinicNum) + ","
                + POut.Long(xWebResponse.PaymentNum) + ","
                + DbHelper.Now() + ","
                + POut.DateT(xWebResponse.DateTUpdate) + ","
                + POut.Int((int)xWebResponse.TransactionStatus) + ","
                + POut.Int(xWebResponse.ResponseCode) + ","
                + "'" + POut.String(xWebResponse.XWebResponseCode.ToString()) + "',"
                + "'" + POut.String(xWebResponse.ResponseDescription) + "',"
                + "'" + POut.String(xWebResponse.OTK) + "',"
                + DbHelper.ParamChar + "paramHpfUrl,"
                + POut.DateT(xWebResponse.HpfExpiration) + ","
                + "'" + POut.String(xWebResponse.TransactionID) + "',"
                + "'" + POut.String(xWebResponse.TransactionType) + "',"
                + "'" + POut.String(xWebResponse.Alias) + "',"
                + "'" + POut.String(xWebResponse.CardType) + "',"
                + "'" + POut.String(xWebResponse.CardBrand) + "',"
                + "'" + POut.String(xWebResponse.CardBrandShort) + "',"
                + "'" + POut.String(xWebResponse.MaskedAcctNum) + "',"
                + "'" + POut.Double(xWebResponse.Amount) + "',"
                + "'" + POut.String(xWebResponse.ApprovalCode) + "',"
                + "'" + POut.String(xWebResponse.CardCodeResponse) + "',"
                + POut.Int(xWebResponse.ReceiptID) + ","
                + "'" + POut.String(xWebResponse.ExpDate) + "',"
                + "'" + POut.String(xWebResponse.EntryMethod) + "',"
                + "'" + POut.String(xWebResponse.ProcessorResponse) + "',"
                + POut.Int(xWebResponse.BatchNum) + ","
                + "'" + POut.Double(xWebResponse.BatchAmount) + "',"
                + POut.Date(xWebResponse.AccountExpirationDate) + ","
                + DbHelper.ParamChar + "paramDebugError,"
                + DbHelper.ParamChar + "paramPayNote,"
                + POut.Int((int)xWebResponse.CCSource) + ")";
            if (xWebResponse.HpfUrl == null)
            {
                xWebResponse.HpfUrl = "";
            }
            OdSqlParameter paramHpfUrl = new OdSqlParameter("paramHpfUrl", OdDbType.Text, POut.StringParam(xWebResponse.HpfUrl));

            if (xWebResponse.DebugError == null)
            {
                xWebResponse.DebugError = "";
            }
            OdSqlParameter paramDebugError = new OdSqlParameter("paramDebugError", OdDbType.Text, POut.StringParam(xWebResponse.DebugError));

            if (xWebResponse.PayNote == null)
            {
                xWebResponse.PayNote = "";
            }
            OdSqlParameter paramPayNote = new OdSqlParameter("paramPayNote", OdDbType.Text, POut.StringParam(xWebResponse.PayNote));

            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command, paramHpfUrl, paramDebugError, paramPayNote);
            }
            else
            {
                xWebResponse.XWebResponseNum = Db.NonQ(command, true, "XWebResponseNum", "xWebResponse", paramHpfUrl, paramDebugError, paramPayNote);
            }
            return(xWebResponse.XWebResponseNum);
        }
コード例 #21
0
ファイル: XWebs.cs プロジェクト: ChemBrain/OpenDental
 ///<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());
 }
コード例 #22
0
 ///<summary>Inserts one XWebResponse into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(XWebResponse xWebResponse)
 {
     return(InsertNoCache(xWebResponse, false));
 }
コード例 #23
0
ファイル: XWebResponseCrud.cs プロジェクト: royedwards/DRDNet
        ///<summary>Updates one XWebResponse in the database.  Uses an old object to compare to, and only alters changed fields.  This prevents collisions and concurrency problems in heavily used tables.  Returns true if an update occurred.</summary>
        public static bool Update(XWebResponse xWebResponse, XWebResponse oldXWebResponse)
        {
            string command = "";

            if (xWebResponse.PatNum != oldXWebResponse.PatNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "PatNum = " + POut.Long(xWebResponse.PatNum) + "";
            }
            if (xWebResponse.ProvNum != oldXWebResponse.ProvNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ProvNum = " + POut.Long(xWebResponse.ProvNum) + "";
            }
            if (xWebResponse.ClinicNum != oldXWebResponse.ClinicNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ClinicNum = " + POut.Long(xWebResponse.ClinicNum) + "";
            }
            if (xWebResponse.PaymentNum != oldXWebResponse.PaymentNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "PaymentNum = " + POut.Long(xWebResponse.PaymentNum) + "";
            }
            //DateTEntry not allowed to change
            if (xWebResponse.DateTUpdate != oldXWebResponse.DateTUpdate)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "DateTUpdate = " + POut.DateT(xWebResponse.DateTUpdate) + "";
            }
            if (xWebResponse.TransactionStatus != oldXWebResponse.TransactionStatus)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "TransactionStatus = " + POut.Int((int)xWebResponse.TransactionStatus) + "";
            }
            if (xWebResponse.ResponseCode != oldXWebResponse.ResponseCode)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ResponseCode = " + POut.Int(xWebResponse.ResponseCode) + "";
            }
            if (xWebResponse.XWebResponseCode != oldXWebResponse.XWebResponseCode)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "XWebResponseCode = '" + POut.String(xWebResponse.XWebResponseCode.ToString()) + "'";
            }
            if (xWebResponse.ResponseDescription != oldXWebResponse.ResponseDescription)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ResponseDescription = '" + POut.String(xWebResponse.ResponseDescription) + "'";
            }
            if (xWebResponse.OTK != oldXWebResponse.OTK)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "OTK = '" + POut.String(xWebResponse.OTK) + "'";
            }
            if (xWebResponse.HpfUrl != oldXWebResponse.HpfUrl)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "HpfUrl = " + DbHelper.ParamChar + "paramHpfUrl";
            }
            if (xWebResponse.HpfExpiration != oldXWebResponse.HpfExpiration)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "HpfExpiration = " + POut.DateT(xWebResponse.HpfExpiration) + "";
            }
            if (xWebResponse.TransactionID != oldXWebResponse.TransactionID)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "TransactionID = '" + POut.String(xWebResponse.TransactionID) + "'";
            }
            if (xWebResponse.TransactionType != oldXWebResponse.TransactionType)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "TransactionType = '" + POut.String(xWebResponse.TransactionType) + "'";
            }
            if (xWebResponse.Alias != oldXWebResponse.Alias)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "Alias = '" + POut.String(xWebResponse.Alias) + "'";
            }
            if (xWebResponse.CardType != oldXWebResponse.CardType)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "CardType = '" + POut.String(xWebResponse.CardType) + "'";
            }
            if (xWebResponse.CardBrand != oldXWebResponse.CardBrand)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "CardBrand = '" + POut.String(xWebResponse.CardBrand) + "'";
            }
            if (xWebResponse.CardBrandShort != oldXWebResponse.CardBrandShort)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "CardBrandShort = '" + POut.String(xWebResponse.CardBrandShort) + "'";
            }
            if (xWebResponse.MaskedAcctNum != oldXWebResponse.MaskedAcctNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "MaskedAcctNum = '" + POut.String(xWebResponse.MaskedAcctNum) + "'";
            }
            if (xWebResponse.Amount != oldXWebResponse.Amount)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "Amount = '" + POut.Double(xWebResponse.Amount) + "'";
            }
            if (xWebResponse.ApprovalCode != oldXWebResponse.ApprovalCode)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ApprovalCode = '" + POut.String(xWebResponse.ApprovalCode) + "'";
            }
            if (xWebResponse.CardCodeResponse != oldXWebResponse.CardCodeResponse)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "CardCodeResponse = '" + POut.String(xWebResponse.CardCodeResponse) + "'";
            }
            if (xWebResponse.ReceiptID != oldXWebResponse.ReceiptID)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ReceiptID = " + POut.Int(xWebResponse.ReceiptID) + "";
            }
            if (xWebResponse.ExpDate != oldXWebResponse.ExpDate)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ExpDate = '" + POut.String(xWebResponse.ExpDate) + "'";
            }
            if (xWebResponse.EntryMethod != oldXWebResponse.EntryMethod)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "EntryMethod = '" + POut.String(xWebResponse.EntryMethod) + "'";
            }
            if (xWebResponse.ProcessorResponse != oldXWebResponse.ProcessorResponse)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ProcessorResponse = '" + POut.String(xWebResponse.ProcessorResponse) + "'";
            }
            if (xWebResponse.BatchNum != oldXWebResponse.BatchNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "BatchNum = " + POut.Int(xWebResponse.BatchNum) + "";
            }
            if (xWebResponse.BatchAmount != oldXWebResponse.BatchAmount)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "BatchAmount = '" + POut.Double(xWebResponse.BatchAmount) + "'";
            }
            if (xWebResponse.AccountExpirationDate.Date != oldXWebResponse.AccountExpirationDate.Date)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "AccountExpirationDate = " + POut.Date(xWebResponse.AccountExpirationDate) + "";
            }
            if (xWebResponse.DebugError != oldXWebResponse.DebugError)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "DebugError = " + DbHelper.ParamChar + "paramDebugError";
            }
            if (xWebResponse.PayNote != oldXWebResponse.PayNote)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "PayNote = " + DbHelper.ParamChar + "paramPayNote";
            }
            if (xWebResponse.CCSource != oldXWebResponse.CCSource)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "CCSource = " + POut.Int((int)xWebResponse.CCSource) + "";
            }
            if (command == "")
            {
                return(false);
            }
            if (xWebResponse.HpfUrl == null)
            {
                xWebResponse.HpfUrl = "";
            }
            OdSqlParameter paramHpfUrl = new OdSqlParameter("paramHpfUrl", OdDbType.Text, POut.StringParam(xWebResponse.HpfUrl));

            if (xWebResponse.DebugError == null)
            {
                xWebResponse.DebugError = "";
            }
            OdSqlParameter paramDebugError = new OdSqlParameter("paramDebugError", OdDbType.Text, POut.StringParam(xWebResponse.DebugError));

            if (xWebResponse.PayNote == null)
            {
                xWebResponse.PayNote = "";
            }
            OdSqlParameter paramPayNote = new OdSqlParameter("paramPayNote", OdDbType.Text, POut.StringParam(xWebResponse.PayNote));

            command = "UPDATE xwebresponse SET " + command
                      + " WHERE XWebResponseNum = " + POut.Long(xWebResponse.XWebResponseNum);
            Db.NonQ(command, paramHpfUrl, paramDebugError, paramPayNote);
            return(true);
        }
コード例 #24
0
ファイル: XWebResponseCrud.cs プロジェクト: royedwards/DRDNet
 ///<summary>Returns true if Update(XWebResponse,XWebResponse) would make changes to the database.
 ///Does not make any changes to the database and can be called before remoting role is checked.</summary>
 public static bool UpdateComparison(XWebResponse xWebResponse, XWebResponse oldXWebResponse)
 {
     if (xWebResponse.PatNum != oldXWebResponse.PatNum)
     {
         return(true);
     }
     if (xWebResponse.ProvNum != oldXWebResponse.ProvNum)
     {
         return(true);
     }
     if (xWebResponse.ClinicNum != oldXWebResponse.ClinicNum)
     {
         return(true);
     }
     if (xWebResponse.PaymentNum != oldXWebResponse.PaymentNum)
     {
         return(true);
     }
     //DateTEntry not allowed to change
     if (xWebResponse.DateTUpdate != oldXWebResponse.DateTUpdate)
     {
         return(true);
     }
     if (xWebResponse.TransactionStatus != oldXWebResponse.TransactionStatus)
     {
         return(true);
     }
     if (xWebResponse.ResponseCode != oldXWebResponse.ResponseCode)
     {
         return(true);
     }
     if (xWebResponse.XWebResponseCode != oldXWebResponse.XWebResponseCode)
     {
         return(true);
     }
     if (xWebResponse.ResponseDescription != oldXWebResponse.ResponseDescription)
     {
         return(true);
     }
     if (xWebResponse.OTK != oldXWebResponse.OTK)
     {
         return(true);
     }
     if (xWebResponse.HpfUrl != oldXWebResponse.HpfUrl)
     {
         return(true);
     }
     if (xWebResponse.HpfExpiration != oldXWebResponse.HpfExpiration)
     {
         return(true);
     }
     if (xWebResponse.TransactionID != oldXWebResponse.TransactionID)
     {
         return(true);
     }
     if (xWebResponse.TransactionType != oldXWebResponse.TransactionType)
     {
         return(true);
     }
     if (xWebResponse.Alias != oldXWebResponse.Alias)
     {
         return(true);
     }
     if (xWebResponse.CardType != oldXWebResponse.CardType)
     {
         return(true);
     }
     if (xWebResponse.CardBrand != oldXWebResponse.CardBrand)
     {
         return(true);
     }
     if (xWebResponse.CardBrandShort != oldXWebResponse.CardBrandShort)
     {
         return(true);
     }
     if (xWebResponse.MaskedAcctNum != oldXWebResponse.MaskedAcctNum)
     {
         return(true);
     }
     if (xWebResponse.Amount != oldXWebResponse.Amount)
     {
         return(true);
     }
     if (xWebResponse.ApprovalCode != oldXWebResponse.ApprovalCode)
     {
         return(true);
     }
     if (xWebResponse.CardCodeResponse != oldXWebResponse.CardCodeResponse)
     {
         return(true);
     }
     if (xWebResponse.ReceiptID != oldXWebResponse.ReceiptID)
     {
         return(true);
     }
     if (xWebResponse.ExpDate != oldXWebResponse.ExpDate)
     {
         return(true);
     }
     if (xWebResponse.EntryMethod != oldXWebResponse.EntryMethod)
     {
         return(true);
     }
     if (xWebResponse.ProcessorResponse != oldXWebResponse.ProcessorResponse)
     {
         return(true);
     }
     if (xWebResponse.BatchNum != oldXWebResponse.BatchNum)
     {
         return(true);
     }
     if (xWebResponse.BatchAmount != oldXWebResponse.BatchAmount)
     {
         return(true);
     }
     if (xWebResponse.AccountExpirationDate.Date != oldXWebResponse.AccountExpirationDate.Date)
     {
         return(true);
     }
     if (xWebResponse.DebugError != oldXWebResponse.DebugError)
     {
         return(true);
     }
     if (xWebResponse.PayNote != oldXWebResponse.PayNote)
     {
         return(true);
     }
     if (xWebResponse.CCSource != oldXWebResponse.CCSource)
     {
         return(true);
     }
     return(false);
 }
コード例 #25
0
 ///<summary>Once XWeb Gateway response had been generated, the inheritor of this class may process it and add it to by overriding this method.</summary>
 protected abstract void PostProcessOutput(XWebResponse response);
コード例 #26
0
 ///<summary>No special processing for XWebInputOtkStatus.</summary>
 protected override void PostProcessOutput(XWebResponse response)
 {
 }