KosmoKrator

sales

Braintree Lua API for KosmoKrator Agents

Agent-facing Lua documentation and function reference for the Braintree KosmoKrator integration.

7 functions 7 read 0 write Bearer token auth

Lua Namespace

Agents call this integration through app.integrations.braintree.*. Use lua_read_doc("integrations.braintree") inside KosmoKrator to discover the same reference at runtime.

Agent-Facing Lua Docs

This is the rendered version of the full Lua documentation exposed to agents when they inspect the integration namespace.

Braintree — Lua API Reference

list_transactions

List payment transactions for the merchant.

Parameters

NameTypeRequiredDescription
limitintegernoMax results (default: 10, max: 100)
pageintegernoPage number (default: 1)
statusstringnoFilter by status: authorized, submitted_for_settlement, settled, settling, failed, voided, declined, gateway_rejected

Example

local result = app.integrations.braintree.list_transactions({
  limit = 20,
  page = 1,
  status = "settled"
})

for _, tx in ipairs(result.transactions) do
  print(tx.id .. ": " .. tx.amount .. " " .. tx.currency_iso_code .. " (" .. tx.status .. ")")
end

get_transaction

Retrieve a single transaction by ID.

Parameters

NameTypeRequiredDescription
idstringyesThe transaction ID

Example

local result = app.integrations.braintree.get_transaction({ id = "abc123xyz" })
print("Amount: " .. result.transaction.amount)
print("Status: " .. result.transaction.status)
print("Customer: " .. result.transaction.customer.email)

list_customers

List customers stored in Braintree.

Parameters

NameTypeRequiredDescription
limitintegernoMax results (default: 10, max: 100)
pageintegernoPage number (default: 1)

Example

local result = app.integrations.braintree.list_customers({ limit = 25, page = 1 })

for _, c in ipairs(result.customers) do
  print(c.id .. ": " .. (c.first_name or "") .. " " .. (c.last_name or "") .. " <" .. (c.email or "") .. ">")
end

get_customer

Retrieve a single customer by ID.

Parameters

NameTypeRequiredDescription
idstringyesThe customer ID

Example

local result = app.integrations.braintree.get_customer({ id = "cust_123" })
print("Name: " .. result.customer.first_name .. " " .. result.customer.last_name)
print("Email: " .. result.customer.email)

list_plans

List recurring billing plans.

Parameters

NameTypeRequiredDescription
limitintegernoMax results (default: 10, max: 100)
pageintegernoPage number (default: 1)

Example

local result = app.integrations.braintree.list_plans({})

for _, plan in ipairs(result.plans) do
  print(plan.id .. ": " .. plan.name .. " - $" .. plan.price .. "/" .. plan.billing_frequency .. " cycles")
end

get_plan

Retrieve a single recurring billing plan by ID.

Parameters

NameTypeRequiredDescription
idstringyesThe plan ID

Example

local result = app.integrations.braintree.get_plan({ id = "plan_abc123" })
print("Plan: " .. result.plan.name)
print("Price: $" .. result.plan.price .. "/" .. result.plan.billing_frequency .. " cycles")

get_current_user

Get the current merchant account information.

Parameters

None.

Example

local result = app.integrations.braintree.get_current_user({})
print("Merchant: " .. result.merchant.business_name)
print("ID: " .. result.merchant.id)
print("Currency: " .. result.merchant.currency_iso_code)

Multi-Account Usage

If you have multiple Braintree accounts configured, use account-specific namespaces:

-- Default account (always works)
app.integrations.braintree.list_transactions({})

-- Explicit default (portable across setups)
app.integrations.braintree.default.list_transactions({})

-- Named accounts
app.integrations.braintree.production.list_transactions({})
app.integrations.braintree.sandbox.list_transactions({})

All functions are identical across accounts — only the credentials differ.

Raw agent markdown
# Braintree — Lua API Reference

## list_transactions

List payment transactions for the merchant.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `limit` | integer | no | Max results (default: 10, max: 100) |
| `page` | integer | no | Page number (default: 1) |
| `status` | string | no | Filter by status: `authorized`, `submitted_for_settlement`, `settled`, `settling`, `failed`, `voided`, `declined`, `gateway_rejected` |

### Example

```lua
local result = app.integrations.braintree.list_transactions({
  limit = 20,
  page = 1,
  status = "settled"
})

for _, tx in ipairs(result.transactions) do
  print(tx.id .. ": " .. tx.amount .. " " .. tx.currency_iso_code .. " (" .. tx.status .. ")")
end
```

---

## get_transaction

Retrieve a single transaction by ID.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id` | string | yes | The transaction ID |

### Example

```lua
local result = app.integrations.braintree.get_transaction({ id = "abc123xyz" })
print("Amount: " .. result.transaction.amount)
print("Status: " .. result.transaction.status)
print("Customer: " .. result.transaction.customer.email)
```

---

## list_customers

List customers stored in Braintree.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `limit` | integer | no | Max results (default: 10, max: 100) |
| `page` | integer | no | Page number (default: 1) |

### Example

```lua
local result = app.integrations.braintree.list_customers({ limit = 25, page = 1 })

for _, c in ipairs(result.customers) do
  print(c.id .. ": " .. (c.first_name or "") .. " " .. (c.last_name or "") .. " <" .. (c.email or "") .. ">")
end
```

---

## get_customer

Retrieve a single customer by ID.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id` | string | yes | The customer ID |

### Example

```lua
local result = app.integrations.braintree.get_customer({ id = "cust_123" })
print("Name: " .. result.customer.first_name .. " " .. result.customer.last_name)
print("Email: " .. result.customer.email)
```

---

## list_plans

List recurring billing plans.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `limit` | integer | no | Max results (default: 10, max: 100) |
| `page` | integer | no | Page number (default: 1) |

### Example

```lua
local result = app.integrations.braintree.list_plans({})

for _, plan in ipairs(result.plans) do
  print(plan.id .. ": " .. plan.name .. " - $" .. plan.price .. "/" .. plan.billing_frequency .. " cycles")
end
```

---

## get_plan

Retrieve a single recurring billing plan by ID.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id` | string | yes | The plan ID |

### Example

```lua
local result = app.integrations.braintree.get_plan({ id = "plan_abc123" })
print("Plan: " .. result.plan.name)
print("Price: $" .. result.plan.price .. "/" .. result.plan.billing_frequency .. " cycles")
```

---

## get_current_user

Get the current merchant account information.

### Parameters

None.

### Example

```lua
local result = app.integrations.braintree.get_current_user({})
print("Merchant: " .. result.merchant.business_name)
print("ID: " .. result.merchant.id)
print("Currency: " .. result.merchant.currency_iso_code)
```

---

## Multi-Account Usage

If you have multiple Braintree accounts configured, use account-specific namespaces:

```lua
-- Default account (always works)
app.integrations.braintree.list_transactions({})

-- Explicit default (portable across setups)
app.integrations.braintree.default.list_transactions({})

-- Named accounts
app.integrations.braintree.production.list_transactions({})
app.integrations.braintree.sandbox.list_transactions({})
```

All functions are identical across accounts — only the credentials differ.

Metadata-Derived Lua Example

local result = app.integrations.braintree.braintree_list_transactions({
  limit = 1,
  page = 1,
  status = "example_status"
})
print(result)

Functions

braintree_list_transactions

List payment transactions for the Braintree merchant. Returns transaction details including amount, status, payment method, and customer info.

Operation
Read read
Full name
braintree.braintree_list_transactions
ParameterTypeRequiredDescription
limit integer no Maximum number of transactions to return (default: 10, max: 100).
page integer no Page number for pagination (default: 1).
status string no Filter by transaction status: authorized, submitted_for_settlement, settled, settling, failed, voided, declined, gateway_rejected.

braintree_get_transaction

Retrieve a single Braintree transaction by its ID. Returns full transaction details including amount, status, payment instrument, and settlement info.

Operation
Read read
Full name
braintree.braintree_get_transaction
ParameterTypeRequiredDescription
id string yes The transaction ID (e.g., "abc123xyz").

braintree_list_customers

List customers stored in Braintree. Returns customer details including name, email, phone, and payment methods.

Operation
Read read
Full name
braintree.braintree_list_customers
ParameterTypeRequiredDescription
limit integer no Maximum number of customers to return (default: 10, max: 100).
page integer no Page number for pagination (default: 1).

braintree_get_customer

Retrieve a single Braintree customer by ID. Returns full customer details including contact info, payment methods, and addresses.

Operation
Read read
Full name
braintree.braintree_get_customer
ParameterTypeRequiredDescription
id string yes The customer ID.

braintree_list_plans

List recurring billing plans configured in Braintree. Returns plan details including billing cycle, price, and trial period.

Operation
Read read
Full name
braintree.braintree_list_plans
ParameterTypeRequiredDescription
limit integer no Maximum number of plans to return (default: 10, max: 100).
page integer no Page number for pagination (default: 1).

braintree_get_plan

Retrieve a single Braintree recurring billing plan by ID. Returns plan details including billing cycle, price, and trial period.

Operation
Read read
Full name
braintree.braintree_get_plan
ParameterTypeRequiredDescription
id string yes The plan ID.

braintree_get_current_user

Get the current Braintree merchant account information. Returns merchant details including business name, currency, and account status.

Operation
Read read
Full name
braintree.braintree_get_current_user
ParameterTypeRequiredDescription
No parameters.