HashPay Button

Accept M-PESA payments with one line of JavaScript.

Integration

Drop this into any page — the merchant only ever exposes their public account_id.

<script src="https://pay.hashback.co.ke/hashpaybutton/hashpay.js"></script>

<button id="pay">Pay KES 100</button>
<script>
  var handler = HashPay.setup({
    account:   'HP945692',      // your public account id
    amount:    100,             // KES
    reference: 'order_12345',   // optional
    onSuccess: function (txn) {
      alert('Paid! Receipt: ' + txn.receipt);
    },
    onCancel:  function () { console.log('closed'); },
    onError:   function (e) { console.error(e); }
  });
  document.getElementById('pay')
          .addEventListener('click', handler.openIframe);
</script>

Or zero JS — just data-attributes:

<button class="hashpay-button"
        data-account="HP945692"
        data-amount="100"
        data-reference="order_12345">Pay KES 100</button>