Examples
Practical examples showing common operations with the Felloh PHP SDK. Each example assumes you have already created a client instance.
Client Setup
use Felloh\FellohClient;
use Felloh\FellohConfig;
$client = new FellohClient(new FellohConfig(
publicKey: $_ENV['FELLOH_PUBLIC_KEY'],
privateKey: $_ENV['FELLOH_PRIVATE_KEY'],
));
Bookings
Create a booking, then list and retrieve bookings. Amounts should be in the lowest currency denomination (e.g. pence for GBP).
Create a Booking
$created = $client->bookings->create([
'organisation' => 'org-id',
'booking_reference' => 'REF-001',
'customer_name' => 'James Dean',
'email' => 'james@example.com',
'currency' => 'GBX',
'gross_amount' => 100000,
'departure_date' => '2025-08-01',
'return_date' => '2025-08-15',
]);
echo 'Booking ID: ' . $created['data']['id'];
List & Search Bookings
$bookings = $client->bookings->list([
'organisation' => 'org-id',
'keyword' => 'james@example.com',
'take' => 20,
]);
echo "Found {$bookings['meta']['count']} bookings";
Update a Booking
$client->bookings->update('booking-id', [
'customer_name' => 'Jane Dean',
'departure_date' => '2025-09-01',
]);
Delete a Booking
$client->bookings->delete('booking-id');
Booking Components
Add and remove components (e.g. flights, hotels) on a booking.
Add a Component
$component = $client->bookingComponents->create('booking-id', [
'supplier' => 'supplier-id',
'amount' => 50000,
'currency' => 'GBX',
'booking_reference' => 'REF-001',
'destination_air' => 'AMS',
'type' => 'flights',
]);
Remove a Component
$client->bookingComponents->delete('booking-id', 'component-id');
Transactions
List transactions, issue refunds, and manage pre-authorisations.
List Transactions
$transactions = $client->transactions->list([
'organisation' => 'org-id',
'statuses' => ['COMPLETE'],
'date_from' => '2025-01-01',
'date_to' => '2025-12-31',
]);
Refund a Transaction
// Amount in lowest denomination (e.g. pence)
$client->transactions->refund('transaction-id', [
'amount' => 5000,
'description' => 'Customer requested refund',
]);
Complete Pre-Auth
// Capture held funds on a pre-authorised transaction
$client->transactions->complete('transaction-id');
Reverse Pre-Auth
// Release held funds on a pre-authorised transaction
$client->transactions->reverse('transaction-id');
Re-assign to Different Booking
$client->transactions->reassign('transaction-id', [
'booking_id' => 'new-booking-id',
]);
Payment Links
Create payment links to send to customers for card or open banking payments.
Create a Payment Link
$link = $client->paymentLinks->create([
'customer_name' => 'John Doe',
'email' => 'john@example.com',
'organisation' => 'org-id',
'amount' => 50000,
'type' => 'CARD',
'booking_id' => 'booking-id',
'open_banking_enabled' => true,
'card_enabled' => true,
'description' => 'Holiday deposit',
'currency' => 'GBX',
]);
Assign a Payment Link to a Booking
$client->paymentLinks->assign('payment-link-id', [
'organisation' => 'org-id',
'customer_name' => 'John Doe',
'email' => 'john@example.com',
'booking_reference' => 'REF-002',
]);
Ecommerce Sessions
Create ecommerce sessions for use with the browser-side JavaScript SDK.
Create an Ecommerce Session
$session = $client->ecommerce->create([
'customer_name' => 'Jane Smith',
'email' => 'jane@example.com',
'organisation' => 'org-id',
'amount' => 75000,
'booking_id' => 'booking-id',
'open_banking_enabled' => true,
'card_enabled' => true,
]);
// Pass session ID to the browser SDK
echo 'Ecommerce ID: ' . $session['data']['id'];
Customers
Create and list customer records.
Create a Customer
$customer = $client->customers->create([
'organisation' => 'org-id',
'customer_name' => 'Jane Smith',
'email' => 'jane@example.com',
'address_1' => '123 High Street',
'city' => 'London',
'county' => 'Greater London',
'post_code' => 'SW1A 1AA',
]);
Search Customers
$customers = $client->customers->list([
'organisation' => 'org-id',
'keyword' => 'jane@example.com',
]);
Refunds
List pending refunds and authorise or decline them.
List and Authorise Refunds
$refunds = $client->refunds->list([
'organisation' => 'org-id',
]);
// Authorise a pending refund
$client->refunds->authorise('authorisation-code');
// Or decline it
$client->refunds->decline('authorisation-code');
Scheduled Payments
Manage stored-card (MOTO) payments and generate customer approval links.
Fetch Available Tokens
// Get stored card tokens for a booking
$tokens = $client->scheduledPayments->availableTokens(
'booking-id'
);
print_r($tokens['data']);
// [['id' => ..., 'cardholder_name' => ..., 'bin' => ..., 'card_brand' => ...]]
Create a Scheduled Payment
$payment = $client->scheduledPayments->createPayment(
'booking-id',
[
'token' => 'token-id',
'amount' => 25000,
'date' => '2025-09-01', // optional: schedule for future
]
);
Generate an Approval Link
$approval = $client->scheduledPayments->approvalLink(
'booking-id',
[
'amount' => 25000,
'token' => 'token-id',
]
);
echo 'Send to customer: ' . $approval['data']['url'];
Credit Notes
Create credit notes and assign them to bookings.
Create and Assign a Credit Note
$note = $client->creditNotes->create([
'organisation' => 'org-id',
'customer_name' => 'James Dean',
'amount' => 15000,
'currency' => 'GBX',
]);
// Assign to a booking
$client->creditNotes->assign($note['data']['id'], [
'organisation' => 'org-id',
'customer_name' => 'James Dean',
'email' => 'james@example.com',
'booking_reference' => 'REF-003',
]);
Suppliers & Beneficiaries
Manage suppliers for booking components and beneficiary bank accounts for disbursements.
Suppliers
// Create a supplier
$supplier = $client->suppliers->create([
'organisation' => 'org-id',
'supplier_name' => 'Felloh Airlines',
]);
// List suppliers
$suppliers = $client->suppliers->list([
'organisation' => 'org-id',
'keyword' => 'airlines',
]);
Beneficiaries
// Create a beneficiary bank account
$beneficiary = $client->beneficiaries->create([
'organisation' => 'org-id',
'account_name' => 'Felloh Travel Ltd',
'account_number' => '12345678',
'sort_code' => '112233',
]);
// Activate a beneficiary
$client->beneficiaries->activate('beneficiary-id');
Organisations & API Keys
List accessible organisations and manage API keys programmatically.
Organisations
$orgs = $client->organisations->list();
foreach ($orgs['data'] as $org) {
echo $org['id'] . ' ' . $org['name'] . "\n";
}
API Keys
// Create a new API key pair
$key = $client->apiKeys->create([
'organisation' => 'org-id',
'name' => 'Production Server',
]);
// Store these securely — secret_key is only returned once
echo 'Public: ' . $key['data']['public_key'];
echo 'Secret: ' . $key['data']['secret_key'];
// Delete a key
$client->apiKeys->delete('key-id');
Logging
Pass a logger callback to observe every HTTP request made by the SDK.
Each LogEntry includes:
- Name
method- Type
- string
- Description
HTTP method (GET, POST, PUT, DELETE).
- Name
url- Type
- string
- Description
Full request URL including query string.
- Name
statusCode- Type
- int|null
- Description
HTTP status code, or
nullif the request failed before receiving a response.
- Name
durationMs- Type
- float
- Description
Request duration in milliseconds.
- Name
attempt- Type
- int
- Description
Retry attempt number (0 for the first attempt).
Request Logging
use Felloh\LogEntry;
$client = new FellohClient(new FellohConfig(
publicKey: 'your-public-key',
privateKey: 'your-private-key',
logger: function (LogEntry $entry) {
error_log(json_encode([
'method' => $entry->method,
'url' => $entry->url,
'status' => $entry->statusCode,
'duration' => $entry->durationMs,
'attempt' => $entry->attempt,
]));
},
));
