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
- The render call validates your API key.
-
When the customer clicks the button, the script creates an invoice
for
merchant_order_id. - The customer pays with the mMoney wallet app.
-
The script receives the paid event on a realtime channel and calls
onPaid. -
mMoney also sends an
invoice.paidwebhook to your server. See Webhooks.