npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

taypi.pe

v1.0.0

Published

SDK oficial de TAYPI — Pagos QR interoperables para e-commerce en Perú

Downloads

101

Readme

TAYPI JS SDK

SDK oficial para integrar pagos QR de TAYPI en aplicaciones Node.js y Next.js.

Acepta pagos con Yape, Plin y cualquier app bancaria conectada a la CCE.

Requisitos

  • Node.js 16 o superior

Instalación

npm install taypi.pe

Uso rápido

import { Taypi } from 'taypi.pe';

const taypi = new Taypi(
    'taypi_pk_test_...',  // Public key
    'taypi_sk_test_...',  // Secret key
);

// Crear sesión de checkout
const session = await taypi.createCheckoutSession({
    amount: '25.00',
    reference: 'ORD-12345',
    description: 'Zapatillas Nike Air',
}, 'ORD-12345'); // Idempotency-Key

console.log(session.checkout_token);

Next.js (API Route + checkout.js)

app/api/checkout/route.ts — Backend (servidor)

import { Taypi } from 'taypi.pe';
import { NextResponse } from 'next/server';

const taypi = new Taypi(
    process.env.TAYPI_PUBLIC_KEY!,
    process.env.TAYPI_SECRET_KEY!,
);

export async function POST(request: Request) {
    const { amount, reference, description } = await request.json();

    const session = await taypi.createCheckoutSession(
        { amount, reference, description },
        reference,
    );

    return NextResponse.json({
        checkoutToken: session.checkout_token,
        publicKey: taypi.publicKey,
    });
}

app/checkout/page.tsx — Frontend (cliente)

'use client';
import Script from 'next/script';

export default function CheckoutPage() {
    async function handlePay() {
        const res = await fetch('/api/checkout', {
            method: 'POST',
            headers: { 'Content-Type': 'application/json' },
            body: JSON.stringify({
                amount: '25.00',
                reference: 'ORD-12345',
                description: 'Zapatillas Nike Air',
            }),
        });

        const { checkoutToken, publicKey } = await res.json();

        window.Taypi.publicKey = publicKey;
        window.Taypi.open({
            sessionToken: checkoutToken,
            onSuccess: (result) => alert('Pago completado: ' + result.paid_at),
            onExpired: () => alert('QR expirado'),
            onClose: () => console.log('Modal cerrado'),
        });
    }

    return (
        <>
            <Script src="https://app.taypi.pe/v1/checkout.js" />
            <button onClick={handlePay}>Pagar con QR</button>
        </>
    );
}

Métodos disponibles

Checkout Sessions

// Crear sesión para checkout.js (retorna solo checkout_token)
const session = await taypi.createCheckoutSession({
    amount: '50.00',
    reference: 'ORD-789',
    description: 'Descripción del pago',
    metadata: { source: 'web' },
}, 'ORD-789');

Pagos

// Crear pago (retorna datos completos: QR, checkout_url, etc.)
const payment = await taypi.createPayment({
    amount: '50.00',
    reference: 'ORD-789',
    description: 'Descripción del pago',
}, 'ORD-789');

// Consultar pago
const payment = await taypi.getPayment('uuid-del-pago');

// Listar pagos
const result = await taypi.listPayments({
    status: 'completed',
    from: '2026-03-01',
    to: '2026-03-31',
    per_page: 50,
});

// Cancelar pago pendiente
const cancelled = await taypi.cancelPayment('uuid-del-pago', 'cancel-ORD-789');

Webhooks

import express from 'express';

// IMPORTANTE: usar express.raw() para verificar la firma sobre el body crudo
app.post('/webhooks/taypi', express.raw({ type: 'application/json' }), (req, res) => {
    const payload = req.body.toString('utf-8');
    const signature = req.headers['taypi-signature'] as string;

    if (taypi.verifyWebhook(payload, signature, 'tu_webhook_secret')) {
        const event = JSON.parse(payload);
        // Webhook válido, procesar
    } else {
        res.status(403).json({ error: 'Firma inválida' });
    }
});

Entornos

// Producción (default)
const taypi = new Taypi('pk', 'sk');

// Desarrollo
const taypi = new Taypi('pk', 'sk', { baseUrl: 'https://dev.taypi.pe' });

// Sandbox
const taypi = new Taypi('pk', 'sk', { baseUrl: 'https://sandbox.taypi.pe' });

Idempotencia

Todos los métodos que crean recursos (createCheckoutSession, createPayment, cancelPayment) requieren un idempotencyKey explícito. Esto protege contra pagos duplicados por reintentos de red.

// Usar la referencia de orden como idempotency key
await taypi.createCheckoutSession(params, 'ORD-12345');

// Si el mismo key se envía dentro de los 15 minutos, retorna la respuesta cacheada
// sin crear un pago nuevo.

Manejo de errores

import { Taypi, TaypiError } from 'taypi.pe';

try {
    const session = await taypi.createCheckoutSession(params, reference);
} catch (err) {
    if (err instanceof TaypiError) {
        console.log(err.message);    // "El monto mínimo es S/ 1.00"
        console.log(err.errorCode);  // "AMOUNT_TOO_LOW"
        console.log(err.httpCode);   // 422
        console.log(err.response);   // Respuesta completa del API (object)
    }
}

Licencia

MIT - NEO TECHNOLOGY PERÚ E.I.R.L.