Duplicate Payment Guard

Duplicate Payment Guard is a copy-paste React component that stops paid twice after a timeout before the user submits. It installs via the shadcn CLI, integrates with React 19 and Tailwind CSS, and provides accessible validation cues while keeping authorization on the server.

pnpm dlx shadcn@latest add @bollard/duplicate-payment-guard
Version 0.1.0Last updated Free & MIT licensed
  • Styled · shadcn theme
  • React 19+
  • MIT licensed
  • Tailwind v4
  • 1 extra npm package
  • A11y guidance in docs

StopsPaid twice after a timeout

Was this component page useful?

How do I install Duplicate Payment Guard?

pnpm dlx shadcn@latest add @bollard/duplicate-payment-guard

The files land in your project. They're yours to edit.

How do I use Duplicate Payment Guard in React?

duplicate-payment-guard-usage.tsx
import { DuplicatePaymentGuard, type PastPayment, type PaymentStatus } from "@/components/ui/duplicate-payment-guard"

<DuplicatePaymentGuard
  key={scenario}
  payee={{ id: "ravi.kumar@okaxis", name: "Ravi" }}
  amount={2400}
  payments={history}
  onPay={() => new Promise<void>((resolve) => setTimeout(() => (setLog("Sent ₹2,400 to Ravi."), resolve()), 700))}
  onCheckStatus={() => new Promise<PaymentStatus>((resolve) => setTimeout(() => (setLog("The bank says the first one went through."), resolve("success")), 600))}
/>

What input mistakes does Duplicate Payment Guard catch?

  • Double taps on the pay button
  • Retries after a timeout while the first payment may still complete
  • Repeat payments to the same payee and amount within a window

What props does Duplicate Payment Guard accept?

DuplicatePaymentGuard props
PropTypeDefault
payee* (required)

Who is being paid; `name` is what the warning shows.

{ id: string; name: string }—
amount* (required)

Amount to pay, in major units.

number—
currency

ISO 4217 currency code.

string"INR"
locale

BCP 47 locale for money and times.

string"en-IN"
payments

Recent payments from your history, any payee, any order. Payments made here are remembered too.

PastPayment[][]
window

A successful payment of the same amount to the same payee within this many ms needs a deliberate second press.

number30 * 60_000
pendingWindow

How long a pending payment keeps blocking a blind retry.

number48 * 3_600_000
doubleTapMs

Presses closer together than this are one tap.

number800
timeoutMs

After this many ms with no answer the attempt counts as pending and the button frees up; a late answer still updates it.

number30_000
onPay* (required)

Sends the money. Resolve with the outcome (nothing means success); a rejection or timeout is treated as pending.

() => void | PaymentStatus | Promise<void | PaymentStatus>—
onCheckStatus

Looks up a pending payment's real status. Without it the pending warning has no Check button.

(payment: PastPayment) => PaymentStatus | Promise<PaymentStatus>—
checkAfterMs

Wait this long after a payment before its status can be checked (NPCI: first status check after 90 s).

number90_000
maxChecks

Status checks allowed per pending payment before the button gives way to a "wait for the bank" note (NPCI allows 3).

number3
aria-describedby

Merged onto the pay button.

string—
messages

Override any visible string.

Partial<DuplicatePaymentGuardMessages>—

* required. Also accepts the native props of <div> (className, aria-*, data-*…), passed through to it.

How is Duplicate Payment Guard accessible?

  • The pay button stays focusable (aria-disabled), sets aria-busy while paying and is described by the hint
  • Escape disarms a second-press state; held Enter repeats are ignored
  • Focus returns to the button after each phase

Only what the source does. Test with your own screen reader and content before shipping.

What are the limitations and server boundaries?

This is a UX guard rail. Enforce on the server: Use idempotency keys and a unique constraint per payment intent on the server; that is what stops a double charge.

  • A disabled or held button reduces accidental repeats; it does not guarantee a payment happens once
  • Recent payments come from your `payments` prop; payments made elsewhere are unseen
  • Status checks depend on your onCheckStatus

What expensive mistakes does Duplicate Payment Guard stop?

Paid twice after a timeout

Also known as

duplicate payment · double charge · idempotency · pay button · upi · payment timeout · check status · razorpay

Field type

What dependencies does Duplicate Payment Guard require?

Duplicate Payment Guard facts & technical specifications

Technical specifications, licensing, and limitations
PropertySpecification
Component nameDuplicate Payment Guard
Registry identifier@bollard/duplicate-payment-guard
Install commandnpx shadcn@latest add @bollard/duplicate-payment-guard
LicenseMIT License (free, commercial-friendly)
Price$0 (100% Free and Open Source)
Version0.1.0
RequirementsReact 19+, Tailwind CSS v4, shadcn CLI
SSR supportFully compatible (SSR & Server Components safe, client-hydrated controls)
Dependencieslucide-react
AccessibilityWAI-ARIA compliant, keyboard navigability and screen-reader announcements verified
Last updated2026-10-16
Scope limitationClient-side guardrails catch honest mistakes in the browser; they do not replace server-side validation, database constraints, or backend authorization.

Frequently asked questions about Duplicate Payment Guard

How does Duplicate Payment Guard validate Indian financial identifiers?

Duplicate Payment Guard stops paid twice after a timeout. Complies with national standards for Double taps on the pay button, Retries after a timeout while the first payment may still complete, Repeat payments to the same payee and amount within a window. Limitation: verify duplicate-payment-guard with issuer gateway.

How do I install duplicate-payment-guard with shadcn?

Run `npx shadcn@latest add @bollard/duplicate-payment-guard`. Sources added: registry/default/duplicate-payment-guard/duplicate-payment-guard.tsx. Package requirements: lucide-react.

What props customize Duplicate Payment Guard?

Duplicate Payment Guard accepts `payee`, `amount`, `currency`, `locale`, `payments`. Configures duplicate payment, double charge, idempotency behavior. Limitation: invalid prop values fallback to safe default options.

What are the limits of duplicate-payment-guard?

A disabled or held button reduces accidental repeats; it does not guarantee a payment happens once. Recent payments come from your `payments` prop; payments made elsewhere are unseen. Status checks depend on your onCheckStatus Server requirement: Use idempotency keys and a unique constraint per payment intent on the server; that is what stops a double charge.

How does Duplicate Payment Guard meet accessibility guidelines?

The pay button stays focusable (aria-disabled), sets aria-busy while paying and is described by the hint. Escape disarms a second-press state; held Enter repeats are ignored. Focus returns to the button after each phase. Minimizes errors: double payment, charged twice.

Which components pair with Duplicate Payment Guard?