PHP code example of marcincook / laravel-renteon-api-client

1. Go to this page and download the library: Download marcincook/laravel-renteon-api-client 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/ */

    

marcincook / laravel-renteon-api-client example snippets


use MarcinCook\RenteonApi\RenteonManager;

$renteon = app(RenteonManager::class);

// Default country — config('renteon.default')
$offices = $renteon->offices()->getOffices();

// Explicit country
$cars = $renteon->for('es')->cars()->getAllCars(['IsActive' => true]);

use Renteon;

$countries = Renteon::for('pl')->countries()->getCountries();

use MarcinCook\RenteonApi\RenteonManager;

$renteon = app(RenteonManager::class)->for('pl');

// 1) Lookup dictionaries for the storefront (cache these).
$offices    = $renteon->offices()->getOffices();
$countries  = $renteon->countries()->getCountries();
$categories = $renteon->carCategories()->searchCarCategories(['IsActive' => true]);

// 2) Identify the customer (email-based lookup).
$customer = $renteon->addressBook()->findByEmail('[email protected]', [
    // Optional pre-filter — keeps the search payload small.
    'AddressBookTypeIds' => [1],
    'IsActive' => true,
]);

if ($customer === null) {
    $customer = $renteon->addressBook()->createAddressBook([
        'Name'              => 'Jane Doe',
        'AddressBookTypeId' => 1,
        'Email'             => '[email protected]',
        'IsAgency'          => false,
        'IsAgent'           => false,
        'IsArtisan'         => false,
        'IsEmployee'        => false,
        'IsForeigner'       => false,
        'IsVatPayer'        => false,
        'AllowB2CAccess'    => true,
        'BillingDelayInDays' => 0,
        'SurveyDoNotEmail'  => false,
        'AddressBookPhones' => [
            ['Number' => '+48123456789', 'PhoneTypeId' => 1],
        ],
    ]);
}

// 3) Check availability for the chosen date window + office pair.
$availability = $renteon->bookings()->availability([
    'OfficeOutId'    => 1,
    'OfficeInId'     => 1,
    'DateTimeOut'    => '2026-06-10T10:00:00+02:00',
    'DateTimeIn'     => '2026-06-15T10:00:00+02:00',
    'AvailableOnly'  => true,
    'CarCategoryIds' => [/* optionally narrow down */],
]);

$pickedCategory = $availability[0]['AvailabilityCarCategories'][0] ?? null;

// 4) Create the booking (server computes prices + mandatory additions).
$draft = $renteon->bookings()->create([
    'OfficeOutId'             => 1,
    'OfficeInId'              => 1,
    'DateTimeOut'             => '2026-06-10T10:00:00+02:00',
    'DateTimeIn'              => '2026-06-15T10:00:00+02:00',
    'ClientId'                => $customer['Id'],
    'BookingTypeId'           => 1,
    'CurrencyId'              => 1,
    'AvailabilityCarCategory' => $pickedCategory,
]);

// (optional) Recalculate after the customer adds extras / insurance.
$draft['Services'][] = ['ServiceId' => 7, 'Quantity' => 1];
$draft = $renteon->bookings()->calculate($draft);

// 5) After your payment gateway clears the deposit & extras — persist it.
$booking = $renteon->bookings()->save(array_merge($draft, [
    'CarId'         => 42,
    'ClientId'      => $customer['Id'],
    'ClientName'    => 'Jane Doe',
    'ClientEmail'   => '[email protected]',
    'TotalDeposit'  => 365.38,
    'Remark'        => 'Paid online via TPay',
]));

// $booking['Number'] is now safe to persist in your local DB for the
// customer's booking history.

$history = $renteon->bookings()->getBookingsByClient($clientId);

$rows = $renteon->reports()->getRealizationByOffice([
    'DateTimeInFrom'           => '01.06.2026.',
    'DateTimeInTo'             => '30.06.2026.',
    'IncludeExternalDocuments' => false,
]);
bash
php artisan vendor:publish --tag=renteon-config