Skip to main content
A self-contained Web Component that opens the Modem Pay checkout modal when clicked. Works in plain HTML and any JavaScript framework, no dependencies, no build step.

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
Clicking the button opens the Modem Pay checkout modal. The SDK and stylesheets are loaded automatically, no manual initialization needed.

Attributes

Usage Examples

Custom label

html

Custom brand color

html

Dynamic amount (user enters amount)

Omit the amount 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 use dangerouslySetInnerHTML to mount the button. Load the script once (e.g. in index.html or a useEffect), then render the element like this:
jsx
To listen for events in React, attach them via a 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, call event.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 at event.detail.transaction.
javascript

modempay:error

Fires if something goes wrong during the payment process. The error message is at event.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.

Accessibility

The button is built with accessibility in mind:
  • Full keyboard navigation
  • aria-label that includes the payment amount
  • aria-busy set 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. Internet Explorer and browsers without customElements support are not supported.