KosmoKrator

data

Paystack Lua API for KosmoKrator Agents

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

Lua Namespace

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

Call Lua from the Headless CLI

Use kosmo integrations:lua when a shell script, CI job, cron job, or another coding CLI should run a deterministic Paystack workflow without starting an interactive agent session.

Inline Lua call
kosmo integrations:lua --eval 'dump(app.integrations.paystack.list_transactions({per_page = 1, page = 1, status = "example_status", customer = "example_customer", from = "example_from", to = "example_to"}))' --json
Read Lua docs headlessly
kosmo integrations:lua --eval 'print(docs.read("paystack"))' --json
kosmo integrations:lua --eval 'print(docs.read("paystack.list_transactions"))' --json

Workflow file

Put repeatable logic in a Lua file, then execute it with JSON output for the calling process.

workflow.lua
local paystack = app.integrations.paystack
local result = paystack.list_transactions({per_page = 1, page = 1, status = "example_status", customer = "example_customer", from = "example_from", to = "example_to"})

dump(result)
Run the workflow
kosmo integrations:lua workflow.lua --json
kosmo integrations:lua workflow.lua --force --json
Namespace note. integrations:lua exposes app.integrations.paystack, app.mcp.*, docs.*, json.*, and regex.*. Use app.integrations.paystack.default.* or app.integrations.paystack.work.* when you configured named credential accounts.

MCP-only Lua

If the script only needs configured MCP servers and does not need Paystack, use the narrower mcp:lua command.

MCP Lua command
# Use mcp:lua for MCP-only scripts; use integrations:lua for this integration namespace.
kosmo mcp:lua --eval 'dump(mcp.servers())' --json

Agent-Facing Lua Docs

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

Paystack — Lua API Reference

list_transactions

List transactions on your Paystack integration.

Parameters

NameTypeRequiredDescription
per_pageintegernoNumber of transactions per page (default: 50, max: 100)
pageintegernoPage number to retrieve
statusstringnoFilter by status: "success", "failed", "abandoned", "reversed"
customerstringnoFilter by customer ID or email
fromstringnoStart date (ISO 8601, e.g., "2025-01-01T00:00:00")
tostringnoEnd date (ISO 8601, e.g., "2025-01-31T23:59:59")

Example

local result = app.integrations.paystack.list_transactions({
  per_page = 10,
  status = "success"
})

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

get_transaction

Get details of a specific transaction by numeric Paystack transaction ID.

Parameters

NameTypeRequiredDescription
idstringyesNumeric transaction ID. Use verify_transaction when you have a transaction reference.

Example

local result = app.integrations.paystack.get_transaction({
  id = "123456789"
})

print("Status: " .. result.data.status)
print("Amount: " .. result.data.amount)

verify_transaction

Verify a transaction by reference. This is the right tool after checkout redirects, webhook delivery, or any workflow where you have the merchant reference rather than Paystack’s numeric transaction ID.

Parameters

NameTypeRequiredDescription
referencestringyesTransaction reference returned during initialization or webhook processing

Example

local result = app.integrations.paystack.verify_transaction({
  reference = "order_123"
})

print("Status: " .. result.data.status)
print("Reference: " .. result.data.reference)

initialize_transaction

Initialize a new payment transaction. Returns an authorization URL for the customer.

Parameters

NameTypeRequiredDescription
amountintegeryesAmount in kobo (e.g., 50000 for ₦500.00)
emailstringyesCustomer email address
referencestringnoUnique transaction reference
callback_urlstringnoURL to redirect after payment

Example

local result = app.integrations.paystack.initialize_transaction({
  amount = 50000,
  email = "customer@example.com",
  callback_url = "https://example.com/callback"
})

print("Authorization URL: " .. result.data.authorization_url)
print("Reference: " .. result.data.reference)

list_customers

List customers on your integration.

Parameters

NameTypeRequiredDescription
per_pageintegernoNumber of customers per page (default: 50)
pageintegernoPage number to retrieve

Example

local result = app.integrations.paystack.list_customers({
  per_page = 20
})

for _, cust in ipairs(result.data) do
  print(cust.email .. " - " .. (cust.first_name or "") .. " " .. (cust.last_name or ""))
end

create_customer

Create a new customer.

Parameters

NameTypeRequiredDescription
emailstringyesCustomer email address
first_namestringnoCustomer first name
last_namestringnoCustomer last name
phonestringnoCustomer phone number

Example

local result = app.integrations.paystack.create_customer({
  email = "jane@example.com",
  first_name = "Jane",
  last_name = "Doe",
  phone = "+2348012345678"
})

print("Created customer: " .. result.data.email)

list_plans

List subscription plans.

Parameters

NameTypeRequiredDescription
per_pageintegernoNumber of plans per page (default: 50)
pageintegernoPage number to retrieve
statusstringnoFilter by status: "active" or "inactive"

Example

local result = app.integrations.paystack.list_plans({
  status = "active"
})

for _, plan in ipairs(result.data) do
  print(plan.name .. " - " .. plan.amount .. " kobo / " .. plan.interval)
end

get_current_user

Verify the Paystack API connection and retrieve payment session timeout settings.

Parameters

None.

Example

local result = app.integrations.paystack.get_current_user({})

print("Payment session timeout: " .. result.data.payment_session_timeout)

Multi-Account Usage

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

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

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

-- Named accounts
app.integrations.paystack.production.list_transactions({})
app.integrations.paystack.test.list_transactions({})

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

Raw agent markdown
# Paystack — Lua API Reference

## list_transactions

List transactions on your Paystack integration.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `per_page` | integer | no | Number of transactions per page (default: 50, max: 100) |
| `page` | integer | no | Page number to retrieve |
| `status` | string | no | Filter by status: `"success"`, `"failed"`, `"abandoned"`, `"reversed"` |
| `customer` | string | no | Filter by customer ID or email |
| `from` | string | no | Start date (ISO 8601, e.g., `"2025-01-01T00:00:00"`) |
| `to` | string | no | End date (ISO 8601, e.g., `"2025-01-31T23:59:59"`) |

### Example

```lua
local result = app.integrations.paystack.list_transactions({
  per_page = 10,
  status = "success"
})

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

---

## get_transaction

Get details of a specific transaction by numeric Paystack transaction ID.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id` | string | yes | Numeric transaction ID. Use `verify_transaction` when you have a transaction reference. |

### Example

```lua
local result = app.integrations.paystack.get_transaction({
  id = "123456789"
})

print("Status: " .. result.data.status)
print("Amount: " .. result.data.amount)
```

---

## verify_transaction

Verify a transaction by reference. This is the right tool after checkout redirects, webhook delivery, or any workflow where you have the merchant reference rather than Paystack's numeric transaction ID.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `reference` | string | yes | Transaction reference returned during initialization or webhook processing |

### Example

```lua
local result = app.integrations.paystack.verify_transaction({
  reference = "order_123"
})

print("Status: " .. result.data.status)
print("Reference: " .. result.data.reference)
```

---

## initialize_transaction

Initialize a new payment transaction. Returns an authorization URL for the customer.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `amount` | integer | yes | Amount in kobo (e.g., `50000` for ₦500.00) |
| `email` | string | yes | Customer email address |
| `reference` | string | no | Unique transaction reference |
| `callback_url` | string | no | URL to redirect after payment |

### Example

```lua
local result = app.integrations.paystack.initialize_transaction({
  amount = 50000,
  email = "customer@example.com",
  callback_url = "https://example.com/callback"
})

print("Authorization URL: " .. result.data.authorization_url)
print("Reference: " .. result.data.reference)
```

---

## list_customers

List customers on your integration.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `per_page` | integer | no | Number of customers per page (default: 50) |
| `page` | integer | no | Page number to retrieve |

### Example

```lua
local result = app.integrations.paystack.list_customers({
  per_page = 20
})

for _, cust in ipairs(result.data) do
  print(cust.email .. " - " .. (cust.first_name or "") .. " " .. (cust.last_name or ""))
end
```

---

## create_customer

Create a new customer.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `email` | string | yes | Customer email address |
| `first_name` | string | no | Customer first name |
| `last_name` | string | no | Customer last name |
| `phone` | string | no | Customer phone number |

### Example

```lua
local result = app.integrations.paystack.create_customer({
  email = "jane@example.com",
  first_name = "Jane",
  last_name = "Doe",
  phone = "+2348012345678"
})

print("Created customer: " .. result.data.email)
```

---

## list_plans

List subscription plans.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `per_page` | integer | no | Number of plans per page (default: 50) |
| `page` | integer | no | Page number to retrieve |
| `status` | string | no | Filter by status: `"active"` or `"inactive"` |

### Example

```lua
local result = app.integrations.paystack.list_plans({
  status = "active"
})

for _, plan in ipairs(result.data) do
  print(plan.name .. " - " .. plan.amount .. " kobo / " .. plan.interval)
end
```

---

## get_current_user

Verify the Paystack API connection and retrieve payment session timeout settings.

### Parameters

None.

### Example

```lua
local result = app.integrations.paystack.get_current_user({})

print("Payment session timeout: " .. result.data.payment_session_timeout)
```

---

## Multi-Account Usage

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

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

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

-- Named accounts
app.integrations.paystack.production.list_transactions({})
app.integrations.paystack.test.list_transactions({})
```

All functions are identical across accounts — only the credentials differ.
Metadata-derived Lua example
local result = app.integrations.paystack.list_transactions({per_page = 1, page = 1, status = "example_status", customer = "example_customer", from = "example_from", to = "example_to"})
print(result)

Functions

list_transactions Read

List transactions on your Paystack integration. Supports filtering by status, customer, and date range with pagination.

Lua path
app.integrations.paystack.list_transactions
Full name
paystack.paystack_list_transactions
ParameterTypeRequiredDescription
per_page integer no Number of transactions per page (default: 50, max: 100).
page integer no Page number to retrieve.
status string no Filter by status: "success", "failed", "abandoned", "reversed".
customer string no Filter by customer ID or email.
from string no Start date for filtering (ISO 8601, e.g., "2025-01-01T00:00:00").
to string no End date for filtering (ISO 8601, e.g., "2025-01-31T23:59:59").
get_transaction Read

Get details of a specific Paystack transaction by its numeric ID. Use paystack_verify_transaction when you have a reference.

Lua path
app.integrations.paystack.get_transaction
Full name
paystack.paystack_get_transaction
ParameterTypeRequiredDescription
id string yes Numeric transaction ID. Use paystack_verify_transaction for transaction references.
verify_transaction Read

Verify a Paystack transaction by reference. Use this after checkout redirects or webhook delivery to confirm final payment status.

Lua path
app.integrations.paystack.verify_transaction
Full name
paystack.paystack_verify_transaction
ParameterTypeRequiredDescription
reference string yes The transaction reference returned by Paystack.
initialize_transaction Write

Initialize a new payment transaction on Paystack. Returns an authorization URL for the customer to complete payment.

Lua path
app.integrations.paystack.initialize_transaction
Full name
paystack.paystack_initialize_transaction
ParameterTypeRequiredDescription
amount integer yes Amount in kobo (e.g., 50000 for ₦500.00).
email string yes Customer email address.
reference string no Unique transaction reference. If not provided, Paystack generates one.
callback_url string no URL to redirect customer to after payment.
list_customers Read

List customers on your Paystack integration. Supports pagination.

Lua path
app.integrations.paystack.list_customers
Full name
paystack.paystack_list_customers
ParameterTypeRequiredDescription
per_page integer no Number of customers per page (default: 50, max: 100).
page integer no Page number to retrieve.
create_customer Write

Create a new customer on your Paystack integration.

Lua path
app.integrations.paystack.create_customer
Full name
paystack.paystack_create_customer
ParameterTypeRequiredDescription
email string yes Customer email address.
first_name string no Customer first name.
last_name string no Customer last name.
phone string no Customer phone number.
list_plans Read

List subscription plans on your Paystack integration. Supports filtering by status and pagination.

Lua path
app.integrations.paystack.list_plans
Full name
paystack.paystack_list_plans
ParameterTypeRequiredDescription
per_page integer no Number of plans per page (default: 50, max: 100).
page integer no Page number to retrieve.
status string no Filter by status: "active" or "inactive".
connection_check Read

Verify the Paystack API connection and retrieve integration payment session timeout settings. Use this to check if the API key is valid and the service is reachable.

Lua path
app.integrations.paystack.connection_check
Full name
paystack.paystack_get_current_user
ParameterTypeRequiredDescription
No parameters.