Zubs / FlightApp

7 stars 8 forks source link

Error submitting flight booking page. #2

Closed stephenmorton closed 1 year ago

stephenmorton commented 2 years ago

Hi, Again, thanks for a great article. I have followed part 1 and 2. Everything worked fine, except, at the very last step I got this error once submitting the flight booking page. "Client error: POST https://test.api.amadeus.com/v1/booking/flight-orders resulted in a 400 Bad Request response: {"errors":[{"status":400,"code":32171,"title":"MANDATORY DATA MISSING","detail":"validatingAirlineCodes needed","source" (truncated...)

It seems to require a Airline code? I can't see why I am getting this error. Regards, Steve

MKHSolidum commented 1 year ago

I seem to get stuck in migrations, is there a minimum php version this supports?

chimake commented 1 year ago

Hi, Again, thanks for a great article. I have followed part 1 and 2. Everything worked fine, except, at the very last step I got this error once submitting the flight booking page. "Client error: POST https://test.api.amadeus.com/v1/booking/flight-orders resulted in a 400 Bad Request response: {"errors":[{"status":400,"code":32171,"title":"MANDATORY DATA MISSING","detail":"validatingAirlineCodes needed","source" (truncated...)

It seems to require a Airline code? I can't see why I am getting this error. Regards, Steve

I get this error too. Any possible fix?

Zubs commented 1 year ago

Hello @stephenmorton and @chimake ,

Thanks for the feedback. I believe the endpoint requires an airline code, and you would have to get one to continue. Unfortunately, I do not know the process of getting one.

chimake commented 1 year ago

The validated airline code is parsed in the flight_offers key. See below. $data = [ 'data' => [ 'type' => 'flight-order', 'flightOffers' => [ json_decode($request['data']) ], //'validatingAirlineCodes' => ['TP'], // fixed syntax error 'travelers' => [ [ 'id' => '1', 'dateOfBirth' => '2001-09-02', 'name' => [ 'firstName' => 'Idris Aweda', 'lastName' => 'Zubair' ], 'gender' => 'MALE', 'contact' => [ 'emailAddress' => 'zubairidrisaweda@gmail.com', 'phones' => [ [ 'deviceType' => 'MOBILE', 'countryCallingCode' => '234', 'number' => '7052053780' ] ] ], 'documents' => [ [ 'documentType' => 'PASSPORT', 'birthPlace' => 'Madrid', 'issuanceLocation' => 'Madrid', 'issuanceDate' => '2015-04-14', 'number' => '00000000', 'expiryDate' => '2025-04-14', 'issuanceCountry' => 'ES', 'validityCountry' => 'ES', 'nationality' => 'ES', 'holder' => true ] ] ] ] ] ];

chimake commented 1 year ago

I have fixed it. I changed line 17 on the price.blade.php from <input type="hidden" value="{{ json_encode($data) }}" name="data"> to <input type="hidden" value="{{ json_encode($data->flightOffers[0]) }}" name="data">

Zubs commented 1 year ago

Thanks @chimake. I will close the Issue now.

cc: @stephenmorton

I have fixed it. I changed line 17 on the price.blade.php from <input type="hidden" value="{{ json_encode($data) }}" name="data"> to <input type="hidden" value="{{ json_encode($data->flightOffers[0]) }}" name="data">