Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adicionando suporte a notificationURL no checkout #43

Open
wants to merge 13 commits into
base: desenvolvimento
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ A biblioteca PagSeguro em Java é um conjunto de classes de domínio que facilit
- Criar [requisições de pagamentos]
- Criar [requisições de assinaturas]
- Cancelar [assinaturas]
- Cancelar [transações por código]
- Estornar [transações por código]
- Consultar [assinaturas]
- Consultar [transações por código]
- Consultar [transações por intervalo de datas]
Expand Down Expand Up @@ -131,6 +133,12 @@ Caso tenha dúvidas ou precise de suporte, acesse nosso [fórum].

Changelog
---------
4.1.1
- Publicação da biblioteca no Repositório Global do Maven: ajustes no javadoc e melhorias gerais

4.1.0
- Melhorias e adicionado exemplos das transações de cancelamento e estorno (total e parcial)

4.0.0
- Remoção de funcionalidade depreciada (checkout com cartão de crédito internacional)

Expand Down
9 changes: 3 additions & 6 deletions public/example-api/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
group 'br.com.uol.pagseguro'
version '1.0-SNAPSHOT'
version '4.1.1'

apply plugin: 'java'
apply plugin: 'idea'
Expand All @@ -8,14 +8,11 @@ apply plugin: 'eclipse'
sourceCompatibility = 1.6

repositories {
maven {
url 'http://repo.mvn.intranet.s2it.com.br/nexus/content/groups/public/'
}
mavenCentral()
}


dependencies {
compile (group: 'br.com.uol.pagseguro', name: 'pagseguro-api', version: '1.0-SNAPSHOT')
compile (group: 'br.com.uol.pagseguro', name: 'pagseguro-api', version: '4.1.1')
}

configurations.all {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public static void main(String[] args){
Credential.sellerCredential(sellerEmail, sellerToken), PagSeguroEnv.SANDBOX);

//Lista as opções de parcelamento

DataList<? extends InstallmentDetail> installmentDetails =
pagSeguro.installments().list(new InstallmentListingBuilder()
.withCardBrand("visa")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* 2007-2016 [PagSeguro Internet Ltda.]
*
* NOTICE OF LICENSE
*
* 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.
*
* Copyright: 2007-2016 PagSeguro Internet Ltda.
* Licence: http://www.apache.org/licenses/LICENSE-2.0
*/

package br.com.uol.pagseguro.example.api.transaction;

import br.com.uol.pagseguro.api.PagSeguro;
import br.com.uol.pagseguro.api.PagSeguroEnv;
import br.com.uol.pagseguro.api.credential.Credential;

public class RequestCancel {
public static void main(String[] args){
try {
String sellerEmail = "your_seller_key";
String sellerToken = "your_seller_token";

final PagSeguro pagSeguro = PagSeguro.instance(Credential.sellerCredential(sellerEmail,
sellerToken), PagSeguroEnv.SANDBOX);

pagSeguro.transactions().cancelByCode("TRANSACATIONCODEHERE");

}catch (Exception e){
e.printStackTrace();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package br.com.uol.pagseguro.example.api.transaction;

import br.com.uol.pagseguro.api.PagSeguro;
import br.com.uol.pagseguro.api.PagSeguroEnv;
import br.com.uol.pagseguro.api.credential.Credential;
import java.math.BigDecimal;

public class RequestRefundPartial {
public static void main(String[] args){
try {
String sellerEmail = "your_seller_key";
String sellerToken = "your_seller_token";

final PagSeguro pagSeguro = PagSeguro.instance(Credential.sellerCredential(sellerEmail,
sellerToken), PagSeguroEnv.SANDBOX);

/* refunds the value of R$ 10.90 from the transaction */
pagSeguro.transactions().refundByCode("TRANSACATIONCODEHERE", new BigDecimal(10.90));

}catch (Exception e){
e.printStackTrace();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package br.com.uol.pagseguro.example.api.transaction;

import br.com.uol.pagseguro.api.PagSeguro;
import br.com.uol.pagseguro.api.PagSeguroEnv;
import br.com.uol.pagseguro.api.credential.Credential;

public class RequestRefundTotal {
public static void main(String[] args){
try {
String sellerEmail = "your_seller_key";
String sellerToken = "your_seller_token";

final PagSeguro pagSeguro = PagSeguro.instance(Credential.sellerCredential(sellerEmail,
sellerToken), PagSeguroEnv.SANDBOX);

pagSeguro.transactions().refundByCode("TRANSACATIONCODEHERE");

}catch (Exception e){
e.printStackTrace();
}
}
}
71 changes: 67 additions & 4 deletions source/build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
group 'br.com.uol.pagseguro'
version '3.1.1'
version '4.1.1'

apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'eclipse'
apply plugin: 'maven'
apply plugin: 'signing'

sourceCompatibility = 1.6

repositories {
maven {
url 'http://repo.mvn.intranet.s2it.com.br/nexus/content/groups/public/'
}
mavenCentral()
}

dependencies {
Expand All @@ -23,3 +23,66 @@ dependencies {
compileOnly(group: 'org.slf4j', name: 'slf4j-api', version: '1.7.21')
compileOnly(group: 'commons-logging', name: 'commons-logging', version: '1.2')
}

uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }

repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}

snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}

pom.project {
name project.name
packaging 'jar'

description 'A collection of domain classes to ease integrations with PagSeguro Api'
url 'https://github.com/pagseguro/pagseguro-java-sdk/'

scm {
url 'https://github.com/pagseguro/pagseguro-java-sdk/'
}

licenses {
license {
name 'The Apache License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}

developers {
developer {
id 'pagseguro'
name 'PagSeguro'
email '[email protected]'
}
}
}
}
}
}

task javadocJar(type: Jar) {
classifier = 'javadoc'
from javadoc
}

task sourcesJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.allSource
}

artifacts {
archives javadocJar, sourcesJar
}

// Uncomment this block to sign the files when building to upload to Maven
//signing {
// sign configurations.archives
//}

8 changes: 8 additions & 0 deletions source/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
### OSSRH credentials to upload do Sonatype Nexus and Maven ###
ossrhUsername=ossrhUsername
ossrhPassword=ossrhPassword

### Signing access and files ###
signing.keyId=THEKEYID
signing.password=THEKEYPASSWORD
signing.secretKeyRingFile=THEKEYRINGPATH
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,18 @@ public interface CheckoutRegistration {
*/
String getReference();

/**
* Define a notification URL to the payment.
* This notification URL is associated with the transaction created by the payment and is useful
* to link PagSeguro transactions to sales registered on your system.
* Format: Valid URL, with the 255-character limit.
*
* Optional
*
* @return Notification URL.
*/
String getNotificationUrl();

/**
* Extra value. Specifies an extra value to be added or subtracted from the total amount of
* payment. This value may represent an extra fee to be charged in the payment or a discount to be
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ public final class CheckoutRegistrationBuilder implements Builder<CheckoutRegist

private String reference = null;

private String notificationUrl = null;

private Sender sender = null;

private Shipping shipping = null;
Expand All @@ -75,6 +77,18 @@ public CheckoutRegistrationBuilder withReference(String reference) {
return this;
}

/**
* Set notificationUrl of checkout
*
* @param notificationUrl NotificationURL of checkout
* @return Builder for checkout registration
* @see CheckoutRegistration#getNotificationUrl()
*/
public CheckoutRegistrationBuilder withNotificationUrl(String notificationUrl) {
this.notificationUrl = notificationUrl;
return this;
}

/**
* Set Extra Amount
*
Expand Down Expand Up @@ -340,6 +354,9 @@ public String getReference() {
return checkoutRegistrationBuilder.reference;
}

@Override
public String getNotificationUrl() {return checkoutRegistrationBuilder.notificationUrl; }

@Override
public BigDecimal getExtraAmount() {
return checkoutRegistrationBuilder.extraAmount;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public class CheckoutRegistrationV2MapConverter extends AbstractMapConverter<Che
protected void convert(RequestMap requestMap, CheckoutRegistration checkoutRegistration) {
requestMap.putCurrency("currency", checkoutRegistration.getCurrency());
requestMap.putString("reference", checkoutRegistration.getReference());
requestMap.putString("notificationURL", checkoutRegistration.getNotificationUrl());
requestMap.putCurrency("extraAmount", checkoutRegistration.getExtraAmount());
requestMap.putMap(SHIPPING_MC.convert(checkoutRegistration.getShipping()));
requestMap.putMap(SENDER_MC.convert(checkoutRegistration.getSender()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public String getStringName() {

/**
* Get bank name by string name
* @return Name
*/
public Name getName() {
return Name.fromName(stringName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,21 @@ public interface Permission {
/**
* Get code of permission
*
* @return
* @return Permission code
*/
PermissionCode getCode();

/**
* Get status of permission
*
* @return
* @return status
*/
String getStatus();

/**
* Get last update of permission
*
* @return
* @return last update date
*/
Date getLastUpdate();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public String getCodeId() {
/**
* Set code of permission
*
* @param code Code
* @param codeId Code
*/
@XmlElement(name = "code")
public void setCodeId(String codeId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public static Credential sellerCredential(String email, String token) {
* @param appId The Application id
* @param appKey Specifies the corresponding token to PagSeguro application that is making the
* request.
* @return ApplicationCredential
*/
public static Credential applicationCredential(String appId, String appKey) {
return new ApplicationCredential(appId, appKey);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ public interface CredentialProvider {
/**
* Get credential
*
* @return The credential used by user.
* @see Credential
* @return The credential used by user.
* @throws Exception if a problem occurs
*/
Credential getCredential() throws Exception;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ public interface EnvironmentProvider {
/**
* Get configurations environment
*
* @return Configurations environment
* @see PagSeguroEnv
* @return Configurations environment
* @throws Exception if a problem occurs
*/
PagSeguroEnv getEnvironment() throws Exception;
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ private String appendParameters(String uri) throws UnsupportedEncodingException,
*
* @param uri Url
* @return Url with correlation id
* @throws URISyntaxException if invalid url is used
* @throws UnsupportedEncodingException if not accepted encode is used
*/
public String appendCorrelationId(String uri) throws URISyntaxException,
UnsupportedEncodingException {
Expand All @@ -125,6 +127,8 @@ public String appendCorrelationId(String uri) throws URISyntaxException,
*
* @param uri Url
* @return Url with credential
* @throws URISyntaxException if invalid url is used
* @throws UnsupportedEncodingException if not accepted encode is used
*/
public String appendCredential(String uri) throws URISyntaxException,
UnsupportedEncodingException {
Expand Down
Loading