PHP code example of santosdave / verteil-wrapper
1. Go to this page and download the library: Download santosdave/verteil-wrapper library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
santosdave / verteil-wrapper example snippets
use Santosdave\VerteilWrapper\Facades\Verteil;
// or
use Santosdave\VerteilWrapper\Services\VerteilService;
$verteil = Verteil::authenticate();
use Santosdave\VerteilWrapper\DataTypes\AirShopping;
$request = AirShopping::create([
'coreQuery' => [
'originDestinations' => [
[
'departureAirport' => 'LHR',
'arrivalAirport' => 'JFK',
'departureDate' => '2024-12-03',
'key' => 'OD1'
]
]
],
'travelers' => [
[
'passengerType' => 'ADT',
'objectKey' => 'T1',
'name' => [
'given' => ['John'],
'surname' => 'Doe',
'title' => 'Mr'
]
]
],
'preference' => [
'cabin' => 'Y',
'fareTypes' => ['PUBL']
],
'responseParameters' => [
'ResultsLimit' => [
'value' => 50
],
'SortOrder' => [
[
'Order' => 'ASCENDING',
'Parameter' => 'PRICE'
],
[
'Order' => 'ASCENDING',
'Parameter' => 'STOP'
],
[
'Order' => 'ASCENDING',
'Parameter' => 'DEPARTURE_TIME'
]
],
'ShopResultPreference' => 'OPTIMIZED'
],
'enableGDS' => true
]);
$response = Verteil::airShopping($request);
use Santosdave\VerteilWrapper\DataTypes\FlightPrice;
use Santosdave\VerteilWrapper\DataTypes\VerteilRequestBuilder as Builder;
// Create flight details using named parameters
$request = FlightPrice::create([
'third_party_id' => 'EK',
'dataLists' => [
'fares' => [
[
'listKey' => 'someOtherValue',
'code' => 'someOtherValue', // Economy fare basis code
'fareCode' => '70J',
'refs' => ['someOtherValue']
],
],
'anonymousTravelers' => [
[
'objectKey' => 'EK-T1',
'passengerType' => 'ADT'
],
[
'objectKey' => 'EK-T2',
'passengerType' => 'ADT'
],
[
'objectKey' => 'EK-T3',
'passengerType' => 'CHD',
'age' => [
'value' => 8,
'birthDate' => '2016-06-15'
]
]
]
],
'query' => [
'originDestinations' => [
[
'flights' => [
[
'segmentKey' => 'someOtherValue',
'departure' => [
'airportCode' => 'NBO',
'date' => '2024-12-27',
'time' => '22:45',
'terminal' => '1B'
],
'arrival' => [
'airportCode' => 'DXB',
'date' => '2024-12-28',
'time' => '04:45',
'terminal' => '3'
],
'airlineCode' => 'EK',
'flightNumber' => '722',
'classOfService' => 'Q',
'classOfServiceRefs' => ['someOtherValue']
],
]
]
],
'offers' => [
[
'owner' => 'EK',
'offerId' => 'someOtherValue',
'offerItems' => [
[
'id' => 'someOtherValue',
'quantity' => '2',
'refs' => ['EK-T1', 'EK-T2'], // Reference to first adult
],
[
'id' => 'someOtherValue',
'quantity' => '1',
'refs' => ['EK-T3'], // Reference to child
]
],
'refs' => [
'VDC-AIRLINE-SRID',
'someOtherValue'
]
]
]
],
'travelers' => [
[
'passengerType' => 'ADT',
'objectKey' => 'EK-T1'
],
[
'passengerType' => 'ADT',
'objectKey' => 'EK-T2'
],
[
'passengerType' => 'CHD',
'objectKey' => 'EK-T3'
]
],
'shoppingResponseId' => [
'owner' => 'EK',
'responseId' => 'someOtherValue' // Response ID from AirShopping response
],
'metadata' => [
[
'priceMetadata' => [
[
'key' => 'someOtherValue',
'type' => 'com.verteil.pricemanager.data.PriceRuleAugPoint',
'value' => 'someOtherValue'
],
[
'key' => 'someOtherValue',
'value' => 'someOtherValue'
],
[
'key' => 'VDC-AIRLINE-SRID',
'javaType' => 'java.util.HashMap',
'value' => 'someOtherValue'
]
]
]
]
]);
$response = Verteil::flightPrice($request);
use Santosdave\VerteilWrapper\DataTypes\OrderCreate;
use Santosdave\VerteilWrapper\DataTypes\VerteilRequestBuilder as Builder;
// Create passenger details using named parameters
$name = Builder::createNameType([
'given' => 'John',
'surname' => 'Doe',
'title' => 'Mr'
]);
$contacts = Builder::createContactType([
'phoneNumber' => '1234567890',
'phoneCountryCode' => '44',
'email' => '[email protected] ',
'street' => '123 Main St',
'city' => 'London',
'postalCode' => '12345',
'countryCode' => 'GB'
]);
$document = Builder::createPassengerDocumentType([
'documentNumber' => 'AB123456',
'issuingCountry' => 'GB',
'type' => 'PT',
'expiryDate' => '2030-01-01'
]);
$payment = Builder::createPaymentCardType([
'cardNumber' => '4111111111111111',
'cvv' => '123',
'expiryDate' => '1225',
'holderName' => 'John Doe',
'brand' => 'VI'
]);
$request = OrderCreate::create([
'query' => [
'owner' => 'BA',
'responseId' => 'SHOP123',
'passengers' => [
[
'objectKey' => 'T1',
'gender' => 'Male',
'passengerType' => 'ADT',
'name' => $name,
'contacts' => $contacts,
'document' => $document
]
]
],
'payments' => [$payment]
]);
$response = Verteil::createOrder($request);
# Order Creation with Enhanced Metadata
When creating orders with complex metadata
'price' => [
[
'key' => 'VDC-AIRLINE-SRID',
'augmentationPoints' => [
[
'javaType' => 'java.util.HashMap',
'value' => ['key' => 'value'],
'key' => 'someKey'
]
],
'offerItemRefs' => ['OI1'],
'description' => 'Description'
]
]
'paymentForm' => [
[
'key' => 'PAYMENT_FORM1',
'text' => 'Credit Card Payment',
'description' => 'Description',
'warningText' => 'Warning message',
'restrictionText' => 'Restrictions'
]
]
'currency' => [
[
'key' => 'INR',
'decimals' => 2,
'roundingPrecision' => 0.01,
'exchangeRate' => [
'rate' => 1.0,
'baseCurrency' => 'INR',
'targetCurrency' => 'EUR'
],
'displayFormat' => '#,##0.00',
'allowedPaymentCurrencies' => ['INR', 'EUR']
]
]
'card' => [
// ... your card details ...
// Automatically added:
'SecurePaymentVersion' => [
'PaymentTrxChannelCode' => 'MO'
]
]
use Santosdave\VerteilWrapper\DataTypes\OrderRetrieve;
use Santosdave\VerteilWrapper\DataTypes\OrderCancel;
// Retrieve order
$retrieveRequest = OrderRetrieve::create([
'owner' => 'BA',
'orderId' => 'ABC123',
'channel' => 'NDC'
]);
$order = Verteil::retrieveOrder($retrieveRequest);
// Cancel order
$cancelRequest = OrderCancel::create([
'orders' => [
[
'owner' => 'BA',
'orderId' => 'ABC123',
'channel' => 'NDC'
]
],
'expectedRefundAmount' => [
'amount' => 1200.00,
'currency' => 'INR'
]
]);
$response = Verteil::cancelOrder($cancelRequest);
use Santosdave\VerteilWrapper\DataTypes\SeatAvailability;
use Santosdave\VerteilWrapper\DataTypes\ServiceList;
// Create flight details for service list
$flight = Builder::createFlightType([
'departureAirport' => 'LHR',
'arrivalAirport' => 'JFK',
'departureDate' => '2024-12-01',
'departureTime' => '09:00',
'airlineCode' => 'BA',
'flightNumber' => '123'
]);
// Check seat availability
$seatRequest = SeatAvailability::create('pre', [
'query' => [
'originDestinations' => [
[
'segmentRefs' => ['SEG1', 'SEG2']
]
],
'offers' => [
[
'owner' => 'BA',
'offerId' => 'OFF123',
'offerItems' => ['ITEM1']
]
]
],
'travelers' => [
[
'objectKey' => 'T1',
'passengerType' => 'ADT'
]
]
]);
$seats = Verteil::getSeatAvailability($seatRequest);
// Get service list
$serviceRequest = ServiceList::create('pre', [
'query' => [
'originDestinations' => [
[
'flights' => [$flight]
]
]
],
'travelers' => [
[
'passengerType' => 'ADT'
]
]
]);
$services = Verteil::getServiceList($serviceRequest);
use Santosdave\VerteilWrapper\DataTypes\OrderChange;
$payment = Builder::createPaymentCardType([
'cardNumber' => '4111111111111111',
'cvv' => '123',
'expiryDate' => '1225',
'holderName' => 'John Doe',
'brand' => 'VI'
]);
// Create order change request
$orderChangeParams = [
'orderId' => [
'owner' => 'BA',
'orderId' => 'ABC123'
],
'changes' => [
[
'type' => 'FLIGHT_CHANGE',
'segments' => [
[
'origin' => 'LHR',
'destination' => 'JFK',
'departureDate' => '2024-12-01',
'departureTime' => '09:00',
'airlineCode' => 'BA',
'flightNumber' => '123'
]
]
]
],
'payments' => [
[
'amount' => 100.00,
'currency' => 'INR',
'card' => [
'number' => '4111111111111111',
'securityCode' => '123',
'holderName' => 'John Doe',
'expiryDate' => '1225'
]
]
]
];
// Change order
$response = Verteil::changeOrder($orderChangeParams);
use Santosdave\VerteilWrapper\DataTypes\VerteilRequestBuilder as Builder;
// Create passenger name
$name = Builder::createNameType([
'given' => 'John',
'surname' => 'Doe',
'title' => 'Mr'
]);
// Create contact information
$contacts = Builder::createContactType([
'phoneNumber' => '1234567890',
'phoneCountryCode' => '44',
'email' => '[email protected] ',
'street' => '123 Main St',
'city' => 'London',
'postalCode' => '12345',
'countryCode' => 'GB'
]);
// Create passport/document information
$document = Builder::createPassengerDocumentType([
'documentNumber' => 'AB123456',
'issuingCountry' => 'GB',
'type' => 'PT',
'expiryDate' => '2030-01-01'
]);
// Create payment card details
$payment = Builder::createPaymentCardType([
'cardNumber' => '4111111111111111',
'cvv' => '123',
'expiryDate' => '1225',
'holderName' => 'John Doe',
'brand' => 'VI'
]);;
// Create flight details
$flight = Builder::createFlightType([
'departureAirport' => 'LHR',
'arrivalAirport' => 'JFK',
'departureDate' => '2024-12-01',
'departureTime' => '09:00',
'airlineCode' => 'BA',
'flightNumber' => '123',
'arrivalDate' => '2024-12-01',
'arrivalTime' => '12:00',
'classOfService' => 'Y'
]);
// Create price information
$price = Builder::createPriceType([
'baseAmount' => 1000.00,
'taxAmount' => 200.00,
'currency' => 'INR'
]);
use Santosdave\VerteilWrapper\DataTypes\OrderReshop;
$reshopParams = [
'owner' => 'BA',
'orderId' => 'ABC123',
'qualifiers' => [
[
'type' => 'CABIN',
'cabin' => 'Y',
'preferenceLevel' => 'Preferred'
],
[
'type' => 'FARE',
'fareTypes' => ['PUBL', 'CORP'],
'fareBasis' => 'Y1N2C3'
]
],
'segments' => [
[
'segmentKey' => 'SEG1',
'newFlight' => [
'origin' => 'LHR',
'destination' => 'JFK',
'departureDate' => '2024-12-01',
'departureTime' => '09:00',
'airlineCode' => 'BA',
'flightNumber' => '123'
]
]
],
'searchAlternateDates' => true
];
$response = Verteil::reshopOrder($reshopParams);
use Santosdave\VerteilWrapper\DataTypes\ItinReshop;
// Create itinerary reshop request
$itinReshopParams = [
'orderId' => [
'owner' => 'BA',
'value' => 'ABC123'
],
'itineraryChanges' => [
[
'type' => 'SEGMENT_CHANGE',
'oldSegment' => [
'origin' => 'LHR',
'destination' => 'JFK',
'departure' => [
'date' => '2024-12-01',
'time' => '09:00'
],
'airline' => 'BA',
'flightNumber' => '123'
],
'newSegment' => [
'origin' => 'LHR',
'destination' => 'JFK',
'departure' => [
'date' => '2024-12-02',
'time' => '11:00'
],
'airline' => 'BA',
'flightNumber' => '175'
]
]
],
'pricingQualifiers' => [
[
'type' => 'CABIN',
'code' => 'Y'
]
],
'party' => [
'type' => 'CORPORATE',
'code' => 'CORP123',
'name' => 'Example Corp'
]
];
// Reshop itinerary
$response = Verteil::reshopItinerary($itinReshopParams);
use Santosdave\VerteilWrapper\DataTypes\OrderChangeNotif;
// Create order change notification
$notificationData = OrderChangeNotif::create([
'orderId' => [
'owner' => 'BA',
'value' => 'ABC123'
],
'notification' => [
'type' => 'SCHEDULE_CHANGE',
'reason' => 'OPERATIONAL',
'severity' => 'WARNING',
'description' => 'Flight schedule has been modified due to operational constraints',
'affectedSegments' => [
[
'segmentRef' => 'SEG1',
'changeType' => 'TIME_CHANGE',
'description' => 'Departure time changed',
'oldValue' => '09:00',
'newValue' => '11:00',
'impacts' => [
'duration' => [
'change' => 120,
'unit' => 'MIN'
]
]
]
],
'customerNotification' => [
' 'departure' => [
'date' => '2024-12-01',
'time' => '14:00'
],
'arrival' => [
'date' => '2024-12-01',
'time' => '17:00'
]
]
],
'pricing' => [
'difference' => 0,
'currency' => 'INR'
]
]
]
]);
$response = Verteil::sendOrderChangeNotification($notificationData);
use Santosdave\VerteilWrapper\Exceptions\VerteilApiException;
try {
$response = Verteil::airShopping($request);
} catch (VerteilApiException $e) {
// Handle API-specific errors
$errorMessage = $e->getErrorMessage();
$errorResponse = $e->getErrorResponse();
// Log the error or notify administrators
Log::error('Verteil API Error', [
'message' => $errorMessage,
'response' => $errorResponse
]);
} catch (\Exception $e) {
// Handle other errors
}
// Check cache
$response = Verteil::getCache()->get('airShopping', $params);
// Clear cache for specific endpoint
Verteil::flushCache('airShopping');
// Clear all cache
Verteil::flushCache();
// config/verteil.php
'rate_limits' => [
'default' => [
'requests' => 60,
'duration' => 60 // seconds
],
'airShopping' => [
'requests' => 30,
'duration' => 60
]
]
// config/verteil.php
'logging' => [
'channel' => 'verteil',
'level' => 'debug'
]
// config/verteil.php
return [
'credentials' => [
'username' => env('VERTEIL_USERNAME'),
'password' => env('VERTEIL_PASSWORD'),
],
'base_url' => env('VERTEIL_BASE_URL'),
'timeout' => env('VERTEIL_TIMEOUT', 30),
'verify_ssl' => env('VERTEIL_VERIFY_SSL', true),
'retry' => [
'max_attempts' => 3,
'delay' => 100, // milliseconds
'multiplier' => 2
],
'cache' => [
'enabled' => true,
'ttl' => [
'airShopping' => 5, // minutes
'flightPrice' => 2,
'serviceList' => 5
]
],
'monitoring' => [
'enabled' => true,
'metrics_retention' => 24 // hours
],
'notifications' => [
'slack_webhook_url' => env('VERTEIL_SLACK_WEBHOOK'),
'notification_email' => env('VERTEIL_NOTIFICATION_EMAIL')
]
];
bash
php artisan vendor:publish --provider="Santosdave\VerteilWrapper\VerteilServiceProvider"