payment-idempotency
БесплатноБез исполняемых скриптовНе проверенApply when implementing idempotency logic in payment connector code or handling duplicate payment requests. Covers paymentId as idempotency key, payment state…
от vtex★ 47 звёзд на GitHubОб этом скилле
Idempotency & Duplicate Prevention
When this skill applies
Use this skill when:
- Implementing any PPP endpoint handler that processes payments, cancellations, captures, or refunds
- Ensuring repeated Gateway calls with the same identifiers produce identical results without re-processing
- Building a payment state machine to prevent invalid transitions (e.g., capturing a cancelled payment)
- Handling the Gateway's 7-day retry window for
undefinedstatus payments
Do not use this skill for:
- PPP endpoint response shapes and HTTP methods — use
payment-provider-protocol - Async callback URL notification logic — use
payment-async-flow - PCI compliance and Secure Proxy — use
payment-pci-security - POS / Sales App terminal payments (
Venda Direta Credito,Venda Direta Debito, overlapping Create Payment while Wait for confirmation polls) — usepayment-ppp-postogether with this skill
Decision rules
- Use
paymentIdas the idempotency key for Create Payment — every call with the samepaymentIdmust return the same result. - Use
requestIdas the idempotency key for Cancel, Capture, and Refund operations. - If the Gateway sends a second Create Payment with the same
paymentId, return the stored response without calling the acquirer again. Those retries can overlap; last-write-wins storage can drop a status update — persist with an etag /ifMatch(seepayment-ppp-posfor the POS overlay). - Async payment methods (Boleto, Pix) MUST return
status: "undefined"— never"approved"until the acquirer confirms. - A payment moves through defined states:
undefined→approved→settled, orundefined→denied, orapproved→cancelled. Enforce valid transitions only. - Use a persistent data store (PostgreSQL, DynamoDB, VBase for VTEX IO) — never in-memory storage that is lost on restart.
Hard constraints
Constraint: MUST use paymentId as idempotency key for Create Payment
The connector MUST check for an existing record with the given paymentId before processing a new payment. If a record exists, return the stored response without calling the acquirer again.
Why this matters
The VTEX Gateway retries Create Payment requests with undefined status for up to 7 days. Without idempotency on paymentId, each retry creates a new charge at the acquirer, resulting in duplicate charges to the customer. This is a financial loss and a critical production incident.
Detection
If the Create Payment handler does not check for an existing paymentId before processing, STOP. The handler must query the data store for the paymentId first.
Correct
async function createPaymentHandler(req: Request, res: Response): Promise<void> {
const { paymentId } = req.body;
// Check for existing payment — idempotency guard
const existingPayment = await paymentStore.findByPaymentId(paymentId);
if (existingPayment) {
// Return the exact same response — no new acquirer call
res.status(200).json(existingPayment.response);
return;
}
// First time seeing this paymentId — process with acquirer
const result = await acquirer.authorize(req.body);
const response = {
paymentId,
status: result.status,
authorizationId: result.authorizationId ?? null,
nsu: result.nsu ?? null,
tid: result.tid ?? null,
acquirer: "MyProvider",
code: result.code ?? null,
message: result.message ?? null,
delayToAutoSettle: 21600,
delayToAutoSettleAfterAntifraud: 1800,
delayToCancel: 21600,
};
// Store the response for future idempotent lookups
await paymentStore.save(paymentId, { request: req.body, response });
res.status(200).json(response);
}
Wrong
async function createPaymentHandler(req: Request, res: Response): Promise<void> {
const { paymentId } = req.body;
// No idempotency check — every call hits the acquirer
// If the Gateway retries this (which it will for undefined status),
// the customer gets charged multiple times
const result = await acquirer.authorize(req.body);
res.status(200).json({
paymentId,
status: result.status,
authorizationId: result.authorizationId ?? null,
nsu: result.nsu ?? null,
tid: result.tid ?? null,
acquirer: "MyProvider",
code: null,
message: null,
delayToAutoSettle: 21600,
delayToAutoSettleAfterAntifraud: 1800,
delayToCancel: 21600,
});
}
Constraint: MUST return identical response for duplicate requests
When the connector receives a Create Payment request with a paymentId that already exists in the data store, it MUST return the exact stored response. It MUST NOT create a new record, generate new identifiers, or re-process the payment.
Why this matters
The Gateway uses the response fields (authorizationId, tid, `
Установить payment-idempotency в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл payment-idempotency?
Apply when implementing idempotency logic in payment connector code or handling duplicate payment requests. Covers paymentId as idempotency key, payment state machine transitions, retry semantics for cancellation and refund operations, and requestId handling. Use for preventing duplicate charges and ensuring correct Gateway retry behavior across Create Payment, Cancel, Capture, and Refund endpoints.
Как установить скилл payment-idempotency?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл payment-idempotency запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic