How it works
- Your server creates a checkout session with your secret key and sends its
urlto the page. - Your page calls
KetaPay.open({ url }). The checkout opens as a centred window on a computer, and fills the screen on a phone. - The buyer pays. You get
onSuccessin the browser andescrow.fundedon your server.
Install
window.KetaPay.
Open the checkout
open returns { close, result }. result resolves once, to 'success' when the buyer pays, 'error' if the checkout doesn’t load, or 'closed' if they close it first:
checkout.close() to close it yourself, for example straight after onSuccess if you’d rather show your own receipt. Opening a second checkout while one is showing returns the one already open.
Branding
The checkout shows your business’s logo and colour from your KetaPay settings. There are no styling options in the browser, so it looks the same as your hosted checkout.Errors
Every error is aKetaPayCheckoutError with a code. Mistakes in the call are thrown by open before anything shows; a checkout that doesn’t load goes to onError.
Good to know
- Server rendering: importing the package touches neither
windownordocument, so it’s safe in Next.js, Remix and Nuxt. - Content Security Policy: add
frame-src https://checkout.ketapay.com, andscript-src https://js.ketapay.comif you use the script tag. The overlay needs nothing instyle-src. - Sandbox: sessions created with an
sk_test_key open the same checkout in test mode. See Testing. - Browsers: the last two versions of Chrome, Edge, Firefox and Safari, and Safari on iOS 15 or later.
Versions
Script tag URLs name an exact version and never change once published. When 1.0 is out,https://js.ketapay.com/v1/checkout.js will always serve the newest 1.x.