Skip to main content

WhiskyPay SDK API Reference

This page documents all the components, functions, and types exported by the WhiskyPay SDK.

Core Functions

createSession

Creates a payment session for a customer.
Parameters:
  • saasId (string) - Your merchant ID from the WhiskyPay dashboard
  • email (string) - Customer’s email address
  • plan (string) - Identifier for the subscription plan
  • apiUrl (string, optional) - Custom API URL
  • maxRetries (number, optional) - Maximum number of retry attempts (default: 3)
Returns:
  • Promise that resolves to the session ID (string) or null if creation failed
Example:

fetchSession

Retrieves information about an existing session.
Parameters:
  • sessionId (string) - ID of the session to fetch
  • apiUrl (string, optional) - Custom API URL
Returns:
  • Promise that resolves to a SessionDetails object or null if fetch failed
Example:

verifyPayment

Verifies that a payment transaction is valid.
Parameters:
  • sessionId (string) - ID of the payment session
  • signature (string) - Transaction signature from Solana
  • publicKey (string) - Customer’s wallet public key
  • apiUrl (string, optional) - Custom API URL
Returns:
  • Promise that resolves to a boolean indicating if the payment is valid
Example:

Components

PaymentModal

A React component that displays a payment interface for customers.
Props:
  • sessionId (string, required) - Payment session ID
  • RPC_URL (string, required) - Solana RPC URL for blockchain communication
  • onRedirect (function, optional) - Callback for when payment completes
  • onClose (function, optional) - Callback for when modal is closed
  • customStyles (object, optional) - Custom styling options
  • apiUrl (string, optional) - Custom API URL
  • defaultToken (string, optional) - Default selected token (e.g., “SOL”, “USDC”)
Example:

PaymentModalComponent

A lower-level component for custom payment modal implementations.

Utilities

Tokens

A utility for working with supported tokens.
Methods:
  • getAll() - Returns all supported tokens
  • getToken(symbol) - Returns a token by its symbol
  • isSupported(symbol) - Checks if a token is supported
Example:

Types

SessionDetails

Represents the details of a payment session.

Error Handling

The SDK functions throw errors for various conditions. It’s recommended to wrap SDK calls in try/catch blocks to handle these errors gracefully.

Browser Compatibility

The SDK is designed to work in modern browsers that support ES6+ features and Web3 capabilities. It has been tested on:
  • Chrome 88+
  • Firefox 85+
  • Safari 14+
  • Edge 88+

Advanced Usage

For advanced use cases, such as custom API integrations or non-React environments, see the Advanced SDK Guide for more details.