Travelport / travelport-uapi-tutorial-php

The travelport-uapi-tutorial-php is a PHP project for Universal API that will help you connect and code a standard workflow including Air, Vehicle, and Hotel.
35 stars 47 forks source link

I have some problem to request booking #101

Open pzanwar03 opened 7 years ago

pzanwar03 commented 7 years ago

public function index() { $TARGETBRANCH = 'P105159'; $CREDENTIALS = ''; $Provider = '1G'; //1G/1V/1P/ACH $dateOfBirth = '1990-10-23'; $nationality = 'BD'; $firstName = 'Anwar'; $lastName = 'Pervez'; $prefix = 'Mr.'; $key = '83eKH87Q2BKAxvyYCAAAAA=='; $group = '0'; $carrier = 'UA'; $flightNumber = '3508'; $origin = 'DEN'; $destination = 'ATL'; $deptTime = '2018-01-01T13:30:00.000-07:00'; $arrivalTime = '2018-01-01T18:29:00.000-05:00'; $flightTime = '179'; $distance = '1207';

    $message = <<<EOM
EOM; $file = "001-" . $Provider . "_AirTickitingReq.xml"; // file name to save the request xml for test only(if you want to save the request/response) $this->prettyPrint($message, $file); //call function to pretty print xml $auth = base64_encode("$CREDENTIALS"); $soap_do = curl_init("https://apac.universal-api.pp.travelport.com/B2BGateway/connect/uAPI/AirService"); $header = array( "Content-Type: text/xml;charset=UTF-8", "Accept: gzip,deflate", "Cache-Control: no-cache", "Pragma: no-cache", "SOAPAction: \"\"", "Authorization: Basic $auth", "Content-length: " . strlen($message), ); curl_setopt($soap_do, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($soap_do, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($soap_do, CURLOPT_POST, true); curl_setopt($soap_do, CURLOPT_POSTFIELDS, $message); curl_setopt($soap_do, CURLOPT_HTTPHEADER, $header); curl_setopt($soap_do, CURLOPT_RETURNTRANSFER, true); // this will prevent the curl_exec to return result and will let us to capture output $return = curl_exec($soap_do); $file = "001-" . $Provider . "_AirTickitingRsp.xml"; // file name to save the response xml for test only(if you want to save the request/response) $content = $this->prettyPrint($return, $file); $this->parseOutput($content); } function prettyPrint($result, $file) { $dom = new DOMDocument; $dom->preserveWhiteSpace = false; $dom->loadXML($result); $dom->formatOutput = true; //call function to write request/response in file $this->outputWriter($file, $dom->saveXML()); return $dom->saveXML(); } function outputWriter($file, $content) { file_put_contents($file, $content); // Write request/response and save them in the File } function parseOutput($content) { //parse the Search response to get values to use in detail request $LowFareSearchRsp = $content; //use this if response is not saved anywhere else use above variable //echo $LowFareSearchRsp; $xml = simplexml_load_String("$LowFareSearchRsp", null, null, 'SOAP', true); if ($xml) echo "Processing! Please wait!"; else { trigger_error("Encoding Error!", E_USER_ERROR); } $Results = $xml->children('SOAP', true); foreach ($Results->children('SOAP', true) as $fault) { if (strcmp($fault->getName(), 'Fault') == 0) { $NoData = true; } } } Showing Error [Error] :7:25: cvc-complex-type.2.4.a: Invalid content was found starting with element 'air:AirItinerary'. One of '{"http://www.travelport.com/schema/common_v33_0":BookingTraveler, "http://www.travelport.com/schema/common_v33_0":OSI, "http://www.travelport.com/schema/common_v33_0":AccountingRemark, "http://www.travelport.com/schema/common_v33_0":GeneralRemark, "http://www.travelport.com/schema/common_v33_0":XMLRemark, "http://www.travelport.com/schema/common_v33_0":UnassociatedRemark, "http://www.travelport.com/schema/common_v33_0":Postscript, "http://www.travelport.com/schema/common_v33_0":PassiveInfo, "http://www.travelport.com/schema/common_v33_0":ContinuityCheckOverride, "http://www.travelport.com/schema/common_v33_0":AgencyContactInfo, "http://www.travelport.com/schema/common_v33_0":CustomerID, "http://www.travelport.com/schema/common_v33_0":FileFinishingInfo, "http://www.travelport.com/schema/common_v33_0":CommissionRemark, "http://www.travelport.com/schema/common_v33_0":ConsolidatorRemark, "http://www.travelport.com/schema/common_v33_0":InvoiceRemark, "http://www.travelport.com/schema/common_v33_0":SSR, "http://www.travelport.com/schema/common_v33_0":EmailNotification, "http://www.travelport.com/schema/common_v33_0":QueuePlace, "http://www.travelport.com/schema/common_v33_0":FormOfPayment, "http://www.travelport.com/schema/common_v33_0":SupplierLocator, "http://www.travelport.com/schema/common_v33_0":ThirdPartyInformation, "http://www.travelport.com/schema/common_v33_0":PointOfSale, "http://www.travelport.com/schema/air_v33_0":AirPricingSolution}' is expected.
vivekjyotipramanik commented 7 years ago

Hi pzanwar03,

AirCreateReservationReq does not have a AirItinerary element. Please find below the sample booking request xml. Please use the AirPricingSolution which you have received from AirPriceRsp and replace the AirSegmentRef with complete AirSegment. Please let us know how it goes. Thanks.

https://support.travelport.com/webhelp/uapi/Content/SampleWeb/SampleFiles/001-03_1G_AirBook_Rq.xml

raselcse10 commented 7 years ago

HI vivekjyotipramanik,

Could you give a schema version 42.0 AirCreateReservationReq xml sample?

vivekjyotipramanik commented 7 years ago

Hi raselcse10,

Please find below the sample request. Thanks.

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
  <soapenv:Header/>
  <soapenv:Body>
    <univ:AirCreateReservationReq xmlns:air="http://www.travelport.com/schema/air_v42_0" xmlns:common_v42_0="http://www.travelport.com/schema/common_v42_0" xmlns:univ="http://www.travelport.com/schema/universal_v42_0" AuthorizedBy="user" RetainReservation="Both" TargetBranch="TRGT_BRCH" TraceId="trace">
      <com:BillingPointOfSaleInfo xmlns:com="http://www.travelport.com/schema/common_v42_0" OriginApplication="UAPI"/>
      <com:BookingTraveler xmlns:com="http://www.travelport.com/schema/common_v42_0" DOB="1957-05-12" Gender="M" Key="gr8AVWGCR064r57Jt0+8bA==" TravelerType="ADT">
        <com:BookingTravelerName First="Frederick" Last="Heinrich" Prefix="Herr"/>
        <com:DeliveryInfo>
          <com:ShippingAddress>
            <com:AddressName>Residence</com:AddressName>
            <com:Street>Rossmarkt 6</com:Street>
            <com:City>Frankfurt</com:City>
            <com:State>Hesse</com:State>
            <com:PostalCode>60311</com:PostalCode>
            <com:Country>DE</com:Country>
          </com:ShippingAddress>
        </com:DeliveryInfo>
        <com:PhoneNumber AreaCode="49" CountryCode="069" Location="FRA" Number="261111111"/>
        <com:Email EmailID="test@travelport.com" Type="Home"/>
        <com:SSR Carrier="LH" FreeText="P/DE/F1234567/DE/12May57/M/08Oct15/Heinrich/Frederick" SegmentRef="IGPfou7vRpyxhVThoKySiQ==" Status="HK" Type="DOCS"/>
        <com:Address>
          <com:AddressName>Residence</com:AddressName>
          <com:Street>Rossmarkt 6</com:Street>
          <com:City>Frankfurt</com:City>
          <com:State>Hesse</com:State>
          <com:PostalCode>60311</com:PostalCode>
          <com:Country>DE</com:Country>
        </com:Address>
      </com:BookingTraveler>
      <com:FormOfPayment xmlns:com="http://www.travelport.com/schema/common_v42_0" Key="jwt2mcK1Qp27I2xfpcCtAw==" Type="Cash"/>
      <air:AirPricingSolution ApproximateBasePrice="USD88.48" ApproximateTotalPrice="USD175.20" BasePrice="EUR80.00" EquivalentBasePrice="AUD121.00" Key="0JV2BlZjQcOgPyhetZpoZg==" Taxes="AUD118.60" TotalPrice="AUD239.60">
        <air:AirSegment ArrivalTime="2015-10-08T08:35:00.000+02:00" AvailabilityDisplayType="Fare Specific Fare Quote Unbooked" AvailabilitySource="S" Carrier="LH" ChangeOfPlane="false" ClassOfService="T" DepartureTime="2015-10-08T06:35:00.000+02:00" Destination="BCN" Distance="681" Equipment="EMJ" FlightNumber="1808" FlightTime="120" Group="0" Key="IGPfou7vRpyxhVThoKySiQ==" LinkAvailability="true" OptionalServicesIndicator="false" Origin="MUC" ParticipantLevel="Secure Sell" PolledAvailabilityOption="Polled avail used" ProviderCode="1G" TravelTime="120">
          <air:FlightDetails ArrivalTime="2015-10-08T08:35:00.000+02:00" DepartureTime="2015-10-08T06:35:00.000+02:00" Destination="BCN" Distance="681" FlightTime="120" Key="N2Qxa314QpSGwjva1k01Pg==" Origin="MUC" TravelTime="120"/>
        </air:AirSegment>
        <air:AirSegment ArrivalTime="2015-10-13T09:50:00.000+02:00" AvailabilityDisplayType="Fare Specific Fare Quote Unbooked" AvailabilitySource="S" Carrier="LH" ChangeOfPlane="false" ClassOfService="T" DepartureTime="2015-10-13T07:50:00.000+02:00" Destination="MUC" Distance="681" Equipment="321" FlightNumber="1817" FlightTime="120" Group="1" Key="UxdCJ5f1TLqqci1GnoXiHw==" LinkAvailability="true" OptionalServicesIndicator="false" Origin="BCN" ParticipantLevel="Secure Sell" PolledAvailabilityOption="Polled avail used" ProviderCode="1G" TravelTime="120">
          <air:FlightDetails ArrivalTime="2015-10-13T09:50:00.000+02:00" DepartureTime="2015-10-13T07:50:00.000+02:00" Destination="MUC" Distance="681" FlightTime="120" Key="xx3mx6dhRbiyENOitfykfg==" Origin="BCN" TravelTime="120"/>
        </air:AirSegment>
        <air:AirPricingInfo ApproximateBasePrice="USD88.48" ApproximateTotalPrice="USD175.20" BasePrice="EUR80.00" ETicketability="Yes" EquivalentBasePrice="AUD121.00" IncludesVAT="false" Key="08bPaljGQ3WAZwldHtDdMg==" LatestTicketingTime="2015-09-02T23:59:00.000-07:00" PlatingCarrier="LH" PricingMethod="Guaranteed" ProviderCode="1G" Taxes="AUD118.60" TotalPrice="AUD239.60">
          <air:FareInfo Amount="NUC44.99" DepartureDate="2015-10-08" Destination="BCN" EffectiveDate="2015-09-01T04:11:00.000-07:00" FareBasis="T30LGT1A" Key="Dzf81FxGSi+WQU8ie+spxA==" NotValidAfter="2015-10-08" NotValidBefore="2015-10-08" Origin="MUC" PassengerTypeCode="ADT">
            <common_v42_0:Endorsement Value="FARE RESTRICTION APPLY"/>
            <air:FareRuleKey FareInfoRef="Dzf81FxGSi+WQU8ie+spxA==" ProviderCode="1G">ehcS2Is9KVNz5/dxhKAqjiKkjb2jJgPMIqSNvaMmA8wipI29oyYDzCKkjb2jJgPMIqSNvaMmA8xVvojmjMvrB7GxUPbfJ3bQOm7ZkYTtotxgUwvOQ+/Qnmov7gvYP3DG9EWzyTiVCCagpgrvvcW2SYBB6PcwkyURnyhvtBv8t31BsAed3p/OTjCeulb8eUADPIfX5TVTS4Kyw3LeVKXQE1NPYqbJDrVvVav9JD3zUH31ASRxYE1p2tquFzLL02Mpen2HCG7Il3gVfO4dJzN/iTcLbQYpvTitIqSNvaMmA8wipI29oyYDzCKkjb2jJgPMIqSNvaMmA8xVvojmjMvrBysPBgQN4LCfFhjKZFNjLEx2qtbSQfsKQHtOVmHTh9bmXx8Yorq6Vwe2PxLx++lMTyefXxHBpmB0</air:FareRuleKey>
          </air:FareInfo>
          <air:FareInfo Amount="NUC44.99" DepartureDate="2015-10-13" Destination="MUC" EffectiveDate="2015-09-01T04:11:00.000-07:00" FareBasis="T30LGT1A" Key="vfrueLzKQe+JIMVB4ugwUg==" NotValidAfter="2015-10-13" NotValidBefore="2015-10-13" Origin="BCN" PassengerTypeCode="ADT">
            <common_v42_0:Endorsement Value="FARE RESTRICTION APPLY"/>
            <air:FareRuleKey FareInfoRef="vfrueLzKQe+JIMVB4ugwUg==" ProviderCode="1G">ehcS2Is9KVNz5/dxhKAqjiKkjb2jJgPMIqSNvaMmA8wipI29oyYDzCKkjb2jJgPMIqSNvaMmA8xVvojmjMvrB7GxUPbfJ3bQOm7ZkYTtotwWrC/PFdSQ/JgWuwpud7J99EWzyTiVCCagpgrvvcW2SYBB6PcwkyURr3g/C1KQm9RBsAed3p/OTjCeulb8eUADPIfX5TVTS4Kyw3LeVKXQE1NPYqbJDrVvVav9JD3zUH3aiuPFYsOxyNquFzLL02Mp3OM0vDfYW64VfO4dJzN/iTcLbQYpvTitIqSNvaMmA8wipI29oyYDzCKkjb2jJgPMIqSNvaMmA8xVvojmjMvrBysPBgQN4LCfFhjKZFNjLEx2qtbSQfsKQHtOVmHTh9bmXx8Yorq6Vwe2PxLx++lMTyefXxHBpmB0</air:FareRuleKey>
          </air:FareInfo>
          <air:BookingInfo BookingCode="T" CabinClass="Economy" FareInfoRef="Dzf81FxGSi+WQU8ie+spxA==" SegmentRef="IGPfou7vRpyxhVThoKySiQ=="/>
          <air:BookingInfo BookingCode="T" CabinClass="Economy" FareInfoRef="vfrueLzKQe+JIMVB4ugwUg==" SegmentRef="UxdCJ5f1TLqqci1GnoXiHw=="/>
          <air:TaxInfo Amount="AUD8.80" Category="DE" Key="RFbO9MjRQTKlsQbNb/sI/w=="/>
          <air:TaxInfo Amount="AUD11.30" Category="OY" Key="DH4Y0belSY2DwQj40fYiuw=="/>
          <air:TaxInfo Amount="AUD29.50" Category="RA" Key="h81HTA1xQ+alcGoxKxcfjQ=="/>
          <air:TaxInfo Amount="AUD23.20" Category="JD" Key="5/00/qqZT4KT4frkdITEaQ=="/>
          <air:TaxInfo Amount="AUD0.90" Category="OG" Key="2Exkoc7oTbe9XV3d2y/IyQ=="/>
          <air:TaxInfo Amount="AUD5.70" Category="QV" Key="W9I9peIgSlONuzSuDfCR6g=="/>
          <air:TaxInfo Amount="AUD39.20" Category="YQ" Key="xktaDhCvTvatxk7cZNXhew=="/>
          <air:FareCalc>MUC LH BCN 44.99T30LGT1A LH MUC 44.99T30LGT1A NUC89.98END ROE0.889078</air:FareCalc>
          <air:PassengerType Code="ADT"/>
          <air:ChangePenalty>
            <air:Percentage>100.00</air:Percentage>
          </air:ChangePenalty>
          <air:BaggageAllowances>
            <air:BaggageAllowanceInfo Carrier="LH" Destination="BCN" Origin="MUC" TravelerType="ADT">
              <air:URLInfo>
                <air:URL>MYTRIPANDMORE.COM/BAGGAGEDETAILSLH.BAGG</air:URL>
              </air:URLInfo>
              <air:TextInfo>
                <air:Text>0P</air:Text>
                <air:Text>BAGGAGE DISCOUNTS MAY APPLY BASED ON FREQUENT FLYER STATUS/ ONLINE CHECKIN/FORM OF PAYMENT/MILITARY/ETC.</air:Text>
              </air:TextInfo>
              <air:BagDetails ApplicableBags="1stChecked" ApproximateBasePrice="USD16.48" ApproximateTotalPrice="USD16.48" BasePrice="EUR15.00" TotalPrice="EUR15.00">
                <air:BaggageRestriction>
                  <air:TextInfo>
                    <air:Text>FIRST BAG</air:Text>
                  </air:TextInfo>
                </air:BaggageRestriction>
              </air:BagDetails>
              <air:BagDetails ApplicableBags="2ndChecked" ApproximateBasePrice="USD16.48" ApproximateTotalPrice="USD16.48" BasePrice="EUR15.00" TotalPrice="EUR15.00">
                <air:BaggageRestriction>
                  <air:TextInfo>
                    <air:Text>FIRST BAG</air:Text>
                  </air:TextInfo>
                </air:BaggageRestriction>
              </air:BagDetails>
            </air:BaggageAllowanceInfo>
            <air:BaggageAllowanceInfo Carrier="LH" Destination="MUC" Origin="BCN" TravelerType="ADT">
              <air:URLInfo>
                <air:URL>MYTRIPANDMORE.COM/BAGGAGEDETAILSLH.BAGG</air:URL>
              </air:URLInfo>
              <air:TextInfo>
                <air:Text>0P</air:Text>
                <air:Text>BAGGAGE DISCOUNTS MAY APPLY BASED ON FREQUENT FLYER STATUS/ ONLINE CHECKIN/FORM OF PAYMENT/MILITARY/ETC.</air:Text>
              </air:TextInfo>
              <air:BagDetails ApplicableBags="1stChecked" ApproximateBasePrice="USD16.48" ApproximateTotalPrice="USD16.48" BasePrice="EUR15.00" TotalPrice="EUR15.00">
                <air:BaggageRestriction>
                  <air:TextInfo>
                    <air:Text>FIRST BAG</air:Text>
                  </air:TextInfo>
                </air:BaggageRestriction>
              </air:BagDetails>
              <air:BagDetails ApplicableBags="2ndChecked" ApproximateBasePrice="USD16.48" ApproximateTotalPrice="USD16.48" BasePrice="EUR15.00" TotalPrice="EUR15.00">
                <air:BaggageRestriction>
                  <air:TextInfo>
                    <air:Text>FIRST BAG</air:Text>
                  </air:TextInfo>
                </air:BaggageRestriction>
              </air:BagDetails>
            </air:BaggageAllowanceInfo>
            <air:CarryOnAllowanceInfo Carrier="LH" Destination="BCN" Origin="MUC">
              <air:TextInfo>
                <air:Text>UPTO18LB/8KG AND UPTO46LI/118LCM</air:Text>
              </air:TextInfo>
              <air:TextInfo>
                <air:Text>CARRY ON PERSONAL ITEMS</air:Text>
              </air:TextInfo>
              <air:CarryOnDetails ApplicableCarryOnBags="1" ApproximateBasePrice="USD0.00" ApproximateTotalPrice="USD0.00" BasePrice="EUR0.00" TotalPrice="EUR0.00"/>
              <air:CarryOnDetails ApplicableCarryOnBags="2" ApproximateBasePrice="USD0.00" ApproximateTotalPrice="USD0.00" BasePrice="EUR0.00" TotalPrice="EUR0.00"/>
            </air:CarryOnAllowanceInfo>
            <air:CarryOnAllowanceInfo Carrier="LH" Destination="MUC" Origin="BCN">
              <air:TextInfo>
                <air:Text>UPTO18LB/8KG AND UPTO46LI/118LCM</air:Text>
              </air:TextInfo>
              <air:TextInfo>
                <air:Text>CARRY ON PERSONAL ITEMS</air:Text>
              </air:TextInfo>
              <air:CarryOnDetails ApplicableCarryOnBags="1" ApproximateBasePrice="USD0.00" ApproximateTotalPrice="USD0.00" BasePrice="EUR0.00" TotalPrice="EUR0.00"/>
              <air:CarryOnDetails ApplicableCarryOnBags="2" ApproximateBasePrice="USD0.00" ApproximateTotalPrice="USD0.00" BasePrice="EUR0.00" TotalPrice="EUR0.00"/>
            </air:CarryOnAllowanceInfo>
          </air:BaggageAllowances>
        </air:AirPricingInfo>
      </air:AirPricingSolution>
      <com:ActionStatus xmlns:com="http://www.travelport.com/schema/common_v42_0" ProviderCode="1G" TicketDate="2015-09-02T16:42:16" Type="TAW"/>
    </univ:AirCreateReservationReq>
  </soapenv:Body>
</soapenv:Envelope>
raselcse10 commented 7 years ago

Hi vivekjyotipramanik,

Is it mandatory to AirPricingRequest before AirCreateReservation? Because of in my Low fare searching i'm receiving AirPricingInfo and as well as AirSegmentInfo. So is it not enough info to AirCreateRequest? In Low fare search response i can see more than one segment so for each segment i have to do AirPricingRequest or only Arrival & Destination?

MalikAhsanAftab commented 4 years ago

In some cases it is mandatory.So it is recommended to make an AirPricingRequest before createReservationReq.