Skip to content

TransactionsAPI

Defined in: v1/transactions.ts:13

Handles all transaction-related API operations. Intended to be instantiated by a parent API client that provides the base fetch logic.

new TransactionsAPI(baseFetch): TransactionsAPI

Defined in: v1/transactions.ts:22

Creates a new TransactionsAPI instance.

<T>(endpoint, schema) => Promise<T>

A generic fetch function provided by the parent client. Handles request execution and response validation against a Zod schema.

TransactionsAPI

const transactions = new TransactionsAPI((endpoint, schema) => myClient.fetch(endpoint, schema));

getById(id): Promise<{ affiliate_fees?: number | null; affiliate_id?: number | null; amount_refunded?: number; author_fees?: number | null; author_id?: number | null; charge: number; chargeback_fee?: number | null; coupon_id?: number | null; created_at: string; currency: string; final_price: number; has_chargeback?: boolean | null; id: number; pricing_plan_id?: number; purchased_at?: string; refunded_at?: string | null; revenue?: number; sale_id?: number; status?: string | null; tax_charge?: number; user_id: number; }>

Defined in: v1/transactions.ts:85

Retrieves a single transaction by its unique numeric ID.

number

The unique identifier of the transaction.

Promise<{ affiliate_fees?: number | null; affiliate_id?: number | null; amount_refunded?: number; author_fees?: number | null; author_id?: number | null; charge: number; chargeback_fee?: number | null; coupon_id?: number | null; created_at: string; currency: string; final_price: number; has_chargeback?: boolean | null; id: number; pricing_plan_id?: number; purchased_at?: string; refunded_at?: string | null; revenue?: number; sale_id?: number; status?: string | null; tax_charge?: number; user_id: number; }>

A promise resolving to a validated Transaction object.

If no transaction exists with the given ID or the request fails.

const transaction = await transactionsAPI.getById(101);

getList(page?, per?, filters?): Promise<{ meta?: { from?: number; number_of_pages?: number; page?: number; per_page?: number; to?: number; total?: number; }; transactions: { affiliate_fees?: number | null; affiliate_id?: number | null; amount_refunded?: number; author_fees?: number | null; author_id?: number | null; charge: number; chargeback_fee?: number | null; coupon_id?: number | null; created_at: string; currency: string; final_price: number; has_chargeback?: boolean | null; id: number; pricing_plan_id?: number; purchased_at?: string; refunded_at?: string | null; revenue?: number; sale_id?: number; status?: string | null; tax_charge?: number; user_id: number; }[]; }>

Defined in: v1/transactions.ts:50

Retrieves a paginated list of transactions with optional filters. All filter parameters are optional and can be combined freely.

number = 1

The page number to retrieve. Defaults to 1.

number = 20

The number of results per page. Defaults to 20, maximum: 100.

Optional filters to apply to the query.

number

If provided, restricts results to transactions for this affiliate.

number

If provided, restricts results to transactions for this course.

string

If provided, restricts results to transactions on or before this date (ISO 8601).

boolean

If true, returns only chargeback transactions.

boolean

If true, returns only fully refunded transactions.

number

If provided, restricts results to transactions for this pricing plan.

string

If provided, restricts results to transactions on or after this date (ISO 8601).

number

If provided, restricts results to transactions belonging to this user.

Promise<{ meta?: { from?: number; number_of_pages?: number; page?: number; per_page?: number; to?: number; total?: number; }; transactions: { affiliate_fees?: number | null; affiliate_id?: number | null; amount_refunded?: number; author_fees?: number | null; author_id?: number | null; charge: number; chargeback_fee?: number | null; coupon_id?: number | null; created_at: string; currency: string; final_price: number; has_chargeback?: boolean | null; id: number; pricing_plan_id?: number; purchased_at?: string; refunded_at?: string | null; revenue?: number; sale_id?: number; status?: string | null; tax_charge?: number; user_id: number; }[]; }>

A promise resolving to a validated TransactionsResponse object.

// All transactions, first page
const all = await transactionsAPI.getList();
// Refunded transactions for a specific user and course
const filtered = await transactionsAPI.getList(1, 20, {
userId: 99,
courseId: 42,
isFullyRefunded: true,
});