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 🙏

© 2024 – Pkg Stats / Ryan Hefner

data7-pix-h

v1.2.7

Published

SDK que permite um conexão simplificada com a API Pix de diversos PSP's.

Downloads

9

Readme

SDK que permite um conexão simplificada com a API Pix de diversos PSP's.

Bancos Implementados: -> Sicredi -> Gerencianet

Bancos com implementação em andamento: -> Sicoob -> Itau -> Bradesco

Exemplos abaixo:

import { PixSicredi } from "data7-pix";
import { DadosCobranca, SicrediProps } from "./types";
import { criar_txid } from "./utils/tx_id.js";

/**
 * O serviço PIX possui os seguintes métodos

ServicoPix {
  config: (props: Props) => ServicoPix;
  criar_cobranca: (data: DadosCobranca) => Promise<Cobranca>;
  alterar_cobranca: (data: DadosCobranca) => Promise<Cobranca>;
  consultar_cobranca: (txid: string) => Promise<CobrancaCompleta | undefined>;
  listar_cobrancas: (filtros: FiltroConsulta) => Promise<ListaCobrancas>;
  cancelar_cobranca: (txid: string) => Promise<boolean>;
  consultar_pix_recebido: (e2eid: string) => Promise<RecebimentoPix | undefined>;
  listar_pix_recebidos: (filtros: FiltroConsulta) => Promise<ListaRecebimentosPix>;
  devolver_pix_recebido: (e2eid: string,id_devolucao: string,valor: number) => Promise<DevolucaoPix>;
  consultar_pix_devolvido: (e2eid: string,id_devolucao: string) => Promise<DevolucaoPix>;
  registrar_webhook: (url: string) => Promise<boolean>;
  consultar_webhook: () => Promise<IWebHook>;
  deletar_webhook: () => Promise<boolean>;
  dto_webhook: (data: any) => RecebimentoPix[];
}
 */

//EXEMPLOS:

// O método config só precisa ser usado uma vez, após isso pode se usar os demais métodos em qualquer lugar da aplicação

const _config: SicrediProps = {
  cert_path: "C:\\Dev\\Certs\\Sicredi\\Certificado.pem",
  key_path: "C:\\Dev\\Certs\\Sicredi\\Certificado.key",
  ca_path: "C:\\Dev\\Certs\\Sicredi\\CadeiaCompleta.cer",
  chave_pix: "+5566988887777",
  client_id: "your_client_id", //Caso use o ambiente de homologação, usar o respectivo client_id
  client_secret: "your_client_secret", //Caso use o ambiente de homologação, usar o respectivo client_secret
  sandbox: true, /// Essa propridade habilita o ambiente de homologação. Valor padrão: false
};

PixSicredi.config(_config);

// >>>>>>> COBRANÇAS
async function CriarCobranca(valor: number) {
  const Cob: DadosCobranca = {
    tx_id: criar_txid(),
    valor: String(valor),
  };
  return await PixSicredi.criar_cobranca(Cob);
  //Retorna objeto de cobrança / Error
}

async function AlterarCobranca() {
  return await PixSicredi.criar_cobranca({
    tx_id: criar_txid(),
    valor: "0.02",
    solicitacaoPagador: "Alteracao de valor teste",
  });
  //Retorna objeto de cobrança / Error
}

async function CancelarCobranca(tx_id: string) {
  return await PixSicredi.cancelar_cobranca(tx_id);
  // Retorna um boolean / Error
}

async function ConsultarCobranca(tx_id: string) {
  return await PixSicredi.consultar_cobranca(tx_id);
  // Retorna um objeto Cobranca com recebimentos e devoluçoes ou undefined / Error
}

async function ConsultaListaCobrancas() {
  const data_inicio = new Date();
  data_inicio.setDate(data_inicio.getDate() - 1);
  return await PixSicredi.listar_cobrancas({
    data_inicio: data_inicio.toISOString(),
    data_fim: new Date().toISOString(),
  });
  // Retorna um objeto de consulta de cobrancas / Error
}

// >>>>>> PIX
async function ConsultarPIX(e2eid: string) {
  return await PixSicredi.consultar_pix_recebido(e2eid);
  // Retorna um objeto de Recebimento com devoluçoes ou undefined / Error
}

async function DevolverPix(tx_id: string, id_devolução: string, valor: number) {
  return await PixSicredi.devolver_pix_recebido(tx_id, id_devolução, valor);
  // Retorna boolean / Error
}

async function ConsultaListaPixRecebidos() {
  const data_inicio = new Date();
  data_inicio.setDate(data_inicio.getDate() - 1);
  return await PixSicredi.listar_pix_recebidos({
    data_inicio: data_inicio.toISOString(),
    data_fim: new Date().toISOString(),
  });
  // Retorna um objeto de consulta de Recebimentos / Error
}

/// Webhook
async function Registrar_Atualizar_Webhook(webhook_url: string) {
  return await PixSicredi.registrar_webhook(webhook_url);
  // Retorna boolean / Error
}

function DTO_Webhook(data: any) {
  return PixSicredi.dto_webhook(data);
  // Retorna o objeto de Recebimento Pix em um formato padrão / Error
  /**
  OBJ:{
  e2eid: string,
  txid: string,
  valor: string,
  valor_cobranca: string,
  valor_devolvido: string,
  horario: string,
  devolucoes: DevolucaoPix[],
  banco: 'BANCO',
  }
   */
}