Пример #1
0
        /// <summary>
        /// Return values from ENett API
        /// and prepare response to caller
        /// </summary>
        /// <param name="user">user</param>
        /// <param name="vNettresponse">IssueVNettVANResponse</param>
        public void SetValues(UserInfo user, AmendVNettVANResponse vNettResponse, ENettAmendVAN reader)
        {
            if (!vNettResponse.IsSuccessful)
            {
                // The request was not succesfully processed
                // we need to get support log id from ENett
                // start EGE-100347
                if (vNettResponse.SupportLogId == "D")
                {
                    SetVNettTransactionID(vNettResponse.VNettTransactionID);
                    SetPaymentID(reader.PaymentID);
                    vNettResponse.IsSuccessful = false;
                    SetSuccesfull(vNettResponse.IsSuccessful);
                }
                else
                {
                    SetSupportLogId(vNettResponse.SupportLogId);
                    // Return error code and error description from ENett
                    SetException(user, new CEEException(vNettResponse.ErrorCode.ToString()
                                                        , vNettResponse.ErrorDescription).GetCompleteExceptionMessage());
                }

                // No need to go further!
                return;
                // END EGE-100347
            }

            // The response is success
            // Let's extract and return to caller all information
            SetVNettTransactionID(vNettResponse.VNettTransactionID);
            SetPaymentID(reader.PaymentID);
            SetSuccesfull(vNettResponse.IsSuccessful);
        }
Пример #2
0
        /// <summary>
        /// Reads request for amendVAN and
        /// parse input
        /// </summary>
        /// <param name="xmlRequest">XML request</param>
        /// <returns>ENettAmendVAN</returns>
        public static ENettAmendVAN ReadAmend(string xmlRequest)
        {
            //XML Serialization
            ENettAmendVAN    RequestObject = new ENettAmendVAN();
            XmlRootAttribute xRoot         = new XmlRootAttribute();

            xRoot.ElementName = XMLHeaderAmendVAN;
            xRoot.IsNullable  = true;

            XmlSerializer mySerializer = new XmlSerializer(typeof(ENettAmendVAN), xRoot);

            using (TextReader tr = new StringReader(xmlRequest))
            {
                RequestObject = (ENettAmendVAN)mySerializer.Deserialize(tr);
            }
            return(RequestObject);
        }
Пример #3
0
        // End EGE-100347

        /// Prepare new Amend ENett Virtual Account Number (VAN)
        /// </summary>
        /// <param name="reader">ENettAmendVAN</param>
        /// <returns>AmendVNettVANRequest</returns>
        public static AmendVNettVANRequest ENettAmendVAN(UserInfo user, ENettAmendVAN reader)
        {
            // Let's request a new VAN
            AmendVNettVANRequest amdReq = new AmendVNettVANRequest();

            // Will be returned from ECN
            // Extract ECN details
            int issuedECN = Util.ConvertStringToInt(reader.ECN);

            amdReq.IntegratorCode      = GetIntegratorCode();
            amdReq.IntegratorAccessKey = GetIntegratorAccessKey();
            amdReq.RequesterECN        = GetRequestorECN();
            amdReq.IssuedToEcn         = issuedECN;

            amdReq.IntegratorReference        = reader.PaymentID;
            amdReq.FundingCurrencyCode        = reader.Currency;
            amdReq.MaximumAuthorisationAmount = Util.ConvertStringToLong(reader.MaxAuthAmount);
            string activationDate = Util.ConvertDateToString(Util.ConvertStringToDate(reader.ActivationDate, Const.ExpirationDateFormat), Const.DateFormat_yyyyMMdd);

            amdReq.ActivationDate = activationDate;
            string expirydDate = Util.ConvertDateToString(Util.ConvertStringToDate(reader.ExpiryDate, Const.ExpirationDateFormat), Const.DateFormat_yyyyMMdd);

            amdReq.ExpiryDate = expirydDate;
            amdReq.IsMultiUse = Util.ConvertStringToBool(reader.IsMultiUse);
            long minumumAuthorisationAmount = Util.ConvertStringToLong(reader.MinAuthAmount);

            if (amdReq.IsMultiUse)
            {
                amdReq.IsMultiUseSpecified              = true;
                amdReq.MultiUseClosePercentage          = Util.ConvertStringToInt(reader.MultiUseClosePercentage);
                amdReq.MultiUseClosePercentageSpecified = true;
                minumumAuthorisationAmount              = 0L;
            }
            amdReq.MinimumAuthorisationAmount = minumumAuthorisationAmount;
            amdReq.MerchantCategoryName       = reader.MerchantCategory;
            amdReq.Username       = reader.UserName;
            amdReq.UserReference1 = reader.PaymentID;
            amdReq.UserReference2 = reader.UserName;
            string bookingDate = Util.ConvertDateToString(Util.ConvertStringToDate(reader.BookingDate, Const.ExpirationDateFormat), Const.DateFormat_yyyyMMdd);

            amdReq.UserReference3 = reader.Product;


            string travelerName    = "Unknown";
            string travelerPercode = "Unknown";

            // We need here to return traveler code and name
            // It depends on which Enett implementation we are
            // in the phase 1, percode and traveler name are provided for one traveller
            //   <PerCode>2001</PerCode>
            //   <TravellerName>Sudhakar</TravellerName>
            // in phase 2, multiple travallers are sent
            // so we need to extract the main traveller
            // <Travellers>
            //    <Traveller>
            //      <IsMainTraveller>true</IsMainTraveller>
            //      <Name>Claire Burns</Name>
            //      ...
            //    </Traveller>
            // <//Travellers>
            //
            if (String.IsNullOrEmpty(reader.PerCode))
            {
                // We have on phase 2 with multiple travellers
                // we need to find the main traveler
                List <ENettAmendVAN.Traveller> travs = reader.Travellers;

                foreach (ENettAmendVAN.Traveller trav in travs)
                {
                    if (Util.ConvertStringToBool(trav.IsMainTraveller))
                    {
                        // This is the main traveller
                        travelerPercode = trav.Percode;
                        travelerName    = trav.Name;
                    }
                }
            }
            else
            {
                // We are in phase 1, only one traveler is provided
                travelerPercode = reader.PerCode;
                travelerName    = reader.TravellerName;
            }


            amdReq.UserReference4 = travelerName;
            // send user references
            UserReference[] str = new UserReference[5];
            // product
            str[0]       = new UserReference();
            str[0].Value = travelerPercode;

            // PNR
            str[1]       = new UserReference();
            str[1].Value = bookingDate;
            // Payment ID
            str[2]       = new UserReference();
            str[2].Value = reader.SupplierName;
            // Username
            str[3]       = new UserReference();
            str[3].Value = reader.PNR;
            //>>EGE-6880
            // new User Refernce for Channel
            str[4]       = new UserReference();
            str[4].Value = reader.Channel;
            //<<EGE-6880

            amdReq.UserReferences = str;


            // Get message digest
            StringBuilder builder = new StringBuilder();

            builder.Append(GetClientAccessKey());
            builder.Append(reader.PaymentID);
            builder.Append(activationDate);
            builder.Append(issuedECN);
            builder.Append(reader.MaxAuthAmount);
            builder.Append(minumumAuthorisationAmount);
            builder.Append(reader.MerchantCategory);
            builder.Append(reader.PaymentID);
            builder.Append(reader.UserName);


            // Send message digest
            string msgDigest = builder.ToString();

            byte[] arr = Encoding.Default.GetBytes(msgDigest);
            amdReq.MessageDigest = SHA1HashEncode(arr);

            return(amdReq);
        }
Пример #4
0
        /// <summary>
        /// Log VCard amend in the table
        /// </summary>
        /// <param name="reader">ENettAmendVAN detail</param>
        public void UpdateForAmend(ENettAmendVAN reader, AmendVNettVANResponse result)
        {
            string request = String.Format("UPDATE VCardBooking SET PNR=@pnr, AmendDate =@AmendDate, "
                                           + "RailTicketNumber=@RailTicketNumber, GrossAmount=@GrossAmount, VATAmount=@VATAmount,IsBookingConfirmed=@IsBookingConfirmed, "
                                           + "TripName=@TripName, FreeText1=@FreeText1, FreeText2=@FreeText2, FreeText3=@FreeText3, HotelId=@HotelId, "
                                           + "ExpectedTransactionAmount=@ExpectedTransactionAmount, OriginDate=@OriginDate, OriginAddress=@OriginAddress, "
                                           + "OriginLocationCode=@OriginLocationCode, OriginCountryCode=@OriginCountryCode, EndDate=@EndDate, EndAddress=@EndAddress, "
                                           // --> EGE-85532 update expiration date for cancel van as per date.
                                           + "CardExpirationDate = @CardExpirationDate, "
                                           //<-- EGE-85532
                                           //>>EGE-60949
                                           //+ "EndLocationCode=@EndLocationCode, EndCountryCode=@EndCountryCode, AdultCount=@AdultCount, FundedAmount=@MaxAuthAmount "
                                           + "EndLocationCode=@EndLocationCode, EndCountryCode=@EndCountryCode, AdultCount=@AdultCount, FundedAmount=@MaxAuthAmount, TransAmtVanCurr=@TransAmtVanCurr "
                                           //>>EGE-60949
                                           + "WHERE PaymentId=@PaymentId");

            // objet command
            SqlCommand command = new SqlCommand(request, GetConnection());

            try
            {
                // Send parameters
                command.Parameters.Add("@pnr", SqlDbType.VarChar, 256);
                command.Parameters["@pnr"].Value = Util.Nvl(reader.PNR, DBNull.Value);

                command.Parameters.Add("@AmendDate", SqlDbType.DateTime);
                command.Parameters["@AmendDate"].Value = DateTime.Now;

                command.Parameters.Add("@RailTicketNumber", SqlDbType.VarChar, 200);
                command.Parameters["@RailTicketNumber"].Value = Util.Nvl(reader.RailTicketNumbers, DBNull.Value);

                command.Parameters.Add("@GrossAmount", SqlDbType.Money);
                command.Parameters["@GrossAmount"].Value = Util.TryConvertStringToDouble(reader.GrossAmount, 0.00);

                command.Parameters.Add("@VATAmount", SqlDbType.Money);
                command.Parameters["@VATAmount"].Value = Util.TryConvertStringToDouble(reader.VATAmount, 0.00);

                command.Parameters.Add("@ExpectedTransactionAmount", SqlDbType.Money);
                //--> EGE-61686 : CEE- VNETT - Follow transaction amount in XML
                string amount = reader.TransactionAmount;
                if (String.IsNullOrEmpty(amount) || amount.Equals("0"))
                {
                    amount = reader.TransAmtPosCurr;
                }
                command.Parameters["@ExpectedTransactionAmount"].Value = Util.TryConvertStringToDouble(amount, DBNull.Value);
                //command.Parameters["@ExpectedTransactionAmount"].Value = Util.TryConvertStringToDouble(reader.TransactionAmount, DBNull.Value);
                //<-- EGE-61686 : CEE- VNETT - Follow transaction amount in XML

                command.Parameters.Add("@IsBookingConfirmed", SqlDbType.Bit);
                command.Parameters["@IsBookingConfirmed"].Value = Util.ConvertStringToBool(reader.IsBookingConfirmed)?1:0;
                //Begin EGE-85532
                command.Parameters.Add("@CardExpirationDate", SqlDbType.DateTime);
                command.Parameters["@CardExpirationDate"].Value = Util.ConvertStringToDate(reader.ExpiryDate, Const.ExpirationDateFormat);
                // END EGE-85532
                command.Parameters.Add("@TripName", SqlDbType.VarChar, 256);
                command.Parameters["@TripName"].Value = Util.Nvl(reader.TripName, DBNull.Value);

                command.Parameters.Add("@FreeText1", SqlDbType.VarChar, 1000);
                command.Parameters["@FreeText1"].Value = Util.Nvl(reader.FreeText1, DBNull.Value);

                command.Parameters.Add("@FreeText2", SqlDbType.VarChar, 1000);
                command.Parameters["@FreeText2"].Value = Util.Nvl(reader.FreeText2, DBNull.Value);

                command.Parameters.Add("@FreeText3", SqlDbType.VarChar, 1000);
                command.Parameters["@FreeText3"].Value = Util.Nvl(reader.FreeText3, DBNull.Value);

                command.Parameters.Add("@HotelId", SqlDbType.BigInt);
                command.Parameters["@HotelId"].Value = Util.TryConvertStringToLong(reader.HotelID, 0L);

                command.Parameters.Add("@OriginDate", SqlDbType.DateTime);
                // Origin date is not available in verion 1 of the XML
                if (String.IsNullOrEmpty(reader.OriginDate))
                {
                    command.Parameters["@OriginDate"].Value = DBNull.Value;
                }
                else
                {
                    command.Parameters["@OriginDate"].Value = Util.ConvertStringToDate(reader.OriginDate, Const.ExpirationDateFormat);
                }

                command.Parameters.Add("@OriginAddress", SqlDbType.VarChar, 2000);
                command.Parameters["@OriginAddress"].Value = Util.Nvl(reader.OriginLocationName, DBNull.Value);

                command.Parameters.Add("@OriginLocationCode", SqlDbType.VarChar, 30);
                command.Parameters["@OriginLocationCode"].Value = Util.Nvl(reader.OriginLocationCode, DBNull.Value);

                command.Parameters.Add("@OriginCountryCode", SqlDbType.VarChar, 3);
                command.Parameters["@OriginCountryCode"].Value = Util.Nvl(reader.OriginCountryCode, DBNull.Value);

                command.Parameters.Add("@EndDate", SqlDbType.DateTime);
                // Origin date is not available in verion 1 of the XML
                if (String.IsNullOrEmpty(reader.EndDate))
                {
                    command.Parameters["@EndDate"].Value = DBNull.Value;
                }
                else
                {
                    command.Parameters["@EndDate"].Value = Util.ConvertStringToDate(reader.EndDate, Const.ExpirationDateFormat);
                }

                command.Parameters.Add("@EndAddress", SqlDbType.VarChar, 2000);
                command.Parameters["@EndAddress"].Value = Util.Nvl(reader.EndLocationName, DBNull.Value);

                command.Parameters.Add("@EndLocationCode", SqlDbType.VarChar, 30);
                command.Parameters["@EndLocationCode"].Value = Util.Nvl(reader.EndLocationCode, DBNull.Value);

                command.Parameters.Add("@EndCountryCode", SqlDbType.VarChar, 3);
                command.Parameters["@EndCountryCode"].Value = Util.Nvl(reader.EndCountryCode, DBNull.Value);

                command.Parameters.Add("@AdultCount", SqlDbType.Int);
                command.Parameters["@AdultCount"].Value = Util.TryConvertStringToInt(reader.AdultsCount, DBNull.Value);

                command.Parameters.Add("@MaxAuthAmount", SqlDbType.Money);
                command.Parameters["@MaxAuthAmount"].Value = Util.TryConvertStringToDouble(reader.MaxAuthAmount, DBNull.Value);

                command.Parameters.Add("@PaymentId", SqlDbType.VarChar, 16);
                command.Parameters["@PaymentId"].Value = Util.Nvl(reader.PaymentID, DBNull.Value);

                command.Parameters.Add("@ErrorCode", SqlDbType.VarChar, 50);
                command.Parameters["@ErrorCode"].Value = result.IsSuccessful ? 0 : result.ErrorCode;

                command.Parameters.Add("@ErrorDesc", SqlDbType.VarChar, 256);
                command.Parameters["@ErrorDesc"].Value = Util.Nvl(result.ErrorDescription, DBNull.Value);
                // Technical infos
                command.Parameters.Add("@ModificationDate", SqlDbType.DateTime);
                command.Parameters["@ModificationDate"].Value = DateTime.Now;

                command.Parameters.Add("@ModifiedBy", SqlDbType.VarChar, 128);
                command.Parameters["@ModifiedBy"].Value = Util.Nvl(reader.AgentLogIn, DBNull.Value);

                //>> EGE-60949
                command.Parameters.Add("@TransAmtVanCurr", SqlDbType.Money);
                command.Parameters["@TransAmtVanCurr"].Value = Util.TryConvertStringToDouble(reader.TransAmtVanCurr, DBNull.Value);
                //<< EGE-60949


                // Execute ...
                command.ExecuteNonQuery();
            }
            catch (Exception e)
            {
                // Something wen wrong
                throw new Exception(GetMessages().GetString("VCardLogConnection.Save.Error", reader.PaymentID, e.Message, true));
            }
            finally
            {
                DisposeCommand(command);
            }
        }