payment-idempotency

Enforce idempotency in payment flows using paymentId and requestId keys.

39|9|Updated Mar 16, 2026
One-click install
npx skills add https://github.com/vtexdocs/ai-skills --skill payment-idempotency
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: payment-idempotency
Source: https://github.com/vtexdocs/ai-skills/tree/main/tracks/payment/skills/payment-idempotency
Command: npx skills add https://github.com/vtexdocs/ai-skills --skill payment-idempotency

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

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.

Core Features & Use Cases

  • Prevent duplicate charges by enforcing idempotency across payment endpoints using paymentId and requestId
  • Manage a payment state machine to ensure valid transitions across Create Payment, Cancel, Capture, and Refund
  • Support retry semantics for gateway retries within the 7-day window and preserve exact responses for duplicates
  • Example: a connector stores the initial response and reuses it for retry requests to the same paymentId

Quick Start

Configure your payment handlers to check a persistent store for existing paymentId before processing and return the exact stored response on duplicates.

Frequently Asked Questions about payment-idempotency

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I prevent duplicate charges when gateway retries hit my payment connector?

To prevent duplicate charges during gateway retries, enforce idempotency by using paymentId as the key. Store the initial response in a persistent data store and return that exact stored output when duplicate requests with the same paymentId arrive.

What is payment idempotency and how does a state machine manage it?

Payment idempotency ensures deterministic results on retries by caching responses and preventing reprocessing. A payment state machine manages valid transitions across Create Payment, Cancel, Capture, and Refund operations to enforce this behavior.

How do I handle requestId and cancellation retries within the 7-day window?

Handle requestId and cancellation retries by checking your persistent store for an existing paymentId before processing. Support gateway retry semantics within the 7-day window by preserving and returning the exact stored response for duplicate requests.

Do I need a persistent data store to implement idempotent payments?

Yes, a persistent data store is required to implement idempotent payments. You must cache initial responses and use the store to return exact stored outputs when the same paymentId or requestId is retried, avoiding reprocessing.

What's the best way to ensure deterministic results for refund and capture operations?

The best way to ensure deterministic results for refund and capture operations is to apply idempotency across all endpoints using paymentId. Configure handlers to check for existing transactions and return exact stored responses on duplicates.

Why does my payment connector reprocess duplicate requests instead of returning the cached response?

Your payment connector reprocesses duplicate requests because it lacks idempotency enforcement. Configure your payment handlers to check a persistent store for existing paymentId before processing and return the exact stored response on duplicates.