Quickstart
Go from zero to a shareable USDC checkout link. Each step maps to a real @settlekit/* package function — the same ones the hosted API calls under /v1.
1. Connect
Authenticate and pick your payout wallet. The wallet address is the payToAddress that every checkout session settles to, so the on-chain USDC transfer lands directly in your account before access is granted.
pnpm add @settlekit/payments @settlekit/entitlements2. Create a product
A product is the thing you sell. For pricing you attach a Price — a USDC Money amount and an interval. Build a priced line item the checkout can total:
import type { PricedLineItem } from "@settlekit/payments";
// "25 USDC, one time" expressed as a priced line item. The Price.amount is a
// decimal string in USDC major units; the line item references it by id.
const item: PricedLineItem = {
lineItem: {
productId: "prod_repo_pro",
priceId: "price_one_time_25",
quantity: 1,
},
price: {
id: "price_one_time_25",
productId: "prod_repo_pro",
amount: "25.00",
currency: "USDC",
interval: "one_time",
usageBased: false,
active: true,
createdAt: new Date().toISOString(),
},
};The Money, Price, and Currency types come from @settlekit/common, the shared contract package every other package depends on. Amounts are decimal strings in USDC major units (six decimals of precision).
3. Set a price and create the checkout
createCheckoutSession computes the total from your line items with computeCheckoutTotal, binds the session to your payout wallet and network, and returns an immutable CheckoutSession with an id you can put behind a link.
import { createCheckoutSession } from "@settlekit/payments";
const session = createCheckoutSession({
organizationId: "org_acme",
merchantId: "mer_acme",
items: [item],
payToAddress: "0xYourUsdcPayoutWallet",
network: "arc",
successUrl: "https://acme.dev/thanks",
cancelUrl: "https://acme.dev/pricing",
});
// session.id, session.amount (total), session.status === "open"
console.log(session.id, session.amount, session.status);4. Share the checkout link
Point buyers at the hosted checkout for the session id. When the buyer pays, you record a pending payment, confirm it once the transfer reaches the required confirmations, then grant access from the confirmed payment:
import {
recordPendingPayment,
confirmPayment,
} from "@settlekit/payments";
import {
EntitlementService,
InMemoryEntitlementRepository,
} from "@settlekit/entitlements";
// 1) buyer submits an on-chain transfer for the session total
let payment = recordPendingPayment({
organizationId: "org_acme",
customerId: "cus_123",
checkoutSessionId: session.id,
amount: session.amount,
network: "arc",
txHash: "0xabc...",
});
// 2) once the transfer reaches the required confirmations
// confirmPayment(payment, txHash, confirmations, minConfirmations?)
payment = confirmPayment(payment, "0xabc...", 12);
// 3) grant the universal entitlement from the confirmed payment
const entitlements = new EntitlementService(
new InMemoryEntitlementRepository(),
);
const entitlement = await entitlements.grantFromPayment({
payment,
product: {
id: "prod_repo_pro",
merchantId: "mer_acme",
organizationId: "org_acme",
name: "Pro trading bot",
description: "Private repo access",
type: "github_repo_access",
status: "active",
deliveryMode: "github_invite",
metadata: { repoOwner: "acme", repoName: "trading-bot" },
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
},
});
console.log(entitlement.status); // "active"Next steps
- Sell a private repo end to end: GitHub repo sales.
- Gate SaaS features with one verify call: SaaS billing.
- Charge per API call with no API keys: Paid APIs (x402).
- Browse every REST route: API reference.