JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q54272F
  • License Apache-2.0

Chilepay SDK module for Payments integration

Package Exports

  • chilepay-sdk

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (chilepay-sdk) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

chilepay-sdk

Warning: In active development. Not ready for production usage.

Kit de integración para la API de Chilepay con node.js.

Instalación

npm install chilepay-sdk

Modo de uso

const ChilePay = require('chilepay-sdk');

let cp = new ChilePay("{apiKey}", "{secretKey}");

Para obtener tu {apiKey} y {secretKey} debes activar Desarrollador Chilepay

Crear una transacción

  1. Inicia la transacción y redirecciona al usuario a la url retornada por Chilepay.
cp.initTransaction('webpay', {
    subject: 'Mi primera transacción',
    buyerEmail: 'comprador@example.com',
    amount: 10000,
    currency: 'clp',
    notifyUrl: 'https://example.com/notificacion',
    returnUrl: 'https://example.com/tienda'
}).then((response) => {
    res.redirect(response.paymentUrl);
});
  1. Al recibir la notificación, llama a .getTransaction("{token}") para obtener la información de la transacción. Finalmente, retorna transaction.checkCode
// en https://example.com/notificacion

let transactionId = req.params.transactionId;

cp.getTransaction(transactionId).then((transaction) => {
    
    // Aquí debes fijarte en transaction.status, si es "preApproved" entonces
    // debes actualizar tu base de datos y disminuir stock. La transacción
    // se considerará aprobada solo si retornas transaction.checkCode
    
    res.send(transaction.checkCode);
    
});

Apache-2 License.