{"_id":"@dokowallet/pay","name":"@dokowallet/pay","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@dokowallet/pay","version":"0.1.0","description":"Pay with DOKO — embeddable checkout button SDK (zero dependencies)","type":"module","publishConfig":{"access":"public"},"main":"dist/doko-pay.js","module":"src/index.js","exports":{".":{"import":"./src/index.js","default":"./dist/doko-pay.js"},"./react":"./src/react.jsx","./dist/doko-pay.js":"./dist/doko-pay.js"},"scripts":{"build":"esbuild src/index.js --bundle --format=iife --global-name=DokoPay --external:react --outfile=dist/doko-pay.js --minify","dev":"esbuild src/index.js --bundle --format=iife --global-name=DokoPay --external:react --outfile=dist/doko-pay.js --watch","prepublishOnly":"npm run build","test":"node --test"},"devDependencies":{"esbuild":"^0.21.0"},"peerDependencies":{"react":">=17"},"peerDependenciesMeta":{"react":{"optional":true}},"keywords":["doko","payments","checkout","wallet"],"license":"MIT","gitHead":"d71e7c51f8a66ad905c280d91acb7d74fc063cb1","_id":"@dokowallet/pay@0.1.0","_nodeVersion":"24.11.0","_npmVersion":"11.6.1","dist":{"integrity":"sha512-iMTO9QmmF1qIsU3zp7EcrHo1vJ0xJH8bJIyP1D6j40J/YANcBXe5E4wg+R/O/xpBlfgXge8LYqzLECKMq6/5Ow==","shasum":"3540dd008bc71dd6dade228ef0c2bf83ed7cd103","tarball":"https://registry.npmjs.org/@dokowallet/pay/-/pay-0.1.0.tgz","fileCount":9,"unpackedSize":29824,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCYk7V/EYHkxSAYlPjr+vFM3jKgncRR/2yvG5EZYSucCgIhAI+tSg8cs/k2C+LpZT/nCNgiofDzSRZzVTqOYbkn2NMM"}]},"_npmUser":{"name":"bidurkhatri","email":"elisoulaj@gmail.com"},"directories":{},"maintainers":[{"name":"bidurkhatri","email":"elisoulaj@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/pay_0.1.0_1781335619061_0.3744377167328683"},"_hasShrinkwrap":false}},"time":{"created":"2026-06-13T07:26:58.889Z","0.1.0":"2026-06-13T07:26:59.207Z","modified":"2026-06-13T07:26:59.450Z"},"maintainers":[{"name":"bidurkhatri","email":"elisoulaj@gmail.com"}],"description":"Pay with DOKO — embeddable checkout button SDK (zero dependencies)","keywords":["doko","payments","checkout","wallet"],"license":"MIT","readme":"# @dokowallet/pay\n\n\"Pay with DOKO\" embed SDK — drop a DOKO checkout button on any merchant site.\nZero runtime dependencies, inline styles only (no CSS file to load).\n\n```\nmerchant server ──(dpk_ secret key)──▶ POST /api/v1/checkout/intent ──▶ intentId\nmerchant page  ──(intentId, public)──▶ @dokowallet/pay button ──▶ hosted checkout\n```\n\nThe browser only ever sees an `intentId`. **Never put your `dpk_` secret key in\nclient-side code** — create intents server-side and hand the resulting id to\nthe SDK.\n\n## CDN (any site, no build step)\n\n```html\n<div id=\"doko-pay\"></div>\n\n<script src=\"https://cdn.jsdelivr.net/npm/@dokowallet/pay@0.1.0/dist/doko-pay.js\"></script>\n<script>\n  DokoPay.renderButton('doko-pay', {\n    intentId: 'INTENT_ID_FROM_YOUR_SERVER',\n    mode: 'popup', // or 'redirect' (default)\n    onSuccess: function (e) { window.location.href = '/thanks?ref=' + e.intentId; },\n    onCancel:  function ()  { /* user closed checkout */ },\n    onError:   function (err) { console.error(err); },\n  });\n</script>\n```\n\n## NPM (ESM)\n\n```sh\nnpm install @dokowallet/pay\n```\n\n```js\nimport { renderButton, openCheckout, pollIntentStatus } from '@dokowallet/pay';\n\nconst button = renderButton('doko-pay', {\n  intentId,\n  label: 'Pay with DOKO',\n  mode: 'popup',\n  onSuccess: (e) => showReceipt(e.intentId),\n});\n\n// Swap the intent later (e.g. cart total changed → new intent from your server):\nbutton.setIntentId(newIntentId);\n// Tear down:\nbutton.remove();\n```\n\n## React\n\n```jsx\nimport { DokoPayButton } from '@dokowallet/pay/react';\n\n<DokoPayButton\n  intentId={intentId}\n  mode=\"popup\"\n  onSuccess={(e) => navigate(`/thanks?ref=${e.intentId}`)}\n  onCancel={() => {}}\n  onError={(err) => toast.error(err.message)}\n/>\n```\n\nReact is an optional peer dependency — it is never bundled into\n`dist/doko-pay.js` and only resolves when you import `@dokowallet/pay/react`.\n\n## API\n\n### `renderButton(target, options) → { setIntentId, remove }`\nRenders the Vault-styled button into `target` (element id or element).\nOptions: `intentId`, `label` (default `'Pay with DOKO'`), `mode`\n(`'redirect'` | `'popup'`), `checkoutBase`, `onSuccess`, `onCancel`, `onError`.\n\n### `openCheckout(intentId, options) → { close } | undefined`\nOpens hosted checkout directly (the button calls this for you).\n`mode: 'redirect'` navigates to `https://pay.dokowallet.com/<intentId>`;\ncompletion then follows the intent's `successUrl`/`cancelUrl`.\n`mode: 'popup'` overlays a 420x640 iframe (`?embed=1`, `allow=\"payment\"`) and\nresolves via `postMessage` events `DOKO_PAY_SUCCESS` / `DOKO_PAY_CANCEL` /\n`DOKO_PAY_ERROR` (origin-checked against `checkoutBase`).\n\n### `getIntentStatus(intentId, { apiBase }) → Promise<intent>`\n`GET /api/v1/checkout/intent/:id`, unwraps the backend's `.data` envelope.\n\n### `pollIntentStatus(intentId, { onStatus, interval, timeout, apiBase }) → { stop }`\nPolls every `interval` ms (default 2000) until a terminal status\n(`COMPLETED` / `CANCELLED` / `EXPIRED` / `FAILED`), `timeout` ms elapse\n(default 900000 = 15 min → emits `'TIMEOUT'`), or you call `stop()`.\nUse this as the server-of-record check after a popup success event.\n\n## Configuration\n\nDefaults target production (`backend.dokowallet.com` / `pay.dokowallet.com`).\nOverride per call via `apiBase` / `checkoutBase` options, or via\n`SDK_API_BASE` / `SDK_CHECKOUT_BASE` env vars in Node/SSR — see `.env.example`.\n\n## Development\n\n```sh\nnpm run build   # esbuild → dist/doko-pay.js (IIFE, window.DokoPay)\nnpm run dev     # watch mode\nnpm test        # node --test (no test framework deps)\n```\n\nMIT\n","readmeFilename":"README.md","_rev":"1-209adf7f84579865ab665461839a7608"}