Skip to content

CDN, pinning and integrity

The runtime is served from js.pesepay.com. The npm package is a small loader that fetches it from there, and a script tag loads it directly. Either way, the path you load decides whether the file can change under you.

PathCachedPromise
/v1/pesepay.js5 minutesNever breaks. Moves under you, including security patches.
/v<x.y.z>/pesepay.js1 year, immutableNever changes, never withdrawn, and never patched.

/v1/ is the one to use, and the one the npm loader loads. It is versioned by the runtime’s compatibility contract, not by its release number: a breaking change becomes /v2/ with a new loader major version, so /v1/ can be patched for every merchant at once. A fix reaches your checkout within five minutes, with no npm update and no redeploy.

<script src="https://js.pesepay.com/v1/pesepay.js"></script>

Don’t add an integrity hash to /v1/. It is meant to change, and the first patch after you pin a hash would stop your checkout from loading. There is deliberately no published hash for it.

If an auditor requires a fixed file, load a numbered version with its subresource integrity hash. Every pinned build’s sha384 hash is published at https://js.pesepay.com/integrity.json, with the newest as version:

{
"version": "0.2.1",
"files": {
"/v0.2.1/pesepay.js": "sha384-…",
"/v0.1.12/pesepay.js": "sha384-…"
}
}

Load that path with its hash:

<script
src="https://js.pesepay.com/v0.2.1/pesepay.js"
integrity="sha384-…"
crossorigin="anonymous"
></script>

Pinned builds are never withdrawn, and integrity.json keeps listing every one. Use a pinned build from a script tag, as in the Quickstart’s script tag tab. The npm loader always loads /v1/ and has no option to pin.

loadPesepay({ scriptOrigin }) loads the runtime from another origin, for local development. Overriding it means you no longer receive patches, the same as pinning, and you take on serving the file yourself.

Whichever path you load, your page’s Content-Security-Policy needs script-src https://js.pesepay.com. The other sources depend on the methods you take: see Accept a payment.