square
БесплатноБез исполняемых скриптовНе проверенSquare is a payments and commerce platform with REST APIs and SDKs for online card payments, in-person POS, catalog, inventory, subscriptions, invoices and…
от TerminalSkills★ 221 звезда на GitHubОб этом скилле
Square
Overview
Square handles online and in-person payments (cards, Apple Pay, Google Pay, POS hardware). The APIs cover payments, orders, subscriptions, invoices, catalog, inventory, customers and webhooks. It is popular for businesses that sell both online and in a store.
The Node.js package square was rewritten in v40: the client is SquareClient (not Client), the token option is token, the environment is SquareEnvironment, and resources are flat properties such as client.payments.create(...) (not client.paymentsApi.createPayment). Older tutorials, and the previous version of this skill, use the removed API. Old code can keep working through import { Client } from "square/legacy" while you migrate. Current package version: 46.x (September 2026). Money amounts are BigInt in the smallest currency unit.
Instructions
Step 1: Install and create a client
npm install square
Use a sandbox access token while developing (Developer Dashboard, your application, Sandbox). Keep tokens in environment variables.
// lib/square.ts
import { SquareClient, SquareEnvironment } from 'square'
export const square = new SquareClient({
token: process.env.SQUARE_ACCESS_TOKEN!,
environment:
process.env.SQUARE_ENV === 'production'
? SquareEnvironment.Production
: SquareEnvironment.Sandbox,
})
Step 2: Take a card payment
Frontend: load the Web Payments SDK (https://sandbox.web.squarecdn.com/v1/square.js for sandbox, https://web.squarecdn.com/v1/square.js for production), tokenize the card, and send only the token to your server.
// components/SquarePayment.ts
const payments = window.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') {
await fetch('/api/pay', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ sourceId: result.token, amount: 2999 }),
})
} else {
console.error(result.errors)
}
})
Backend:
// app/api/pay/route.ts
import { randomUUID } from 'crypto'
import { SquareError } from 'square'
import { square } from '@/lib/square'
export async function POST(req: Request) {
const { sourceId, amount } = await req.json()
try {
const { payment } = await square.payments.create({
sourceId, // token from the Web Payments SDK
idempotencyKey: randomUUID(), // reuse the same key when retrying the same charge
locationId: process.env.SQUARE_LOCATION_ID!,
amountMoney: { amount: BigInt(amount), currency: 'USD' },
})
return Response.json({ id: payment?.id, status: payment?.status })
} catch (err) {
if (err instanceof SquareError) {
return Response.json({ errors: err.body }, { status: err.statusCode })
}
throw err
}
}
BigInt does not serialize with JSON.stringify; never return the raw payment object, return the fields you need.
Step 3: Catalog and inventory
const { catalogObject } = await square.catalog.object.upsert({
idempotencyKey: 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' },
},
}],
},
},
})
Temporary ids starting with # are replaced by real ids in the response; use the returned ids for inventory counts and orders. If a method name differs in your installed version, check reference.md in the SDK repository.
Step 4: Webhooks
Verify every webhook against the raw request body before acting on it:
import { WebhooksHelper } from 'square'
const valid = await WebhooksHelper.verifySignature({
requestBody: rawBody, // the unparsed string
signatureHeader: request.headers.get('x-square-hmacsha256-signature') ?? '',
signatureKey: process.env.SQUARE_WEBHOOK_SIGNATURE_KEY!,
notificationUrl: 'https://shop.bluefinbikes.com/api/square/webhook',
})
if (!valid) return new Response('invalid signature', { status: 401 })
verifySignature is async and returns a Promise<boolean>: without await, !valid is never true and every request passes. notificationUrl must be exactly the URL registered in the Developer Dashboard.
Examples
"Charge a customer $29.99 with a card on my checkout page." Add the Web Payments SDK card form, tokenize, POST the token and 2999 to /api/pay as in Step 2. A successful response is {"id":"…","status":"COMPLETED"}; declined cards throw a SquareError with the reason in err.body.errors. Test wi
Установить square в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл square?
Square is a payments and commerce platform with REST APIs and SDKs for online card payments, in-person POS, catalog, inventory, subscriptions, invoices and customers. Use when a user asks to accept in-person and online payments, process credit cards, manage inventory, handle subscriptions, verify Square webhooks, or build a POS integration.
Как установить скилл square?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл square запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic