@lemonway/lemonway-js
v1.0.1
Published
CDN loader for the Lemonway payment client SDK
Readme
@lemonway/lemonway-js
Load the Lemonway payment SDK from the official CDN with TypeScript support (similar to Stripe.js).
The package injects paygreen.min.js and paygreen.min.css from Lemonway hosts. Do not bundle or self-host these assets (PCI).
Install
npm install @lemonway/lemonway-jsQuick start
import {
loadLemonwayJS,
type LemonwayJS,
} from "@lemonway/lemonway-js";
const lemonwayJS = await loadLemonwayJS({ env: "sandbox" });
lemonwayJS?.init({
publicKey: "pk_test_xxx",
mode: "payment",
paymentOrder: { id: "po_xxx", objectSecret: "secret" },
});After load, the SDK is available as window.paygreenjs. Use try/catch around loadLemonwayJS and handle load errors in production.
Loader options
| Option | Default | Description |
| --------- | ------------ | --------------------------------------------------------------------------------------------------------- |
| env | production | production · sandbox · recette |
| version | latest | CDN path on production / sandbox (e.g. 1.14.25 → /1.14/). Ignored on recette (always latest). |
Environments & CDN
| env | CDN host | Scripts / styles |
| ------------ | ------------------------------ | ------------------------------------- |
| production | https://pgjs.paygreen.fr | paygreen.min.js, paygreen.min.css |
| sandbox | https://sb-pgjs.paygreen.fr | same |
| recette | https://rc-pgjs.paygreen.dev | same |
Preload
const lwJsPromise = loadLemonwayJS({ env: "sandbox" });
// later
const lwJs = await lwJsPromise;
lwJs?.init({
/* … */
});TypeScript
Types ship with this package (LemonwayJS, InitParamsType, event types, etc.) for IDE autocomplete and tsc.
| What | Where |
| ----------------- | ------------------------------------ |
| Runtime (browser) | CDN script above |
| Types | node_modules/@lemonway/lemonway-js |
Versioning: Pin the loader version option to your PGJS line in production (e.g. version: "1.14.25" → CDN folder 1.14). Keep the npm package version in sync when types change.
Pre-releases: npm install @lemonway/lemonway-js@beta.
Events
After init(), listen to SDK events on the instance, for example:
lwJs?.on(lwJs.Events.ERROR, (event) => {
console.error(event.detail);
});See the Paygreen developer documentation for the full payment API.
License
MIT
