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

safe2pay_sdk

v0.0.4

Published

Biblioteca para integração com a plataforma de pagamentos Safe2Pay

Downloads

7

Readme

Safe2Pay SDK (nodejs / deno / bun.js) -> W.I.P.

  • 0 dependencias
  • typescript friendly
  • compativel com nodejs (>=10) / deno ( >= 1.29.1) / bun.js (0.4.0)

Principais recursos

  • [x] Consulta de transações.
  • [x] Tokenização de cartão.
  • [x] Pagamentos.
    • [x] Boleto bancário.
    • [x] Cartão de crédito.
    • [x] Bitcoin.
    • [x] Carnê.
    • [x] Lote de Carnês.

Instalação

npm i safe2pay_sdk
yarn add safe2pay_sdk
pnpm add safe2pay_sdk
bun add safe2pay_sdk

Utilização

A integração com a API do Safe2Pay se dá pelo modelo RESTful, de forma a realizar a transferência segura e simplificada dos dados pelo formato JSON. Para facilitar o envio dos dados, deve-se montar um objeto para envio baseado nos modelos disponíveis, com exemplos abaixo, e a própria chamada do método desejado realizará o tratamento e conversão deste objeto para JSON.

Exemplo

  • import { createSafe2pay } from 'safe2pay_sdk'
  • const apiClient = createSafe2pay(TOKEN)

Após a importação da biblioteca para utilizar basta utilizar o comando 'apiClient' e utilizar o módulo desejado.

As APIs do inclusas na SDK são:

  • Carnet
  • Payments (boleto, creditCard, cryptocurrency, pix)
  • Tokenization
  • Transaction

Pagamentos / Transações

Consultar transação

import { createSafe2Pay } from  'safe2pay_sdk';
const { consultTransaction } =  createSafe2pay('key');

consultTransaction({
	params: {
		Id:  848906
	}
}).then((result) => {
	//...
	}).catch((error) {
	//...
});

Tokenizando um cartão

import { createSafe2Pay } from  'safe2pay_sdk';
const { createToken } =  createSafe2pay('key');

createToken({
	data: {
			IsSandbox:  false,
			CardNumber:  '44654654654654564',
			Holder:  'JOÂO DA SILVA SAURO',
			ExpirationDate:  '20/1990',
			SecurityCode:  '222'
		}
}).then((result) => {
	//...
	}).catch((error) {
	//...
});

Criando uma venda com Boleto

import { createSafe2pay, CodeTaxTypeEnum, CodeReceiverTypeEnum, DiscountTypeEnum } from  'safe2pay_sdk';

const { createBoleto } =  createSafe2pay('key');

createBoleto({
	data: {
		IsSandbox:  false,
		IpAddress:  '',
		Application:  '',
		Vendor:  '',
		CallbackUrl:  '',
		Reference:  '',
		Meta: {
			bla:  'lol'
		},
		Customer: {
			Identity:  '456465456465'
		},
		Products: [
			{
				Code:  '3333',
				Description:  'string',
				UnitPrice:  111,
				Quantity:  1
			}
		],
		Splits: [
			{
				CodeTaxType:  CodeTaxTypeEnum.FIXED,
				CodeReceiverType:  CodeReceiverTypeEnum.COMPANY,
				IdReceiver:  10,
				Identity:  '651651651561',
				Name:  'jão mingal',
				IsPayTax:  true,
				Amount:  222
			}
		],
		PaymentObject: {
			DueDate:  '20/12/2066',
			Instruction:  '',
			Message: ['Mensagem 1', 'Mensagem 2', 'Mensagem 3'],
			PenaltyRate:  10,
			InterestRate:  50,
			CancelAfterDue:  true,
			DaysBeforeCancel:  6,
			IsEnablePartialPayment:  false,
			DiscountAmount:  10,
			DiscountType:  DiscountTypeEnum.FIXED,
			DiscountDue:  '19/12/2066'
		}
	}
});

TODO ->

  • [x] Tipagem de todos os metodos.
  • [ ] Criar documentação detalhada.
  • [ ] Teste unitario.