Skip to content

API Reference

Defined in: sdk.ts:29

Constructs the base class with provided configuration.

SDK configuration containing credentials and environment.

You can use this SDK to interact with Funtico’s APIs for payments, transactions, games, and more.

const sdk = new FunticoSDK({
pspClientId: "your-psp-client-id",
pspClientSecret: "your-psp-client-secret",
authClientId: "your-auth-client-id",
authClientSecret: "your-auth-client-secret",
env: "staging"
});
const tx = await sdk.getTransactionById("tx_123");
  • Base.Transactions.Auth

new FunticoSDK(config): FunticoSDK

Defined in: base.ts:59

Constructs the base class with provided configuration.

Config

SDK configuration containing credentials and environment.

FunticoSDK

Base.constructor

protected authClientId: null | string

Defined in: base.ts:51

Base.authClientId


protected authClientSecret: null | string

Defined in: base.ts:52

Base.authClientSecret


protected baseAuthApiUrl: string

Defined in: base.ts:50

Base.baseAuthApiUrl

createTransaction(newTransaction): Promise<ReadTransaction>

Defined in: transactions/index.ts:29

Creates a new transaction.

CreateTransaction

The transaction payload to create.

Promise<ReadTransaction>

  • The newly created transaction.
  • Throws if the creation fails or request is invalid.

protected funticoApiRequest<T>(endpoint, accessToken, options?): Promise<T>

Defined in: base.ts:139

Makes a request to the Funtico API using configured authentication.

T

string

The relative endpoint to call.

string

RequestInit

Optional fetch configuration.

Promise<T>

  • Parsed response data of type T.
  • If the request fails or authentication is missing.

Base.funticoApiRequest


getTokens(params): Promise<GetTokensResponse>

Defined in: auth/index.ts:89

Exchanges an authorization code for access tokens using the provided code verifier.

GetTokensParams

Token exchange parameters.

Promise<GetTokensResponse>

Object containing the access and refresh tokens.

If auth client credentials are not set or token exchange fails.


getTransactionById(id): Promise<null | ReadTransaction>

Defined in: transactions/index.ts:15

Retrieves a transaction by its unique ID.

string

The ID of the transaction to retrieve.

Promise<null | ReadTransaction>

  • The transaction object if found, otherwise null.
  • Throws if the request fails or transaction is not found.

getUserBalance(params): Promise<number>

Defined in: auth/index.ts:191

Retrieves user balance using an access token.

GetUserBalanceParams

Parameters for fetching user balance.

Promise<number>

Object containing raw user balance data.

If request fails.


getUserInfo(params): Promise<GetUserInfoResponse>

Defined in: auth/index.ts:152

Retrieves user profile information using an access token.

GetUserInfoParams

Parameters for fetching user info.

Promise<GetUserInfoResponse>

Object containing raw user profile data.

If auth client credentials are not set or request fails.


protected pspRequest<T>(endpoint, options?): Promise<T>

Defined in: base.ts:90

Makes a request to the PSP API using configured authentication.

T

string

The relative endpoint to call.

RequestInit

Optional fetch configuration.

Promise<T>

  • Parsed response data of type T.
  • If the request fails or authentication is missing.

Base.pspRequest


signInWithFuntico(params): Promise<SignInWithFunticoResponse>

Defined in: auth/index.ts:33

Starts the Funtico sign-in flow by generating a redirect URL and PKCE code verifier.

SignInWithFunticoParams

Parameters for initiating the auth flow.

Promise<SignInWithFunticoResponse>

Object containing the code verifier, redirect URL, and state.

If auth client credentials are not set or internal error occurs.

@pillarex/funtico-sdk


@pillarex/funtico-sdk / SDKError

Defined in: errors.ts:10

Represents a structured error returned by the Funtico SDK. Note: This does not extend the native Error class.

new SDKError(name, status): SDKError

Defined in: errors.ts:29

Constructs a new SDKError.

"internal_server_error"

The type of SDK error.

number

The associated HTTP status code.

SDKError

name: "internal_server_error"

Defined in: errors.ts:21

A predefined error name identifying the type of SDK error.

"transaction_not_found"

status: number

Defined in: errors.ts:15

The HTTP status code associated with the error.

404

@pillarex/funtico-sdk


@pillarex/funtico-sdk / isSDKError

isSDKError(error): error is SDKError

Defined in: errors.ts:41

Type guard to check whether an unknown value is an SDKError.

unknown

The value to check.

error is SDKError

true if the error is an instance of SDKError.

@pillarex/funtico-sdk


@pillarex/funtico-sdk


@pillarex/funtico-sdk / GetTokensParams

Defined in: auth/types.ts:56

Parameters required to exchange an authorization code for tokens.

codeVerifier: string

Defined in: auth/types.ts:60

The PKCE code verifier string that was generated during sign-in initiation.


url: string

Defined in: auth/types.ts:66

The full redirect URL received from Funtico after user authentication, including query parameters like code and state.

@pillarex/funtico-sdk


@pillarex/funtico-sdk / GetTokensResponse

Defined in: auth/types.ts:72

Response returned after exchanging authorization code for tokens.

accessToken: string

Defined in: auth/types.ts:76

The access token that can be used to authorize API requests and fetch user info.


refreshToken: string

Defined in: auth/types.ts:82

The refresh token obtained from the token exchange, used to refresh the access token.

@pillarex/funtico-sdk


@pillarex/funtico-sdk / GetUserBalanceParams

Defined in: auth/types.ts:88

Parameters required to fetch user balance from Funtico.

accessToken: string

Defined in: auth/types.ts:93

The access token obtained from the token exchange, used to authorize the user balance request.

@pillarex/funtico-sdk


@pillarex/funtico-sdk / GetUserInfoParams

Defined in: auth/types.ts:40

Parameters required to fetch user info from Funtico.

accessToken: string

Defined in: auth/types.ts:45

The access token obtained from the token exchange, used to authorize the user info request.

@pillarex/funtico-sdk


@pillarex/funtico-sdk / SignInWithFunticoParams

Defined in: auth/types.ts:4

Parameters for initiating the Funtico sign-in process.

callbackUrl: string

Defined in: auth/types.ts:8

The URL to which Funtico will redirect after the user completes authentication.


scopes: "balance:read"[]

Defined in: auth/types.ts:13

The scopes requested during sign-in. Currently, only “profile” is supported.

@pillarex/funtico-sdk


@pillarex/funtico-sdk / SignInWithFunticoResponse

Defined in: auth/types.ts:19

Response returned from the Funtico sign-in initiation.

codeVerifier: string

Defined in: auth/types.ts:24

The PKCE code verifier string, which must be saved and provided later when exchanging the authorization code for tokens.


redirectUrl: string

Defined in: auth/types.ts:29

The URL to redirect the user to in order to authenticate with Funtico.


state: string

Defined in: auth/types.ts:34

A random state string used to prevent CSRF attacks and validate the response.

@pillarex/funtico-sdk


@pillarex/funtico-sdk / CreateTransaction

CreateTransaction = object

Defined in: transactions/types.ts:101

Structure for creating a new transaction request.

cancel_url: string

Defined in: transactions/types.ts:112

URL to redirect to if the user cancels the transaction.


expiration_sec: number

Defined in: transactions/types.ts:118

Transaction expiration time in seconds from creation.


items: CreateTransactionItem[]

Defined in: transactions/types.ts:103

List of items to include in the transaction.


metadata: Record<string, unknown>

Defined in: transactions/types.ts:106

Arbitrary metadata attached to the transaction.


success_url: string

Defined in: transactions/types.ts:109

URL to redirect to after successful payment.


ui_mode: UIMode

Defined in: transactions/types.ts:115

UI display mode for the transaction.

@pillarex/funtico-sdk


@pillarex/funtico-sdk / CreateTransactionItem

CreateTransactionItem = object

Defined in: transactions/types.ts:124

Item format used when creating a transaction.

currency: Currency

Defined in: transactions/types.ts:144

Currency used for the item.


optional description: string

Defined in: transactions/types.ts:135

Optional description of the item.


optional image_url: string

Defined in: transactions/types.ts:138

Optional image URL for the item.


metadata: Record<string, unknown>

Defined in: transactions/types.ts:141

Arbitrary metadata attached to the item.


name: string

Defined in: transactions/types.ts:132

Name of the item.


quantity: number

Defined in: transactions/types.ts:129

Quantity of the item to include in the transaction.


unit_price: number

Defined in: transactions/types.ts:126

Price per unit in the smallest currency unit (e.g. cents).

@pillarex/funtico-sdk


@pillarex/funtico-sdk / Currency

Currency = "usd" | "tico"

Defined in: transactions/types.ts:150

Supported currencies for transactions.

@pillarex/funtico-sdk


@pillarex/funtico-sdk / GetUserBalanceResponse

GetUserBalanceResponse = number

Defined in: auth/types.ts:99

Response containing the user balance retrieved from Funtico.

@pillarex/funtico-sdk


@pillarex/funtico-sdk / GetUserInfoResponse

GetUserInfoResponse = Record<string, unknown>

Defined in: auth/types.ts:51

Response containing the user information retrieved from Funtico.

@pillarex/funtico-sdk


@pillarex/funtico-sdk / ReadGame

ReadGame = object

Defined in: transactions/types.ts:47

Represents game information returned in a transaction.

banner_url: string | null

Defined in: transactions/types.ts:58

Optional banner image URL.


icon_url: string | null

Defined in: transactions/types.ts:55

Optional icon image URL.


id: string

Defined in: transactions/types.ts:49

Unique identifier for the game.


name: string

Defined in: transactions/types.ts:52

Name of the game.

@pillarex/funtico-sdk


@pillarex/funtico-sdk / ReadTransaction

ReadTransaction = object

Defined in: transactions/types.ts:4

Represents a transaction returned by the Funtico API.

cancel_url: string

Defined in: transactions/types.ts:18

URL the user is redirected to if they cancel.


created_at: string

Defined in: transactions/types.ts:27

When the transaction was created (ISO 8601 timestamp).


expires_at: string

Defined in: transactions/types.ts:24

When the transaction will expire (ISO 8601 timestamp).


game: ReadGame | null

Defined in: transactions/types.ts:36

Game associated with the transaction, if any.


id: string

Defined in: transactions/types.ts:6

Unique identifier for the transaction.


items: ReadTransactionItem[]

Defined in: transactions/types.ts:9

List of items included in the transaction.


metadata: Record<string, unknown>

Defined in: transactions/types.ts:12

Arbitrary metadata provided by the developer.


status: ReadTransactionStatus

Defined in: transactions/types.ts:33

Current status of the transaction.


success_url: string

Defined in: transactions/types.ts:15

URL the user is redirected to after successful completion.


ui_mode: UIMode

Defined in: transactions/types.ts:21

Determines how the UI is presented to the user.


updated_at: string

Defined in: transactions/types.ts:30

When the transaction was last updated (ISO 8601 timestamp).

@pillarex/funtico-sdk


@pillarex/funtico-sdk / ReadTransactionItem

ReadTransactionItem = object

Defined in: transactions/types.ts:75

A single item in a transaction returned from the API.

currency: Currency

Defined in: transactions/types.ts:95

Currency used for the transaction.


optional description: string

Defined in: transactions/types.ts:80

Optional description of the item.


optional image_url: string

Defined in: transactions/types.ts:83

Optional image URL for the item.


metadata: Record<string, unknown>

Defined in: transactions/types.ts:86

Arbitrary metadata for the item.


name: string

Defined in: transactions/types.ts:77

Item name.


quantity: number

Defined in: transactions/types.ts:89

Quantity of the item purchased.


unit_price: number

Defined in: transactions/types.ts:92

Price per item, in the smallest currency unit (e.g. cents).

@pillarex/funtico-sdk


@pillarex/funtico-sdk / ReadTransactionStatus

ReadTransactionStatus = object

Defined in: transactions/types.ts:64

Represents the current status of a transaction.

current: TransactionStatusType

Defined in: transactions/types.ts:66

The current transaction status.


reason: string | null

Defined in: transactions/types.ts:69

Optional reason or message for the current status.

@pillarex/funtico-sdk


@pillarex/funtico-sdk / SDKErrorName

SDKErrorName = "internal_server_error"

Defined in: errors.ts:4

List of all possible SDK error identifiers returned by the Funtico SDK.

@pillarex/funtico-sdk


@pillarex/funtico-sdk / TransactionStatusType

TransactionStatusType = "created" | "confirmed" | "completed" | "failed" | "canceled" | "expired"

Defined in: transactions/types.ts:155

All possible transaction lifecycle statuses.

@pillarex/funtico-sdk


@pillarex/funtico-sdk / UIMode

UIMode = "new_card" | "embedded" | "redirect"

Defined in: transactions/types.ts:42

Defines the UI presentation mode for transactions.