Embed a Fortpesa payment link into any website as a modal overlay or an inline iframe. The widget is pure browser-side, so your backend language does not matter — plain HTML, WordPress, React, Laravel, Django or a static site. The payment page is hosted at https://fortpesa.co.ke/pay/{uuid}; the widget just frames it and tells your page when the payment succeeds.

Before you start

  1. Create a payment link in the dashboard (sidebar Payment links) — fixed amount or open amount.
  2. Copy its UUID from the link detail page. The shared URL looks like https://fortpesa.co.ke/pay/9k3f2x....
  3. Make sure the link is active and your merchant account has an approved channel.
The script is a single static file — no build step, no npm.
Fortpesa.pay() opens the payment in a modal, returns a Promise, and rejects with Payment modal closed by user if the customer dismisses it.
All options are optional. A fixed-amount link always charges its own amount, whatever you pass.

Inline iframe

No script needed:
For a full checkout page where you want to prefill the customer’s details:

Embed parameters

Events (embed mode)

In embed mode the payment page posts messages to the parent window:
In embed mode the iframe stays on the success card instead of redirecting to the receipt page — your page decides what happens next.

Verify the payment server-side

The success message is a UI hint, not proof. Before you deliver goods or mark an order paid, confirm the transaction with the API (GET /api/v1/transactions/{uuid}) or wait for the signed webhook. Both are covered in Transaction status and Webhooks.

Notes

  • The widget needs no API key in the browser — the UUID is the only identifier.
  • X-Frame-Options is removed on /pay/* and frame-ancestors * is sent, so framing works on any site. Everything else in the app stays unframeable.
  • The hosted link without ?embed=1 remains available as a plain page you can share on WhatsApp or by SMS.