Marlin handles the full lifecycle of a stablecoin payment — from creating a customer record to confirming settlement on Solana. This guide walks you through each step using the TypeScript SDK. By the end, your server creates an invoice, hands the customer a payment URL, and fulfills the order automatically when the payment is confirmed on-chain.Documentation Index
Fetch the complete documentation index at: https://yanhgming.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Install the SDK
Add Initialize the client with your secret API key. Keep this key server-side only — never expose it to the browser.
@marlin/sdk to your project:Create a customer
Every invoice belongs to a customer record. Create one with the customer’s email address and, optionally, their Solana wallet address.Store the returned
customer.id in your own database so you can associate future invoices and subscriptions with the same customer.Create an invoice
Create an invoice with one or more line items. Set The API returns a full
autoSend: true to have Marlin email the payment link to the customer automatically.Invoice object:Share the payment URL
The The checkout page handles wallet connection, balance checks, transaction building, and on-chain confirmation automatically.
invoice.paymentUrl is a fully hosted checkout page at checkout.marlin.fi. Share it directly — by email, SMS, or in-app — and the customer can pay with any Solana wallet.Listen for the invoice.paid webhook
When payment is confirmed on Solana, Marlin posts an Configure your webhook URL and retrieve your signing secret from Dashboard → Settings → Webhooks.
invoice.paid event to your webhook endpoint. Use verifyWebhook from the SDK to validate the HMAC-SHA256 signature before processing.Error handling
The SDK throws aMarlinAPIError for any non-2xx response. Check statusCode and code to handle specific cases: