API Reference
Class: FunticoSDK
Section titled “Class: FunticoSDK”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.
Example
Section titled “Example”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");Extends
Section titled “Extends”Base.Transactions.Auth
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new FunticoSDK(
config):FunticoSDK
Defined in: base.ts:59
Constructs the base class with provided configuration.
Parameters
Section titled “Parameters”config
Section titled “config”Config
SDK configuration containing credentials and environment.
Returns
Section titled “Returns”FunticoSDK
Inherited from
Section titled “Inherited from”Base.constructor
Properties
Section titled “Properties”authClientId
Section titled “authClientId”
protectedauthClientId:null|string
Defined in: base.ts:51
Inherited from
Section titled “Inherited from”Base.authClientId
authClientSecret
Section titled “authClientSecret”
protectedauthClientSecret:null|string
Defined in: base.ts:52
Inherited from
Section titled “Inherited from”Base.authClientSecret
baseAuthApiUrl
Section titled “baseAuthApiUrl”
protectedbaseAuthApiUrl:string
Defined in: base.ts:50
Inherited from
Section titled “Inherited from”Base.baseAuthApiUrl
Methods
Section titled “Methods”createTransaction()
Section titled “createTransaction()”createTransaction(
newTransaction):Promise<ReadTransaction>
Defined in: transactions/index.ts:29
Creates a new transaction.
Parameters
Section titled “Parameters”newTransaction
Section titled “newTransaction”The transaction payload to create.
Returns
Section titled “Returns”Promise<ReadTransaction>
- The newly created transaction.
Throws
Section titled “Throws”- Throws if the creation fails or request is invalid.
funticoApiRequest()
Section titled “funticoApiRequest()”
protectedfunticoApiRequest<T>(endpoint,accessToken,options?):Promise<T>
Defined in: base.ts:139
Makes a request to the Funtico API using configured authentication.
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”endpoint
Section titled “endpoint”string
The relative endpoint to call.
accessToken
Section titled “accessToken”string
options?
Section titled “options?”RequestInit
Optional fetch configuration.
Returns
Section titled “Returns”Promise<T>
- Parsed response data of type T.
Throws
Section titled “Throws”- If the request fails or authentication is missing.
Inherited from
Section titled “Inherited from”Base.funticoApiRequest
getTokens()
Section titled “getTokens()”getTokens(
params):Promise<GetTokensResponse>
Defined in: auth/index.ts:89
Exchanges an authorization code for access tokens using the provided code verifier.
Parameters
Section titled “Parameters”params
Section titled “params”Token exchange parameters.
Returns
Section titled “Returns”Promise<GetTokensResponse>
Object containing the access and refresh tokens.
Throws
Section titled “Throws”If auth client credentials are not set or token exchange fails.
getTransactionById()
Section titled “getTransactionById()”getTransactionById(
id):Promise<null|ReadTransaction>
Defined in: transactions/index.ts:15
Retrieves a transaction by its unique ID.
Parameters
Section titled “Parameters”string
The ID of the transaction to retrieve.
Returns
Section titled “Returns”Promise<null | ReadTransaction>
- The transaction object if found, otherwise null.
Throws
Section titled “Throws”- Throws if the request fails or transaction is not found.
getUserBalance()
Section titled “getUserBalance()”getUserBalance(
params):Promise<number>
Defined in: auth/index.ts:191
Retrieves user balance using an access token.
Parameters
Section titled “Parameters”params
Section titled “params”Parameters for fetching user balance.
Returns
Section titled “Returns”Promise<number>
Object containing raw user balance data.
Throws
Section titled “Throws”If request fails.
getUserInfo()
Section titled “getUserInfo()”getUserInfo(
params):Promise<GetUserInfoResponse>
Defined in: auth/index.ts:152
Retrieves user profile information using an access token.
Parameters
Section titled “Parameters”params
Section titled “params”Parameters for fetching user info.
Returns
Section titled “Returns”Promise<GetUserInfoResponse>
Object containing raw user profile data.
Throws
Section titled “Throws”If auth client credentials are not set or request fails.
pspRequest()
Section titled “pspRequest()”
protectedpspRequest<T>(endpoint,options?):Promise<T>
Defined in: base.ts:90
Makes a request to the PSP API using configured authentication.
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”endpoint
Section titled “endpoint”string
The relative endpoint to call.
options?
Section titled “options?”RequestInit
Optional fetch configuration.
Returns
Section titled “Returns”Promise<T>
- Parsed response data of type T.
Throws
Section titled “Throws”- If the request fails or authentication is missing.
Inherited from
Section titled “Inherited from”Base.pspRequest
signInWithFuntico()
Section titled “signInWithFuntico()”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.
Parameters
Section titled “Parameters”params
Section titled “params”Parameters for initiating the auth flow.
Returns
Section titled “Returns”Promise<SignInWithFunticoResponse>
Object containing the code verifier, redirect URL, and state.
Throws
Section titled “Throws”If auth client credentials are not set or internal error occurs.
@pillarex/funtico-sdk / SDKError
Class: SDKError
Section titled “Class: SDKError”Defined in: errors.ts:10
Represents a structured error returned by the Funtico SDK. Note: This does not extend the native Error class.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new SDKError(
name,status):SDKError
Defined in: errors.ts:29
Constructs a new SDKError.
Parameters
Section titled “Parameters”"internal_server_error"
The type of SDK error.
status
Section titled “status”number
The associated HTTP status code.
Returns
Section titled “Returns”SDKError
Properties
Section titled “Properties”name:
"internal_server_error"
Defined in: errors.ts:21
A predefined error name identifying the type of SDK error.
Example
Section titled “Example”"transaction_not_found"status
Section titled “status”status:
number
Defined in: errors.ts:15
The HTTP status code associated with the error.
Example
Section titled “Example”404@pillarex/funtico-sdk / isSDKError
Function: isSDKError()
Section titled “Function: isSDKError()”isSDKError(
error):error is SDKError
Defined in: errors.ts:41
Type guard to check whether an unknown value is an SDKError.
Parameters
Section titled “Parameters”unknown
The value to check.
Returns
Section titled “Returns”error is SDKError
true if the error is an instance of SDKError.
@pillarex/funtico-sdk
Section titled “@pillarex/funtico-sdk”Classes
Section titled “Classes”Interfaces
Section titled “Interfaces”- GetTokensParams
- GetTokensResponse
- GetUserBalanceParams
- GetUserInfoParams
- SignInWithFunticoParams
- SignInWithFunticoResponse
Type Aliases
Section titled “Type Aliases”- CreateTransaction
- CreateTransactionItem
- Currency
- GetUserBalanceResponse
- GetUserInfoResponse
- ReadGame
- ReadTransaction
- ReadTransactionItem
- ReadTransactionStatus
- SDKErrorName
- TransactionStatusType
- UIMode
Functions
Section titled “Functions”@pillarex/funtico-sdk / GetTokensParams
Interface: GetTokensParams
Section titled “Interface: GetTokensParams”Defined in: auth/types.ts:56
Parameters required to exchange an authorization code for tokens.
Properties
Section titled “Properties”codeVerifier
Section titled “codeVerifier”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 / GetTokensResponse
Interface: GetTokensResponse
Section titled “Interface: GetTokensResponse”Defined in: auth/types.ts:72
Response returned after exchanging authorization code for tokens.
Properties
Section titled “Properties”accessToken
Section titled “accessToken”accessToken:
string
Defined in: auth/types.ts:76
The access token that can be used to authorize API requests and fetch user info.
refreshToken
Section titled “refreshToken”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 / GetUserBalanceParams
Interface: GetUserBalanceParams
Section titled “Interface: GetUserBalanceParams”Defined in: auth/types.ts:88
Parameters required to fetch user balance from Funtico.
Properties
Section titled “Properties”accessToken
Section titled “accessToken”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 / GetUserInfoParams
Interface: GetUserInfoParams
Section titled “Interface: GetUserInfoParams”Defined in: auth/types.ts:40
Parameters required to fetch user info from Funtico.
Properties
Section titled “Properties”accessToken
Section titled “accessToken”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 / SignInWithFunticoParams
Interface: SignInWithFunticoParams
Section titled “Interface: SignInWithFunticoParams”Defined in: auth/types.ts:4
Parameters for initiating the Funtico sign-in process.
Properties
Section titled “Properties”callbackUrl
Section titled “callbackUrl”callbackUrl:
string
Defined in: auth/types.ts:8
The URL to which Funtico will redirect after the user completes authentication.
scopes
Section titled “scopes”scopes:
"balance:read"[]
Defined in: auth/types.ts:13
The scopes requested during sign-in. Currently, only “profile” is supported.
@pillarex/funtico-sdk / SignInWithFunticoResponse
Interface: SignInWithFunticoResponse
Section titled “Interface: SignInWithFunticoResponse”Defined in: auth/types.ts:19
Response returned from the Funtico sign-in initiation.
Properties
Section titled “Properties”codeVerifier
Section titled “codeVerifier”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
Section titled “redirectUrl”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 / CreateTransaction
Type Alias: CreateTransaction
Section titled “Type Alias: CreateTransaction”CreateTransaction =
object
Defined in: transactions/types.ts:101
Structure for creating a new transaction request.
Properties
Section titled “Properties”cancel_url
Section titled “cancel_url”cancel_url:
string
Defined in: transactions/types.ts:112
URL to redirect to if the user cancels the transaction.
expiration_sec
Section titled “expiration_sec”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
Section titled “metadata”metadata:
Record<string,unknown>
Defined in: transactions/types.ts:106
Arbitrary metadata attached to the transaction.
success_url
Section titled “success_url”success_url:
string
Defined in: transactions/types.ts:109
URL to redirect to after successful payment.
ui_mode
Section titled “ui_mode”ui_mode:
UIMode
Defined in: transactions/types.ts:115
UI display mode for the transaction.
@pillarex/funtico-sdk / CreateTransactionItem
Type Alias: CreateTransactionItem
Section titled “Type Alias: CreateTransactionItem”CreateTransactionItem =
object
Defined in: transactions/types.ts:124
Item format used when creating a transaction.
Properties
Section titled “Properties”currency
Section titled “currency”currency:
Currency
Defined in: transactions/types.ts:144
Currency used for the item.
description?
Section titled “description?”
optionaldescription:string
Defined in: transactions/types.ts:135
Optional description of the item.
image_url?
Section titled “image_url?”
optionalimage_url:string
Defined in: transactions/types.ts:138
Optional image URL for the item.
metadata
Section titled “metadata”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
Section titled “quantity”quantity:
number
Defined in: transactions/types.ts:129
Quantity of the item to include in the transaction.
unit_price
Section titled “unit_price”unit_price:
number
Defined in: transactions/types.ts:126
Price per unit in the smallest currency unit (e.g. cents).
@pillarex/funtico-sdk / Currency
Type Alias: Currency
Section titled “Type Alias: Currency”Currency =
"usd"|"tico"
Defined in: transactions/types.ts:150
Supported currencies for transactions.
@pillarex/funtico-sdk / GetUserBalanceResponse
Type Alias: GetUserBalanceResponse
Section titled “Type Alias: GetUserBalanceResponse”GetUserBalanceResponse =
number
Defined in: auth/types.ts:99
Response containing the user balance retrieved from Funtico.
@pillarex/funtico-sdk / GetUserInfoResponse
Type Alias: GetUserInfoResponse
Section titled “Type Alias: GetUserInfoResponse”GetUserInfoResponse =
Record<string,unknown>
Defined in: auth/types.ts:51
Response containing the user information retrieved from Funtico.
@pillarex/funtico-sdk / ReadGame
Type Alias: ReadGame
Section titled “Type Alias: ReadGame”ReadGame =
object
Defined in: transactions/types.ts:47
Represents game information returned in a transaction.
Properties
Section titled “Properties”banner_url
Section titled “banner_url”banner_url:
string|null
Defined in: transactions/types.ts:58
Optional banner image URL.
icon_url
Section titled “icon_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 / ReadTransaction
Type Alias: ReadTransaction
Section titled “Type Alias: ReadTransaction”ReadTransaction =
object
Defined in: transactions/types.ts:4
Represents a transaction returned by the Funtico API.
Properties
Section titled “Properties”cancel_url
Section titled “cancel_url”cancel_url:
string
Defined in: transactions/types.ts:18
URL the user is redirected to if they cancel.
created_at
Section titled “created_at”created_at:
string
Defined in: transactions/types.ts:27
When the transaction was created (ISO 8601 timestamp).
expires_at
Section titled “expires_at”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
Section titled “metadata”metadata:
Record<string,unknown>
Defined in: transactions/types.ts:12
Arbitrary metadata provided by the developer.
status
Section titled “status”status:
ReadTransactionStatus
Defined in: transactions/types.ts:33
Current status of the transaction.
success_url
Section titled “success_url”success_url:
string
Defined in: transactions/types.ts:15
URL the user is redirected to after successful completion.
ui_mode
Section titled “ui_mode”ui_mode:
UIMode
Defined in: transactions/types.ts:21
Determines how the UI is presented to the user.
updated_at
Section titled “updated_at”updated_at:
string
Defined in: transactions/types.ts:30
When the transaction was last updated (ISO 8601 timestamp).
@pillarex/funtico-sdk / ReadTransactionItem
Type Alias: ReadTransactionItem
Section titled “Type Alias: ReadTransactionItem”ReadTransactionItem =
object
Defined in: transactions/types.ts:75
A single item in a transaction returned from the API.
Properties
Section titled “Properties”currency
Section titled “currency”currency:
Currency
Defined in: transactions/types.ts:95
Currency used for the transaction.
description?
Section titled “description?”
optionaldescription:string
Defined in: transactions/types.ts:80
Optional description of the item.
image_url?
Section titled “image_url?”
optionalimage_url:string
Defined in: transactions/types.ts:83
Optional image URL for the item.
metadata
Section titled “metadata”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
Section titled “quantity”quantity:
number
Defined in: transactions/types.ts:89
Quantity of the item purchased.
unit_price
Section titled “unit_price”unit_price:
number
Defined in: transactions/types.ts:92
Price per item, in the smallest currency unit (e.g. cents).
@pillarex/funtico-sdk / ReadTransactionStatus
Type Alias: ReadTransactionStatus
Section titled “Type Alias: ReadTransactionStatus”ReadTransactionStatus =
object
Defined in: transactions/types.ts:64
Represents the current status of a transaction.
Properties
Section titled “Properties”current
Section titled “current”current:
TransactionStatusType
Defined in: transactions/types.ts:66
The current transaction status.
reason
Section titled “reason”reason:
string|null
Defined in: transactions/types.ts:69
Optional reason or message for the current status.
@pillarex/funtico-sdk / SDKErrorName
Type Alias: SDKErrorName
Section titled “Type Alias: 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 / TransactionStatusType
Type Alias: TransactionStatusType
Section titled “Type Alias: TransactionStatusType”TransactionStatusType =
"created"|"confirmed"|"completed"|"failed"|"canceled"|"expired"
Defined in: transactions/types.ts:155
All possible transaction lifecycle statuses.
@pillarex/funtico-sdk / UIMode
Type Alias: UIMode
Section titled “Type Alias: UIMode”UIMode =
"new_card"|"embedded"|"redirect"
Defined in: transactions/types.ts:42
Defines the UI presentation mode for transactions.