Skip to content

TkxPaymentButton

Mock config, buttons disabled — no SDK loads, no real payment
import { TkxPaymentButton } from 'tekivex-ui';
<TkxPaymentButton
config={{
provider: 'razorpay',
publicKey: 'rzp_live_...',
orderId: 'order_...', // server-generated
amount: 49900, // paise
currency: 'INR',
}}
onSuccess={(result) => console.log(result.id)}
onFailure={(err) => console.error(err.message)}
>
Pay ₹499
</TkxPaymentButton>

A button that loads the payment provider’s SDK lazily on first click. No SDK is downloaded on page load — keeps your bundle clean and your CSP strict. Falls back to a clear error message if the SDK fails to load (blocked by ad-blocker, network error, etc.).

PropTypeNotes
provider'stripe' | 'razorpay' | 'paypal'required
amountnumbersmallest unit (paise / cents)
currencyISO-4217required
publicKeystringprovider’s publishable / public key
onSuccess(payment) => voidrequired
onError(err) => voidrequired
disabledbooleanalso disables during SDK load
size='sm' | 'md' | 'lg' (still mock + disabled)

The button shows a spinner and is aria-busy while:

  1. SDK script is downloading (first click only)
  2. The provider’s modal is open
  • Real <button> element with aria-busy and aria-live="polite" status
  • Error messages render in an <Alert role="alert"> below the button
  • Keyboard-triggerable; payment modal handles focus trap

See tests/TkxPaymentButton.test.tsx — 6 tests covering provider switching

  • SDK-load failure paths.