Installation
Add the script to your page. That’s it, the<modempay-button> element is now available everywhere on the page.
html
Quick Start
html
Attributes
| Attribute | Required | Default | Description |
|---|---|---|---|
merchant | Yes | — | Your Modem Pay public key |
amount | No | — | Payment amount. Omit to show an input field |
currency | No | GMD | ISO currency code |
description | No | — | Description shown in the checkout modal |
label | No | Secure checkout with Modem Pay | Override the button text |
color | No | #16a34a | Primary button color |
radius | No | 12 | Border radius in pixels |
disabled | No | — | Disables the button when present |
Usage Examples
Custom label
html
Custom brand color
html
Dynamic amount (user enters amount)
Omit theamount attribute and the button renders an input field for the user to fill in. The minimum accepted amount is 10 GMD.
html
Usage in React
Web Components don’t render through JSX, so usedangerouslySetInnerHTML to mount the button. Load the script once (e.g. in index.html or a useEffect), then render the element like this:
jsx
ref:
jsx
Make sure the script is loaded before the component mounts. The easiest way is to add the
<script> tag to your public/index.html.Events
The button emits events at each stage of the payment lifecycle. Listen on the element directly.modempay:click
Fires when the button is clicked, before the checkout modal opens. The event is cancelable, callevent.preventDefault() to stop the checkout from launching (e.g. to run validation first).
javascript
modempay:success
Fires when the payment completes. The completed transaction object is available atevent.detail.transaction.
javascript
modempay:error
Fires if something goes wrong during the payment process. The error message is atevent.detail.message.
javascript
modempay:cancel
Fires when the user closes the checkout modal without completing the payment. No detail payload.javascript
Styling
Customize the button with CSS custom properties. Set them on the element itself or in your stylesheet.| Variable | Description | Default |
|---|---|---|
--mp-color | Primary button color | #16a34a |
--mp-color-hover | Hover state color | #15803d |
--mp-radius | Border radius | 12px |
Accessibility
The button is built with accessibility in mind:- Full keyboard navigation
aria-labelthat includes the payment amountaria-busyset during loading so screen readers announce the state- Visible focus ring on keyboard navigation
- Disabled state properly conveyed to assistive technology
Accepted Payment Methods
Supported wallets are shown directly on the button to build user trust at the point of payment.Browser Support
Works in all modern browsers that support the Web Components standard.| Browser | Supported |
|---|---|
| Chrome | ✅ |
| Edge | ✅ |
| Firefox | ✅ |
| Safari | ✅ |
customElements support are not supported.