Pay Button
ProNewA pay, donate or subscribe button with amount presets, optional shipping/tax breakdown, custom amounts and accepted-method marks. It calls onPay; your code talks to the provider.
Installation
First time? Add the @viewport registry to components.json. Setup takes one minute.
Usage
Props
| Prop | Type | Default |
|---|---|---|
| mode | "pay" | "donate" | "subscribe"What the button does: a one-off purchase, a donation, or a recurring plan. | "pay" |
| label | stringText before the brand name. Defaults to "Buy now with", "Donate with" or "Subscribe with". | — |
| brand | Brand | nullThe brand shown on the button, from Brand Icon. Pass `null` for a plain button with only the label. | "paypal" |
| amount | numberA fixed amount. Use it instead of `amounts` when the buyer has nothing to choose. | — |
| amounts | number[]Preset amounts the buyer picks from. | — |
| defaultAmount | numberThe preset that starts selected. Defaults to the first one. | — |
| allowCustom | booleanAdds a field for typing any amount. | false |
| min | numberSmallest amount accepted in the custom field. | 1 |
| max | numberLargest amount accepted in the custom field. | 10000 |
| currency | stringISO 4217 currency code. | "USD" |
| shipping | numberFlat delivery charge, in major currency units. | 0 |
| tax | { type: "fixed" | "percentage"; value: number }Flat currency amount or percent of the selected price. | — |
| locale | stringBCP 47 locale used to format amounts. | "en-US" |
| interval | "week" | "month" | "year"How often a subscription renews. | "month" |
| methods | PayMethod[]Marks under the button for the methods you accept. An empty list hides the row. | ["visa", "mastercard", "amex", "discover"] |
| color | "gold" | "blue" | "black" | "white"Button color. | "gold" |
| shape | "pill" | "rect"Button outline. | "pill" |
| title | React.ReactNodeA heading above the amounts. | — |
| description | React.ReactNodeSupporting text under the heading. | — |
| onPay | (payment: Payment) => void | Promise<unknown>Called with the payment to start. Hand it to your own checkout. Return a promise to show the busy state; resolve it for success, reject it for the error state. | — |
| successText | stringShown on the button after `onPay` resolves. | "Thank you!" |
| errorText | stringShown under the button after `onPay` rejects. | "The payment did not go through. Please try again." |
| disabled | boolean | false |
| className | string | — |
Accessibility
- Amount presets are a native radio group inside a fieldset, so arrow keys move between them.
- The custom amount is a labelled field; a bad amount is announced with role=alert and marked aria-invalid.
- While the payment is pending the button is aria-busy and the result is announced in a live region.
- Each method mark has a text name, and the row is a labelled list.
- The spinner and the error shake are stilled under reduced motion.