// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../../core/resource'; import { APIPromise } from '../../core/api-promise'; import { RequestOptions } from '../../internal/request-options'; import { path } from '../../internal/utils/path'; export class Payouts extends APIResource { /** * Get a paginated list of payout requests for the authenticated creator with * payment method details including bank name, account name, and masked account * number. * * @example * ```ts * const payouts = await client.creators.payouts.list(); * ``` */ list(options?: RequestOptions): APIPromise { return this._client.get('/creators/payouts', options); } /** * Get a paginated and filterable list of all payout requests for the authenticated * creator. Supports filtering by status, date range, sorting, and pagination. * * @example * ```ts * const response = await client.creators.payouts.history(); * ``` */ history( query: PayoutHistoryParams | null | undefined = {}, options?: RequestOptions, ): APIPromise { return this._client.get('/creators/payouts/history', { query, ...options }); } /** * Request a payout for available earnings. Validates minimum amount, sufficient * balance, and that the payout method exists, belongs to the creator, and is * active. * * @example * ```ts * const response = await client.creators.payouts.request({ * amount: 5000, * }); * ``` */ request(body: PayoutRequestParams, options?: RequestOptions): APIPromise { return this._client.post('/creators/payouts/requests', { body, ...options }); } /** * Get detailed receipt information for a paid payout request, including creator * details, destination account, and fee breakdown for PDF generation * * @example * ```ts * const response = * await client.creators.payouts.retrieveInvoice( * '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', * ); * ``` */ retrieveInvoice(id: string, options?: RequestOptions): APIPromise { return this._client.get(path`/creators/payouts/${id}/receipt`, options); } /** * Get payout summary for the authenticated creator. * * @example * ```ts * const response = * await client.creators.payouts.retrieveSummary(); * ``` */ retrieveSummary(options?: RequestOptions): APIPromise { return this._client.get('/creators/payouts/summary', options); } } export interface PayoutListResponse { data: Array; pagination: PayoutListResponse.Pagination; } export namespace PayoutListResponse { export interface Data { id: string; amount: number; createdAt: string; currency: string; depositAccountId: string; status: 'pending' | 'processing' | 'paid' | 'failed' | 'rejected'; updatedAt: string; creator?: Data.Creator; destinationAccount?: Data.DestinationAccount; failureReason?: string; financialMovementId?: string; name?: string; processedAt?: string; } export namespace Data { export interface Creator { id: string; email: string; handle: string; name: string; country?: string; } export interface DestinationAccount { accountNumber: string; accountType: 'wire'; bank: string; name: string; } } export interface Pagination { limit: number; page: number; total: number; totalPages: number; } } /** * Response schema for paginated payout history */ export interface PayoutHistoryResponse { data: PayoutHistoryResponse.Data; /** * Whether the request was successful */ success: boolean; } export namespace PayoutHistoryResponse { export interface Data { pagination: Data.Pagination; /** * List of payout history items */ payouts: Array; } export namespace Data { export interface Pagination { /** * Items per page */ limit: number; /** * Current page number */ page: number; /** * Total number of items */ total: number; /** * Total number of pages */ totalPages: number; } /** * Payout history item information */ export interface Payout { /** * Unique identifier for the payout */ id: string; /** * Payout amount */ amount: number; /** * ISO 8601 timestamp of when the payout was created */ createdAt: string; destinationAccount: Payout.DestinationAccount; /** * Payout description */ name: string; /** * Status of the payout */ status: 'pending' | 'processing' | 'paid' | 'failed' | 'rejected'; /** * ISO 8601 timestamp of when the payout was last updated */ updatedAt: string; } export namespace Payout { export interface DestinationAccount { /** * Masked account number for security */ accountNumber: string; /** * Type of deposit account */ accountType: 'wire'; /** * Name of the destination bank */ bank: string; /** * Name of the destination account */ name: string; } } } } /** * Response schema for creating a payout request */ export interface PayoutRequestResponse { data: PayoutRequestResponse.Data; /** * Success message */ message: string; /** * Whether the request was successful */ success: boolean; } export namespace PayoutRequestResponse { export interface Data { /** * ID of the created payout request */ id: string; /** * Payout amount in cents */ amount: number; /** * ISO 8601 timestamp of when the payout request was created */ createdAt: string; /** * Status of the payout request */ status: 'pending' | 'processing' | 'paid' | 'failed' | 'rejected'; /** * Optional notes for the payout request */ notes?: string; } } export interface PayoutRetrieveInvoiceResponse { data: PayoutRetrieveInvoiceResponse.Data; success: boolean; } export namespace PayoutRetrieveInvoiceResponse { export interface Data { creator: Data.Creator; destination: Data.Destination; fees: Data.Fees; grossAmount: number; netAmount: number; payoutRequest: Data.PayoutRequest; receiptDate: string; receiptId: string; } export namespace Data { export interface Creator { id: string; name: string; email?: string; } export interface Destination { accountHolderName: string; accountNumber: string; accountType: string; bank: string; routingNumber: string; swiftCode?: string; } export interface Fees { processingFee: number; totalFees: number; transferFee: number; } export interface PayoutRequest { id: string; amount: number; createdAt: string; currency: string; processedAt: string; status: 'paid'; } } } export interface PayoutRetrieveSummaryResponse { data: PayoutRetrieveSummaryResponse.Data; /** * Indicates if the request was successful */ success: boolean; } export namespace PayoutRetrieveSummaryResponse { export interface Data { /** * ISO 8601 timestamp of the last successful payout, or null if no payouts yet */ lastPayoutDate: string | null; /** * Total amount of pending payouts in dollars */ pendingPayout: number; /** * Total lifetime earnings from all completed payouts in dollars */ totalEarnings: number; } } export interface PayoutHistoryParams { /** * Filter payouts from this date (ISO 8601) */ dateFrom?: string; /** * Filter payouts to this date (ISO 8601) */ dateTo?: string; /** * Number of items per page (max 100) */ limit?: number; /** * Page number for pagination */ page?: number; /** * Field to sort by */ sortBy?: 'amount' | 'createdAt' | 'updatedAt'; /** * Sort order */ sortOrder?: 'asc' | 'desc'; /** * Filter by payout status */ status?: 'pending' | 'processing' | 'paid' | 'failed' | 'rejected'; } export interface PayoutRequestParams { /** * Payout amount in cents (minimum: 1000 cents = $10) */ amount: number; /** * Optional notes for the payout request */ notes?: string; } export declare namespace Payouts { export { type PayoutListResponse as PayoutListResponse, type PayoutHistoryResponse as PayoutHistoryResponse, type PayoutRequestResponse as PayoutRequestResponse, type PayoutRetrieveInvoiceResponse as PayoutRetrieveInvoiceResponse, type PayoutRetrieveSummaryResponse as PayoutRetrieveSummaryResponse, type PayoutHistoryParams as PayoutHistoryParams, type PayoutRequestParams as PayoutRequestParams, }; }