Skip to content

Quick Start

Terminal window
npm install @zatlas/card-capture

The SDK handles the full payment flow. Your page just mounts the card form and calls checkout().

<div id="card-element"></div>
<script type="module">
import { ZatlasCardCapture } from '@zatlas/card-capture';
const zatlas = new ZatlasCardCapture({
publishableKey: 'pk_sandbox_your_key',
locale: 'es-MX',
});
const card = zatlas.create('card', { mode: 'checkout' });
card.mount('#card-element');
// Get a fresh access token from your server
const { accessToken } = await fetch('/api/payment-token').then(r => r.json());
card.on('cta_clicked', async () => {
const { payment, error } = await zatlas.checkout({
accessToken,
amount: 12000, // amount in currency units (e.g. 12000 = $12,000.00 MXN)
currency: 'mxn',
reservationId: 'RES-123',
installments: { required: true }, // show installment picker
});
if (payment) {
window.location.href = `/success?id=${payment.id}`;
} else {
console.error('Payment failed:', error.code);
// Error is also shown to the guest inside the card form
}
});
</script>

This is what the card form looks like once mounted — the guest fills in their details and clicks “Continuar”:

Card form

What happens:

  1. Guest fills the card form and clicks “Continuar”.
  2. The SDK fires the cta_clicked event.
  3. Your code calls checkout() with the payment details.
  4. The SDK tokenizes the card, creates the payment, shows installment options (if requested), handles 3D Secure, and polls for the result.
  5. The promise resolves with { payment } on success or { error } on failure.

The SDK captures the card and returns a token. Your server charges later.

<div id="card-element"></div>
<script type="module">
import { ZatlasCardCapture } from '@zatlas/card-capture';
const zatlas = new ZatlasCardCapture({
publishableKey: 'pk_sandbox_your_key',
locale: 'es-MX',
});
const card = zatlas.create('card', { mode: 'tokenize' });
card.mount('#card-element');
// Get a fresh access token from your server
const { accessToken } = await fetch('/api/payment-token').then(r => r.json());
card.on('cta_clicked', async () => {
const { token, error } = await zatlas.createToken({
accessToken,
currency: 'mxn',
});
if (token) {
// Send token.id to your server — it can charge later via the Payments API
await fetch('/api/save-method', {
method: 'POST',
body: JSON.stringify({ methodId: token.id, last4: token.card.last4 }),
});
}
});
</script>

What happens:

  1. Guest fills the card form and clicks “Guardar metodo”.
  2. The SDK fires the cta_clicked event.
  3. Your code calls createToken().
  4. The SDK tokenizes the card and returns a mth_* token with card metadata (last4, brand, expiry).
  5. Your server stores the token and creates payments via the Payments API when needed.

Use these in sandbox:

CardNumberResult
Visa4242 4242 4242 4242Success
MSI4000 0048 4000 0008Installment picker (3, 6, 9, 12, 18, 24 months)
3DS4000 0000 0000 32203D Secure challenge
Declined4000 0000 0000 0002card_declined
Insufficient4000 0000 0000 9995insufficient_funds

Use any future expiry (e.g. 12/30) and any 3-digit CVC.