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

getnet

v1.0.2

Published

A library/abstraction in Node.JS to implements the Getnet's services.

Downloads

45

Readme

Getnet

A library/abstraction in Node.JS to implements the Getnet's services. https://developers.getnet.com.br/api

Install

npm install getnet

or via YARN

yarn install getnet

Usage

import getnet, { Card, Safebox, Payment } from 'getnet';

//configure your credentials and define the getnet's env.
getnet.config(sellerId, clientId, secret);
getnet.useEnv('sandbox'); //sandbox, homolog or production

//Card token generation 
//(https://developers.getnet.com.br/api#tag/Tokenizacao)
const numberToken = await Card.asToken({
  cardNumber: '5155901222280001',
  customerId: 'customer_21081826',
});

//Card verification 
//(https://developers.getnet.com.br/api#tag/Pagamento%2Fpaths%2F~1v1~1cards~1verification%2Fpost)
const {
  status,
  verificationId,
  authorizationCode,
} = await Card.verification({
  numberToken: numberToken,
  expirationMonth: 12,
  expirationYear: 24,
  securityCode: 123,
});

//Add card on safebox
//https://developers.getnet.com.br/api#tag/Cofre%2Fpaths%2F~1v1~1cards%2Fpost
const { cardId, numberToken } = await Safebox.add({
  numberToken: numberToken,
  expirationMonth: 12,
  expirationYear: 24,
  customerId: 'customer_21081826',
  cardholderName: 'SR ABRAVANEL',
  verifyCard: false,
  securityCode: "123",
});

//Find card on safebox by Id
//https://developers.getnet.com.br/api#tag/Cofre%2Fpaths%2F~1v1~1cards~1%7Bcard_id%7D%2Fget
const {
  cardId,
  lastFourDigits,
  bin,
  expirationMonth,
  expirationYear,
  brand,
  cardholderName,
  customerId,
  numberToken,
  status,
} = await Safebox.findOne(cardId);

//Find the customer's cards on safebox
//https://developers.getnet.com.br/api#tag/Cofre%2Fpaths%2F~1v1~1cards%2Fget
const cards = await Safebox.findAllByCustomerId(customerId, status); //status: all, active, renewed. Default is all'

//Remove card from safebox
//https://developers.getnet.com.br/api#tag/Cofre%2Fpaths%2F~1v1~1cards~1%7Bcard_id%7D%2Fdelete
const wasRemoved = await Safebox.remove(cardId);

//Payment on credit
//https://developers.getnet.com.br/api#tag/Pagamento%2Fpaths%2F~1v1~1payments~1credit%2Fpost
const {
  paymentId,
  sellerId,
  amount,
  currency,
  orderId,
  status,
  receivedAt,
  credit,
} = await Payment.onCredit({
  sellerId: "6eb2412c-165a-41cd-b1d9-76c575d70a28",
  amount: 100,
  currency: "BRL",
  order: {
    orderId: "6d2e4380-d8a3-4ccb-9138-c289182818a3",
    salesTax: 0,
    productType: "service"
  },
  customer: {
    customerId: "customer_21081826",
    firstName: "João",
    lastName: "da Silva",
    name: "João da Silva",
    email: "[email protected]",
    documentType: "CPF",
    documentNumber: "12345678912",
    phoneNumber: "5551999887766",
    billingAddress: {
      street: "Av. Brasil",
      number: "1000",
      complement: "Sala 1",
      district: "São Geraldo",
      city: "Porto Alegre",
      state: "RS",
      country: "Brasil",
      postalCode: "90230060"
    }
  },
  device: {
    ipAddress: "127.0.0.1",
    deviceId: "hash-device-id"
  },
  shippings: [
    {
      firstName: "João",
      name: "João da Silva",
      email: "[email protected]",
      phoneNumber: "5551999887766",
      shippingAmount: 3000,
      address: {
        street: "Av. Brasil",
        number: "1000",
        complement: "Sala 1",
        district: "São Geraldo",
        city: "Porto Alegre",
        state: "RS",
        country: "Brasil",
        postal_code: "90230060"
      }
    }
  ],
  subMerchant: {
    identificationCode: "9058344",
    documentType: "CNPJ",
    documentNumber: "20551625000159",
    address: "Torre Negra 44",
    city: "Cidade",
    state: "RS",
    postalCode: "90520000"
  },
  credit: {
    delayed: false,
    preAuthorization: false,
    saveCardData: false,
    transactionType: "FULL",
    numberInstallments: 1,
    softDescriptor: "LOJA*TESTE*COMPRA-123",
    dynamicMcc: 1799,
    card: {
      numberToken: "dfe05208b105578c070f806c80abd3af09e246827d29b866cf4ce16c205849977c9496cbf0d0234f42339937f327747075f68763537b90b31389e01231d4d13c",
      cardholderName: "JOAO DA SILVA",
      securityCode: "123",
      brand: "Mastercard",
      expirationMonth: "12",
      expirationYear: "20"
    }
  }     
});


//Cancel payment on credit
//https://developers.getnet.com.br/api#tag/Pagamento%2Fpaths%2F~1v1~1payments~1credit~1%7Bpayment_id%7D~1cancel%2Fpost
const wasCanceled = await Payment.cancelCredit(paymentId);

//Request the payment's cancelation on credit
//https://developers.getnet.com.br/api#tag/Cancelamento%2Fpaths%2F~1v1~1payments~1cancel~1request%2Fpost
const wasCanceled = await Payment.cancelRequestOnCredit(paymentId, cancelAmount, cancelCustomKey);