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.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new TransactionsAPI(
baseFetch):TransactionsAPI
Defined in: v1/transactions.ts:22
Creates a new TransactionsAPI instance.
Parameters
Section titled “Parameters”baseFetch
Section titled “baseFetch”<T>(endpoint, schema) => Promise<T>
A generic fetch function provided by the parent client. Handles request execution and response validation against a Zod schema.
Returns
Section titled “Returns”TransactionsAPI
Example
Section titled “Example”const transactions = new TransactionsAPI((endpoint, schema) => myClient.fetch(endpoint, schema));Methods
Section titled “Methods”getById()
Section titled “getById()”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.
Parameters
Section titled “Parameters”number
The unique identifier of the transaction.
Returns
Section titled “Returns”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.
Throws
Section titled “Throws”If no transaction exists with the given ID or the request fails.
Example
Section titled “Example”const transaction = await transactionsAPI.getById(101);getList()
Section titled “getList()”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.
Parameters
Section titled “Parameters”number = 1
The page number to retrieve. Defaults to 1.
number = 20
The number of results per page. Defaults to 20, maximum: 100.
filters?
Section titled “filters?”Optional filters to apply to the query.
affiliateId?
Section titled “affiliateId?”number
If provided, restricts results to transactions for this affiliate.
courseId?
Section titled “courseId?”number
If provided, restricts results to transactions for this course.
endDate?
Section titled “endDate?”string
If provided, restricts results to transactions on or before this date (ISO 8601).
isChargeback?
Section titled “isChargeback?”boolean
If true, returns only chargeback transactions.
isFullyRefunded?
Section titled “isFullyRefunded?”boolean
If true, returns only fully refunded transactions.
pricingPlanId?
Section titled “pricingPlanId?”number
If provided, restricts results to transactions for this pricing plan.
startDate?
Section titled “startDate?”string
If provided, restricts results to transactions on or after this date (ISO 8601).
userId?
Section titled “userId?”number
If provided, restricts results to transactions belonging to this user.
Returns
Section titled “Returns”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.
Example
Section titled “Example”// All transactions, first pageconst all = await transactionsAPI.getList();
// Refunded transactions for a specific user and courseconst filtered = await transactionsAPI.getList(1, 20, { userId: 99, courseId: 42, isFullyRefunded: true,});