Beispiel #1
0
        private static SegmentSSRRequest CreateSegmentSSRRequest(SSR ssr, string departureStation, string arrivalStation, int[] paxNumbers,
                                                                 FlightDesignator flightDesignator, DateTime departureDateTime, int ssrCount, Dictionary <int, List <short> > ssrNumbersToCancelDict = null, string note = "")
        {
            var list = new List <PaxSSR>();

            foreach (var paxNumber in paxNumbers)
            {
                for (var i = 0; i < ssrCount; i++)
                {
                    var   isCancel  = ssrNumbersToCancelDict != null && ssrNumbersToCancelDict.ContainsKey(paxNumber);
                    short ssrNumber = isCancel ? ssrNumbersToCancelDict[paxNumber].LastOrDefault() : (short)i;
                    list.Add(new PaxSSR
                    {
                        ArrivalStation   = arrivalStation,
                        DepartureStation = departureStation,
                        FeeCode          = ssr.FeeCode,
                        PassengerNumber  = (short)paxNumber,
                        SSRCode          = ssr.SSRCode,
                        SSRDetail        = string.Empty,
                        Note             = note,
                        SSRNumber        = ssrNumber
                    });
                    if (isCancel)
                    {
                        ssrNumbersToCancelDict[paxNumber].Remove(ssrNumber);
                    }
                }
            }
            var segmentSSRRequest = new SegmentSSRRequest
            {
                ArrivalStation   = arrivalStation,
                DepartureStation = departureStation,
                FlightDesignator = flightDesignator,
                PaxSSRs          = list.ToArray(),
                STD = departureDateTime
            };

            return(segmentSSRRequest);
        }
        // public BookingUpdateResponseData createBooking(GetLowFareAvailabilityResponse availresponse, String faretype, int numadt, int numchd, String currency, String sourceorg, String agentcode)
        // {
        public BookingUpdateResponseData createBooking(GetAvailabilityResponse availresponse, String faretype, int numadt, int numchd, String currency, String sourceorg, String agentcode)
        {
            SellRequest sellrequest = new SellRequest();
            sellrequest.Signature = signature;

            //to indicate we are selling the ticket a journey:
            sellrequest.SellRequestData = new SellRequestData();
            sellrequest.SellRequestData.SellBy = SellBy.Journey;//sell the ticket by journey
            sellrequest.SellRequestData.SellJourneyRequest = new SellJourneyRequest();

               SellJourneyRequestData selldata = new SellJourneyRequestData();

               selldata.TypeOfSale = new TypeOfSale();
               selldata.TypeOfSale.FareTypes = new string[1];
               selldata.TypeOfSale.FareTypes[0] = faretype;

            selldata.CurrencyCode = currency;//this is required to get pricing details

            //i need to specify Adult + child in the pax count variable but in the xml log this will be overrriden by the passenger info
            selldata.PaxCount = (short)(numadt + numchd);//this will define the number of passengers 2 sell
            //selldata.PaxCount = 0;

            // selldata.Journeys = new SellJourney[pricedata.PriceJourneys.Length];//in the case of 1 way trip, just replace by new SellJourney[1]
            selldata.Journeys = new SellJourney[1];// for 1 way flight- put 1 as original , for 2 way flight as 2

            for (int i = 0; i < selldata.Journeys.Length; i++)
            {
                selldata.Journeys[i] = new SellJourney();

                Segment[] availsegment = availresponse.GetTripAvailabilityResponse.Schedules[i][0].Journeys[0].Segments;//change back to index 0 for Journeys

                selldata.Journeys[i].Segments = new SellSegment[availsegment.Length];

                Console.WriteLine("Flight Number is :" + availsegment[i].FlightDesignator.CarrierCode + " " + availsegment[i].FlightDesignator.FlightNumber);
                Console.WriteLine("Flight Timing is :" + availsegment[i].STD + " " + availsegment[i].STA);
                Console.WriteLine("Flight Duration is :" + availsegment[i].STA.AddMinutes(availsegment[i].Legs[availsegment[i].Legs.Length-1].LegInfo.ArrvLTV*-1).Subtract(availsegment[i].STD.AddMinutes(availsegment[i].Legs[0].LegInfo.DeptLTV*-1)));//provided by peiru

               // Fare fare = availsegment[i].Fares[0];//get the fares at index 0 for starter and 1 for starter plus and 2 for max which will only apply for voucher details

                for (int j = 0; j < selldata.Journeys[i].Segments.Length; j++)
                {

                    selldata.Journeys[i].Segments[j] = new SellSegment();
                    selldata.Journeys[i].Segments[j].ActionStatusCode = "NN";
                    selldata.Journeys[i].Segments[j].FlightDesignator = availsegment[j].FlightDesignator;
                    selldata.Journeys[i].Segments[j].ArrivalStation = availsegment[j].ArrivalStation;
                    selldata.Journeys[i].Segments[j].DepartureStation = availsegment[j].DepartureStation;
                    selldata.Journeys[i].Segments[j].STA = availsegment[j].STA;
                    selldata.Journeys[i].Segments[j].STD = availsegment[j].STD;

                    //if (fare.ProductClass.StartsWith("S"))
                    //    Console.Write("Starter ");
                    //else if (fare.ProductClass.StartsWith("P"))
                    //    Console.Write("Starter Plus");
                    //else if (fare.ProductClass.StartsWith("Y"))
                    //    Console.Write("Starter Max");
                    //else if (fare.ProductClass.StartsWith("F"))
                    //    Console.Write("Business Max");
                    //else if (fare.ProductClass.StartsWith("J"))
                    //    Console.Write("Business");

                   // selldata.Journeys[i].Segments[j].Fare = new SellFare();//uncomment this
                   //selldata.Journeys[i].Segments[j].Fare.CarrierCode = fare.CarrierCode;//uncomment this
                   ////selldata.Journeys[i].Segments[j].Fare.CarrierCode = "BL";//- this is for test

                   //selldata.Journeys[i].Segments[j].Fare.ClassOfService = fare.ClassOfService;//uncomment this
                   // // segments[j].Fare.ClassOfService = fare.ClassOfService;
                   // selldata.Journeys[i].Segments[j].Fare.FareApplicationType = fare.FareApplicationType;//uncomment this
                   // // segments[j].Fare.FareApplicationType = fare.FareApplicationType;
                   // selldata.Journeys[i].Segments[j].Fare.FareBasisCode = fare.FareBasisCode;//uncomment this
                   // //segments[j].Fare.FareBasisCode = fare.FareBasisCode;
                   //selldata.Journeys[i].Segments[j].Fare.ProductClass = fare.ProductClass;//uncomment this
                   // //segments[j].Fare.ProductClass = fare.ProductClass;
                   // selldata.Journeys[i].Segments[j].Fare.RuleNumber = fare.RuleNumber;//uncommnet this
                   // // segments[j].Fare.RuleNumber = fare.RuleNumber;

                    for (int k = 0; k < availsegment[i].Fares.Length; k++)// i do not use availsegment.Length directly here as i need to get the fares associated with each segment
                    {
                        Fare fare = availsegment[i].Fares[k];
                        Console.WriteLine((k + 1) + ")Class: ");
                        if (fare.ProductClass.StartsWith("S"))
                            Console.Write("Startter");
                        else if (fare.ProductClass.StartsWith("P"))
                            Console.Write("Starter Plus");
                        else if (fare.ProductClass.StartsWith("Y"))
                            Console.Write("StarterMax");
                        else if (fare.ProductClass.StartsWith("F"))
                            Console.Write("Business Max");
                        else if (fare.ProductClass.StartsWith("J"))
                            Console.Write("Business");
                        Console.WriteLine(fare.ProductClass + ", Basis Code :" + fare.FareBasisCode);

                        selldata.Journeys[i].Segments[j].Fare = new SellFare();
                        selldata.Journeys[i].Segments[j].Fare.CarrierCode = availsegment[j].Fares[k].CarrierCode;
                        selldata.Journeys[i].Segments[j].Fare.ClassOfService = availsegment[j].Fares[k].ClassOfService;
                        selldata.Journeys[i].Segments[j].Fare.FareApplicationType = availsegment[j].Fares[k].FareApplicationType;
                        selldata.Journeys[i].Segments[j].Fare.FareBasisCode = availsegment[j].Fares[k].FareBasisCode;
                        selldata.Journeys[i].Segments[j].Fare.ProductClass = availsegment[j].Fares[k].ProductClass;
                        selldata.Journeys[i].Segments[j].Fare.RuleNumber = availsegment[j].Fares[k].RuleNumber;

                    }

                      //  Console.WriteLine(fare.ProductClass + ", Basis Code : " + fare.FareBasisCode + ", Class of Service : " + fare.ClassOfService);// writing in the loop will return me the fare details in each segment of journey

                }

            }
            //to retrieve n chnage booknigs, it must belong to a current agent and organization, which are set in POS
            //SellRequest must contain a correct SourcePOS
            if (sourceorg.Length > 0)
            {
                selldata.SourcePOS = new PointOfSale();
                selldata.SourcePOS.AgentCode = agentcode;
                selldata.SourcePOS.OrganizationCode = sourceorg;
                selldata.SourcePOS.DomainCode = "EXT";
                selldata.SourcePOS.LocationCode = "API";

            }
            else
            {
                selldata.SourcePOS = new PointOfSale();
                selldata.SourcePOS.AgentCode = "JQ";
                selldata.SourcePOS.OrganizationCode = "JQ";
                selldata.SourcePOS.DomainCode = "EXT";
                selldata.SourcePOS.LocationCode = "APT";

            }

            //i have to assign the value back to obj selldata in the last state for most updated value

            sellrequest.SellRequestData.SellJourneyRequest.SellJourneyRequestData = selldata;

            SellResponse sellresponse = clientapi.Sell(sellrequest);
            System.Console.WriteLine("Total Flight Cost {0:C}", sellresponse.BookingUpdateResponseData.Success.PNRAmount.TotalCost);

            //this completes the flightcost by using SellRequest using SellBy Journey.
            //---------------------------------------------------------------------------------------------------------

            GetBookingFromStateRequest bookingfromstaterequest = new GetBookingFromStateRequest();
            bookingfromstaterequest.Signature = signature;
            GetBookingFromStateResponse bookingfromstateresponse = clientapi.GetBookingFromState(bookingfromstaterequest);

            // this is to get the SSR cost

            //------------------------------------------------------------------------------------------------------------

               // PassengerInfant passengerInfant = null;
              PassengerInfant []passengerInfant = new PassengerInfant[2];
              passengerInfant[0] = new PassengerInfant();
              passengerInfant[1] = new PassengerInfant();
            //----------------------------------------------------------------------------------------------------------------------
            //lets say if i have 3 ssr to sell, so i put in a for loop

              // SellRequest []sellSSRRequest3 = new SellRequest[3]; //if i need to put this in an array

              //for (int m = 0; m < sellSSRRequest3.Length; m++)
              //{
              //    sellSSRRequest3[m] = new SellRequest();
              //    sellSSRRequest3[m].Signature = signature;
              //    SellRequestData sellrequestdata3 = new SellRequestData();
              //    sellSSRRequest3[m].SellRequestData = sellrequestdata3;
              //    sellrequestdata3.SellBy = SellBy.SSR;
              //    SellSSR sellssr3 = new SellSSR();
              //    sellrequestdata3.SellSSR = sellssr3;
              //    sellssr3.SSRRequest = new SSRRequest();
              //    SSRRequest ssrrequest3 = new SSRRequest();
              //    sellssr3.SSRRequest = ssrrequest3;

              //    ssrrequest3.CurrencyCode = "AUD";

              //ssrrequest3.SegmentSSRRequests = new SegmentSSRRequest[1];
              //SegmentSSRRequest segmentSSRRequest = new SegmentSSRRequest();
              //ssrrequest3.SegmentSSRRequests[0] = segmentSSRRequest;

            //----------------------------------------------------------------------------------------------------

            SellRequest sellSSRRequest = new SellRequest();
            sellSSRRequest.Signature = signature;
            SellRequestData sellrequestdata = new SellRequestData();
            sellSSRRequest.SellRequestData = sellrequestdata;

            sellrequestdata.SellBy = SellBy.SSR;
            SellSSR sellssr = new SellSSR();
            sellrequestdata.SellSSR = sellssr;

            sellssr.SSRRequest = new SSRRequest();
            SSRRequest ssrrequest = new SSRRequest();
            sellssr.SSRRequest = ssrrequest;
            ssrrequest.CurrencyCode = "AUD";
            //----------------------------------------------------------------
            //this is for  the second SSR
            SellRequest sellSSRRequest2 = new SellRequest();
            sellSSRRequest2.Signature = signature;
            SellRequestData sellrequestdata2 = new SellRequestData();
            sellSSRRequest2.SellRequestData = sellrequestdata2;

            sellrequestdata2.SellBy = SellBy.SSR;
            SellSSR sellssr2 = new SellSSR();
            sellrequestdata2.SellSSR = sellssr2;

            sellssr2.SSRRequest = new SSRRequest();
            SSRRequest ssrrequest2 = new SSRRequest();
            sellssr2.SSRRequest = ssrrequest2;
            ssrrequest2.CurrencyCode = "AUD";

            //-------------------------------------------------------------------------------------------------
               //this is for the first SSR
            ssrrequest.SegmentSSRRequests = new SegmentSSRRequest[1];
            //since SegmentSSRRequests is an array data type, the way to write in one step is :
            //ssrrequest.SegmentSSRRequests[0] = new SegmentSSRRequest(); otherwise as below in 2 steps
            SegmentSSRRequest segmentSSRRequest = new SegmentSSRRequest();
            ssrrequest.SegmentSSRRequests[0] = segmentSSRRequest;

            //-------------------------------------------------------------------------------------------------
            //this is for the second SSR
               ssrrequest2.SegmentSSRRequests = new SegmentSSRRequest[1];
            SegmentSSRRequest segmentSSRRequest2 = new SegmentSSRRequest();
            ssrrequest2.SegmentSSRRequests[0] = segmentSSRRequest2;

            //--------------------------------------------------------------------------------------------------------------------

            //--------------------------------------------------------------------------------------------------------

            selldata.Journeys = new SellJourney[1];// for 1 way flight

            for (int i = 0; i < selldata.Journeys.Length; i++)
            {
                selldata.Journeys[i] = new SellJourney();

                Segment[] availsegment = availresponse.GetTripAvailabilityResponse.Schedules[i][0].Journeys[0].Segments;

                selldata.Journeys[i].Segments = new SellSegment[availsegment.Length];

                for (int j = 0; j < selldata.Journeys[i].Segments.Length; j++)
                {

                    selldata.Journeys[i].Segments[j] = new SellSegment();

                    segmentSSRRequest.ArrivalStation = availsegment[j].ArrivalStation;
                    segmentSSRRequest.DepartureStation = availsegment[j].DepartureStation;
                    segmentSSRRequest.FlightDesignator = availsegment[j].FlightDesignator;
                    segmentSSRRequest.STD = availsegment[j].STD;

                    //this is for the second SSRRequest

                    segmentSSRRequest2.ArrivalStation = availsegment[j].ArrivalStation;
                    segmentSSRRequest2.DepartureStation = availsegment[j].DepartureStation;
                    segmentSSRRequest2.FlightDesignator = availsegment[j].FlightDesignator;
                    segmentSSRRequest2.STD = availsegment[j].STD;

                    ssrrequest.SegmentSSRRequests[0].PaxSSRs = new PaxSSR[selldata.PaxCount];//change this back to 0 instead of j

                    ssrrequest2.SegmentSSRRequests[0].PaxSSRs = new PaxSSR[selldata.PaxCount];//change this back to 0 instead of j

                    for (int k = 0; k < selldata.PaxCount; k++)
                    {
                        ssrrequest.SegmentSSRRequests[0].PaxSSRs[k] = new PaxSSR();//only first segment has ssr

                        ssrrequest.SegmentSSRRequests[0].PaxSSRs[k].ActionStatusCode = "NN";
                        ssrrequest.SegmentSSRRequests[0].PaxSSRs[k].DepartureStation = availsegment[j].DepartureStation;
                        ssrrequest.SegmentSSRRequests[0].PaxSSRs[k].ArrivalStation = availsegment[j].ArrivalStation;

                        Console.Write("SSR : (BG20): ");//BA droid is added by BCS we dont check....IFOO SSR is only made available on long haul flights
                        String line2 = Console.ReadLine();
                        if (line2.Length == 0)
                        {
                            line2 = "BG20";//BA droid is added by BCS we dont check
                        }

                        ssrrequest.SegmentSSRRequests[0].PaxSSRs[k].SSRCode = line2.ToUpper();
                        ssrrequest.SegmentSSRRequests[0].PaxSSRs[k].SSRNumber = (short)k;
                        ssrrequest.SegmentSSRRequests[0].PaxSSRs[k].PassengerNumber = (short)(k % selldata.PaxCount);

                    }

            //---------------------------------------------------------------------------------------------------------------------

                    for (int k = 0; k < selldata.PaxCount; k++)
                    {
                        ssrrequest2.SegmentSSRRequests[0].PaxSSRs[k] = new PaxSSR();

                        ssrrequest2.SegmentSSRRequests[0].PaxSSRs[k].ActionStatusCode = "NN";
                        ssrrequest2.SegmentSSRRequests[0].PaxSSRs[k].DepartureStation = availsegment[j].DepartureStation;
                        ssrrequest2.SegmentSSRRequests[0].PaxSSRs[k].ArrivalStation = availsegment[j].ArrivalStation;

                        Console.Write("SSR 2 (INFT): ");
                        String line3 = Console.ReadLine();
                        if (line3.Length == 0)
                            line3 = "INFT";

                        if (line3.ToUpper().Equals("INFT"))
                        {
                            passengerInfant[0] = new PassengerInfant();
                            passengerInfant[0].DOB = new DateTime(2014, 2, 03);
                            passengerInfant[0].Gender = Gender.Female;
                            passengerInfant[0].State = MessageState.New;
                            passengerInfant[0].Names = new BookingName[1];
                            passengerInfant[0].Names[0] = new BookingName();

                            passengerInfant[0].Names[0].FirstName = "Michelle";
                           passengerInfant[0].Names[0].LastName = "idontknow";
                            passengerInfant[0].Names[0].Title = "Miss";//master

                            passengerInfant[0].Nationality = "SG";
                            passengerInfant[0].ResidentCountry = "SG";

                            passengerInfant[1] = new PassengerInfant();
                            passengerInfant[1].DOB = new DateTime(2013, 3, 03);
                            passengerInfant[1].Gender = Gender.Female;
                            passengerInfant[1].State = MessageState.New;
                            passengerInfant[1].Names = new BookingName[1];
                            passengerInfant[1].Names[0] = new BookingName();

                            passengerInfant[1].Names[0].FirstName = "Michelle2";
                            passengerInfant[1].Names[0].LastName = "idontknow2";
                            passengerInfant[1].Names[0].Title = "Miss";//master

                            passengerInfant[1].Nationality = "SG";
                            passengerInfant[1].ResidentCountry = "SG";

                        }

                        ssrrequest2.SegmentSSRRequests[0].PaxSSRs[k].SSRCode = line3.ToUpper();
                        ssrrequest2.SegmentSSRRequests[0].PaxSSRs[k].SSRNumber = (short)k;
                        ssrrequest2.SegmentSSRRequests[0].PaxSSRs[k].PassengerNumber = (short)(k % selldata.PaxCount);

                    }

                }

            }

            SellResponse sellssrresponse = clientapi.Sell(sellSSRRequest);

            SellResponse sellssrresponse2 = clientapi.Sell(sellSSRRequest2);

            System.Console.WriteLine("Total Flight + 1st SSR Cost : {0:C}", sellssrresponse.BookingUpdateResponseData.Success.PNRAmount.TotalCost);
            System.Console.WriteLine("Total Flight + 1st and 2nd SSR Cost : {0:C}", sellssrresponse2.BookingUpdateResponseData.Success.PNRAmount.TotalCost);

             //---------------------------------------------------------------------------------------------------------------------------------------
             // this is the end of the SSR cost

            Booking booking = new Booking();
            booking.Passengers = new Passenger[numadt + numchd];
               // booking.Passengers = new Passenger[numadt];this means the credit card fee will only be applied to the adt

            Decimal balancedue = 0.0M;

            //this is to get the credit card fees for per journey and passenger basis
            //------------------------------------------------------------------------------------------------------------------------
               for (int i = 0; i < numadt+ numchd; i++)//selldata.Paxcount
            {
                booking.Passengers[i] = new Passenger();
                booking.Passengers[i].PassengerFees = new PassengerFee[1];
                booking.Passengers[i].PassengerFees[0] = new PassengerFee();

                GetPaymentFeePriceRequest paymentfeepricerequest = new GetPaymentFeePriceRequest();
                paymentfeepricerequest.paymentFeePriceReqData = new PaymentFeePriceRequest();//i added this
                paymentfeepricerequest.Signature = signature;

                paymentfeepricerequest.paymentFeePriceReqData.FeeCode = "CC";
                paymentfeepricerequest.paymentFeePriceReqData.CurrencyCode = "AUD";
                paymentfeepricerequest.paymentFeePriceReqData.PaymentAmount = sellresponse.BookingUpdateResponseData.Success.PNRAmount.BalanceDue;

                GetPaymentFeePriceResponse paymentfeeresponse = new GetPaymentFeePriceResponse();
                paymentfeeresponse.paymentFeePriceRespData = new PaymentFeePriceResponse();

                paymentfeeresponse = clientapi.GetPaymentFeePrice(paymentfeepricerequest);

                //since the booking charge is made on per passenger per journey basis

                //balancedue = sellssrresponse2.BookingUpdateResponseData.Success.PNRAmount.TotalCost;//required for payment currency. this will pass the most updated balance due...** if it is stored somewhere else, will show discrepancy in total cost and payment.

                if (paymentfeeresponse.paymentFeePriceRespData.PassengerFees.Length > 0)//this checks for passenger fees
                {
                    Console.WriteLine("CC Fee: {0:C} " + paymentfeeresponse.paymentFeePriceRespData.PassengerFees[0].ServiceCharges[0].Amount);
                }
            }

               balancedue = sellssrresponse2.BookingUpdateResponseData.Success.PNRAmount.TotalCost;//required for payment currency. this will pass the most updated balance due...** if it is stored somewhere else, will show discrepancy in total cost and payment.
            //before make payment thru credit card, need to get the most updated balance thru balancedue after i have sold the flight and the SSR
            //-------------------------------------------------------------------------------------------------------------------------------------------
            //this is the end of the Credit Card fees

            //this is for Sell Fee(additional fees outside of credit cards)-- not required for external partners
            //-------------------------------------------------------------------------------------------------------------

            //payment using 2 function calls : AddPaymentToBooking() + BookingCommit() : can be a method byitself of paybooking(String PNR)

            //creditcard fees
               // Decimal balancedue = sellresponse.BookingUpdateResponseData.Success.PNRAmount.BalanceDue;

            //start payment
            AddPaymentToBookingRequest paymentrequest = new AddPaymentToBookingRequest();
            paymentrequest.addPaymentToBookingReqData = new AddPaymentToBookingRequestData();
            paymentrequest.Signature = signature;
            paymentrequest.ContractVersion = 0;

            String response;

            if (Double.Parse(balancedue.ToString()) > 0.0)
            {
                Console.Write("Payment (MC/VI/AX/DI/JB/TP/AG): ");
                response = Console.ReadLine().ToUpper();

                if (response.Equals("MC"))
                {
                    paymentrequest.addPaymentToBookingReqData.PaymentMethodType = RequestPaymentMethodType.ExternalAccount;
                    paymentrequest.addPaymentToBookingReqData.PaymentMethodCode = "MC";
                    paymentrequest.addPaymentToBookingReqData.QuotedCurrencyCode = currency;
                    paymentrequest.addPaymentToBookingReqData.QuotedAmount = balancedue;
                 paymentrequest.addPaymentToBookingReqData.AccountNumber = "5453010000064154";
                   // paymentrequest.addPaymentToBookingReqData.AccountNumber = "5224999999999909";// for test
                    paymentrequest.addPaymentToBookingReqData.Expiration = DateTime.Parse("2015-05");
                    paymentrequest.addPaymentToBookingReqData.PaymentText = "Test Payment";

                    paymentrequest.addPaymentToBookingReqData.PaymentFields = new PaymentField[2];
                    paymentrequest.addPaymentToBookingReqData.PaymentFields[0] = new PaymentField();
                    paymentrequest.addPaymentToBookingReqData.PaymentFields[0].FieldName = "CC::AccountHolderName";
                    paymentrequest.addPaymentToBookingReqData.PaymentFields[0].FieldValue = "Test";
                    paymentrequest.addPaymentToBookingReqData.PaymentFields[1] = new PaymentField();
                    paymentrequest.addPaymentToBookingReqData.PaymentFields[1].FieldName = "CC::VerificationCode";
                    paymentrequest.addPaymentToBookingReqData.PaymentFields[1].FieldValue = "123";
                }
                else if (response.Equals("AX"))
                {
                    paymentrequest.addPaymentToBookingReqData.PaymentMethodType = RequestPaymentMethodType.ExternalAccount;
                    paymentrequest.addPaymentToBookingReqData.PaymentMethodCode = "AX";
                    paymentrequest.addPaymentToBookingReqData.QuotedCurrencyCode = currency;
                    paymentrequest.addPaymentToBookingReqData.QuotedAmount = balancedue;
                    paymentrequest.addPaymentToBookingReqData.AccountNumber = "345678000000007";
                    paymentrequest.addPaymentToBookingReqData.PaymentText = "Amex Payment";
                    paymentrequest.addPaymentToBookingReqData.Expiration = DateTime.Parse("2015-05");

                    paymentrequest.addPaymentToBookingReqData.PaymentFields = new PaymentField[2];
                    paymentrequest.addPaymentToBookingReqData.PaymentFields[0] = new PaymentField();
                    paymentrequest.addPaymentToBookingReqData.PaymentFields[0].FieldName = "CC::AccountHolderName";
                    paymentrequest.addPaymentToBookingReqData.PaymentFields[0].FieldValue = "Test";
                    paymentrequest.addPaymentToBookingReqData.PaymentFields[1] = new PaymentField();
                    paymentrequest.addPaymentToBookingReqData.PaymentFields[1].FieldName = "CC::VerificationCode";
                    paymentrequest.addPaymentToBookingReqData.PaymentFields[1].FieldValue = "1234";

                }
                else if (response.Equals("TP"))
                {

                    paymentrequest.addPaymentToBookingReqData.PaymentMethodType = RequestPaymentMethodType.ExternalAccount;
                    paymentrequest.addPaymentToBookingReqData.PaymentMethodCode = "TP";
                    paymentrequest.addPaymentToBookingReqData.QuotedCurrencyCode = currency;
                    paymentrequest.addPaymentToBookingReqData.QuotedAmount = balancedue;

                    paymentrequest.addPaymentToBookingReqData.AccountNumber = "135416000696332";
                    paymentrequest.addPaymentToBookingReqData.PaymentText = "UATP Payment";
                    paymentrequest.addPaymentToBookingReqData.Expiration = DateTime.Parse("2014-12");

                    paymentrequest.addPaymentToBookingReqData.PaymentFields = new PaymentField[2];
                    paymentrequest.addPaymentToBookingReqData.PaymentFields[0] = new PaymentField();
                    paymentrequest.addPaymentToBookingReqData.PaymentFields[0].FieldName = "CC::AccountHolderName";
                    paymentrequest.addPaymentToBookingReqData.PaymentFields[0].FieldValue = "Anannya";
                    paymentrequest.addPaymentToBookingReqData.PaymentFields[1] = new PaymentField();
                    paymentrequest.addPaymentToBookingReqData.PaymentFields[1].FieldName = "CC::Verification Code";

                }

                else if (response.Equals("AG"))//if i use this, then i need to call AddPaymentToBooking twice
                {

                    paymentrequest.addPaymentToBookingReqData.PaymentMethodType = RequestPaymentMethodType.AgencyAccount;
                    paymentrequest.addPaymentToBookingReqData.PaymentMethodCode = "AG";
                    paymentrequest.addPaymentToBookingReqData.QuotedCurrencyCode = currency;

                    if (sourceorg.Length > 0)
                    {
                        paymentrequest.addPaymentToBookingReqData.AccountNumber = sourceorg;
                    }

                    paymentrequest.addPaymentToBookingReqData.PaymentFields = null;

                }

                else //if (response.Equals("VI"))
                {
                    paymentrequest.addPaymentToBookingReqData.PaymentMethodType = RequestPaymentMethodType.ExternalAccount;
                    paymentrequest.addPaymentToBookingReqData.PaymentMethodCode = "VI";
                    paymentrequest.addPaymentToBookingReqData.QuotedCurrencyCode = currency;
                    paymentrequest.addPaymentToBookingReqData.QuotedAmount = balancedue;
                    // paymentrequest.addPaymentToBookingReqData.AccountNumber = "30123400000000";- for Diners

                    paymentrequest.addPaymentToBookingReqData.AccountNumber = "4929498311400002";// this is a 3DS card-the authorization status will be pending client response
                    // paymentrequest.addPaymentToBookingReqData.AccountNumber = "4123450131001381";
                    // paymentrequest.addPaymentToBookingReqData.AccountNumber = "4543059790016721";- for test booking
                    paymentrequest.addPaymentToBookingReqData.Expiration = DateTime.Parse("2015-05");
                    paymentrequest.addPaymentToBookingReqData.PaymentText = "Test Payment";

                    paymentrequest.addPaymentToBookingReqData.PaymentFields = new PaymentField[2];
                    paymentrequest.addPaymentToBookingReqData.PaymentFields[0] = new PaymentField();
                    paymentrequest.addPaymentToBookingReqData.PaymentFields[0].FieldName = "CC::AccountHolderName";
                    paymentrequest.addPaymentToBookingReqData.PaymentFields[0].FieldValue = "Test";
                    paymentrequest.addPaymentToBookingReqData.PaymentFields[1] = new PaymentField();
                    paymentrequest.addPaymentToBookingReqData.PaymentFields[1].FieldName = "CC::VerificationCode";
                    paymentrequest.addPaymentToBookingReqData.PaymentFields[1].FieldValue = "123";
                }
            }

            //paymentrequest.addPaymentToBookingReqData.AccountNumberID = 0;// not required for new booking; only  use this  if the card cd has been swipped before n then it has an account tied to it

            AddPaymentToBookingResponse paymentresponse = clientapi.AddPaymentToBooking(paymentrequest);

            //validate the payments
            ValidationPayment validationpayment = paymentresponse.BookingPaymentResponse.ValidationPayment;

            if (validationpayment.PaymentValidationErrors.Length > 0)
            {
                Console.WriteLine(validationpayment.PaymentValidationErrors[0].ErrorDescription);
                return null;
            }

            if (validationpayment.Payment.PaymentAddedToState)
            {
                Console.WriteLine("Payment added to booking state : Payment complete");
            }

            //for adding AG payment
            // .
            //.
            //.

            //after AddpaymentToBooking; then i need to do BookingCommit(); first do the bookingcontacts and update passenger list first

            BookingCommitRequest bookingcommitrequest = new BookingCommitRequest();
            bookingcommitrequest.Signature = signature;
               // bookingcommitrequest.BookingCommitRequestData = new BookingCommitRequestData();
            BookingCommitRequestData bookingcommitrequestdata = new BookingCommitRequestData();
            bookingcommitrequest.BookingCommitRequestData = bookingcommitrequestdata;

            //-------------------------------------------------------------------------------------------------------------------

            //BookingContact[] bookingContacts = new BookingContact[1];
            //bookingContacts[0] = new BookingContact();
            //bookingContacts[0].State = MessageState.New;
            //bookingContacts[0].Names = new BookingName[1];
            //bookingContacts[0].Names[0] = new BookingName();
            //bookingContacts[0].Names[0].FirstName = "Michelle";
            //bookingContacts[0].Names[0].LastName = "Sadhnani";
            //bookingContacts[0].Names[0].Title = "Miss";
            //if (sourceorg.Length > 0)
            //{
            //    bookingContacts[0].SourceOrganization = sourceorg;
            //}
            //bookingContacts[0].AddressLine1 = "123 Airport Road";
            //bookingContacts[0].AddressLine2 = "Boulevard Terminal";
            //bookingContacts[0].City = "Singapore";
            //bookingContacts[0].CountryCode = "SG";
            //bookingContacts[0].EmailAddress = "*****@*****.**";
            //// bookingContacts[0].EmailAddress = "*****@*****.**";//for test purposes
            //bookingContacts[0].ProvinceState = "AB";
            //bookingContacts[0].PostalCode = "123456789";
            //bookingContacts[0].OtherPhone = "91444345";// this is my mobile number
            //bookingContacts[0].HomePhone = "+65654321";
            //bookingContacts[0].TypeCode = "P";
            //bookingContacts[0].CultureCode = "en-AU";
            //bookingContacts[0].DistributionOption = DistributionOption.Email;
            //bookingContacts[0].NotificationPreference = NotificationPreference.None;
                //-----------------------------------------------------------------------------------------------------------------

            //Anannya- get prompt from user : another way of writing
            //-----------------------------------------------------------------------------------------------------------
                   //this is for declaring 2 booking contacts
             //           BookingContact[] BookingContacts = new BookingContact[2];

             //           for (int i = 0; i < BookingContacts.Length; i++)
             //           {
             //              BookingContacts[i] = new BookingContact();
             //              BookingContacts[i].State = MessageState.New;
             //              BookingContacts[i].Names = new BookingName[1];
             //               BookingName bookingname = new BookingName();
             //               BookingContacts[i].Names[0] = bookingname;

             //               String firstname, lastname, salutation, emailadd, mobilenumber;

             //               Console.Write("Provide Booking Contact First Name for Emeergency :");
             //               firstname = Console.ReadLine().ToUpper();
             //               Console.Write("Provide Booking Contact Last Name for Emeergency :");
             //               lastname = Console.ReadLine().ToUpper();
             //               Console.Write("Provide Booking Contact Title :");
             //               salutation = Console.ReadLine().ToUpper();
             //               Console.Write("Provide Booking Contact E-Mail add for Emeergency :");
             //               emailadd = Console.ReadLine().ToUpper();
             //               Console.Write("Provide Booking Contact Mobile Number for Emeergency :");
             //               mobilenumber = Console.ReadLine().ToUpper();

             //               bookingname.FirstName = firstname;
             //               bookingname.LastName = lastname;
             //               bookingname.Title = salutation;

             //               if (sourceorg.Length > 0)
             //               {
             //                  BookingContacts[i].SourceOrganization = sourceorg;
             //               }

             //              BookingContacts[i].AddressLine1 = "123 Airport Road";
             //              BookingContacts[i].AddressLine2 = "Boulevard Terminal";
             //               BookingContacts[i].City = "Singapore";
             //             BookingContacts[i].CountryCode = "SG";
             //              BookingContacts[i].EmailAddress = emailadd;
             //                BookingContacts[i].ProvinceState = "AB";
             //               BookingContacts[i].PostalCode = "123456789";
             //                BookingContacts[i].OtherPhone = mobilenumber;// this is my mobile number
             //               BookingContacts[i].HomePhone = "+65654321";
             //BookingContacts[i].TypeCode = "P";
             //BookingContacts[i].CultureCode = "en-AU";
             //               BookingContacts[i].DistributionOption = DistributionOption.Email;
             //              BookingContacts[i].NotificationPreference = NotificationPreference.None;

             //         }----------------------------------------------------------------------------------------------------------
            //in the even i do not want a prompt and just pur to one booknig contact only still in an array:
            BookingContact[] BookingContacts = new BookingContact[1];

                BookingContacts[0] = new BookingContact();
                BookingContacts[0].State = MessageState.New;
                BookingContacts[0].Names = new BookingName[1];
                BookingName bookingname = new BookingName();
                BookingContacts[0].Names[0] = bookingname;

                bookingname.FirstName = "Anannya";
                bookingname.LastName = "Sadhnani";
                bookingname.Title = "ms".ToUpper();

                if (sourceorg.Length > 0)
                {
                    BookingContacts[0].SourceOrganization = sourceorg;
                }

                BookingContacts[0].AddressLine1 = "123 Airport Road";
                BookingContacts[0].AddressLine2 = "Boulevard Terminal";
                BookingContacts[0].City = "Singapore";
                BookingContacts[0].CountryCode = "SG";
                BookingContacts[0].EmailAddress = "*****@*****.**";
                BookingContacts[0].ProvinceState = "AB";
                BookingContacts[0].PostalCode = "123456789";
                BookingContacts[0].OtherPhone = "91444345";// this is my mobile number
                BookingContacts[0].HomePhone = "+65654321";
                BookingContacts[0].TypeCode = "P";
                BookingContacts[0].CultureCode = "en-AU";
                BookingContacts[0].DistributionOption = DistributionOption.Email;
                BookingContacts[0].NotificationPreference = NotificationPreference.None;

                bookingcommitrequestdata.DistributeToContacts = true;//by default this is set to false, we need to set this line to true.

            //---------------------------------------------------------------------------------------------------------

            //update the booking contacts in the bookingcommit request
            UpdateContactsRequest updatecontactrequest = new UpdateContactsRequest();
            updatecontactrequest.Signature = signature;
            updatecontactrequest.updateContactsRequestData = new UpdateContactsRequestData();
            //updatecontactrequest.updateContactsRequestData.BookingContactList = bookingContacts;
               updatecontactrequest.updateContactsRequestData.BookingContactList = BookingContacts;
            clientapi.UpdateContacts(updatecontactrequest);

            //----------------------------------------------------------------------------

            // booking comment array setup here

               // Booking booking = new Booking();//create the booking obj so that i can pass the passenger info to it
            booking.ReceivedBy = new ReceivedByInfo();
            booking.ReceivedBy.LatestReceivedBy = "TesttoMichelle";

            booking.BookingComments = new BookingComment[2];
            booking.BookingComments[0] = new BookingComment();
            booking.BookingComments[0].CommentText = "This is a one way intl route booking test-PER to DPS";
            booking.BookingComments[0].CommentType = CommentType.Default;
            booking.BookingComments[1] = new BookingComment();
            booking.BookingComments[1].CommentText = "Whatever crap";
            booking.BookingComments[1].CommentType = CommentType.Default;

            bookingcommitrequest.BookingCommitRequestData.BookingComments = booking.BookingComments;
            //---------------------------------------------------------------------------------------------------

            //BookingHold bookinghold = new BookingHold();
               // booking.BookingHold.HoldDateTime = DateTime.Parse("0001-01-01T00:00:00"); this is not required in .net framework

            booking.Passengers = new Passenger[numadt + numchd];

            String title;
            String line;

            for (int i = 0; i < booking.Passengers.Length; i++)// or (int i=0; i<(numadt + numchd); i++)
            {
                booking.Passengers[i] = new Passenger();
                booking.Passengers[i].PassengerTypeInfos = new PassengerTypeInfo[1];//change back to 1
                booking.Passengers[i].PassengerTypeInfos[0] = new PassengerTypeInfo();

                //this is the way to write in 2 steps
               // PassengerTypeInfo passengertypeinfo = new PassengerTypeInfo();
                //booking.Passengers[i].PassengerTypeInfos[0] = passengertypeinfo;

                line = "M";

                if (i < numadt - 1)
                {
                    title = "MR";
                    line = "M";
                }
                else
                {
                    title = "MS";
                    line = "F";
                }
                //this is setting up the Passenger array object info

                booking.Passengers[i] = new Passenger();
                booking.Passengers[i].State = MessageState.New;//cannot put this to modified state as it will only take pax=1
                booking.Passengers[i].Names = new BookingName[1];//change back to 1
                booking.Passengers[i].Names[0] = new BookingName();
                booking.Passengers[i].Names[0].Title = title.ToUpper();//MR; MRS; etc

                String firstname, lastname, salutation;

                Console.Write("Provide your first name): ");
                firstname = Console.ReadLine().ToUpper();
                Console.Write("Provide your last name): ");
                lastname = Console.ReadLine().ToUpper();
                Console.Write("Salution): ");
                salutation = Console.ReadLine().ToUpper();

                booking.Passengers[i].Names[0].FirstName = firstname;
                booking.Passengers[i].Names[0].LastName = lastname;
                booking.Passengers[i].Names[0].Title = salutation;

                //if i hardcode
                //booking.Passengers[i].Names[0].FirstName = "Michelle";//replace back to the Passengers[i]
                //booking.Passengers[i].Names[0].LastName = "Sadhnani";
                //booking.Passengers[i].Names[0].Title = "MISS";

              //  if (i == 0 && passengerInfant != null)// i need this for passenger infant type SSR
                //{
                //if(i==0 && passengerInfant != null)//means not an adult or child
                if(i==0)
                    booking.Passengers[i].Infant = passengerInfant[0];
                    booking.Passengers[i].Infant = passengerInfant[1];

                //}

                    if (i > 0)
                    {
                        booking.Passengers[i].Names[0].Suffix = "EXST";
                    }

                booking.Passengers[i].PassengerInfo = new PassengerInfo();
                booking.Passengers[i].PassengerInfo.State = MessageState.Modified;
                booking.Passengers[i].PassengerInfo.Nationality = "SG";
                booking.Passengers[i].PassengerNumber = (short)i;

                if (line == "M")
                {
                    booking.Passengers[i].PassengerInfo.Gender = Gender.Male;
                    booking.Passengers[i].PassengerInfo.WeightCategory = WeightCategory.Male;
                }
                else
                {
                    booking.Passengers[i].PassengerInfo.Gender = Gender.Female;
                    booking.Passengers[i].PassengerInfo.WeightCategory = WeightCategory.Female;
                }

                //create the new PassengerTypeInfos array where i specify the total number of passengers, this excludes infants in PassegerTypeInfo[variable]
                booking.Passengers[i].PassengerTypeInfos = new PassengerTypeInfo[1];//change back to 1 if it does not work
                booking.Passengers[i].PassengerTypeInfos[0] = new PassengerTypeInfo();//change back PassengerTypeInfos to 0 if it doesnt work
               // booking.Passengers[i].PassengerTypeInfos[0].State = MessageState.Modified;
               // PassengerTypeInfo passengertypeinfo = new PassengerTypeInfo();
                //booking.Passengers[i].PassengerTypeInfos[0] = passengertypeinfo;
                //passengertypeinfo.PaxType = "ADT";
                //booking.Passengers[i].PassengerTypeInfos[1] = passengertypeinfo;
                //passengertypeinfo.PaxType = "CHD";

                if (i < numadt)
                {

                    booking.Passengers[i].PassengerTypeInfos[0].PaxType = "ADT";
                    booking.Passengers[i].PassengerTypeInfos[0].DOB = DateTime.Parse("1987-12-10T00:00:00");

                }
                else
                {
                    booking.Passengers[i].PassengerTypeInfos[0].PaxType = "CHD";
                    booking.Passengers[i].PassengerInfo.WeightCategory = WeightCategory.Child;
                    //selldata.Passengers[i].PassengerTypeInfos[0].DOB = DateTime.Parse("2008-8-12T00:00:00Z");
                }

                booking.Passengers[i].PaxDiscountCode = null;

                //this information is needed per the SkySpeed Passenger sub-object

                booking.Passengers[i].PassengerTravelDocuments = new PassengerTravelDocument[1];
                booking.Passengers[i].PassengerTravelDocuments[0] = new PassengerTravelDocument();
                booking.Passengers[i].PassengerTravelDocuments[0].Names = new BookingName[1];
                booking.Passengers[i].PassengerTravelDocuments[0].Names[0] = new BookingName();
                booking.Passengers[i].PassengerTravelDocuments[0].Names[0].Title = booking.Passengers[i].Names[0].Title;
                booking.Passengers[i].PassengerTravelDocuments[0].Names[0].FirstName = booking.Passengers[i].Names[0].FirstName;
                booking.Passengers[i].PassengerTravelDocuments[0].Names[0].LastName = booking.Passengers[i].Names[0].LastName;
                booking.Passengers[i].PassengerTravelDocuments[0].Gender = booking.Passengers[i].PassengerInfo.Gender;

                booking.Passengers[i].PassengerTravelDocuments[0].DocTypeCode = "P";
                booking.Passengers[i].PassengerTravelDocuments[0].IssuedByCode = "US";
                booking.Passengers[i].PassengerTravelDocuments[0].DocNumber = "12345";
                booking.Passengers[i].PassengerTravelDocuments[0].ExpirationDate = new DateTime(2010, 02, 01);

                //booking.Passengers[i].PassengerTravelDocuments[0].Names = new BookingName[1];
                //BookingName name = new BookingName();
                //booking.Passengers[i].PassengerTravelDocuments[0].Names[0] = name;

                //name.FirstName = "Anannya";
                //name.LastName = "Sadhnani";

                //now equate the passenger docs info to the passenger info
               // passengertraveldocs.Names = new BookingName[1];//uncomment this
               // BookingName bookingname2 = new BookingName();//uncomment this
               // passengertraveldocs.Names[0] = bookingname2;//uncomment this

                //bookingname2.Title = salutation;//uncomment this
                //bookingname2.LastName = lastname;//uncomment this
                //bookingname2.FirstName = firstname;//uncomment this
                //bookingname2.MiddleName = booking.Passengers[i].Names[0].MiddleName;//uncomment this

                //passengertraveldocs.DOB = booking.Passengers[i].PassengerTypeInfos[0].DOB;//uncomment this
                //passengertraveldocs.Gender = booking.Passengers[i].PassengerInfo.Gender;//uncomment this
                //passengertraveldocs.Nationality = booking.Passengers[i].PassengerInfo.Nationality;//uncomment this

                //passengertraveldocs.DocTypeCode = "OAFF";//uncomment this
                //passengertraveldocs.IssuedByCode = "QF";//uncomment this
                //passengertraveldocs.DocNumber = "6142116";//uncomment this
                //booking.Passengers[i].PassengerTravelDocuments[0].ExpirationDate = new DateTime(2020, 01, 01);//optional field//uncomment this
                //passengertraveldocs.IssuedDate = new DateTime(2012, 02, 01);//uncomment this

            }

            //------------------------------------------------------------------------------------------------------------------

            // start - use this to set the passenger info using the UpdatePassengers method

            UpdatePassengersRequest updatepassengerrequest = new UpdatePassengersRequest();
            updatepassengerrequest.Signature = signature;
            updatepassengerrequest.updatePassengersRequestData = new UpdatePassengersRequestData();
            updatepassengerrequest.updatePassengersRequestData.Passengers = booking.Passengers;

            clientapi.UpdatePassengers(updatepassengerrequest);

            // end - use this to set the passenger info using the UpdatePassengers method

            //----------------------------------------------------------------------------------------------------------------

            //------------------------------------------------------------------------------------------------------------------------

            //booking.BookingContacts = new BookingContact[2];//BookingContacts is an object of class BookingContacct,declariing to create 2 instances of the class [0] & [1]
            //booking.BookingContacts[0] = new BookingContact();//initialize the object
            //booking.BookingContacts[0].State = MessageState.New;//state is a propoerty of the BookingContact class
            //booking.BookingContacts[0].Names = new BookingName[2];//Names is a property of BookingContact class and an onject of BookingName class
            //booking.BookingContacts[0].Names[0] = new BookingName();
            //booking.BookingContacts[0].Names[0].FirstName = "Michelle";
            //booking.BookingContacts[0].Names[0].LastName = "Sadhnani";
            //booking.BookingContacts[0].Names[0].Title = "Miss";
            //if (sourceorg.Length > 0)
            //{
            //    booking.BookingContacts[0].SourceOrganization = sourceorg;
            //}
            //booking.BookingContacts[0].AddressLine1 = "123 Airport Road";
            //booking.BookingContacts[0].AddressLine2 = "Airport Boulevard";
            //booking.BookingContacts[0].City = "Singapore";
            //booking.BookingContacts[0].CountryCode = "SG";
            //booking.BookingContacts[0].EmailAddress = "*****@*****.**";
            //booking.BookingContacts[0].OtherPhone = "+659999999";
            //booking.BookingContacts[0].TypeCode = "P";
            //booking.BookingContacts[0].CultureCode = "en-AU";
            //booking.BookingContacts[0].DistributionOption = DistributionOption.Email;
            //booking.BookingContacts[0].NotificationPreference = NotificationPreference.None;

            // bookingcommitrequest.BookingCommitRequestData.BookingContacts = booking.BookingContacts;

            //booking.BookingComments = new BookingComment[2];
            //booking.BookingComments[0] = new BookingComment();
            //booking.BookingComments[0].CommentText = "This is a one way intl route booking test-PER to DPS";
            //booking.BookingComments[0].CommentType = CommentType.Default;
            //booking.BookingComments[1] = new BookingComment();
            //booking.BookingComments[1].CommentText = "Whatever crap";
            //booking.BookingComments[1].CommentType = CommentType.Default;

            //bookingcommitrequest.BookingCommitRequestData.BookingComments = booking.BookingComments;

            //now call the flight + cc + SSR cost
            //--------------------------------------------------------------------------------------------------------

            //--------------------------------------------------------------------------------------------------------------------
            BookingCommitResponse bookingcommitresponse = new BookingCommitResponse();

            bookingcommitresponse = clientapi.BookingCommit(bookingcommitrequest);
            Console.WriteLine("Booking Commited: " + bookingcommitresponse.BookingUpdateResponseData.Success.RecordLocator);

            // balancedue = bookingfromstateresponse.BookingData.BookingSum.BalanceDue;

            GetBookingPaymentsRequest getbookingpaymentrequest = new GetBookingPaymentsRequest();
            getbookingpaymentrequest.GetBookingPaymentsReqData = new GetBookingPaymentsRequestData();
            getbookingpaymentrequest.GetBookingPaymentsReqData.GetCurrentState = true;
            getbookingpaymentrequest.Signature = signature;
            GetBookingPaymentsResponse getbookingpaymentresponse = clientapi.GetBookingPayments(getbookingpaymentrequest);

            //    else if (response.Equals("AG"))
            //    {
            //        booking.Payments[0].PaymentMethodType = PaymentMethodType.AgencyAccount;
            //        booking.Payments[0].PaymentMethodCode = "AG";

            //        if (sourceorg.Length > 0)
            //        {
            //            booking.Payments[0].AccountNumber = sourceorg;
            //        }
            //        else
            //        {
            //            booking.Payments[0].AccountNumber = agentcode;
            //        }

            //    }

            return null;//--this returns the BooknigUpdateResponseData
        }
        //---------------------------------------------------------------------------------------------------------------------
        public BookingManager.PriceItineraryRequest GetPriceIntineraryRequest(int numadt, int numchd, String faretype, String currency, String sourceorg, String agentcode, GetAvailabilityResponse availresponse)
        {
            PriceItineraryRequest priceitinrequest = new PriceItineraryRequest();
            priceitinrequest.Signature = signature;
            priceitinrequest.ItineraryPriceRequest = new ItineraryPriceRequest();// this is from service contract class
            priceitinrequest.ItineraryPriceRequest.TypeOfSale = new TypeOfSale();
            priceitinrequest.ItineraryPriceRequest.TypeOfSale.FareTypes = new string[1];
            priceitinrequest.ItineraryPriceRequest.TypeOfSale.FareTypes[0] = faretype;
            priceitinrequest.ItineraryPriceRequest.SSRRequest = new SSRRequest();

            priceitinrequest.ItineraryPriceRequest.PriceItineraryBy = PriceItineraryBy.JourneyWithLegs;

            SellJourneyByKeyRequestData sellkeyrequest = new SellJourneyByKeyRequestData();
            priceitinrequest.ItineraryPriceRequest.SellByKeyRequest = sellkeyrequest;

            PriceJourneyRequestData pricerequest = new PriceJourneyRequestData();
            pricerequest.CurrencyCode = currency;
            pricerequest.PaxCount = (short)(numadt + numchd);// to check if this is required

            //setting up the paxdetails to get the pricing correctly, must follow my get avaialbility function call
            pricerequest.Passengers = new Passenger[numadt + numchd];

            for (int i = 0; i < (numadt + numchd); i++)
            {
                pricerequest.Passengers[i] = new Passenger();// instantiate to avoid Null Pointer Exception error
                pricerequest.Passengers[i].State = MessageState.New;

               pricerequest.Passengers[i].PassengerTypeInfos = new PassengerTypeInfo[1];//change back to 1 if it does not work
               pricerequest.Passengers[i].PassengerTypeInfos[0] = new PassengerTypeInfo();//change back PassengerTypeInfos to 0 if it doesnt work

                if (i < numadt)
                {
                    pricerequest.Passengers[i].PassengerTypeInfos[0].PaxType = "ADT";
                }
                else
                {
                    pricerequest.Passengers[i].PassengerTypeInfos[0].PaxType = "CHD";
                }

                pricerequest.Passengers[i].PassengerTypeInfos[0].DOB = DateTime.Parse("0001-01-01");

            }
            //new set input on 20nd March
            SellRequest sellrequest = new SellRequest();
            sellrequest.Signature = signature;
            sellrequest.SellRequestData = new SellRequestData();
            sellrequest.SellRequestData.SellBy = SellBy.Journey;
            sellrequest.SellRequestData.SellJourneyRequest = new SellJourneyRequest();
            SellResponse sellresponse = clientapi.Sell(sellrequest);
            //end of input

            pricerequest.PriceJourneys = new PriceJourney[1];// set this to 1 for a 1 way trip

            for (int i = 0; i < pricerequest.PriceJourneys.Length; i++)
            {
                pricerequest.PriceJourneys[i] = new PriceJourney();

                // now i need to get all the available segments for price itinerary

                Segment[] segment = availresponse.GetTripAvailabilityResponse.Schedules[i][0].Journeys[0].Segments;

                //i want to use the flight designator object for the segment as it contains the carriercode, flight number used to identify a flight
                Console.WriteLine("Flight Number is :" + segment[i].FlightDesignator.CarrierCode + " " + segment[i].FlightDesignator.FlightNumber);
                Console.WriteLine("FlightTiming is : " + segment[i].STD + " " + segment[i].STA);

                PriceSegment[] pricesegment = new PriceSegment[segment.Length];//find the pricing of that particular segment : for a 1 way journey with 2 points, it will be 1 segment

                SegmentSSRRequest[] ssrRequest = new SegmentSSRRequest[segment.Length];

                for (int j = 0; j < segment.Length; j++)
                {

                    //to setup the segment details and equate the values of price to segment

                    pricesegment[j] = new PriceSegment();
                    pricesegment[j].ActionStatusCode = "NN";
                    pricesegment[j].FlightDesignator = segment[j].FlightDesignator;
                    pricesegment[j].DepartureStation = segment[j].DepartureStation;
                    pricesegment[j].ArrivalStation = segment[j].ArrivalStation;
                    pricesegment[j].STA = pricesegment[j].STA;

                    //SSR setup

                    ssrRequest[j] = new SegmentSSRRequest();
                    ssrRequest[j].DepartureStation = segment[j].DepartureStation;
                    ssrRequest[j].ArrivalStation = segment[j].ArrivalStation;
                    ssrRequest[j].FlightDesignator = segment[j].FlightDesignator;
                    ssrRequest[j].STD = segment[j].STD;

                    //now assume that 1 SSR is tied to 1 passenger to 1 direct flight

                    ssrRequest[j].PaxSSRs = new PaxSSR[1];
                    ssrRequest[j].PaxSSRs[0] = new PaxSSR();
                    ssrRequest[j].PaxSSRs[0].ActionStatusCode = "SS";
                    ssrRequest[j].PaxSSRs[0].DepartureStation = segment[j].DepartureStation;
                    ssrRequest[j].PaxSSRs[0].ArrivalStation = segment[j].ArrivalStation;
                    ssrRequest[j].PaxSSRs[0].SSRCode = "BG20";// type of SSR
                    ssrRequest[j].PaxSSRs[0].SSRNumber = 0;//this is the index of the passenger array, tag the SSR to the first passenger

                    //now set up the Fare according to the GetAvailability Response, no need to choose the option- same as Booking2

                    Fare fare = segment[j].Fares[0];
                    pricesegment[j].Fare = new SellFare();
                    pricesegment[j].Fare.CarrierCode = fare.CarrierCode;
                    pricesegment[j].Fare.ClassOfService = fare.ClassOfService;
                    pricesegment[j].Fare.FareApplicationType = fare.FareApplicationType;
                    pricesegment[j].Fare.FareBasisCode = fare.FareBasisCode;
                    pricesegment[j].Fare.ProductClass = fare.ProductClass;
                    pricesegment[j].Fare.RuleNumber = fare.RuleNumber;
                }
                priceitinrequest.ItineraryPriceRequest.SSRRequest.SegmentSSRRequests = ssrRequest;

                priceitinrequest.ItineraryPriceRequest.PriceItineraryBy = PriceItineraryBy.JourneyWithLegs;
                priceitinrequest.ItineraryPriceRequest.PriceJourneyWithLegsRequest = pricerequest;

            }

            if (sourceorg.Length > 0)
            {
                pricerequest.SourcePOS = new PointOfSale();
                pricerequest.SourcePOS.AgentCode = agentcode;
                pricerequest.SourcePOS.OrganizationCode = sourceorg;
                pricerequest.SourcePOS.DomainCode = "EXT";
                pricerequest.SourcePOS.LocationCode = "API";
            }
            else
            {
                pricerequest.SourcePOS = null;
            }
            //sell my SSR on 22nd March -new input
            if (priceitinrequest.ItineraryPriceRequest.SSRRequest.SegmentSSRRequests != null)
            {
                sellrequest.SellRequestData = new SellRequestData();
                sellrequest.SellRequestData.SellSSR = new SellSSR();
                sellrequest.SellRequestData.SellSSR.SSRRequest = priceitinrequest.ItineraryPriceRequest.SSRRequest;
                sellrequest.SellRequestData.SellBy = SellBy.SSR;
                sellresponse = clientapi.Sell(sellrequest);
                System.Console.WriteLine("Total Flight + SSR cost {0:C}", sellresponse.BookingUpdateResponseData.Success.PNRAmount.TotalCost);
            }
            //end of SSR code

            return priceitinrequest;
        }