Giter Site home page Giter Site logo

pagseguro-api's Introduction

Esta API faz a integração com a nova API do PagSeguro via WebServices com XML. A intenção deste projeto é ajudar na integração com o Sistema do PagSeguro facilitando o uso da API.

Serviço de Pagamento

Abaixo um exemplo de como usar a api para processamento de um pagamento

	Payment payment = new PaymentBuilder()
				.shipping(Shipping.SEDEX, 
						"Rua do Comprador", "000", "Compl.", "Bairro", "04293000", 
					"São Paulo", "SP",  "BRA", BigDecimal.ZERO)
				.sender("João da Silva", "[email protected]", "11", "99999999")
				.currency("BRL")
				.reference("RF1234")
				.item("1", "Descrição 1", 1, new BigDecimal("150.00"), 1L, new BigDecimal("10.00"))
				.build();
				
	PaymentRequest request = new PaymentRequest(payment, new PaymentConfig() {
				public String getUrl() {
					return "https://ws.pagseguro.uol.com.br/v2/checkout";
				}

				public String getToken() {
					return "COLOQUE SEU TOKEN AQUI";
				}

				public String getEncoding() {
					return "ISO-8859-1";
				}

				public String getEmail() {
					return "COLOQUE SEU EMAIL AQUI";
				}
				
				public String getPaymentUrl(String code) {
					return "https://pagseguro.uol.com.br/v2/checkout/payment.html?code="+code;
				}
	});			
	
	PaymentOrder order = PaymentService.pay(request);
	
	order.getOrderCode().getCode();
	order.getOrderCode().getDate();

Caso ocorra algum erro no processamento do pagamento o serviço retorna as mensagens de erro retornadas pelo PagSeguro

	PaymentOrder order = PaymentService.pay(request);
	
	List<Error> errors = order.getError().getErrors(); // error.code, error.message

Serviço de Notificação

	NotificationRequest request = new NotificationRequest(notificationCode, new Config() {
				public String getUrl() {
					return "https://ws.pagseguro.uol.com.br/v2/transactions/notifications";
				}

				public String getToken() {
					return "COLOQUE SEU TOKEN AQUI";
				}

				public String getEncoding() {
					return "ISO-8859-1";
				}

				public String getEmail() {
					return "COLOQUE SEU EMAIL AQUI";
				}
	});
	
	Transaction transaction = NotificationService.get(request);
	
	transaction.getCode();
	transaction.getReference(); // E assim por diante...

Serviço de Consulta (Detalhe)

	TransactionDetailRequest request = new TransactionDetailRequest(transactionCode, new Config() {
				public String getUrl() {
					return "https://ws.pagseguro.uol.com.br/v2/transactions";
				}

				public String getToken() {
					return "COLOQUE SEU TOKEN AQUI";
				}

				public String getEncoding() {
					return "ISO-8859-1";
				}

				public String getEmail() {
					return "COLOQUE SEU EMAIL AQUI";
				}
	});
	
	Transaction transaction = TransactionService.detail(request);
	
	transaction.getCode();
	transaction.getReference(); // E assim por diante...

Serviço de Consulta (Histórico)

	TransactionSearchRequest request = new TransactionSearchRequest(initialDate, finalDate, 1, 10, new Config() {
				public String getUrl() {
					return "https://ws.pagseguro.uol.com.br/v2/transactions";
				}

				public String getToken() {
					return "COLOQUE SEU TOKEN AQUI";
				}

				public String getEncoding() {
					return "ISO-8859-1";
				}

				public String getEmail() {
					return "COLOQUE SEU EMAIL AQUI";
				}
	});
	
	TransactionSearchResult resultSearch = TransactionService.search(request);
	
	resultSearch.getDate();
	resultSearch.getCurrentPage();
	resultSearch.getResultsInThisPage();
	resultSearch.getTransactions(); // Transaction Summary

O mesmo server para as transações abandonadas, trocando apenas a URL do serviço para (https://ws.pagseguro.uol.com.br/v2/transactions/abandoned)

pagseguro-api's People

Contributors

leandrostoroli avatar

Watchers

James Cloos avatar Cleiton Ferreira avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.