@klingis/embed
v0.1.0
Published
Kling Embeddable Checkout SDK
Downloads
101
Maintainers
Readme
@klingis/embed
Embeddable checkout SDK for Kling — a payments platform for Iceland.
Install
npm install @klingis/embedUsage
import { Kling } from '@klingis/embed';
// 1. Initialize
const kling = Kling.init({ locale: 'is' });
// 2. Open checkout (sessionId comes from your server via the Kling API)
const result = await kling.checkout({
sessionId: 'cs_...',
onSuccess: (res) => console.log('Paid!', res.paymentIntentId),
onError: (err) => console.log('Failed', err.message),
onCancel: () => console.log('Cancelled'),
});Options
Kling.init(options)
| Option | Type | Default | Description |
|--------|------|---------|-------------|
| locale | 'is' \| 'en' | auto-detect | Checkout UI language |
| baseUrl | string | https://pay.kling.is | Override checkout URL (for local dev) |
| apiUrl | string | https://api.kling.is | Override API URL |
kling.checkout(options)
| Option | Type | Description |
|--------|------|-------------|
| sessionId | string | Required. Checkout session ID from the API |
| onSuccess | (result) => void | Called on successful payment |
| onError | (error) => void | Called on payment failure |
| onCancel | () => void | Called when user closes checkout |
| showSuccessScreen | boolean | Show success screen after payment (default: true) |
CDN
You can also load the SDK via script tag:
<script src="https://api.kling.is/v1/kling.js"></script>
<script>
const kling = Kling.init();
kling.checkout({ sessionId: 'cs_...' });
</script>License
MIT
