/// <summary> /// Return values from ENett API /// and prepare response to caller /// </summary> /// <param name="user">user</param> /// <param name="vNettresponse">CompleteIssueVNettVANResponse</param> /// <param name="ENettRequestVAN">ENettRequestVAN</param> public void SetValues(UserInfo user, CompleteIssueVNettVANResponse vNettResponse, ENettRequestVAN reader) { if (!vNettResponse.GetIssuedVNettResponse().IsSuccessful) { // The request failed // we need to get support log id from ENett SetSupportLogId(vNettResponse.GetIssuedVNettResponse().SupportLogId); // The request was not succesfully processed // Set the exception code and message SetException(user, new CEEException(vNettResponse.GetIssuedVNettResponse().ErrorCode.ToString() , vNettResponse.GetIssuedVNettResponse().ErrorDescription).GetCompleteExceptionMessage()); // No need to go further! return; } // The response is success // Let's extract and return to caller all information SetVNettTransactionID(vNettResponse.GetIssuedVNettResponse().VNettTransactionID); SetPaymentID(vNettResponse.GetReferenceId()); SetVAN(vNettResponse.GetIssuedVNettResponse().VirtualAccountNumber); SetActivationDate(Util.ConvertStringToDate(vNettResponse.GetIssuedVNettResponse().ActivationDate, Const.DateFormat_yyyyMMdd)); /// EGE - 70723 ENett Response Expiry Date send to FO SetExpirationDate(Util.ConvertStringToDate(vNettResponse.GetIssuedVNettResponse().ExpiryDate, Const.DateFormat_MMyyyy)); SetCardSecurityCode(vNettResponse.GetIssuedVNettResponse().CardSecurityCode); SetCardHolderName(vNettResponse.GetIssuedVNettResponse().CardHolderName); SetFundedAmount(vNettResponse.GetIssuedVNettResponse().FundedAmount); SetMultiUse(Util.ConvertStringToBool(reader.IsMultiUse)); SetCurrency(vNettResponse.GetIssuedVNettResponse().CurrencyCode); }
/// <summary> /// Log VCard request in the table /// </summary> /// <param name="reader">XML request</param> /// <param name="travelerOrder">Traveler order</param> /// <param name="percode">Traveler code</param> /// <param name="travelerName">Traveler Name</param> /// <param name="cc1">Cost center 1</param> /// <param name="cc2">Cost center 2</param> /// <param name="cc3">Cost center 3</param> /// <param name="channel">channel</param> /// <param name="response">CompleteIssueVNettVANResponse</param> public void InsertNewRequest(ENettRequestVAN reader, int travelerOrder, string percode, string travelerName , string cc1, string cc2, string cc3, string channel, CompleteIssueVNettVANResponse response) { string request = String.Format("INSERT INTO VCardBooking (" + "PaymentId ,TravelerOrder, PosCode, Comcode, BookerPercode, TravelerPercode, TravelerName, AdultCount, AgentLogin, " + "BookingDate, FundedAmount, Currency, CardActivationDate, CardExpirationDate, IsMultiUseCard, " + "TruncatedVAN, Product, Channel, ECN, MerchantCategory, MdCode, RefDossierType, RefDossierCode, OriginDate, OriginAddress, " + "OriginLocationCode, OriginCountryCode, EndDate, EndAddress, EndLocationCode, EndCountryCode, SupplierName, " + "CC1, CC2, CC3, RequestDate, TripName, FreeText1, FreeText2, FreeText3, HotelId, " //>>EGE-60949 //+ "ErrorCode, ErrorDesc, CreationDate, CreatedBy, ModificationDate, ModifiedBy, SupportLogId, VNettTransactionID) " + "ErrorCode, ErrorDesc, CreationDate, CreatedBy, ModificationDate, ModifiedBy, SupportLogId, VNettTransactionID, PosCurrency, VanCountryCode) " //<< EGE-60949 + "VALUES (" + "@PaymentId ,@TravelerOrder, @PosCode, @Comcode, @BookerPercode, @TravelerPercode, @TravelerName, @AdultCount, @AgentLogin, " + "@BookingDate, @FundedAmount, @Currency, @CardActivationDate, @CardExpirationDate, @IsMultiUseCard, " + "@TruncatedVAN, @Product, @Channel, @ECN, @MerchantCategory, @MdCode, @RefDossierType, @RefDossierCode, @OriginDate, @OriginAddress, " + "@OriginLocationCode, @OriginCountryCode, @EndDate, @EndAddress, @EndLocationCode, @EndCountryCode, @SupplierName, " + "@CC1, @CC2, @CC3, @RequestDate, @TripName, @FreeText1, @FreeText2, @FreeText3, @HotelId, " //>>EGE-60949 //+ "@ErrorCode, @ErrorDesc, @CreationDate, @CreatedBy, @ModificationDate, @ModifiedBy, @SupportLogId, @VNettTransactionID)"); + "@ErrorCode, @ErrorDesc, @CreationDate, @CreatedBy, @ModificationDate, @ModifiedBy, @SupportLogId, @VNettTransactionID, @PosCurrency, @VanCountryCode)"); //<< EGE-60949 // objet command SqlCommand command = new SqlCommand(request, GetConnection()); try { // Send parameters command.Parameters.Add("@PaymentId", SqlDbType.VarChar, 16); command.Parameters["@PaymentId"].Value = Util.Nvl(response.GetReferenceId(), DBNull.Value); command.Parameters.Add("@SupportLogId", SqlDbType.VarChar, 256); command.Parameters["@SupportLogId"].Value = Util.Nvl(response.GetIssuedVNettResponse().SupportLogId, DBNull.Value); command.Parameters.Add("@VNettTransactionID", SqlDbType.VarChar, 100); command.Parameters["@VNettTransactionID"].Value = Util.Nvl(response.GetIssuedVNettResponse().VNettTransactionID, DBNull.Value); //<< EGE-60949 command.Parameters.Add("@PosCode", SqlDbType.VarChar, 2); command.Parameters["@PosCode"].Value = Util.Nvl(reader.PosCountryCode, DBNull.Value); command.Parameters.Add("@PosCurrency", SqlDbType.VarChar, 3); command.Parameters["@PosCurrency"].Value = Util.Nvl(reader.PosCurrency, DBNull.Value); command.Parameters.Add("@VanCountryCode ", SqlDbType.VarChar, 2); command.Parameters["@VanCountryCode "].Value = Util.Nvl(reader.Market, DBNull.Value); //<< EGE-60949 command.Parameters.Add("@TravelerOrder", SqlDbType.Int); command.Parameters["@TravelerOrder"].Value = travelerOrder; //<< EGE-60949 //command.Parameters.Add("@PosCode", SqlDbType.VarChar, 2); //command.Parameters["@PosCode"].Value = Util.Nvl(reader.Market, DBNull.Value); //<< EGE-60949 command.Parameters.Add("@Comcode", SqlDbType.Int); command.Parameters["@Comcode"].Value = Util.TryConvertStringToInt(reader.ComCode, DBNull.Value); command.Parameters.Add("@BookerPercode", SqlDbType.BigInt); command.Parameters["@BookerPercode"].Value = Util.TryConvertStringToLong(reader.BookerPerCode, DBNull.Value); command.Parameters.Add("@TravelerPercode", SqlDbType.BigInt); command.Parameters["@TravelerPercode"].Value = Util.TryConvertStringToLong(percode, DBNull.Value); command.Parameters.Add("@TravelerName", SqlDbType.VarChar, 512); command.Parameters["@TravelerName"].Value = Util.Nvl(travelerName, DBNull.Value); command.Parameters.Add("@AdultCount", SqlDbType.Int); command.Parameters["@AdultCount"].Value = Util.TryConvertStringToInt(reader.AdultsCount, DBNull.Value); command.Parameters.Add("@AgentLogin", SqlDbType.VarChar, 100); command.Parameters["@AgentLogin"].Value = Util.Nvl(reader.UserName, DBNull.Value); command.Parameters.Add("@BookingDate", SqlDbType.DateTime); command.Parameters["@BookingDate"].Value = Util.ConvertStringToDate(reader.BookingDate, Const.ExpirationDateFormat); command.Parameters.Add("@FundedAmount", SqlDbType.Money); command.Parameters["@FundedAmount"].Value = response.GetIssuedVNettResponse().IsSuccessful ?response.GetIssuedVNettResponse().FundedAmount:0; command.Parameters.Add("@Currency", SqlDbType.VarChar, 3); command.Parameters["@Currency"].Value = Util.Nvl(reader.Currency, DBNull.Value); command.Parameters.Add("@CardActivationDate", SqlDbType.DateTime); command.Parameters["@CardActivationDate"].Value = Util.ConvertStringToDate(reader.ActivationDate, Const.ExpirationDateFormat); command.Parameters.Add("@CardExpirationDate", SqlDbType.DateTime); command.Parameters["@CardExpirationDate"].Value = Util.ConvertStringToDate(reader.ExpiryDate, Const.ExpirationDateFormat); command.Parameters.Add("@IsMultiUseCard", SqlDbType.Bit); command.Parameters["@IsMultiUseCard"].Value = Util.ConvertStringToBool(reader.IsMultiUse) ? 1 : 0; command.Parameters.Add("@TruncatedVAN", SqlDbType.VarChar, 16); command.Parameters["@TruncatedVAN"].Value = response.GetIssuedVNettResponse().IsSuccessful ? CreditCardVerifier.TruncatePan(response.GetIssuedVNettResponse().VirtualAccountNumber) : string.Empty; command.Parameters.Add("@Product", SqlDbType.VarChar, 30); command.Parameters["@Product"].Value = Util.Nvl(reader.Product, DBNull.Value); command.Parameters.Add("@Channel", SqlDbType.VarChar, 10); command.Parameters["@Channel"].Value = Util.Nvl(channel, DBNull.Value); command.Parameters.Add("@ECN", SqlDbType.Int); command.Parameters["@ECN"].Value = Util.TryConvertStringToInt(reader.ECN, DBNull.Value); command.Parameters.Add("@MerchantCategory", SqlDbType.VarChar, 30); command.Parameters["@MerchantCategory"].Value = Util.Nvl(reader.MerchantCategory, DBNull.Value); command.Parameters.Add("@MdCode", SqlDbType.Int); command.Parameters["@MdCode"].Value = Util.TryConvertStringToInt(reader.MdCode, DBNull.Value); command.Parameters.Add("@RefDossierType", SqlDbType.VarChar, 10); command.Parameters["@RefDossierType"].Value = Util.Nvl(reader.RefDossierType, DBNull.Value); command.Parameters.Add("@RefDossierCode", SqlDbType.Int); command.Parameters["@RefDossierCode"].Value = Util.TryConvertStringToInt(reader.RefDossierCode, DBNull.Value); // Origin date is not available in verion 1 of the XML command.Parameters.Add("@OriginDate", SqlDbType.DateTime); 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); // Origin date is not available in verion 1 of the XML command.Parameters.Add("@EndDate", SqlDbType.DateTime); 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("@SupplierName", SqlDbType.VarChar, 512); command.Parameters["@SupplierName"].Value = Util.Nvl(reader.SupplierName, DBNull.Value); command.Parameters.Add("@CC1", SqlDbType.VarChar, 100); command.Parameters["@CC1"].Value = Util.Nvl(cc1, DBNull.Value); command.Parameters.Add("@CC2", SqlDbType.VarChar, 100); command.Parameters["@CC2"].Value = Util.Nvl(cc2, DBNull.Value); command.Parameters.Add("@CC3", SqlDbType.VarChar, 100); command.Parameters["@CC3"].Value = Util.Nvl(cc3, DBNull.Value); command.Parameters.Add("@RequestDate", SqlDbType.DateTime); command.Parameters["@RequestDate"].Value = DateTime.Now; 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("@ErrorCode", SqlDbType.VarChar, 50); command.Parameters["@ErrorCode"].Value = response.GetIssuedVNettResponse().IsSuccessful?0:response.GetIssuedVNettResponse().ErrorCode; command.Parameters.Add("@ErrorDesc", SqlDbType.VarChar, 256); command.Parameters["@ErrorDesc"].Value = response.GetIssuedVNettResponse().IsSuccessful ? string.Empty : response.GetIssuedVNettResponse().ErrorDescription; // Technical infos command.Parameters.Add("@CreationDate", SqlDbType.DateTime); command.Parameters["@CreationDate"].Value = DateTime.Now; command.Parameters.Add("@CreatedBy", SqlDbType.VarChar, 256); command.Parameters["@CreatedBy"].Value = Util.Nvl(reader.AgentLogIn, DBNull.Value); command.Parameters.Add("@ModificationDate", SqlDbType.DateTime); command.Parameters["@ModificationDate"].Value = DateTime.Now; command.Parameters.Add("@ModifiedBy", SqlDbType.VarChar, 256); command.Parameters["@ModifiedBy"].Value = Util.Nvl(reader.AgentLogIn, DBNull.Value); // Execute ... command.ExecuteNonQuery(); } catch (Exception e) { // Something wen wrong throw new Exception(GetMessages().GetString("VCardLogConnection.Save.Error", response.GetReferenceId(), e.Message, true)); } finally { DisposeCommand(command); } }