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

pagarme-bifrost-js

v0.2.5

Published

PagarMe Bifrost WebSocket JS Class. An easy implementation of PagarMe Bifrost WebSocket Service.

Readme

PagarME Bifrost.JS

Uma forma mais fácil de implementar o websocket da Pagar.me em seu sistema.

Como Usar

NPM / Yarn

npm install pagarme-bifrost-js --save

# For Yarn, use the command below.
yarn add pagarme-bifrost-js

CDN

<!-- For UNPKG use the code below. -->
<script src="https://unpkg.com/pagarme-bifrost-js@latest/dist/index.umd.js"></script>

<!-- For JSDelivr use the code below. -->
<script src="https://cdn.jsdelivr.net/npm/pagarme-bifrost-js@latest/dist/index.umd.js"></script>

<script>
  console.log(PagarMeBifrost);
</script>

API

Classe

Iniciando a classe

import PagarMeBifrost from 'pagarme-bifrost-js';

const Bifrost = new PagarMeBifrost({
  contextId: 'ABC123',
  encryptionKey: 'ENCKEY',
});

Construtor

Argumentos

|Propiedade|Tipo|Default| |--|--|--| | debug | boolean | Ativa o modo de Debug | | host | string | Endereço de conexão do WebSocket | | contextId | string | ID do contexto de conexão | | baudRate | number | Taxa de comunicação | | encryptionKey | string | Chave de criptografia Pagar.ME | | pinPadMaxCharLine | number | Quantidade máxima de caracteres por linha do PinPad | | pinPadMaxChar | number | Quantidade máxima de caracteres na tela do PinPad | | pinPanDisplayLines | number | Número de linhas disponíveis no PinPad |

initialize

Inicializa o WebSocket. Caso esteja tudo Ok, será retornado true, senão um Error

  Bifrost.initialize();

terminate

Finaliza o WebSocket. Caso esteja tudo Ok, será retornado true, senão um Error

  Bifrost.terminate();

status

Retorna o status do WebSocket. Caso esteja tudo Ok, será retornado um objeto de status BifrostServiceStatus, senão um Error

  /**
   * @typedef {object} BifrostServiceStatus
   * @property {boolean} connected - Is device connected
   * @property {string} contextId - Device Context
   * @property {string} connectedDeviceId - Connected Device Id
   */
  Bifrost.status();

showMessage

Exibe uma mensagem ou array de mensagens no display do Pinpad.

  Bifrost.showMessage('MSG' || ['MSG']);

payment

Inicializa o processo de pagamento no WebSocket, você deve passar dois parâmetros. O primeiro é o valor (float) e o segundo o metodo de pagamento ('credit'|'debit'|1|2). Caso esteja tudo Ok, será retornado PinPadProcessedCardReturn, senão um Error

  /**
   * @typedef {object} PinPadProcessedCardReturn
   * @property {string} card_hash
   * @property {string} card_holder_name
   * @property {number} error_code
   * @property {boolean} is_online_pin
   * @property {number} payment_method
   * @property {number} status
   */
  const amount = 10; // Float
  const method = 'credit'; // 'credit'|'debit'|1|2
  Bifrost.payment(amount, method);

finish

Finaliza o processo de pagamento no WebSocket, após o pagamento iniciado e o backEnd processado ele, você deve passar os códigos devolvidos pelo backend para o serviço de WebSocket. Caso esteja tudo Ok, será retornado a resposta do serviço Object, senão um Error

  Bifrost.finish({
    code: '', // Código devolvido pelo servidor
    emvData: '', // Código devolvido pelo servidor
    messages: [''], // Array de mensagens para serem mostradas no PinPad
  });

Exemplo

import PagarMeBifrost from 'pagarme-bifrost-js';

const Bifrost = new PagarMeBifrost({
  contextId: 'ABC123',
  encryptionKey: 'ENCKEY',
});
// Inicializando o serviço
Bifrost.initialize()
.then((status) =>{
  if(status){
    Bifrost.showMessage('Msg no PINPAD');
  }
})
.catch(() => {
  Bifrost.terminate();
});

// Fazendo um pagamento via crédito
Bifrost.payment(10.00, 'credit')
.then((response) => {
  /* Após enviar para o backend a resposta (response)
  * você vai receber os dados para a finalização 
  * */
  Bifrost.finish({
    code: '', // Código devolvido pelo servidor
    emvData: '', // Código devolvido pelo servidor
    messages: [''], // Array de mensagens para serem mostradas no PinPad
  });
});