Payment Models
Detailed documentation for payment models in the core package.
PaymentRequest
The PaymentRequest class represents a payment request from a server.
Properties
class PaymentRequest {
maxAmountRequired: string; // Maximum payment amount required
assetType: string; // Asset type (e.g., "SPL")
assetAddress: string; // Token mint address or "native" for SOL
paymentAddress: string; // Recipient wallet address
network: string; // Blockchain network identifier
expiresAt: Date; // Payment request expiration time
nonce: string; // Unique nonce for this request
paymentId: string; // Unique payment identifier
resource: string; // Resource path being requested
description?: string; // Optional description
}Creating a Payment Request
Methods
isExpired()
isExpired()Check if the payment request has expired:
toDict()
toDict()Convert to dictionary format:
toJSON()
toJSON()Convert to JSON string:
fromDict()
fromDict()Create from dictionary:
Validation
The PaymentRequest constructor validates all fields using Zod schemas:
PaymentAuthorization
The PaymentAuthorization class represents proof of payment.
Properties
Creating a Payment Authorization
Methods
toHeaderValue()
toHeaderValue()Convert to header value (base64-encoded JSON):
fromHeader()
fromHeader()Create from header value:
toDict()
toDict()Convert to dictionary:
toJSON()
toJSON()Convert to JSON string:
Validation
The PaymentAuthorization constructor validates all fields:
Usage Examples
Creating Payment Request on Server
Parsing Payment Authorization on Server
Validating Payment Authorization
Type Definitions
Next Steps
Learn about Solana Processor for payment creation
Check out Core Package overview
See Examples for usage
Last updated
