Skip to content
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
37 changes: 37 additions & 0 deletions src/main/java/br/com/userede/erede/AbstractTransaction.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,15 @@ public class AbstractTransaction<C> {
@SerializedName("links")
private List<Link> links;

@SerializedName("SubMerchant")
private SubMerchant submerchant;

@SerializedName("PaymentFacilitatorID")
private Long paymentFacilitatorID;

@SerializedName("IndependentSalesOrganizationID")
private String independentSalesOrganizationID;

private void prepareUrls() {
if (urls == null) {
urls = new ArrayList<>();
Expand Down Expand Up @@ -446,4 +455,32 @@ public AbstractTransaction<C> setLinks(List<Link> links) {
this.links = links;
return this;
}

public SubMerchant getSubmerchant() {
return submerchant;
}

public AbstractTransaction<C> setSubmerchant(SubMerchant submerchant) {
this.submerchant = submerchant;
return this;
}

public Long getPaymentFacilitatorID() {
return paymentFacilitatorID;
}

public AbstractTransaction<C> setPaymentFacilitatorID(Long paymentFacilitatorID) {
this.paymentFacilitatorID = paymentFacilitatorID;
return this;
}

public String getIndependentSalesOrganizationID() {
return independentSalesOrganizationID;
}

public AbstractTransaction<C> setIndependentSalesOrganizationID(String independentSalesOrganizationID) {
this.independentSalesOrganizationID = independentSalesOrganizationID;
return this;
}

}
19 changes: 19 additions & 0 deletions src/main/java/br/com/userede/erede/Authorization.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ public class Authorization {
@SerializedName("tid")
private String tid;

@SerializedName("brand")
private Brand brand;

public String getAffiliation() {
return affiliation;
}
Expand All @@ -74,6 +77,13 @@ public Authorization setAmount(int amount) {
}

public String getAuthorizationCode() {
if (brand != null) {
authorizationCode = brand.getAuthorizationCode();
}

if (authorizationCode != null) {
authorizationCode = authorizationCode.isEmpty() ? null : authorizationCode;
}
return authorizationCode;
}

Expand Down Expand Up @@ -207,4 +217,13 @@ public Authorization setTid(String tid) {
this.tid = tid;
return this;
}

public Brand getBrand() {
return brand;
}

public Authorization setBrand(Brand brand) {
this.brand = brand;
return this;
}
}
55 changes: 55 additions & 0 deletions src/main/java/br/com/userede/erede/Brand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package br.com.userede.erede;

import com.google.gson.annotations.SerializedName;

public class Brand {

@SerializedName("name")
private String name;

@SerializedName("returnCode")
private String returnCode;

@SerializedName("returnMessage")
private String returnMessage;

@SerializedName("authorizationCode")
private String authorizationCode;

public String getName() {
return name;
}

public Brand setName(String name) {
this.name = name;
return this;
}

public String getReturnCode() {
return returnCode;
}

public Brand setReturnCode(String returnCode) {
this.returnCode = returnCode;
return this;
}

public String getReturnMessage() {
return returnMessage;
}

public Brand setReturnMessage(String returnMessage) {
this.returnMessage = returnMessage;
return this;
}

public String getAuthorizationCode() {
return authorizationCode;
}

public Brand setAuthorizationCode(String authorizationCode) {
this.authorizationCode = authorizationCode;
return this;
}

}
9 changes: 9 additions & 0 deletions src/main/java/br/com/userede/erede/Store.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ public class Store {
private Environment environment;
private String filiation;
private String token;
private Boolean brandReturnOpen;

public Store(String filiation, String token, Environment environment) {
this.environment = environment;
Expand Down Expand Up @@ -42,4 +43,12 @@ public Store setToken(String token) {
this.token = token;
return this;
}

public Boolean getBrandReturnOpen() {
return brandReturnOpen;
}

public void setBrandReturnOpen(Boolean brandReturnOpen) {
this.brandReturnOpen = brandReturnOpen;
}
}
103 changes: 103 additions & 0 deletions src/main/java/br/com/userede/erede/SubMerchant.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
package br.com.userede.erede;

import com.google.gson.annotations.SerializedName;

public class SubMerchant {

@SerializedName("MCC")
private Long mcc;

@SerializedName("SubMerchantID")
private String submerchantID;

@SerializedName("Address")
private String address;

@SerializedName("City")
private String city;

@SerializedName("State")
private String state;

@SerializedName("Country")
private String country;

@SerializedName("Cep")
private String cep;

@SerializedName("Cnpj")
private String cnpj;

public Long getMcc() {
return mcc;
}

public SubMerchant setMcc(Long mcc) {
this.mcc = mcc;
return this;
}

public String getSubmerchantID() {
return submerchantID;
}

public SubMerchant setSubmerchantID(String submerchantID) {
this.submerchantID = submerchantID;
return this;
}

public String getAddress() {
return address;
}

public SubMerchant setAddress(String address) {
this.address = address;
return this;
}

public String getCity() {
return city;
}

public SubMerchant setCity(String city) {
this.city = city;
return this;
}

public String getState() {
return state;
}

public SubMerchant setState(String state) {
this.state = state;
return this;
}

public String getCountry() {
return country;
}

public SubMerchant setCountry(String country) {
this.country = country;
return this;
}

public String getCep() {
return cep;
}

public SubMerchant setCep(String cep) {
this.cep = cep;
return this;
}

public String getCnpj() {
return cnpj;
}

public SubMerchant setCnpj(String cnpj) {
this.cnpj = cnpj;
return this;
}

}
2 changes: 1 addition & 1 deletion src/main/java/br/com/userede/erede/Transaction.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public Transaction(double amount, String reference) {
setReference(reference);
}

public Transaction(int amount, String reference) {
public Transaction(Integer amount, String reference) {
setAmount(amount);
setReference(reference);
}
Expand Down
27 changes: 18 additions & 9 deletions src/main/java/br/com/userede/erede/eRede.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package br.com.userede.erede;

import java.io.IOException;
import java.net.URISyntaxException;
import java.util.logging.Logger;

import br.com.userede.erede.service.CancelTransactionService;
import br.com.userede.erede.service.CaptureTransactionService;
import br.com.userede.erede.service.CreateTransactionService;
import br.com.userede.erede.service.GetTransactionService;
import java.util.logging.Logger;

public class eRede {

Expand All @@ -24,54 +27,60 @@ public eRede(Store store, Logger logger) {
this.logger = logger;
}

public TransactionResponse authorize(Transaction transaction) {
public TransactionResponse authorize(Transaction transaction) throws URISyntaxException, IOException {
return create(transaction);
}

public TransactionResponse create(Transaction transaction) {
public TransactionResponse create(Transaction transaction) throws URISyntaxException, IOException {
CreateTransactionService createTransactionService = new CreateTransactionService(store,
transaction, logger);
createTransactionService.setUserAgent(String.format(eRede.USER_AGENT, store.getFiliation()));

return createTransactionService.execute();
}

public TransactionResponse cancel(Transaction transaction) {
public TransactionResponse cancel(Transaction transaction) throws IOException, URISyntaxException {
CancelTransactionService cancelTransactionService = new CancelTransactionService(store,
transaction, logger);
cancelTransactionService.setUserAgent(String.format(eRede.USER_AGENT, store.getFiliation()));

return cancelTransactionService.execute();
}

public TransactionResponse capture(Transaction transaction) {
public TransactionResponse capture(Transaction transaction) throws IOException, URISyntaxException {
CaptureTransactionService captureTransactionService = new CaptureTransactionService(store,
transaction, logger);
captureTransactionService.setUserAgent(String.format(eRede.USER_AGENT, store.getFiliation()));

return captureTransactionService.execute();
}

public TransactionResponse get(String tid) {
public TransactionResponse get(String tid) throws IOException, URISyntaxException {
GetTransactionService getTransactionService = new GetTransactionService(store, null, logger);
getTransactionService.setTid(tid);
getTransactionService.setUserAgent(String.format(eRede.USER_AGENT, store.getFiliation()));

return getTransactionService.execute();
}

public TransactionResponse getByReference(String reference) {
public TransactionResponse getByReference(String reference) throws IOException, URISyntaxException {
GetTransactionService getTransactionService = new GetTransactionService(store, null, logger);
getTransactionService.setReference(reference);
getTransactionService.setUserAgent(String.format(eRede.USER_AGENT, store.getFiliation()));

return getTransactionService.execute();
}

public TransactionResponse getRefunds(String tid) {
public TransactionResponse getRefunds(String tid) throws IOException, URISyntaxException {
GetTransactionService getTransactionService = new GetTransactionService(store, null, logger);
getTransactionService.setTid(tid);
getTransactionService.setRefund(true);
getTransactionService.setUserAgent(String.format(eRede.USER_AGENT, store.getFiliation()));

return getTransactionService.execute();
}

public TransactionResponse zero(Transaction transaction) {
public TransactionResponse zero(Transaction transaction) throws Exception {
transaction.setAmount(0);
transaction.capture();

Expand Down
Loading