Examples

Practical examples showing common operations with the Felloh Ruby SDK. Each example assumes you have already created a client instance.

Client Setup

require "felloh"

client = Felloh::Client.new(
  public_key: ENV["FELLOH_PUBLIC_KEY"],
  private_key: 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: 100_000,
)

puts "Booking ID: #{created.data['id']}"

List & Search Bookings

bookings = client.bookings.list(
  organisation: "org-id",
  keyword: "james@example.com",
  take: 20,
)

puts "Found #{bookings.meta['count']} bookings"

Get a Single Booking

booking = client.bookings.get("booking-id")
puts booking.data

Update a Booking

client.bookings.update(
  "booking-id",
  customer_name: "Jane Dean",
)

Delete a Booking

client.bookings.delete("booking-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,
)

Complete Pre-Auth

# Capture held funds
client.transactions.complete("transaction-id")

Reverse Pre-Auth

# Release held funds
client.transactions.reverse("transaction-id")

Re-assign to Different Booking

client.transactions.reassign(
  "transaction-id",
  booking_id: "new-booking-id",
)

Create payment links to send to customers for card or open banking payments.

Create a Payment Link

link = client.payment_links.create(
  customer_name: "John Doe",
  email: "john@example.com",
  organisation: "org-id",
  amount: 50_000,
  type: "CARD",
)

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",
)

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: 75_000,
  booking_id: "booking-id",
  open_banking_enabled: true,
  card_enabled: true,
)

# Pass session.data["id"] to the browser SDK
puts "Ecommerce ID: #{session.data['id']}"

Logging

Pass a logger lambda to observe every HTTP request made by the SDK.

Each entry includes:

  • Name
    method
    Type
    Symbol
    Description

    HTTP method (:get, :post, :put, :delete).

  • Name
    url
    Type
    String
    Description

    Full request URL including query string.

  • Name
    status_code
    Type
    Integer
    Description

    HTTP status code, or nil if the request failed before receiving a response.

  • Name
    duration_ms
    Type
    Integer
    Description

    Request duration in milliseconds.

  • Name
    attempt
    Type
    Integer
    Description

    Retry attempt number (0 for the first attempt).

Request Logging

client = Felloh::Client.new(
  public_key: "your-public-key",
  private_key: "your-private-key",
  logger: ->(entry) {
    puts "#{entry[:method]} #{entry[:url]}" \
         " -> #{entry[:status_code]}" \
         " (#{entry[:duration_ms]}ms)"
  },
)