Accept payments and manage commerce with Square. Use when a user asks to accept in-person and online payments, process credit cards, manage inventory, handle subscriptions, or build a POS integration.
Square handles both online and in-person payments — credit cards, Apple Pay, Google Pay, and POS hardware. APIs cover payments, subscriptions, invoices, catalog, inventory, and customers. Popular for businesses that sell both online and in stores.
// lib/square.ts — Process a payment
import { Client, Environment } from 'square'
const client = new Client({
accessToken: process.env.SQUARE_ACCESS_TOKEN!,
environment: Environment.Production,
})
export async function createPayment(amount: number, currency: string, sourceId: string) {
const { result } = await client.paymentsApi.createPayment({
sourceId, // payment token from Web Payments SDK
idempotencyKey: crypto.randomUUID(),
amountMoney: {
amount: BigInt(amount), // in smallest currency unit (cents)
currency,
},
})
return result.payment
}
// components/SquarePayment.tsx — Payment form
const payments = Square.payments(appId, locationId)
const card = await payments.card()
await card.attach('#card-container')
document.getElementById('pay-btn').addEventListener('click', async () => {
const result = await card.tokenize()
if (result.status === 'OK') {
// Send result.token to your server
await fetch('/api/pay', {
method: 'POST',
body: JSON.stringify({ sourceId: result.token, amount: 2999 }),
})
}
})
// Manage products and inventory
const { result } = await client.catalogApi.upsertCatalogObject({
idempotencyKey: crypto.randomUUID(),
object: {
type: 'ITEM',
id: '#coffee-mug',
itemData: {
name: 'Coffee Mug',
variations: [{
type: 'ITEM_VARIATION',
id: '#coffee-mug-regular',
itemVariationData: {
name: 'Regular',
pricingType: 'FIXED_PRICING',
priceMoney: { amount: BigInt(1499), currency: 'USD' },
},
}],
},
},
})
npx skills add TerminalSkills/square下载完整 Skill 目录,包含 SKILL.md 及所有相关文件
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer