PagSeguro Node.js: Process payments using UOL PagSeguro

Recommend this page to a friend!
  Info   View files Example   View files View files (9)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 59 All time: 487 This week: 3Up
Version License JavaScript version Categories
pagseguro-nodejs 1.0MIT/X Consortium ...5Node.js, Web services, E-Commerce
Description Author
This package is specific mainly for applications used in Brazil Brazil .

This Node.js module can process payments using UOL PagSeguro.

It can configure the details of a payment and redirect the user to a page of PagSeguro on which the user can conclude the payment.

This module can also process notifications about the status of the payments.

In Portuguese:

Integra a API de pagamento do UOL PagSeguro. Pode ser utilizada para fazer pagamentos, consultar detalhes de transações e detalhes de notificações.

Innovation Award
JavaScript Programming Innovation award nominee
April 2016
Number 3
PagSeguro is a well know payment system very used in Brazil.

This package is a Node.js module for processing e-commerce payments with PagSeguro. It can redirect the users to the payment pages, as well process requests that notify about the status of payments.

Manuel Lemos
Picture of Edvaldo Szymonek
  Performance   Level  
Name: Edvaldo Szymonek <contact>
Classes: 1 package by
Country: Brazil Brazil
Age: 28
All time rank: 17717 in Brazil Brazil
Week rank: 6 Up1 in Brazil Brazil Up
Innovation award
Innovation award
Nominee: 1x

Details

pagseguro-nodejs

Biblioteca para integração do UOL PagSeguro com Nodejs

Instalação

npm install pagseguro-nodejs --save

Como usar

Pagamentos

Inicializando

var PagSeguro = require('pagseguro-nodejs');

var pagseguro = new PagSeguro({
    email: 'name@example.com',
    token: 'ACCESS_TOKEN'
});

Modo e Debug

var pagseguro = new PagSeguro({
    ...
    mode: (PagSeguro.MODE_PAYMENT | PagSeguro.MODE_SANDBOX),
    debug: (true | false)
});

Configuração da moeda e referência do pagamento

pagseguro.currency('BRL');
pagseguro.reference('REFERENCE_CODE');

Configuração das URLs de redirecionamento e notificação (opcional)

pagseguro.redirect('http://www.example.com/callback');
pagseguro.notify('http://www.example.com/notify');

Adicionando produtos

A documentaçao completa dos parametros pode se encontrada no site do PagSeguro

pagseguro.addItem({
    id: '1',
    description: 'Descrição do primeiro produto',
    amount: '40.00',
    quantity: '1'
});

pagseguro.addItem({
    id: '2',
    description: 'Descrição do segundo produto',
    amount: '40.00',
    quantity: '9'
});

Configurando informações do comprador

pagseguro.sender({
    name: 'Some name',
    email: 'name@example.com',
    phone: {
        areaCode: '51',
        number: '12345678'
    }
});

Configurando entrega do pedido

pagseguro.shipping({
    type: 1,
    name: 'Some name',
    email: 'name@example.com',
    address: {
        street: 'Endereço',
        number: '10',
        city: 'Nome da cidade',
        state: 'PR',
        country: 'BRA'
    }
});

Enviando informações

pagseguro.checkout(function(success, response) {
    if (success) {
        console.log('Success');
        console.log(response);
    } else {
        console.log('Error');
        console.error(response);
    }
});

Transações

Checando transação através do código

pagseguro.transaction('TRANSACTION_CODE', function(success, response) {
    if (success) {
        console.log('Success');
        console.log(response);
    } else {
        console.log('Error');
        console.error(response);
    }
});

Notificaçoes

Checando transação através do código de notificação

pagseguro.notification('NOTIFICATION_CODE', function(success, response) {
    if (success) {
        console.log('Success');
        console.log(response);
    } else {
        console.log('Error');
        console.error(response);
    }
});
  Files folder image Files  
File Role Description
Files folder imageexamples (3 files)
Files folder imagelib (2 files)
Plain text file index.js Class index
Accessible without login Plain text file LICENSE Data LICENSE
Accessible without login Plain text file package.json Data package
Accessible without login Plain text file README.md Doc. README

  Files folder image Files  /  examples  
File Role Description
  Accessible without login Plain text file new-payment.js Example example
  Accessible without login Plain text file notification-details.js Example example
  Accessible without login Plain text file transaction-details.js Example example

  Files folder image Files  /  lib  
File Role Description
  Plain text file foreach.js Class foreach
  Plain text file xml-node.js Class xml-node

 Version Control Unique User Downloads Download Rankings  
 100%
Total:59
This week:0
All time:487
This week:3Up