@nexus-pay/js
v0.1.1
Published
NexusPay.js — PCI-compliant card tokenization and payment elements
Maintainers
Readme
@nexus-pay/js
PCI-compliant card tokenization and payment elements for the browser. Card data is entered inside a sandboxed iframe and tokenized before it ever touches your page, so your site stays out of PCI scope.
Install
npm install @nexus-pay/jsOr load it straight from a CDN — the IIFE build exposes a global NexusPay:
<script src="https://unpkg.com/@nexus-pay/js"></script>
<!-- or: https://cdn.jsdelivr.net/npm/@nexus-pay/js -->
<script>
const nexus = new NexusPay.NexusPay('pk_test_...');
</script>Usage
Create an instance with your publishable key, load the checkout session with
the client_secret from your server, then mount a CardElement and tokenize:
import { NexusPay, CardElement } from '@nexus-pay/js';
// 1. Init with the publishable key (safe to ship to the browser).
const nexus = new NexusPay('pk_test_...');
// 2. Load the session — `clientSecret` comes from your server
// (created via @nexus-pay/node). It IS the session JWT.
await nexus.loadSession(clientSecret);
// 3. Mount a PCI-safe card input into a container element.
const card = new CardElement();
card.mount('#card-container'); // selector or HTMLElement
card.on('change', (e) => {
// e.brand, e.complete, etc.
});
// 4. Tokenize, then confirm the payment.
async function pay() {
// `id` is the payment-token id that confirm() consumes.
const { id } = await nexus.tokenize({ type: 'card' });
const result = await nexus.confirm(id);
console.log(result.status); // 'succeeded' | 'requires_action' | ...
}The SDK also ships PaymentElement, AddressElement, Apple Pay / Google Pay /
BNPL handlers, 3DS challenge handling, and theming helpers. See the source
exports for the full surface.
License
MIT © Pierce Lonergan. Part of the NexusPay project.
