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.saasId(string) - Your merchant ID from the WhiskyPay dashboardemail(string) - Customer’s email addressplan(string) - Identifier for the subscription planapiUrl(string, optional) - Custom API URLmaxRetries(number, optional) - Maximum number of retry attempts (default: 3)
- Promise that resolves to the session ID (string) or null if creation failed
fetchSession
Retrieves information about an existing session.sessionId(string) - ID of the session to fetchapiUrl(string, optional) - Custom API URL
- Promise that resolves to a SessionDetails object or null if fetch failed
verifyPayment
Verifies that a payment transaction is valid.sessionId(string) - ID of the payment sessionsignature(string) - Transaction signature from SolanapublicKey(string) - Customer’s wallet public keyapiUrl(string, optional) - Custom API URL
- Promise that resolves to a boolean indicating if the payment is valid
Components
PaymentModal
A React component that displays a payment interface for customers.sessionId(string, required) - Payment session IDRPC_URL(string, required) - Solana RPC URL for blockchain communicationonRedirect(function, optional) - Callback for when payment completesonClose(function, optional) - Callback for when modal is closedcustomStyles(object, optional) - Custom styling optionsapiUrl(string, optional) - Custom API URLdefaultToken(string, optional) - Default selected token (e.g., “SOL”, “USDC”)
PaymentModalComponent
A lower-level component for custom payment modal implementations.Utilities
Tokens
A utility for working with supported tokens.getAll()- Returns all supported tokensgetToken(symbol)- Returns a token by its symbolisSupported(symbol)- Checks if a token is supported
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+