mMoney Docs

Payment buttons

Full page example

Copy this page, replace the API key and order ID, and open it in a browser.

<!DOCTYPE html>
<html>
<head>
  <title>mMoney Payment Example</title>
</head>
<body>
  <h1>My Store</h1>
  <p>Product: Test Item</p>
  <p>Price: $10.00 BBD</p>

<!-- The payment button appears here -->

  <div id="mmoney-payment-button"></div>

  <script src="https://merchant.mmoneyapp.com/assets/mmoney-payment.js"></script>
  <script>
    window.addEventListener('mMoneyReady', function () {
      window.mMoney.payment.button.render({
        amount: 10.00,
        api_key: 'YOUR_API_KEY',
        merchant_order_id: 'order_123',
        currency: 'BBD',
        onPaid: function (details) {
          alert('Payment successful! Order: ' + details.merchant_order_id)
        },
        onCancel: function () {
          alert('Payment cancelled')
        },
        onRenderError: function (error) {
          console.error('Payment error:', error)
        }
      }, '#mmoney-payment-button')
    })
  </script>
</body>
</html>

How it works

  1. The render call validates your API key.
  2. When the customer clicks the button, the script creates an invoice for merchant_order_id.
  3. The customer pays with the mMoney wallet app.
  4. The script receives the paid event on a realtime channel and calls onPaid.
  5. mMoney also sends an invoice.paid webhook to your server. See Webhooks.