/// <summary>
        /// GiveX batch Close
        /// </summary>
        /// <param name="saleNum">Sale number</param>
        /// <param name="cashoutId">Cash out id</param>
        /// <param name="report">Report</param>
        /// <param name="userCode">User code</param>
        /// <param name="errorMessage">Error message</param>
        /// <returns>True or false</returns>
        public bool GiveX_Close(int saleNum, ref string cashoutId, ref string report,
                                string userCode, out ErrorMessage errorMessage)
        {
            var dateStart = DateTime.Now;

            Performancelog.Debug($"Start,GivexClientManager,GiveX_Close,{string.Empty},{DateTime.Now:hh.mm.ss.ffffff}");

            var returnValue = false;
            var response    = new Variables.GiveXResponseType();
            var strReport   = "";

            cashoutId = "";
            report    = "";

            modStringPad.InitGiveXRequest();
            Variables.GX_Request.ServiceType = "CashOut";

            Variables.GX_Request.UserID = Convert.ToString(_givexPolicies["GIVEX_USER"]);

            Variables.GX_Request.UserPassword     = Convert.ToString(_givexPolicies["GIVEX_PASS"]);
            Variables.GX_Request.OperatorID       = "ALL";
            Variables.GX_Request.Language         = "0";
            Variables.GX_Request.TransactionCode  = (saleNum).ToString();
            Variables.GX_Request.TransmissionDate = DateAndTime.Today.ToString("MM/dd/yyyy");
            Variables.GX_Request.TransmissionTime = DateAndTime.TimeOfDay.ToString("hh:mm:ss");
            Variables.GX_Request.TerminalID       = "ALL";
            var strSend = modStringPad.GetGiveXRequest();

            if (SendGiveXRequest(strSend, "CashOut," + (saleNum), "CashOut", ref response, out errorMessage))
            {
                if (response.Result != "Approved")
                {
                    //Call DisplayMsgForm("CashOut is declined from GiveX TPS, CANNOT close batch for GiveX.", 99)
                    errorMessage.MessageStyle = _resourceManager.DisplayMsgForm(_offSet, 3273, 99, null, CriticalOkMessageType);
                    errorMessage.StatusCode   = HttpStatusCode.NotAcceptable;
                    return(false);
                }
                cashoutId = response.CashoutId.Trim();
                if (cashoutId == "0")
                {
                    errorMessage.MessageStyle = _resourceManager.DisplayMsgForm(_offSet, 3274, 99, null, CriticalOkMessageType);
                    errorMessage.StatusCode   = HttpStatusCode.NotAcceptable;
                    return(false);
                }



                returnValue = true;

                if (GetGiveXReport(saleNum, cashoutId, ref strReport, userCode, out errorMessage))
                {
                    report = strReport;
                }
            }
            Performancelog.Debug($"End,GivexClientManager,GiveX_Close,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}");

            return(returnValue);
        }
Exemple #2
0
        public static bool SplitGiveXResponse(string strBuffer, string strWaiting, ref Variables.GiveXResponseType GX_Response, ref string strRemain)
        {
            bool returnValue = false;

            short  i           = 0;
            short  j           = 0;
            string strResponse = "";

            string[] Arr1 = null;

            returnValue = false;
            strResponse = "";
            strRemain   = "";
            if (strBuffer == "")
            {
                returnValue = false;
            }
            else //if strBuffer<>""
            {
                i = (short)(strBuffer.IndexOf(strWaiting) + 1);
                if (i < 1)
                {
                    returnValue = false;
                }
                else
                {
                    j = (short)(strBuffer.IndexOf(",END-DATA", i + 1 - 1) + 1);
                    if (j < 1)
                    {
                        return(returnValue);
                    }
                    strResponse = strBuffer.Substring(i - 1, j - i);
                    strRemain   = strBuffer.Substring(0, i - 1) + strBuffer.Substring(j + 9 - 1);

                    Arr1 = Strings.Split(Expression: strResponse, Delimiter: ",", Compare: CompareMethod.Text);
                    for (i = 0; i <= (Arr1.Length - 1); i++)
                    {
                        switch (i)
                        {
                        case (short)0:
                            GX_Response.ServiceType = Arr1[i].Trim();
                            break;

                        case (short)1:
                            GX_Response.TransactionCode = Arr1[i].Trim();
                            break;

                        case (short)2:
                            GX_Response.Result = Arr1[i].Trim();
                            break;

                        case (short)3:
                            GX_Response.OperatorID = Arr1[i].Trim();
                            break;

                        case (short)4:
                            GX_Response.TerminalID = Arr1[i].Trim();
                            break;

                        case (short)5:
                            GX_Response.TransactionReference = Arr1[i].Trim();
                            break;

                        case (short)6:
                            GX_Response.TransactionReferenceFrom = Arr1[i].Trim();
                            break;

                        case (short)7:
                            GX_Response.PointsTransactionReference = Arr1[i].Trim();
                            break;

                        case (short)8:
                            GX_Response.PointsTransactionReferenceFrom = Arr1[i].Trim();
                            break;

                        case (short)9:
                            GX_Response.PreAuthReference = Arr1[i].Trim();
                            break;

                        case (short)10:
                            GX_Response.SecurityCode = Arr1[i].Trim();
                            break;

                        case (short)11:
                            GX_Response.Amount = Arr1[i].Trim();
                            break;

                        case (short)12:
                            GX_Response.AmountRedeemed = Arr1[i].Trim();
                            break;

                        case (short)13:
                            GX_Response.AuthorizedAmount = Arr1[i].Trim();
                            break;

                        case (short)14:
                            GX_Response.Units = Arr1[i].Trim();
                            break;

                        case (short)15:
                            GX_Response.Points = Arr1[i].Trim();
                            break;

                        case (short)16:
                            GX_Response.PointsAdded = Arr1[i].Trim();
                            break;

                        case (short)17:
                            GX_Response.PointsCancelled = Arr1[i].Trim();
                            break;

                        case (short)18:
                            GX_Response.CertificateBalance = Arr1[i].Trim();
                            break;

                        case (short)19:
                            GX_Response.PointsBalance = Arr1[i].Trim();
                            break;

                        case (short)20:
                            GX_Response.GivexNumber = Arr1[i].Trim();
                            break;

                        case (short)21:
                            GX_Response.ExpiryDate = Arr1[i].Trim();
                            break;

                        case (short)22:
                            GX_Response.TransmissionDate = Arr1[i].Trim();
                            break;

                        case (short)23:
                            GX_Response.TransmissionTime = Arr1[i].Trim();
                            break;

                        case (short)24:
                            GX_Response.CurrencyCode = Arr1[i].Trim();
                            break;

                        case (short)25:
                            GX_Response.MemberName = Arr1[i].Trim();
                            break;

                        case (short)26:
                            GX_Response.Services = Arr1[i].Trim();
                            break;

                        case (short)27:
                            GX_Response.OperatorLoginFlag = Arr1[i].Trim();
                            break;

                        case (short)28:
                            GX_Response.OperatorPasswordFlag = Arr1[i].Trim();
                            break;

                        case (short)29:
                            GX_Response.Continuation = Arr1[i].Trim();
                            break;

                        case (short)30:
                            GX_Response.CashoutId = Arr1[i].Trim();
                            break;

                        case (short)31:
                            GX_Response.ReportLines = Arr1[i].Trim();
                            break;
                        }
                    }

                    returnValue = true;
                }
            }
            return(returnValue);
        }
        /// <summary>
        /// Send GiveX Request
        /// </summary>
        /// <param name="strSend">Send string</param>
        /// <param name="strToCheck">Check</param>
        /// <param name="strDisplay">Display</param>
        /// <param name="gxResponse">Response</param>
        /// <param name="errorMessage">Error</param>
        /// <returns>True or false</returns>
        private bool SendGiveXRequest(string strSend, string strToCheck, string strDisplay,
                                      ref Variables.GiveXResponseType gxResponse, out ErrorMessage errorMessage)
        {
            var dateStart = DateTime.Now;

            Performancelog.Debug($"Start,GivexClientManager,SendGiveXRequest,{string.Empty},{DateTime.Now:hh.mm.ss.ffffff}");

            var strRemain   = "";
            var gotResponse = false;

            errorMessage = new ErrorMessage();

            Variables.GiveX_TCP = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

            var ipAddress = IPAddress.Parse(_givexPolicies["GIVEX_IP"].ToString());

            var remoteEndPoint = new IPEndPoint(ipAddress, Convert.ToInt16(_givexPolicies["GIVEX_PORT"]));

            try
            {
                Variables.GiveX_TCP.Connect(remoteEndPoint);

                var timeIn = (float)DateAndTime.Timer;

                while (!(Variables.GiveX_TCP.Connected || DateAndTime.Timer - timeIn > Convert.ToInt16(_givexPolicies["GIVETIMEOUT"])))
                {
                    if (DateAndTime.Timer < timeIn)
                    {
                        timeIn = (float)DateAndTime.Timer;
                    }
                }

                if (!Variables.GiveX_TCP.Connected)
                {
                    //Call DisplayMsgForm("Cannot communicate to GiveX TPS, {} Not Successful!", vbCritical + vbOKOnly, , , True)
                    errorMessage.MessageStyle = _resourceManager.DisplayMsgForm(_offSet, 8368, 99, strDisplay, CriticalOkMessageType);
                    errorMessage.StatusCode   = HttpStatusCode.NotAcceptable;

                    Variables.GiveX_TCP = null;
                    return(false);
                }

                // Encode the data string into a byte array.
                var msg = Encoding.ASCII.GetBytes(strSend);
                Variables.GiveX_TCP.Send(msg);


                // Data buffer for incoming data.
                var bytes = new byte[1024];

                while (!(DateAndTime.Timer - timeIn > Convert.ToInt16(_givexPolicies["GIVETIMEOUT"])))
                {
                    var bytesRec = Variables.GiveX_TCP.Receive(bytes);
                    //int bytesRec = 0;
                    var strBuffer = Encoding.ASCII.GetString(bytes, 0, bytesRec);
                    WriteToLogFile("GiveX_TCP.PortReading: " + strBuffer + " from waiting " + strToCheck);
                    if (!string.IsNullOrEmpty(strBuffer))
                    {
                        if (modStringPad.SplitGiveXResponse(strBuffer, strToCheck, ref gxResponse, ref strRemain))
                        {
                            //Variables.GiveX_TCP.PortReading = strRemain;
                            WriteToLogFile("modify GiveX_TCP.PortReading to: " + strRemain);
                            gotResponse = true;
                            break;
                        }
                    }
                    // Variables.Sleep(100);
                    if (DateAndTime.Timer < timeIn)
                    {
                        timeIn = (float)DateAndTime.Timer;
                    }
                }

                if (!gotResponse)
                {
                    errorMessage.MessageStyle = _resourceManager.DisplayMsgForm(_offSet, 3272, 99, strDisplay, CriticalOkMessageType);
                    errorMessage.StatusCode   = HttpStatusCode.NotAcceptable;

                    WriteToLogFile("TimeOut for waiting " + strToCheck);
                }

                Variables.GiveX_TCP.Shutdown(SocketShutdown.Both);
                Variables.GiveX_TCP.Close();

                Variables.GiveX_TCP = null;

                var returnValue = gotResponse;
                Performancelog.Debug($"End,GivexClientManager,SendGiveXRequest,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}");
                return(returnValue);
            }
            catch (Exception)
            {
                //Call DisplayMsgForm("Cannot communicate to GiveX TPS, {} Not Successful!", vbCritical + vbOKOnly, , , True)
                errorMessage.MessageStyle = _resourceManager.DisplayMsgForm(_offSet, 8368, 99, strDisplay, CriticalOkMessageType);
                errorMessage.StatusCode   = HttpStatusCode.NotAcceptable;
                return(false);
            }
        }
        // Feb 25, 2009: Nicolette moved here this function from modGlobalFunctions module
        // It is called only in this form, so there is no reason to have it public
        // Also, in order to fix the GiveX issue (click or scroll when GiveX is processed
        // messes up other Tenders_Renamed) this function has to access boolCardProcessing variable
        // that is a private variable to this form, so I would have had to make boolCardProcessing
        // public if the function has not been moved
        /// <summary>
        /// Method to redeem givex
        /// </summary>
        /// <param name="userCode">User code</param>
        /// <param name="strCardNum">Card number</param>
        /// <param name="amount">Amount</param>
        /// <param name="securityCode">Security code</param>
        /// <param name="saleNum">Sale number</param>
        /// <param name="newBalance">New balance</param>
        /// <param name="refNum">Reference number</param>
        /// <param name="expDate">Expiry date</param>
        /// <param name="result">Result</param>
        /// <param name="errorMessage">Error message</param>
        /// <param name="givexReceipt">Givex receipt</param>
        /// <returns>Trur or false</returns>
        public bool RedeemGiveX(string userCode, string strCardNum, float amount, string securityCode,
                                int saleNum, ref decimal newBalance, ref string refNum, ref string expDate,
                                ref string result, out ErrorMessage errorMessage, out GiveXReceiptType givexReceipt)
        {
            errorMessage = new ErrorMessage();
            givexReceipt = new GiveXReceiptType();
            string strSend  = "";
            var    response = new Variables.GiveXResponseType();
            var    capValue = new object[3];

            var returnValue = false;

            newBalance = 0;
            refNum     = "";
            if (string.IsNullOrEmpty(strCardNum))
            {
                return(false);
            }

            modStringPad.InitGiveXRequest();
            Variables.GX_Request.ServiceType      = "Redemption";
            Variables.GX_Request.UserID           = Convert.ToString(_givexPolicies["GIVEX_USER"]);
            Variables.GX_Request.UserPassword     = Convert.ToString(_givexPolicies["GIVEX_PASS"]);
            Variables.GX_Request.OperatorID       = Convert.ToString(userCode); // "ALL"
            Variables.GX_Request.GivexNumber      = strCardNum.Trim();
            Variables.GX_Request.Language         = "0";
            Variables.GX_Request.Amount           = (amount).ToString();
            Variables.GX_Request.TransactionCode  = (saleNum).ToString();
            Variables.GX_Request.SecurityCode     = securityCode.Trim();
            Variables.GX_Request.TransmissionDate = DateAndTime.Today.ToString("MM/dd/yyyy");
            Variables.GX_Request.TransmissionTime = DateAndTime.TimeOfDay.ToString("hh:mm:ss");
            Variables.GX_Request.TerminalID       = "ALL";
            strSend = modStringPad.GetGiveXRequest();

            if (SendGiveXRequest(strSend, "Redemption," + saleNum, "Redemption", ref response,
                                 out errorMessage))
            {
                if (response.Result != "Approved")
                {
                    if (response.TransactionReference.Trim() == "")
                    {
                        capValue[1] = "";
                    }
                    else
                    {
                        capValue[1] = "(" + response.TransactionReference.Trim() + ") ";
                    }
                    capValue[2] = strCardNum.Trim();

                    errorMessage.MessageStyle = _resourceManager.DisplayMsgForm(_offSet, 3271, 99, capValue, 0);
                    return(false);
                }
                if (response.GivexNumber != strCardNum.Trim())
                {
                    capValue[1] = "";
                    capValue[2] = strCardNum.Trim();

                    errorMessage.MessageStyle = _resourceManager.DisplayMsgForm(_offSet, 3271, 99, capValue, 0);
                }
                else
                {
                    newBalance  = (decimal)(Conversion.Val(response.CertificateBalance));
                    refNum      = response.TransactionReference;
                    expDate     = response.ExpiryDate != "****" ? string.Format("yyMM", response.ExpiryDate) : response.ExpiryDate;
                    result      = response.Result;
                    returnValue = true;

                    modStringPad.InitGiveXReceipt();
                    Variables.GX_Receipt.Date         = DateAndTime.Today.ToString("MM/dd/yyyy");
                    Variables.GX_Receipt.Time         = DateAndTime.TimeOfDay.ToString("hh:mm:ss");
                    Variables.GX_Receipt.UserID       = Convert.ToString(_givexPolicies["GIVEX_USER"]);
                    Variables.GX_Receipt.TranType     = 6; //Redemption
                    Variables.GX_Receipt.SeqNum       = (saleNum).ToString();
                    Variables.GX_Receipt.CardNum      = response.GivexNumber;
                    Variables.GX_Receipt.ExpDate      = response.ExpiryDate != "****" ? string.Format("yyMM", response.ExpiryDate) : response.ExpiryDate;
                    Variables.GX_Receipt.Balance      = (float)(Conversion.Val(response.CertificateBalance));
                    Variables.GX_Receipt.SaleAmount   = amount;
                    Variables.GX_Receipt.PointBalance = (float)(Conversion.Val(response.PointsBalance));
                    Variables.GX_Receipt.ResponseCode = response.Result;
                }
            }
            givexReceipt = new GiveXReceiptType
            {
                Date         = DateAndTime.Today.ToString("MM/dd/yyyy"),
                Time         = DateAndTime.TimeOfDay.ToString("hh:mm:ss"),
                UserID       = Convert.ToString(_givexPolicies["GIVEX_USER"]),
                TranType     = 6, //Redemption
                SeqNum       = (saleNum).ToString(),
                CardNum      = response.GivexNumber,
                ExpDate      = response.ExpiryDate != "****" ? string.Format("yyMM", response.ExpiryDate) : response.ExpiryDate,
                Balance      = (float)(Conversion.Val(response.CertificateBalance)),
                SaleAmount   = amount,
                PointBalance = (float)(Conversion.Val(response.PointsBalance)),
                ResponseCode = response.Result
            };
            return(returnValue);
        }
        /// <summary>
        /// Increase givex amount
        /// </summary>
        /// <param name="strCardNum">Card number</param>
        /// <param name="amount">Amount</param>
        /// <param name="saleNum">Sale number</param>
        /// <param name="newBalance">New balance</param>
        /// <param name="refNum">Reference number</param>
        /// <param name="userCode">User code</param>
        /// <param name="errorMessage">Error message</param>
        /// <param name="givexReceipt">Givex receipt</param>
        /// <returns>True or false</returns>
        public bool IncreaseGiveX(string strCardNum, float amount, int saleNum, ref decimal newBalance, ref string refNum,
                                  string userCode, out ErrorMessage errorMessage, out GiveXReceiptType givexReceipt)
        {
            var dateStart = DateTime.Now;

            Performancelog.Debug($"Start,GivexClientManager,IncreaseGiveX,{string.Empty},{DateTime.Now:hh.mm.ss.ffffff}");
            givexReceipt = new GiveXReceiptType();
            var returnValue = false;

            errorMessage = new ErrorMessage();
            var response = new Variables.GiveXResponseType();

            var capValue = new object[3];

            newBalance = 0;
            refNum     = "";
            if (strCardNum.Trim() == "")
            {
                return(false);
            }

            modStringPad.InitGiveXRequest();
            Variables.GX_Request.ServiceType = "Increment";

            Variables.GX_Request.UserID = Convert.ToString(_givexPolicies["GIVEX_USER"]);

            Variables.GX_Request.UserPassword = Convert.ToString(_givexPolicies["GIVEX_PASS"]);

            Variables.GX_Request.OperatorID       = Convert.ToString(userCode); // "ALL"
            Variables.GX_Request.GivexNumber      = strCardNum.Trim();
            Variables.GX_Request.Language         = "0";
            Variables.GX_Request.Amount           = (amount).ToString(CultureInfo.InvariantCulture);
            Variables.GX_Request.TransactionCode  = (saleNum).ToString();
            Variables.GX_Request.TransmissionDate = DateAndTime.Today.ToString("MM/dd/yyyy");
            Variables.GX_Request.TransmissionTime = DateAndTime.TimeOfDay.ToString("hh:mm:ss");
            Variables.GX_Request.TerminalID       = "ALL";
            var strSend = modStringPad.GetGiveXRequest();

            if (SendGiveXRequest(strSend, "Increment," + (saleNum), "Increment", ref response, out errorMessage))
            {
                if (response.Result != "Approved")
                {
                    if (!string.IsNullOrEmpty(response.TransactionReference))
                    {
                        if (response.TransactionReference.Trim() == "")
                        {
                            capValue[1] = "";
                        }
                        else
                        {
                            capValue[1] = "(" + response.TransactionReference.Trim() + ") ";
                        }
                    }
                    else
                    {
                        capValue[1] = "";
                    }

                    capValue[2] = strCardNum.Trim();

                    // Call DisplayMsgForm("Invalid response {}from GiveX TPS, CANNOT increase the amount for GiveX card {}.", 99)

                    errorMessage.MessageStyle = _resourceManager.DisplayMsgForm(_offSet, 3270, 99, capValue, CriticalOkMessageType);
                    return(false);
                }
                if (response.GivexNumber != strCardNum.Trim())
                {
                    capValue[1] = "";

                    capValue[2] = strCardNum.Trim();
                    //Call DisplayMsgForm("Invalid response {}from GiveX TPS, CANNOT increase the amount for GiveX card {}.", 99)
                    errorMessage.MessageStyle = _resourceManager.DisplayMsgForm(_offSet, 3270, 99, null, CriticalOkMessageType);
                    return(false);
                }
                newBalance  = decimal.Parse(response.CertificateBalance);
                refNum      = response.TransactionReference;
                returnValue = true;

                modStringPad.InitGiveXReceipt();
                Variables.GX_Receipt.Date = DateAndTime.Today.ToString("MM/dd/yyyy");
                Variables.GX_Receipt.Time = DateAndTime.TimeOfDay.ToString("hh:mm:ss");

                Variables.GX_Receipt.UserID       = Convert.ToString(_givexPolicies["GIVEX_PASS"]);
                Variables.GX_Receipt.TranType     = 5; //Increment
                Variables.GX_Receipt.SeqNum       = (saleNum).ToString();
                Variables.GX_Receipt.CardNum      = response.GivexNumber;
                Variables.GX_Receipt.ExpDate      = string.Format(response.ExpiryDate, "yyMM");
                Variables.GX_Receipt.Balance      = (float)(Conversion.Val(response.CertificateBalance));
                Variables.GX_Receipt.SaleAmount   = amount;
                Variables.GX_Receipt.PointBalance = (float)(Conversion.Val(response.PointsBalance));
                Variables.GX_Receipt.ResponseCode = response.Result;

                givexReceipt = new GiveXReceiptType
                {
                    Date         = DateAndTime.Today.ToString("MM/dd/yyyy"),
                    Time         = DateAndTime.TimeOfDay.ToString("hh:mm:ss"),
                    UserID       = Convert.ToString(_givexPolicies["GIVEX_PASS"]),
                    TranType     = 5,//Increment
                    SeqNum       = (saleNum).ToString(),
                    CardNum      = response.GivexNumber,
                    ExpDate      = string.Format(response.ExpiryDate, "yyMM"),
                    Balance      = (float)(Conversion.Val(response.CertificateBalance)),
                    SaleAmount   = amount,
                    PointBalance = (float)(Conversion.Val(response.PointsBalance)),
                    ResponseCode = response.Result
                };
            }
            Performancelog.Debug($"End,GivexClientManager,IncreaseGiveX,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}");

            return(returnValue);
        }
        /// <summary>
        /// Activate GiveX
        /// </summary>
        /// <param name="strCardNum">Card number</param>
        /// <param name="amount">Amount</param>
        /// <param name="saleNum">Sale number</param>
        /// <param name="refNum">Reference number</param>
        /// <param name="userCode">User code</param>
        /// <param name="errorMessage">Error message</param>
        /// <param name="givexReceipt">Givex receipt</param>
        /// <returns>true/false</returns>
        public bool ActivateGiveX(string strCardNum, float amount, int saleNum, ref string refNum,
                                  string userCode, out ErrorMessage errorMessage, out GiveXReceiptType givexReceipt)
        {
            var dateStart = DateTime.Now;

            Performancelog.Debug($"Start,GivexClientManager,ActivateGiveX,{string.Empty},{DateTime.Now:hh.mm.ss.ffffff}");
            var returnValue = false;

            errorMessage = new ErrorMessage();
            var response = new Variables.GiveXResponseType();

            givexReceipt = new GiveXReceiptType();
            refNum       = "";
            if (string.IsNullOrEmpty(strCardNum))
            {
                return(false);
            }

            modStringPad.InitGiveXRequest();
            Variables.GX_Request.ServiceType = "Activation";

            Variables.GX_Request.UserID = Convert.ToString(_givexPolicies["GIVEX_USER"]);

            Variables.GX_Request.UserPassword = Convert.ToString(_givexPolicies["GIVEX_PASS"]);

            Variables.GX_Request.OperatorID       = Convert.ToString(userCode); // "ALL"
            Variables.GX_Request.GivexNumber      = strCardNum.Trim();
            Variables.GX_Request.Language         = "0";
            Variables.GX_Request.Amount           = (amount).ToString(CultureInfo.InvariantCulture);
            Variables.GX_Request.TransactionCode  = (saleNum).ToString();
            Variables.GX_Request.TransmissionDate = DateAndTime.Today.ToString("MM/dd/yyyy");
            Variables.GX_Request.TransmissionTime = DateAndTime.TimeOfDay.ToString("hh:mm:ss");
            Variables.GX_Request.TerminalID       = "ALL";
            var strSend = modStringPad.GetGiveXRequest();

            if (SendGiveXRequest(strSend, "Activation," + (saleNum), "Activation", ref response, out errorMessage))
            {
                if (response.Result != "Approved")
                {
                    errorMessage.MessageStyle = _resourceManager.DisplayMsgForm(_offSet, response.TransactionReference.Trim() != "" ? 3265 : 3264, 99, response.TransactionReference, CriticalOkMessageType);
                    errorMessage.StatusCode   = HttpStatusCode.NotAcceptable;
                    return(false);
                }
                if (response.GivexNumber != strCardNum.Trim())
                {
                    //Call DisplayMsgForm("Invalid response from GiveX TPS, Gift Certificate is canceled!", 99)
                    errorMessage.MessageStyle = _resourceManager.DisplayMsgForm(_offSet, 3264, 99,
                                                                                response.TransactionReference, CriticalOkMessageType);
                }
                else
                {
                    returnValue = true;
                    refNum      = response.TransactionReference;



                    modStringPad.InitGiveXReceipt();
                    Variables.GX_Receipt.Date = DateAndTime.Today.ToString("MM/dd/yyyy");
                    Variables.GX_Receipt.Time = DateAndTime.TimeOfDay.ToString("hh:mm:ss");

                    Variables.GX_Receipt.UserID       = Convert.ToString(_givexPolicies["GIVEX_USER"]);
                    Variables.GX_Receipt.TranType     = 1; //Activation
                    Variables.GX_Receipt.SaleNum      = saleNum;
                    Variables.GX_Receipt.SeqNum       = response.TransactionReference;
                    Variables.GX_Receipt.CardNum      = response.GivexNumber;
                    Variables.GX_Receipt.SaleAmount   = float.Parse(response.Amount);
                    Variables.GX_Receipt.ExpDate      = string.Format(response.ExpiryDate, "yyMM");
                    Variables.GX_Receipt.Balance      = (float)(Conversion.Val(response.CertificateBalance));
                    Variables.GX_Receipt.PointBalance = (float)(Conversion.Val(response.PointsBalance));
                    Variables.GX_Receipt.ResponseCode = response.Result;

                    givexReceipt = new GiveXReceiptType
                    {
                        Date         = DateAndTime.Today.ToString("MM/dd/yyyy"),
                        Time         = DateAndTime.TimeOfDay.ToString("hh:mm:ss"),
                        UserID       = Convert.ToString(_givexPolicies["GIVEX_USER"]),
                        TranType     = 1, //Activation
                        SaleNum      = saleNum,
                        SeqNum       = response.TransactionReference,
                        CardNum      = response.GivexNumber,
                        SaleAmount   = float.Parse(response.Amount),
                        ExpDate      = string.Format(response.ExpiryDate, "yyMM"),
                        Balance      = (float)(Conversion.Val(response.CertificateBalance)),
                        PointBalance = (float)(Conversion.Val(response.PointsBalance)),
                        ResponseCode = response.Result,
                    };
                }
            }
            Performancelog.Debug($"End,GivexClientManager,ActivateGiveX,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}");

            return(returnValue);
        }