p3140 / webpay-nodejs

[Spanish/Chile] Módulo no oficial para integrar WebPay Plus en Node.js, con soporte para promesas.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

#webpay-nodejs

Módulo no oficial para integrar WebPay Plus en Node.js, con soporte para promesas.

#Instalación

npm install webpay-nodejs --save

#Transacción normal

La explicación detallada de los ejemplos de código está en /tests

  1. Instanciar
const WebPay = require('webpay-nodejs');

let wp = new WebPay({
    commerceCode: youCommerceCode,
    publicKey: youPublicKey,
    privateKey: youPrivateKey,
    webpayKey: youWebpayKey,
    env: WebPay.ENV.INTEGRACION
});
  1. Iniciar Transacción
wp.initTransaction({
    buyOrder: buyOrden,
    sessionId: req.sessionId,
    returnURL: url + '/verificar',
    finalURL: url + '/comprobante',
    amount: amount
}).then((data) => {
    res.redirect(data.url + '?token_ws=' + data.token);
})
  1. Obtener datos de la transacción
wp.getTransactionResult(token).then((transaccion) => {
    // datos de la transaccion
})
  1. Aceptar la transacción
wp.acknowledgeTransaction(token)

Opcionalmente; Anular

wp.nullify({
authorizationCode: '123',
authorizedAmount: 2000,
buyOrder: buyOrder
})

#Breaking Changes v1.0.0

  • getTransactionResult retornaba transaction.detailOutput como un array con un único objeto las propiedades, ahora transaction.detailOutput retorna directamente dicho objeto.

    • Ejemplo antes: transaction.detailOutput[0].amount
    • Ejemplo ahora: transaction.detailOutput.amount

#Legalidades

La verificación del certificado único y especial de WebPay fue gracias a (FabianBravoA)[https://github.com/FabianBravoA/tbk_node].

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Licencia LGPL.

About

[Spanish/Chile] Módulo no oficial para integrar WebPay Plus en Node.js, con soporte para promesas.


Languages

Language:JavaScript 100.0%