Skip to content

Commit

Permalink
Inclusão de suporte ao modelo de aplicações
Browse files Browse the repository at this point in the history
  • Loading branch information
andrevicente committed Jan 19, 2015
1 parent 5fe56f4 commit 4e2152c
Show file tree
Hide file tree
Showing 42 changed files with 2,023 additions and 50 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ Changelog
---------
---

2.5.0

- Adicionado suporte ao modelo de aplicações.

2.4.0

- Adicionada nova funcionalidade que permite a busca de notificação de solicitação de pagamento.
Expand Down
Binary file added pagseguro-api-2.5.0.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static void main(String[] args) {
PaymentRequest paymentRequest = new PaymentRequest();

paymentRequest.addItem("0001", //
"Notebook Lilás", //
"Notebook Lilás", //
Integer.valueOf(1), //
new BigDecimal("2430.00"), //
new Long(1000), null);
Expand All @@ -66,7 +66,7 @@ public static void main(String[] args) {

paymentRequest.setShippingCost(new BigDecimal("2.02"));

paymentRequest.setSender("João Comprador", //
paymentRequest.setSender("João Comprador", //
"[email protected]", //
"11", //
"56273440", //
Expand Down Expand Up @@ -122,7 +122,13 @@ public static void main(String[] args) {

Boolean onlyCheckoutCode = false;

// Set your account credentials on src/pagseguro-config.properties
/* Set your account credentials on src/pagseguro-config.properties
* You can create an payment using an application credential and set an authorizationCode
* ApplicationCredentials applicationCredentials = PagSeguroConfig.getApplicationCredentials();
* applicationCredentials.setAuthorizationCode("your_authorizationCode");
* String paymentURL = paymentRequest.register(applicationCredentials), onlyCheckoutCode);
*/

String paymentURL = paymentRequest.register(PagSeguroConfig.getAccountCredentials(), onlyCheckoutCode);

System.out.println(paymentURL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ public class CreateSession {

public static void main(String[] args) {
try {

/* Set your account credentials on src/pagseguro-config.properties
* You can create an payment using an application credential and set an authorizationCode
* ApplicationCredentials applicationCredentials = PagSeguroConfig.getApplicationCredentials();
* applicationCredentials.setAuthorizationCode("your_authorizationCode");
*/

final AccountCredentials accountCredentials = PagSeguroConfig.getAccountCredentials();

final String sessionId = SessionService.createSession(accountCredentials);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,21 @@ public static void createTransactionUsingDefaultMode() {

request.setReference("REF1234");

request.setSender(new Sender("João Comprador", //
request.setSender(new Sender("João Comprador", //
"[email protected]", //
new Phone("11", "56273440"), //
new SenderDocument(DocumentType.CPF, "000.000.001-91")));

request.setSenderHash("f6888bea84a2f114f6eef0ad9d1e662377ca440e71729fdd0ba1af7f3927fa53");

request.setShippingAddress(new Address("BRA", //
"SP", //
"Sao Paulo", //
"Jardim Paulistano", //
"01452002", //
"Av. Brig. Faria Lima", //
"1384", //
"5º andar"));
"5º andar"));

request.setShippingType(ShippingType.SEDEX);

Expand All @@ -90,6 +92,15 @@ public static void createTransactionUsingDefaultMode() {
new BigDecimal("2500.00")));

try {
/*
* If you use application credential you don't need to set request.setReceiverEmail();
* Set your account credentials on src/pagseguro-config.properties
* You can create an payment using an application credential and set an authorizationCode
* ApplicationCredentials applicationCredentials = PagSeguroConfig.getApplicationCredentials();
* applicationCredentials.setAuthorizationCode("your_authorizationCode");
*
*/

final AccountCredentials accountCredentials = PagSeguroConfig.getAccountCredentials();

final Transaction transaction = TransactionService.createTransaction(accountCredentials, //
Expand All @@ -116,12 +127,25 @@ public static void createTransactionUsingGatewayMode() {

request.setReference("REF1234");

request.setSender(new Sender("João Comprador", "[email protected]"));
request.setSender(new Sender("João Comprador", "[email protected]"));

request.setSenderHash("0db5776271490042a3b89f7f54d7e54244cf74d469695aa67c49e11c8a56c2c4");

request.addItem(new Item("1", "Notebook Prata", Integer.valueOf(1), new BigDecimal("2500.00")));
request.addItem(new Item("2", "Notebook Rosa", Integer.valueOf(1), new BigDecimal("2500.00")));

try {

/*
* If you use application credential you don't need to set request.setReceiverEmail();
* Set your account credentials on src/pagseguro-config.properties
* You can create an payment using an application credential and set an authorizationCode
* ApplicationCredentials applicationCredentials = PagSeguroConfig.getApplicationCredentials();
* applicationCredentials.setAuthorizationCode("your_authorizationCode");
*
*/


final AccountCredentials accountCredentials = PagSeguroConfig.getAccountCredentials();

final Transaction transaction = TransactionService.createTransaction(accountCredentials, //
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public static void createTransactionUsingDefaultMode() {

request.setReference("REF1234");

request.setSender(new Sender("João Comprador", //
request.setSender(new Sender("João Comprador", //
"[email protected]", //
new Phone("11", "56273440"), //
new SenderDocument(DocumentType.CPF, "000.000.001-91")));
Expand All @@ -76,7 +76,7 @@ public static void createTransactionUsingDefaultMode() {
"01452002", //
"Av. Brig. Faria Lima", //
"1384", //
"5º andar"));
"5º andar"));
request.setShippingType(ShippingType.SEDEX);

request.setShippingCost(new BigDecimal("5.00"));
Expand All @@ -95,7 +95,7 @@ public static void createTransactionUsingDefaultMode() {

request.setInstallment(new Installment(1, new BigDecimal("5005.00")));

request.setHolder(new Holder("João Comprador", //
request.setHolder(new Holder("João Comprador", //
new Phone("11", "56273440"), //
new Document(DocumentType.CPF, "000.000.001-91"), //
"07/05/1981"));
Expand All @@ -107,9 +107,17 @@ public static void createTransactionUsingDefaultMode() {
"01452002", //
"Av. Brig. Faria Lima", //
"1384", //
"5º andar"));
"5º andar"));

try {
/*
* If you use application credential you don't need to set request.setReceiverEmail();
* Set your account credentials on src/pagseguro-config.properties
* You can create an payment using an application credential and set an authorizationCode
* ApplicationCredentials applicationCredentials = PagSeguroConfig.getApplicationCredentials();
* applicationCredentials.setAuthorizationCode("your_authorizationCode");
*
*/
final AccountCredentials accountCredentials = PagSeguroConfig.getAccountCredentials();

final Transaction transaction = TransactionService.createTransaction(accountCredentials, //
Expand All @@ -136,7 +144,9 @@ public static void createTransactionUsingGatewayMode() {

request.setReference("REF1234");

request.setSender(new Sender("João Comprador", "[email protected]"));
request.setSender(new Sender("João Comprador", "[email protected]"));

request.setSenderHash("0db5776271490042a3b89f7f54d7e54244cf74d469695aa67c49e11c8a56c2c4");

request.addItem(new Item("1", "Notebook Prata", Integer.valueOf(1), new BigDecimal("2500.00")));
request.addItem(new Item("2", "Notebook Rosa", Integer.valueOf(1), new BigDecimal("2500.00")));
Expand All @@ -146,6 +156,15 @@ public static void createTransactionUsingGatewayMode() {
request.setInstallment(new Installment(1, new BigDecimal("5000.00")));

try {
/*
* If you use application credential you don't need to set request.setReceiverEmail();
* Set your account credentials on src/pagseguro-config.properties
* You can create an payment using an application credential and set an authorizationCode
* ApplicationCredentials applicationCredentials = PagSeguroConfig.getApplicationCredentials();
* applicationCredentials.setAuthorizationCode("your_authorizationCode");
*
*/

final AccountCredentials accountCredentials = PagSeguroConfig.getAccountCredentials();

final Transaction transaction = TransactionService.createTransaction(accountCredentials, //
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public static void createTransactionUsingDefaultMode() {

request.setReference("REF1234");

request.setSender(new Sender("João Comprador", //
request.setSender(new Sender("João Comprador", //
"[email protected]", //
new Phone("11", "56273440"), //
new SenderDocument(DocumentType.CPF, "000.000.001-91")));
Expand All @@ -73,7 +73,7 @@ public static void createTransactionUsingDefaultMode() {
"01452002", //
"Av. Brig. Faria Lima", //
"1384", //
"5º andar"));
"5º andar"));

request.setShippingType(ShippingType.SEDEX);

Expand All @@ -92,6 +92,16 @@ public static void createTransactionUsingDefaultMode() {
request.setBankName("BRADESCO");

try {

/*
* If you use application credential you don't need to set request.setReceiverEmail();
* Set your account credentials on src/pagseguro-config.properties
* You can create an payment using an application credential and set an authorizationCode
* ApplicationCredentials applicationCredentials = PagSeguroConfig.getApplicationCredentials();
* applicationCredentials.setAuthorizationCode("your_authorizationCode");
*
*/

final AccountCredentials accountCredentials = PagSeguroConfig.getAccountCredentials();

final Transaction transaction = TransactionService.createTransaction(accountCredentials, //
Expand All @@ -118,14 +128,25 @@ public static void createTransactionUsingGatewayMode() {

request.setReference("REF1234");

request.setSender(new Sender("João Comprador", "[email protected]"));
request.setSender(new Sender("João Comprador", "[email protected]"));

request.setSenderHash("0db5776271490042a3b89f7f54d7e54244cf74d469695aa67c49e11c8a56c2c4");

request.addItem(new Item("1", "Notebook Prata", Integer.valueOf(1), new BigDecimal("500.00")));
request.addItem(new Item("2", "Notebook Rosa", Integer.valueOf(1), new BigDecimal("500.00")));

request.setBankName("BRADESCO");

try {
/*
* If you use application credential you don't need to set request.setReceiverEmail();
* Set your account credentials on src/pagseguro-config.properties
* You can create an payment using an application credential and set an authorizationCode
* ApplicationCredentials applicationCredentials = PagSeguroConfig.getApplicationCredentials();
* applicationCredentials.setAuthorizationCode("your_authorizationCode");
*
*/

final AccountCredentials accountCredentials = PagSeguroConfig.getAccountCredentials();

final Transaction transaction = TransactionService.createTransaction(accountCredentials, //
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ public static void main(String[] args) {
String cardBrand;

try {

/* Set your account credentials on src/pagseguro-config.properties
* You can create an payment using an application credential and set an authorizationCode
* ApplicationCredentials applicationCredentials = PagSeguroConfig.getApplicationCredentials();
* applicationCredentials.setAuthorizationCode("your_authorizationCode");
*/

final AccountCredentials accountCredentials = PagSeguroConfig.getAccountCredentials();

cardBrand = "visa";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ public class GetPaymentMethods {

public static void main(String[] args) {
try {

/* Set your account credentials on src/pagseguro-config.properties
* You can create an payment using an application credential and set an authorizationCode
* ApplicationCredentials applicationCredentials = PagSeguroConfig.getApplicationCredentials();
* applicationCredentials.setAuthorizationCode("your_authorizationCode");
*/

final AccountCredentials accountCredentials = PagSeguroConfig.getAccountCredentials();

final String publicKey = "PUBE469778A81D64C838DA121DB3180FE36";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
************************************************************************
Copyright [2011] [PagSeguro Internet Ltda.]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
************************************************************************
*/

package br.com.uol.pagseguro.example;

import java.util.List;

import br.com.uol.pagseguro.domain.Authorization;
import br.com.uol.pagseguro.domain.Permission;
import br.com.uol.pagseguro.exception.PagSeguroServiceException;
import br.com.uol.pagseguro.properties.PagSeguroConfig;
import br.com.uol.pagseguro.service.NotificationService;

public class ReceiveAuthorizationNotifications {

public static void main(String[] args) {

// The notificationCode received by your system
String notificationCode = "FF422A1EE6AEE6AEEFB444AB9F963C2EF0B7";

Authorization authorization = null;

try {

/* Set your account credentials on src/pagseguro-config.properties
* You can create an payment using an application credential and set an authorizationCode
* ApplicationCredentials applicationCredentials = PagSeguroConfig.getApplicationCredentials();
* applicationCredentials.setAuthorizationCode("your_authorizationCode");
*/

authorization = NotificationService.checkAuthorization(PagSeguroConfig.getApplicationCredentials(),
notificationCode);

} catch (PagSeguroServiceException e) {
System.err.println(e.getMessage());
}

if (authorization != null) {
System.out.println("code: " + authorization.getCode());
System.out.println("reference: " + authorization.getReference());
List<Permission> permissions = authorization.getPermissions();
for (Permission permission : permissions) {
System.out.println("Permission " + permission.getPermission() + " - Status: " + permission.getStatus());
}
}

}

private ReceiveAuthorizationNotifications() {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import br.com.uol.pagseguro.properties.PagSeguroConfig;
import br.com.uol.pagseguro.service.NotificationService;

public class ReceiveNotifications {
public class ReceiveCheckoutNotifications {

public static void main(String[] args) {

Expand All @@ -33,7 +33,13 @@ public static void main(String[] args) {
Transaction transaction = null;

try {


/* Set your account credentials on src/pagseguro-config.properties
* You can create an payment using an application credential and set an authorizationCode
* ApplicationCredentials applicationCredentials = PagSeguroConfig.getApplicationCredentials();
* applicationCredentials.setAuthorizationCode("your_authorizationCode");
*/

transaction = NotificationService.checkTransaction(PagSeguroConfig.getAccountCredentials(),
notificationCode);

Expand All @@ -49,6 +55,6 @@ public static void main(String[] args) {

}

private ReceiveNotifications() {
private ReceiveCheckoutNotifications() {
}
}
Loading

0 comments on commit 4e2152c

Please sign in to comment.