forked from danilomagrini/java
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Inclusão de suporte ao modelo de aplicações
- Loading branch information
1 parent
5fe56f4
commit 4e2152c
Showing
42 changed files
with
2,023 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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); | ||
|
@@ -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", // | ||
|
@@ -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); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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); | ||
|
||
|
@@ -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, // | ||
|
@@ -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, // | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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"))); | ||
|
@@ -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")); | ||
|
@@ -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")); | ||
|
@@ -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, // | ||
|
@@ -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"))); | ||
|
@@ -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, // | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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"))); | ||
|
@@ -73,7 +73,7 @@ public static void createTransactionUsingDefaultMode() { | |
"01452002", // | ||
"Av. Brig. Faria Lima", // | ||
"1384", // | ||
"5º andar")); | ||
"5º andar")); | ||
|
||
request.setShippingType(ShippingType.SEDEX); | ||
|
||
|
@@ -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, // | ||
|
@@ -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, // | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
...eguro-api-example/src/br/com/uol/pagseguro/example/ReceiveAuthorizationNotifications.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.