diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..973ec05 --- /dev/null +++ b/.classpath @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1e926af --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +target/ +.settings +src/main/java/br/com/efi/open_accounts/ \ No newline at end of file diff --git a/.project b/.project new file mode 100644 index 0000000..e96cd86 --- /dev/null +++ b/.project @@ -0,0 +1,34 @@ + + + sdk-java-examples-apis-efi + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + + + 1665497833948 + + 30 + + org.eclipse.core.resources.regexFilterMatcher + node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ + + + + diff --git a/README-en.md b/README-en.md new file mode 100644 index 0000000..01d3f9c --- /dev/null +++ b/README-en.md @@ -0,0 +1,26 @@ +

Java SDK for APIs Efí Pay using Examples

+ +![Banner APIs Efí Pay](https://gnetbr.com/BJgSIUhlYs) + +

+ Portuguese | + English +

+ +This project has some java file examples to test the Java SDK for efi API. + +## Requirements +* Java >= 7.0 + +## Running examples +Update the src/main/resources/credentials.json file with client_id, client_secret and certificate of your application. + +You can run using any Java IDE, like Eclipse or Netbeans, with Maven plugin installed, and follow these steps: +1. clone this git repository in a local directory of your choice; +2. on your IDE, open the folder as a Maven project. It'll download sdk-java-apis-efi as a dependencie; +3. choose any project's example and run it as a Java Application. The result will be displayed on the console. + +**Warning:** Some examples require you to change some parameters to work, like br.com.efi.charges.carnet.json.DetailCarnet.java where you must change the id parameter. + + + diff --git a/README.md b/README.md index ac7e0fd..a995ca6 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,30 @@ -# sdk-java-examples-apis-efi +

SDK Java para APIs Efí Pay usando Examplos

+ +![Banner APIs Efí Pay](https://gnetbr.com/BJgSIUhlYs) + +

+ Português | + Inglês +

+ Este projeto contém alguns exemplos de arquivos java para testar a SDK Java para APIs Efí Pay + +## Requisitos +* Java >= 7.0 + +## Execução de exemplos + +Atualize o arquivo src/main/resources/credentials.json com client_id, client_secret e certificate de seu aplicativo. + +Você pode rodar usando qualquer IDE Java, como Eclipse ou Netbeans, com o plugin Maven instalado, e seguir os seguintes passos: +1. clone este repositório git em um diretório local de sua escolha; +2. em sua IDE, abra a pasta como um projeto Maven. Ele fará o download do sdk-java-apis-efi como uma dependência; +3. escolha qualquer exemplo de projeto e execute-o como um aplicativo Java. O resultado será exibido no console. + +**Aviso:** Alguns exemplos requerem que você altere alguns parâmetros para funcionar, como br.com.efi.charges.carnet.json.DetailCarnet.java onde você deve alterar o parâmetro id. + + + + + + diff --git a/certs/developmentCertificate.p12 b/certs/developmentCertificate.p12 new file mode 100644 index 0000000..e69de29 diff --git a/certs/productionCertificate.p12 b/certs/productionCertificate.p12 new file mode 100644 index 0000000..e69de29 diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..e0baa20 --- /dev/null +++ b/pom.xml @@ -0,0 +1,35 @@ + + 4.0.0 + br.com.efipay + sdk-java-examples-apis-efi + 0.0.1-SNAPSHOT + + + UTF-8 + UTF-8 + + + + + br.com.efipay.efisdk + sdk-java-apis-efi + 1.0.0 + + + javax.xml.bind + jaxb-api + 2.3.1 + + + com.sun.xml.bind + jaxb-impl + 2.3.0 + + + com.sun.xml.bind + jaxb-core + 2.3.0 + + + diff --git a/src/main/java/br/com/efi/Credentials.java b/src/main/java/br/com/efi/Credentials.java new file mode 100644 index 0000000..5ca5ab9 --- /dev/null +++ b/src/main/java/br/com/efi/Credentials.java @@ -0,0 +1,53 @@ +package br.com.efi; + +import java.io.IOException; +import java.io.InputStream; +import org.json.JSONObject; +import org.json.JSONTokener; + +public class Credentials { + private String clientId; + private String clientSecret; + private String certificate; + private boolean sandbox; + private boolean debug; + + public Credentials() { + ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); + InputStream credentialsFile = classLoader.getResourceAsStream("credentials.json"); + JSONTokener tokener = new JSONTokener(credentialsFile); + JSONObject credentials = new JSONObject(tokener); + try { + credentialsFile.close(); + } catch (IOException e) { + System.out.println("Impossible to close file credentials.json"); + } + + this.clientId = credentials.getString("client_id"); + this.clientSecret = credentials.getString("client_secret"); + this.certificate = credentials.getString("certificate"); + this.sandbox = credentials.getBoolean("sandbox"); + this.debug = credentials.getBoolean("debug"); + } + + public String getClientId() { + return clientId; + } + + public String getClientSecret() { + return clientSecret; + } + + public String getCertificate() { + return certificate; + } + + public boolean isSandbox() { + return sandbox; + } + + public boolean isDebug() { + return debug; + } + +} diff --git a/src/main/java/br/com/efi/charges/billet/json/CancelBillet.java b/src/main/java/br/com/efi/charges/billet/json/CancelBillet.java new file mode 100644 index 0000000..ca144e3 --- /dev/null +++ b/src/main/java/br/com/efi/charges/billet/json/CancelBillet.java @@ -0,0 +1,40 @@ +package br.com.efi.charges.billet.json; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class CancelBillet { + public static void main(String[] args) { + /* ********* Set credential parameters ******** */ + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("cancelCharge", params, new JSONObject()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/billet/json/CreateBilletHistory.java b/src/main/java/br/com/efi/charges/billet/json/CreateBilletHistory.java new file mode 100644 index 0000000..6133183 --- /dev/null +++ b/src/main/java/br/com/efi/charges/billet/json/CreateBilletHistory.java @@ -0,0 +1,43 @@ +package br.com.efi.charges.billet.json; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class CreateBilletHistory { + public static void main(String[] args) { + /* ********* Set credential parameters ******** */ + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + JSONObject body = new JSONObject(); + body.put("description", "This charge was not fully paid"); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("createChargeHistory", params, body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/billet/json/CreateCharge.java b/src/main/java/br/com/efi/charges/billet/json/CreateCharge.java new file mode 100644 index 0000000..b84e649 --- /dev/null +++ b/src/main/java/br/com/efi/charges/billet/json/CreateCharge.java @@ -0,0 +1,52 @@ +package br.com.efi.charges.billet.json; + +import java.util.HashMap; +import org.json.JSONArray; +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class CreateCharge { + public static void main(String[] args) { + /* ********* Set credentials parameters ******** */ + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + JSONArray items = new JSONArray(); + + JSONObject item1 = new JSONObject(); + item1.put("name", "Item 1"); + item1.put("amount", 1); + item1.put("value", 2000); + + JSONObject item2 = new JSONObject("{\"name\":\"Item 1\", \"amount\":1, \"value\":1}"); + + items.put(item1); + items.put(item2); + + JSONObject body = new JSONObject(); + body.put("items", items); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("createCharge", new HashMap(), body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/billet/json/CreateOneStepBillet.java b/src/main/java/br/com/efi/charges/billet/json/CreateOneStepBillet.java new file mode 100644 index 0000000..858204e --- /dev/null +++ b/src/main/java/br/com/efi/charges/billet/json/CreateOneStepBillet.java @@ -0,0 +1,95 @@ +package br.com.efi.charges.billet.json; + +import java.util.HashMap; + +import org.json.JSONArray; +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class CreateOneStepBillet { + public static void main(String[] args) { + /* ********* Set credentials parameters ******** */ + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + // items + JSONArray items = new JSONArray(); + + JSONObject item1 = new JSONObject(); + item1.put("name", "Item 4"); + item1.put("amount", 1); + item1.put("value", 5000); + + JSONObject item2 = new JSONObject("{\"name\":\"Item 2\", \"amount\":1, \"value\":1000}"); + + items.put(item1); + items.put(item2); + + //customer + JSONObject customer = new JSONObject(); + customer.put("name", "Gorbadoc Oldbuck"); + customer.put("cpf", "94271564656"); + customer.put("phone_number", "5144916523"); + + //notification url + JSONObject metadata = new JSONObject(); + metadata.put("notification_url", "https://seudominio.com.br"); + + //discount + JSONObject discount = new JSONObject(); + discount.put("type","currency"); + discount.put("value",599); + + //configurations + JSONObject configurations = new JSONObject(); + configurations.put("fine", 200); + configurations.put("interest", 100); + + //conditional discount + JSONObject conditional_discount = new JSONObject(); + conditional_discount.put("type","percentage"); + conditional_discount.put("value", 500); + conditional_discount.put("until_date", "2023-01-29"); + + + JSONObject bankingBillet = new JSONObject(); + bankingBillet.put("expire_at", "2023-01-30"); + bankingBillet.put("customer", customer); + bankingBillet.put("discount", discount); + bankingBillet.put("configurations", configurations); + bankingBillet.put("conditional_discount", conditional_discount); + bankingBillet.put("message", "Pague pelo código de barras ou pelo QR Code"); + + + JSONObject payment = new JSONObject(); + payment.put("banking_billet", bankingBillet); + + JSONObject body = new JSONObject(); + body.put("payment", payment); + body.put("items", items); + body.put("metadata", metadata); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("createOneStepCharge", new HashMap(), body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/billet/json/DefineBalanceSheetBillet.java b/src/main/java/br/com/efi/charges/billet/json/DefineBalanceSheetBillet.java new file mode 100644 index 0000000..682575b --- /dev/null +++ b/src/main/java/br/com/efi/charges/billet/json/DefineBalanceSheetBillet.java @@ -0,0 +1,123 @@ +package br.com.efi.charges.billet.json; + +import java.util.HashMap; + +import org.json.JSONArray; +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class DefineBalanceSheetBillet { + public static void main(String[] args) { + /* ********* Set credential parameters ******** */ + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + JSONObject defOne = new JSONObject(); + defOne.put("align", "left"); + defOne.put("color", "#000000"); + defOne.put("style", "bold"); + defOne.put("text", "Exemplo de despesa"); + defOne.put("colspan", 2); + + JSONObject defTwo = new JSONObject(); + defTwo.put("align", "left"); + defTwo.put("color", "#000000"); + defTwo.put("style", "bold"); + defTwo.put("text", "Total lan�ado"); + defTwo.put("colspan", 2); + + JSONArray rowOne = new JSONArray(); + rowOne.put(defOne); + rowOne.put(defTwo); + + JSONObject defThree = new JSONObject(); + defThree.put("align", "left"); + defThree.put("color", "#000000"); + defThree.put("style", "normal"); + defThree.put("text", "Instala��o"); + defThree.put("colspan", 2); + + JSONObject defFour = new JSONObject(); + defFour.put("align", "left"); + defFour.put("color", "#000000"); + defFour.put("style", "normal"); + defFour.put("text", "R$ 100,00"); + defFour.put("colspan", 2); + + JSONArray rowTwo = new JSONArray(); + rowTwo.put(defThree); + rowTwo.put(defFour); + + JSONArray rowsSideOne = new JSONArray(); + rowsSideOne.put(rowOne); + rowsSideOne.put(rowTwo); + + JSONObject rowObjectSideOne = new JSONObject(); + rowObjectSideOne.put("rows", rowsSideOne); + + JSONArray tablesSideOne = new JSONArray(); + tablesSideOne.put(rowObjectSideOne); + + JSONObject sideOne = new JSONObject(); + sideOne.put("header", "Demonstrativo de Consumo"); + sideOne.put("tables", tablesSideOne); + + JSONObject defFive = new JSONObject(); + defFive.put("align", "left"); + defFive.put("color", "#000000"); + defFive.put("style", "normal"); + defFive.put("text", "Confira na documenta��o da efi todas as configura��es poss�veis de um boleto balancete."); + defFive.put("colspan", 4); + + JSONArray rowThree = new JSONArray(); + rowThree.put(defFive); + + JSONArray rowsSideTwo = new JSONArray(); + rowsSideTwo.put(rowThree); + + JSONObject rowObjectSideTwo = new JSONObject(); + rowObjectSideTwo.put("rows", rowsSideTwo); + + JSONArray tablesSideTwo = new JSONArray(); + tablesSideTwo.put(rowObjectSideTwo); + + JSONObject sideTwo = new JSONObject(); + sideTwo.put("header", "Balancete Geral"); + sideTwo.put("tables", tablesSideTwo); + + JSONArray balanceSheet = new JSONArray(); + balanceSheet.put(sideOne); + balanceSheet.put(sideTwo); + + JSONObject body = new JSONObject(); + body.put("title", "Balancete Demonstrativo"); + body.put("body", balanceSheet); + + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("defineBalanceSheetBillet", params, body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/billet/json/DefineBilletPayMethod.java b/src/main/java/br/com/efi/charges/billet/json/DefineBilletPayMethod.java new file mode 100644 index 0000000..b597377 --- /dev/null +++ b/src/main/java/br/com/efi/charges/billet/json/DefineBilletPayMethod.java @@ -0,0 +1,56 @@ +package br.com.efi.charges.billet.json; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class DefineBilletPayMethod { + public static void main(String[] args) { + /* ********* Set credentials parameters ******** */ + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + + HashMap params = new HashMap(); + params.put("id", "0"); + + JSONObject customer = new JSONObject(); + customer.put("name", "Gorbadoc Oldbuck"); + customer.put("cpf", "94271564656"); + customer.put("phone_number", "5144916523"); + + JSONObject bankingBillet = new JSONObject(); + bankingBillet.put("expire_at", "2023-12-12"); + bankingBillet.put("customer", customer); + + JSONObject payment = new JSONObject(); + payment.put("banking_billet", bankingBillet); + + JSONObject body = new JSONObject(); + body.put("payment", payment); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("definePayMethod", params, body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/billet/json/DetailBillet.java b/src/main/java/br/com/efi/charges/billet/json/DetailBillet.java new file mode 100644 index 0000000..ed71e1d --- /dev/null +++ b/src/main/java/br/com/efi/charges/billet/json/DetailBillet.java @@ -0,0 +1,40 @@ +package br.com.efi.charges.billet.json; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class DetailBillet { + public static void main(String[] args) { + /* ********* Set credential parameters ******** */ + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("detailCharge", params, new JSONObject()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/billet/json/SendBilletEmail.java b/src/main/java/br/com/efi/charges/billet/json/SendBilletEmail.java new file mode 100644 index 0000000..fba5869 --- /dev/null +++ b/src/main/java/br/com/efi/charges/billet/json/SendBilletEmail.java @@ -0,0 +1,43 @@ +package br.com.efi.charges.billet.json; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class SendBilletEmail { + public static void main(String[] args) { + /* ********* Set credential parameters ******** */ + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + JSONObject body = new JSONObject(); + body.put("email", "client_email@server.com.br"); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("sendBilletEmail", params, body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/billet/json/SettleBillet.java b/src/main/java/br/com/efi/charges/billet/json/SettleBillet.java new file mode 100644 index 0000000..63a697e --- /dev/null +++ b/src/main/java/br/com/efi/charges/billet/json/SettleBillet.java @@ -0,0 +1,40 @@ +package br.com.efi.charges.billet.json; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class SettleBillet { + public static void main(String[] args) { + /* ********* Set credential parameters ******** */ + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("settleCharge", params, new JSONObject()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/billet/json/UpdateBillet.java b/src/main/java/br/com/efi/charges/billet/json/UpdateBillet.java new file mode 100644 index 0000000..2d4b4f3 --- /dev/null +++ b/src/main/java/br/com/efi/charges/billet/json/UpdateBillet.java @@ -0,0 +1,43 @@ +package br.com.efi.charges.billet.json; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class UpdateBillet { + public static void main(String[] args) { + /* ********* Set credential parameters ******** */ + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + JSONObject body = new JSONObject(); + body.put("expire_at", "2020-12-12"); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("updateBillet", params, body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/billet/json/UpdateBilletMetadata.java b/src/main/java/br/com/efi/charges/billet/json/UpdateBilletMetadata.java new file mode 100644 index 0000000..6987873 --- /dev/null +++ b/src/main/java/br/com/efi/charges/billet/json/UpdateBilletMetadata.java @@ -0,0 +1,44 @@ +package br.com.efi.charges.billet.json; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class UpdateBilletMetadata { + public static void main(String[] args) { + /* ********* Set credential parameters ******** */ + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + JSONObject body = new JSONObject(); + body.put("custom_id", "Product 0001"); + body.put("notification_url", "http://domain.com/notification"); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("updateChargeMetadata", params, body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/billet/map/CancelBillet.java b/src/main/java/br/com/efi/charges/billet/map/CancelBillet.java new file mode 100644 index 0000000..07c12c8 --- /dev/null +++ b/src/main/java/br/com/efi/charges/billet/map/CancelBillet.java @@ -0,0 +1,39 @@ +package br.com.efi.charges.billet.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class CancelBillet { + public static void main(String[] args) { + /* ********* Set credential parameters ******** */ + + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("cancelCharge", params, new HashMap()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/billet/map/CreateBilletHistory.java b/src/main/java/br/com/efi/charges/billet/map/CreateBilletHistory.java new file mode 100644 index 0000000..93ad4dc --- /dev/null +++ b/src/main/java/br/com/efi/charges/billet/map/CreateBilletHistory.java @@ -0,0 +1,42 @@ +package br.com.efi.charges.billet.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class CreateBilletHistory { + public static void main(String[] args) { + /* ********* Set credential parameters ******** */ + + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + Map body = new HashMap(); + body.put("description", "This charge was not fully paid"); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("createChargeHistory", params, body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/billet/map/CreateCharge.java b/src/main/java/br/com/efi/charges/billet/map/CreateCharge.java new file mode 100644 index 0000000..4407172 --- /dev/null +++ b/src/main/java/br/com/efi/charges/billet/map/CreateCharge.java @@ -0,0 +1,56 @@ +package br.com.efi.charges.billet.map; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class CreateCharge { + public static void main(String[] args) { + /* ********* Set credentials parameters ******** */ + + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + List items = new ArrayList(); + + Map item1 = new HashMap(); + item1.put("name", "Item 1"); + item1.put("amount", 1); + item1.put("value", 1000); + + Map item2 = new HashMap(); + item2.put("name", "Item 2"); + item2.put("amount", 1); + item2.put("value", 2000); + + items.add(item1); + items.add(item2); + + Map body = new HashMap(); + body.put("items", items); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("createCharge", new HashMap(), body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/billet/map/CreateOneStepBillet.java b/src/main/java/br/com/efi/charges/billet/map/CreateOneStepBillet.java new file mode 100644 index 0000000..7908deb --- /dev/null +++ b/src/main/java/br/com/efi/charges/billet/map/CreateOneStepBillet.java @@ -0,0 +1,65 @@ +package br.com.efi.charges.billet.map; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class CreateOneStepBillet { + public static void main(String[] args) { + + /* ********* Set credentials parameters ******** */ + Credentials credentials = new Credentials(); + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + List items = new ArrayList(); + Map item1 = new HashMap(); + item1.put("name", "Item 1"); + item1.put("amount", 1); + item1.put("value", 1000); + + Map item2 = new HashMap(); + item2.put("name", "Item 2"); + item2.put("amount", 1); + item2.put("value", 2000); + items.add(item1); + items.add(item2); + + Map customer = new HashMap(); + customer.put("name", "Gorbadoc Oldbuck"); + customer.put("cpf", "94271564656"); + customer.put("phone_number", "5144916523"); + + Map bankingBillet = new HashMap(); + bankingBillet.put("expire_at", "2019-08-29"); + bankingBillet.put("customer", customer); + + Map payment = new HashMap(); + payment.put("banking_billet", bankingBillet); + + Map body = new HashMap(); + body.put("payment", payment); + body.put("items", items); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("createOneStepCharge", new HashMap(), body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/billet/map/DefineBalanceSheetBillet.java b/src/main/java/br/com/efi/charges/billet/map/DefineBalanceSheetBillet.java new file mode 100644 index 0000000..ffedf76 --- /dev/null +++ b/src/main/java/br/com/efi/charges/billet/map/DefineBalanceSheetBillet.java @@ -0,0 +1,122 @@ +package br.com.efi.charges.billet.map; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class DefineBalanceSheetBillet { + public static void main(String[] args) { + /* ********* Set credentials parameters ******** */ + + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "1"); + + Map defOne = new HashMap(); + defOne.put("align", "left"); + defOne.put("color", "#000000"); + defOne.put("style", "bold"); + defOne.put("text", "Exemplo de despesa"); + defOne.put("colspan", 2); + + Map defTwo = new HashMap(); + defTwo.put("align", "left"); + defTwo.put("color", "#000000"); + defTwo.put("style", "bold"); + defTwo.put("text", "Total lan�ado"); + defTwo.put("colspan", 2); + + List rowOne = new ArrayList(); + rowOne.add(defOne); + rowOne.add(defTwo); + + Map defThree = new HashMap(); + defThree.put("align", "left"); + defThree.put("color", "#000000"); + defThree.put("style", "normal"); + defThree.put("text", "Instala��o"); + defThree.put("colspan", 2); + + Map defFour = new HashMap(); + defFour.put("align", "left"); + defFour.put("color", "#000000"); + defFour.put("style", "normal"); + defFour.put("text", "R$ 100,00"); + defFour.put("colspan", 2); + + List rowTwo = new ArrayList(); + rowTwo.add(defThree); + rowTwo.add(defFour); + + List rowsSideOne = new ArrayList(); + rowsSideOne.add(rowOne); + rowsSideOne.add(rowTwo); + + Map rowObjectSideOne = new HashMap(); + rowObjectSideOne.put("rows", rowsSideOne); + + List tablesSideOne = new ArrayList(); + tablesSideOne.add(rowObjectSideOne); + + Map sideOne = new HashMap(); + sideOne.put("header", "Demonstrativo de Consumo"); + sideOne.put("tables", tablesSideOne); + + Map defFive = new HashMap(); + defFive.put("align", "left"); + defFive.put("color", "#000000"); + defFive.put("style", "normal"); + defFive.put("text", "Confira na documenta��o da efi todas as configura��es poss�veis de um boleto balancete."); + defFive.put("colspan", 4); + + List rowThree = new ArrayList(); + rowThree.add(defFive); + + List rowsSideTwo = new ArrayList(); + rowsSideTwo.add(rowThree); + + Map rowObjectSideTwo = new HashMap(); + rowObjectSideTwo.put("rows", rowsSideTwo); + + List tablesSideTwo = new ArrayList(); + tablesSideTwo.add(rowObjectSideTwo); + + Map sideTwo = new HashMap(); + sideTwo.put("header", "Balancete Geral"); + sideTwo.put("tables", tablesSideTwo); + + List balanceSheet = new ArrayList(); + balanceSheet.add(sideOne); + balanceSheet.add(sideTwo); + + Map body = new HashMap(); + body.put("title", "Balancete Demonstrativo"); + body.put("body", balanceSheet); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("defineBalanceSheetBillet", params, body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/billet/map/DefineBilletPayMethod.java b/src/main/java/br/com/efi/charges/billet/map/DefineBilletPayMethod.java new file mode 100644 index 0000000..dbdb3a3 --- /dev/null +++ b/src/main/java/br/com/efi/charges/billet/map/DefineBilletPayMethod.java @@ -0,0 +1,54 @@ +package br.com.efi.charges.billet.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class DefineBilletPayMethod { + public static void main(String[] args) { + /* ********* Set credentials parameters ******** */ + + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + Map customer = new HashMap(); + customer.put("name", "Gorbadoc Oldbuck"); + customer.put("cpf", "94271564656"); + customer.put("phone_number", "5144916523"); + + Map bankingBillet = new HashMap(); + bankingBillet.put("expire_at", "2018-12-12"); + bankingBillet.put("customer", customer); + + Map payment = new HashMap(); + payment.put("banking_billet", bankingBillet); + + Map body = new HashMap(); + body.put("payment", payment); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("definePayMethod", params, body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/billet/map/DetailBillet.java b/src/main/java/br/com/efi/charges/billet/map/DetailBillet.java new file mode 100644 index 0000000..2ada9e5 --- /dev/null +++ b/src/main/java/br/com/efi/charges/billet/map/DetailBillet.java @@ -0,0 +1,39 @@ +package br.com.efi.charges.billet.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class DetailBillet { + public static void main(String[] args) { + /* ********* Set credential parameters ******** */ + + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("detailCharge", params, new HashMap()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/billet/map/SendBilletEmail.java b/src/main/java/br/com/efi/charges/billet/map/SendBilletEmail.java new file mode 100644 index 0000000..aaeb4f9 --- /dev/null +++ b/src/main/java/br/com/efi/charges/billet/map/SendBilletEmail.java @@ -0,0 +1,42 @@ +package br.com.efi.charges.billet.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class SendBilletEmail { + public static void main(String[] args) { + /* ********* Set credential parameters ******** */ + + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + Map body = new HashMap(); + body.put("email", "client_email@server.com.br"); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("sendBilletEmail", params, body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/billet/map/SettleBillet.java b/src/main/java/br/com/efi/charges/billet/map/SettleBillet.java new file mode 100644 index 0000000..13ab2e2 --- /dev/null +++ b/src/main/java/br/com/efi/charges/billet/map/SettleBillet.java @@ -0,0 +1,39 @@ +package br.com.efi.charges.billet.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class SettleBillet { + public static void main(String[] args) { + /* ********* Set credential parameters ******** */ + + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("settleCharge", params, new HashMap()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/billet/map/UpdateBillet.java b/src/main/java/br/com/efi/charges/billet/map/UpdateBillet.java new file mode 100644 index 0000000..a1fef3d --- /dev/null +++ b/src/main/java/br/com/efi/charges/billet/map/UpdateBillet.java @@ -0,0 +1,42 @@ +package br.com.efi.charges.billet.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class UpdateBillet { + public static void main(String[] args) { + /* ********* Set credential parameters ******** */ + + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + Map body = new HashMap(); + body.put("expire_at", "2020-12-12"); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("updateBillet", params, body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/billet/map/UpdateBilletMetadata.java b/src/main/java/br/com/efi/charges/billet/map/UpdateBilletMetadata.java new file mode 100644 index 0000000..35d6c66 --- /dev/null +++ b/src/main/java/br/com/efi/charges/billet/map/UpdateBilletMetadata.java @@ -0,0 +1,43 @@ +package br.com.efi.charges.billet.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class UpdateBilletMetadata { + public static void main(String[] args) { + /* ********* Set credential parameters ******** */ + + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + Map body = new HashMap(); + body.put("custom_id", "Product 0001"); + body.put("notification_url", "http://domain.com/notification"); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("updateChargeMetadata", params, body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/card/json/CancelCard.java b/src/main/java/br/com/efi/charges/card/json/CancelCard.java new file mode 100644 index 0000000..8dcbea1 --- /dev/null +++ b/src/main/java/br/com/efi/charges/card/json/CancelCard.java @@ -0,0 +1,40 @@ +package br.com.efi.charges.card.json; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class CancelCard { + public static void main(String[] args) { + /* ********* Set credential parameters ******** */ + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("cancelCharge", params, new JSONObject()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/card/json/CreateCardHistory.java b/src/main/java/br/com/efi/charges/card/json/CreateCardHistory.java new file mode 100644 index 0000000..1bacba8 --- /dev/null +++ b/src/main/java/br/com/efi/charges/card/json/CreateCardHistory.java @@ -0,0 +1,43 @@ +package br.com.efi.charges.card.json; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class CreateCardHistory { + public static void main(String[] args) { + /* ********* Set credential parameters ******** */ + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + JSONObject body = new JSONObject(); + body.put("description", "This charge was not fully paid"); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("createChargeHistory", params, body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/card/json/CreateCharge.java b/src/main/java/br/com/efi/charges/card/json/CreateCharge.java new file mode 100644 index 0000000..05d19da --- /dev/null +++ b/src/main/java/br/com/efi/charges/card/json/CreateCharge.java @@ -0,0 +1,52 @@ +package br.com.efi.charges.card.json; + +import java.util.HashMap; +import org.json.JSONArray; +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class CreateCharge { + public static void main(String[] args) { + /* ********* Set credentials parameters ******** */ + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + JSONArray items = new JSONArray(); + + JSONObject item1 = new JSONObject(); + item1.put("name", "Item 1"); + item1.put("amount", 1); + item1.put("value", 2000); + + JSONObject item2 = new JSONObject("{\"name\":\"Item 1\", \"amount\":1, \"value\":1}"); + + items.put(item1); + items.put(item2); + + JSONObject body = new JSONObject(); + body.put("items", items); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("createCharge", new HashMap(), body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/card/json/CreateOneStepCard.java b/src/main/java/br/com/efi/charges/card/json/CreateOneStepCard.java new file mode 100644 index 0000000..1c510b5 --- /dev/null +++ b/src/main/java/br/com/efi/charges/card/json/CreateOneStepCard.java @@ -0,0 +1,89 @@ +package br.com.efi.charges.card.json; + +import java.util.HashMap; + +import org.json.JSONArray; +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class CreateOneStepCard { + public static void main(String[] args) { + + /* ********* Set credentials parameters ******** */ + Credentials credentials = new Credentials(); + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + /* ************************************************* */ + String paymentToken = "insira_seu_payment_token"; + + // items + JSONArray items = new JSONArray(); + JSONObject item1 = new JSONObject(); + item1.put("name", "Item 4"); + item1.put("amount", 1); + item1.put("value", 600); + JSONObject item2 = new JSONObject("{\"name\":\"Item 2\", \"amount\":1, \"value\":1000}"); + items.put(item1); + items.put(item2); + + //customer + JSONObject customer = new JSONObject(); + customer.put("name", "Gorbadoc Oldbuck"); + customer.put("cpf", "94271564656"); + customer.put("phone_number", "5144916523"); + customer.put("email", "client_email@server.com.br"); + customer.put("birth", "1990-05-04"); + + //address + JSONObject billingAddress = new JSONObject(); + billingAddress.put("street", "Av. JK"); + billingAddress.put("number", 909); + billingAddress.put("neighborhood", "Bauxita"); + billingAddress.put("zipcode", "35400000"); + billingAddress.put("city", "Ouro Preto"); + billingAddress.put("state", "MG"); + + //notification URL + JSONObject metadata = new JSONObject(); + metadata.put("notification_url", "https://requestb.in/16rpx6y1"); + metadata.put("custom_id", "id_0007"); + + //discount + JSONObject discount = new JSONObject(); + discount.put("type","currency"); + discount.put("value",599); + + JSONObject creditCard = new JSONObject(); + creditCard.put("installments", 1); + creditCard.put("billing_address", billingAddress); + creditCard.put("payment_token", paymentToken); + creditCard.put("customer", customer); + creditCard.put("discount", discount); + + JSONObject payment = new JSONObject(); + payment.put("credit_card", creditCard); + + JSONObject body = new JSONObject(); + body.put("payment", payment); + body.put("items", items); + body.put("metadata", metadata); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("createOneStepCharge", new HashMap(), body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} \ No newline at end of file diff --git a/src/main/java/br/com/efi/charges/card/json/DefineCardPayMethod.java b/src/main/java/br/com/efi/charges/card/json/DefineCardPayMethod.java new file mode 100644 index 0000000..d3d912b --- /dev/null +++ b/src/main/java/br/com/efi/charges/card/json/DefineCardPayMethod.java @@ -0,0 +1,69 @@ +package br.com.efi.charges.card.json; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class DefineCardPayMethod { + public static void main(String[] args) { + /* ********* Set credentials parameters ******** */ + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + String paymentToken = "Insira_aqui_o_payment_token"; + + JSONObject customer = new JSONObject(); + customer.put("name", "Gorbadoc Oldbuck"); + customer.put("cpf", "94271564656"); + customer.put("phone_number", "5144916523"); + customer.put("email", "client_email@server.com.br"); + customer.put("birth", "1977-01-15"); + + JSONObject billingAddress = new JSONObject(); + billingAddress.put("street", "Av. JK"); + billingAddress.put("number", 909); + billingAddress.put("neighborhood", "Bauxita"); + billingAddress.put("zipcode", "5400000"); + billingAddress.put("city", "Ouro Preto"); + billingAddress.put("state", "MG"); + + JSONObject creditCard = new JSONObject(); + creditCard.put("installments", 1); + creditCard.put("billing_address", billingAddress); + creditCard.put("payment_token", paymentToken); + creditCard.put("customer", customer); + + JSONObject payment = new JSONObject(); + payment.put("credit_card", creditCard); + + JSONObject body = new JSONObject(); + body.put("payment", payment); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("definePayMethod", params, body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/card/json/DetailCard.java b/src/main/java/br/com/efi/charges/card/json/DetailCard.java new file mode 100644 index 0000000..8ec82ee --- /dev/null +++ b/src/main/java/br/com/efi/charges/card/json/DetailCard.java @@ -0,0 +1,40 @@ +package br.com.efi.charges.card.json; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class DetailCard { + public static void main(String[] args) { + /* ********* Set credential parameters ******** */ + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("detailCharge", params, new JSONObject()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/card/json/GetInstallments.java b/src/main/java/br/com/efi/charges/card/json/GetInstallments.java new file mode 100644 index 0000000..9778bfd --- /dev/null +++ b/src/main/java/br/com/efi/charges/card/json/GetInstallments.java @@ -0,0 +1,41 @@ +package br.com.efi.charges.card.json; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class GetInstallments { + public static void main(String[] args) { + /* ********* Set credential parameters ******** */ + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("total", "20000"); + params.put("brand", "visa"); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("getInstallments", params, new JSONObject()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/card/json/UpdateCardMetadata.java b/src/main/java/br/com/efi/charges/card/json/UpdateCardMetadata.java new file mode 100644 index 0000000..434317c --- /dev/null +++ b/src/main/java/br/com/efi/charges/card/json/UpdateCardMetadata.java @@ -0,0 +1,44 @@ +package br.com.efi.charges.card.json; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class UpdateCardMetadata { + public static void main(String[] args) { + /* ********* Set credential parameters ******** */ + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + JSONObject body = new JSONObject(); + body.put("custom_id", "Product 0001"); + body.put("notification_url", "http://domain.com/notification"); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("updateChargeMetadata", params, body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/card/map/CancelCard.java b/src/main/java/br/com/efi/charges/card/map/CancelCard.java new file mode 100644 index 0000000..925363f --- /dev/null +++ b/src/main/java/br/com/efi/charges/card/map/CancelCard.java @@ -0,0 +1,39 @@ +package br.com.efi.charges.card.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class CancelCard { + public static void main(String[] args) { + /* ********* Set credential parameters ******** */ + + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("cancelCharge", params, new HashMap()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/card/map/CreateCardHistory.java b/src/main/java/br/com/efi/charges/card/map/CreateCardHistory.java new file mode 100644 index 0000000..c5fdd07 --- /dev/null +++ b/src/main/java/br/com/efi/charges/card/map/CreateCardHistory.java @@ -0,0 +1,42 @@ +package br.com.efi.charges.card.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class CreateCardHistory { + public static void main(String[] args) { + /* ********* Set credential parameters ******** */ + + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + Map body = new HashMap(); + body.put("description", "This charge was not fully paid"); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("createChargeHistory", params, body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/card/map/CreateCharge.java b/src/main/java/br/com/efi/charges/card/map/CreateCharge.java new file mode 100644 index 0000000..3a43176 --- /dev/null +++ b/src/main/java/br/com/efi/charges/card/map/CreateCharge.java @@ -0,0 +1,56 @@ +package br.com.efi.charges.card.map; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class CreateCharge { + public static void main(String[] args) { + /* ********* Set credentials parameters ******** */ + + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + List items = new ArrayList(); + + Map item1 = new HashMap(); + item1.put("name", "Item 1"); + item1.put("amount", 1); + item1.put("value", 1000); + + Map item2 = new HashMap(); + item2.put("name", "Item 2"); + item2.put("amount", 1); + item2.put("value", 2000); + + items.add(item1); + items.add(item2); + + Map body = new HashMap(); + body.put("items", items); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("createCharge", new HashMap(), body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/card/map/CreateOneStepCard.java b/src/main/java/br/com/efi/charges/card/map/CreateOneStepCard.java new file mode 100644 index 0000000..2fc774b --- /dev/null +++ b/src/main/java/br/com/efi/charges/card/map/CreateOneStepCard.java @@ -0,0 +1,73 @@ +package br.com.efi.charges.card.map; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; +public class CreateOneStepCard { + public static void main(String[] args) { + /* ********* Set credentials parameters ******** */ + Credentials credentials = new Credentials(); + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + /* ************************************************* */ + + List items = new ArrayList(); + Map item1 = new HashMap(); + item1.put("name", "Item 1"); + item1.put("amount", 1); + item1.put("value", 1000); + Map item2 = new HashMap(); + item2.put("name", "Item 2"); + item2.put("amount", 1); + item2.put("value", 2000); + items.add(item1); + items.add(item2); + + String paymentToken = "Insira_aqui_o_payment_token"; + + Map customer = new HashMap(); + customer.put("name", "Gorbadoc Oldbuck"); + customer.put("cpf", "94271564656"); + customer.put("phone_number", "5144916523"); + customer.put("email", "client_email@server.com.br"); + customer.put("birth", "1977-01-15"); + + Map billingAddress = new HashMap(); + billingAddress.put("street", "Av. JK"); + billingAddress.put("number", 909); + billingAddress.put("neighborhood", "Bauxita"); + billingAddress.put("zipcode", "35400000"); + billingAddress.put("city", "Ouro Preto"); + billingAddress.put("state", "MG"); + + Map creditCard = new HashMap(); + creditCard.put("installments", 1); + creditCard.put("billing_address", billingAddress); + creditCard.put("payment_token", paymentToken); + creditCard.put("customer", customer); + Map payment = new HashMap(); + payment.put("credit_card", creditCard); + Map body = new HashMap(); + body.put("items", items); + body.put("payment", payment); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("createOneStepCharge", new HashMap(), body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} \ No newline at end of file diff --git a/src/main/java/br/com/efi/charges/card/map/DefineCardPayMethod.java b/src/main/java/br/com/efi/charges/card/map/DefineCardPayMethod.java new file mode 100644 index 0000000..339ca48 --- /dev/null +++ b/src/main/java/br/com/efi/charges/card/map/DefineCardPayMethod.java @@ -0,0 +1,68 @@ +package br.com.efi.charges.card.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class DefineCardPayMethod { + public static void main(String[] args) { + /* ********* Set credentials parameters ******** */ + + Credentials credentials = new Credentials(); + + Map options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + String paymentToken = "Insira_aqui_o_payment_token"; + + Map customer = new HashMap(); + customer.put("name", "Gorbadoc Oldbuck"); + customer.put("cpf", "94271564656"); + customer.put("phone_number", "5144916523"); + customer.put("email", "client_email@server.com.br"); + customer.put("birth", "1977-01-15"); + + Map billingAddress = new HashMap(); + billingAddress.put("street", "Av. JK"); + billingAddress.put("number", 909); + billingAddress.put("neighborhood", "Bauxita"); + billingAddress.put("zipcode", "5400000"); + billingAddress.put("city", "Ouro Preto"); + billingAddress.put("state", "MG"); + + Map creditCard = new HashMap(); + creditCard.put("installments", 1); + creditCard.put("billing_address", billingAddress); + creditCard.put("payment_token", paymentToken); + creditCard.put("customer", customer); + + Map payment = new HashMap(); + payment.put("credit_card", creditCard); + + Map body = new HashMap(); + body.put("payment", payment); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("definePayMethod", params, body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/card/map/DetailCard.java b/src/main/java/br/com/efi/charges/card/map/DetailCard.java new file mode 100644 index 0000000..483c3eb --- /dev/null +++ b/src/main/java/br/com/efi/charges/card/map/DetailCard.java @@ -0,0 +1,39 @@ +package br.com.efi.charges.card.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class DetailCard { + public static void main(String[] args) { + /* ********* Set credential parameters ******** */ + + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("detailCharge", params, new HashMap()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/card/map/GetInstallments.java b/src/main/java/br/com/efi/charges/card/map/GetInstallments.java new file mode 100644 index 0000000..a90fb73 --- /dev/null +++ b/src/main/java/br/com/efi/charges/card/map/GetInstallments.java @@ -0,0 +1,40 @@ +package br.com.efi.charges.card.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class GetInstallments { + public static void main(String[] args) { + /* ********* Set credential parameters ******** */ + + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("total", "20000"); + params.put("brand", "visa"); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("getInstallments", params, new HashMap()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/card/map/UpdateCardMetadata.java b/src/main/java/br/com/efi/charges/card/map/UpdateCardMetadata.java new file mode 100644 index 0000000..ed7b58d --- /dev/null +++ b/src/main/java/br/com/efi/charges/card/map/UpdateCardMetadata.java @@ -0,0 +1,43 @@ +package br.com.efi.charges.card.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class UpdateCardMetadata { + public static void main(String[] args) { + /* ********* Set credential parameters ******** */ + + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + Map body = new HashMap(); + body.put("custom_id", "Product 0001"); + body.put("notification_url", "http://domain.com/notification"); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("updateChargeMetadata", params, body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/carnet/json/CancelCarnet.java b/src/main/java/br/com/efi/charges/carnet/json/CancelCarnet.java new file mode 100644 index 0000000..c473b4c --- /dev/null +++ b/src/main/java/br/com/efi/charges/carnet/json/CancelCarnet.java @@ -0,0 +1,42 @@ +package br.com.efi.charges.carnet.json; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class CancelCarnet { + + public static void main(String[] args) { + /* ********* Set credential parameters ******** */ + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("cancelCarnet", params, new JSONObject()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } + +} diff --git a/src/main/java/br/com/efi/charges/carnet/json/CancelCarnetParcel.java b/src/main/java/br/com/efi/charges/carnet/json/CancelCarnetParcel.java new file mode 100644 index 0000000..09595dd --- /dev/null +++ b/src/main/java/br/com/efi/charges/carnet/json/CancelCarnetParcel.java @@ -0,0 +1,43 @@ +package br.com.efi.charges.carnet.json; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class CancelCarnetParcel { + + public static void main(String[] args) { + /* ********* Set credentials parameters ******** */ + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + HashMap params = new HashMap(); + params.put("id", "0"); + params.put("parcel", "1"); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("cancelCarnetParcel", params, new JSONObject()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + + } + +} diff --git a/src/main/java/br/com/efi/charges/carnet/json/CreateCarnet.java b/src/main/java/br/com/efi/charges/carnet/json/CreateCarnet.java new file mode 100644 index 0000000..3a009d7 --- /dev/null +++ b/src/main/java/br/com/efi/charges/carnet/json/CreateCarnet.java @@ -0,0 +1,66 @@ +package br.com.efi.charges.carnet.json; + +import java.util.HashMap; + +import org.json.JSONArray; +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class CreateCarnet { + + public static void main(String[] args) { + /* ********* Set credentials parameters ******** */ + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + JSONArray items = new JSONArray(); + + JSONObject item1 = new JSONObject(); + item1.put("name", "Item 1"); + item1.put("amount", 1); + item1.put("value", 2000); + + JSONObject item2 = new JSONObject("{\"name\":\"Item 1\", \"amount\":1, \"value\":1000}"); + + items.put(item1); + items.put(item2); + + JSONObject customer = new JSONObject(); + customer.put("name", "Gorbadoc Oldbuck"); + customer.put("cpf", "94271564656"); + customer.put("phone_number", "5144916523"); + + JSONObject body = new JSONObject(); + body.put("items", items); + body.put("customer", customer); + body.put("expire_at", "2022-12-30"); + body.put("repeats", 4); + body.put("message", "Pague pelo código de barras ou pelo QR Code"); + body.put("split_items", false); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("createCarnet", new HashMap(), body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + + } + +} diff --git a/src/main/java/br/com/efi/charges/carnet/json/CreateCarnetHistory.java b/src/main/java/br/com/efi/charges/carnet/json/CreateCarnetHistory.java new file mode 100644 index 0000000..d774ef6 --- /dev/null +++ b/src/main/java/br/com/efi/charges/carnet/json/CreateCarnetHistory.java @@ -0,0 +1,46 @@ +package br.com.efi.charges.carnet.json; + +import java.util.HashMap; +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class CreateCarnetHistory { + + public static void main(String[] args) { + /* ********* Set credentials parameters ******** */ + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + JSONObject body = new JSONObject(); + body.put("description", "This carnet is about a service"); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("createCarnetHistory", params, body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + e.printStackTrace(); + System.out.println(e.getMessage()); + } + + } + +} diff --git a/src/main/java/br/com/efi/charges/carnet/json/DetailCarnet.java b/src/main/java/br/com/efi/charges/carnet/json/DetailCarnet.java new file mode 100644 index 0000000..19dc9e2 --- /dev/null +++ b/src/main/java/br/com/efi/charges/carnet/json/DetailCarnet.java @@ -0,0 +1,44 @@ +package br.com.efi.charges.carnet.json; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class DetailCarnet { + + public static void main(String[] args) { + /* ********* Set credentials parameters ******** */ + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("detailCarnet", params, new JSONObject()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + e.printStackTrace(); + System.out.println(e.getMessage()); + } + + } + +} diff --git a/src/main/java/br/com/efi/charges/carnet/json/SendCarnetEmail.java b/src/main/java/br/com/efi/charges/carnet/json/SendCarnetEmail.java new file mode 100644 index 0000000..f82e71b --- /dev/null +++ b/src/main/java/br/com/efi/charges/carnet/json/SendCarnetEmail.java @@ -0,0 +1,47 @@ +package br.com.efi.charges.carnet.json; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class SendCarnetEmail { + + public static void main(String[] args) { + /* ********* Set credentials parameters ******** */ + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + JSONObject body = new JSONObject(); + body.put("email", "client_email@server.com.br"); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("sendCarnetEmail", params, body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + e.printStackTrace(); + System.out.println(e.getMessage()); + } + + } + +} diff --git a/src/main/java/br/com/efi/charges/carnet/json/SendCarnetParcelEmail.java b/src/main/java/br/com/efi/charges/carnet/json/SendCarnetParcelEmail.java new file mode 100644 index 0000000..b3acaff --- /dev/null +++ b/src/main/java/br/com/efi/charges/carnet/json/SendCarnetParcelEmail.java @@ -0,0 +1,46 @@ +package br.com.efi.charges.carnet.json; + +import java.util.HashMap; +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class SendCarnetParcelEmail { + + public static void main(String[] args) { + /* ********* Set credentials parameters ******** */ + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + params.put("parcel", "1"); + + JSONObject body = new JSONObject(); + body.put("email", "client_email@server.com.br"); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("sendCarnetParcelEmail", params, body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + e.printStackTrace(); + System.out.println(e.getMessage()); + } + } + +} diff --git a/src/main/java/br/com/efi/charges/carnet/json/SettleCarnet.java b/src/main/java/br/com/efi/charges/carnet/json/SettleCarnet.java new file mode 100644 index 0000000..5fd2541 --- /dev/null +++ b/src/main/java/br/com/efi/charges/carnet/json/SettleCarnet.java @@ -0,0 +1,40 @@ +package br.com.efi.charges.carnet.json; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class SettleCarnet { + public static void main(String[] args) { + /* ********* Set credential parameters ******** */ + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("settleCarnet", params, new JSONObject()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/carnet/json/SettleCarnetParcel.java b/src/main/java/br/com/efi/charges/carnet/json/SettleCarnetParcel.java new file mode 100644 index 0000000..dbb859f --- /dev/null +++ b/src/main/java/br/com/efi/charges/carnet/json/SettleCarnetParcel.java @@ -0,0 +1,44 @@ +package br.com.efi.charges.carnet.json; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class SettleCarnetParcel { + + public static void main(String[] args) { + /* ********* Set credentials parameters ******** */ + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + params.put("parcel", "1"); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("settleCarnetParcel", params, new JSONObject()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + + } + +} diff --git a/src/main/java/br/com/efi/charges/carnet/json/UpdateCarnetMetadata.java b/src/main/java/br/com/efi/charges/carnet/json/UpdateCarnetMetadata.java new file mode 100644 index 0000000..0a27ac5 --- /dev/null +++ b/src/main/java/br/com/efi/charges/carnet/json/UpdateCarnetMetadata.java @@ -0,0 +1,47 @@ +package br.com.efi.charges.carnet.json; + +import java.util.HashMap; +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class UpdateCarnetMetadata { + + public static void main(String[] args) { + /* ********* Set credentials parameters ******** */ + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + JSONObject body = new JSONObject(); + body.put("custom_id", "Carnet 0001"); + body.put("notification_url", "http://domain.com/notification"); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("updateCarnetMetadata", params, body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + e.printStackTrace(); + System.out.println(e.getMessage()); + } + + } + +} diff --git a/src/main/java/br/com/efi/charges/carnet/json/UpdateCarnetParcel.java b/src/main/java/br/com/efi/charges/carnet/json/UpdateCarnetParcel.java new file mode 100644 index 0000000..4ec2356 --- /dev/null +++ b/src/main/java/br/com/efi/charges/carnet/json/UpdateCarnetParcel.java @@ -0,0 +1,48 @@ +package br.com.efi.charges.carnet.json; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class UpdateCarnetParcel { + + public static void main(String[] args) { + /* ********* Set credentials parameters ******** */ + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + params.put("parcel", "1"); + + JSONObject body = new JSONObject(); + body.put("expire_at", "2018-01-01"); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("updateCarnetParcel", params, body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + e.printStackTrace(); + System.out.println(e.getMessage()); + } + + } + +} diff --git a/src/main/java/br/com/efi/charges/carnet/map/CancelCarnet.java b/src/main/java/br/com/efi/charges/carnet/map/CancelCarnet.java new file mode 100644 index 0000000..c9d48ef --- /dev/null +++ b/src/main/java/br/com/efi/charges/carnet/map/CancelCarnet.java @@ -0,0 +1,41 @@ +package br.com.efi.charges.carnet.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class CancelCarnet { + + public static void main(String[] args) { + /* ********* Set credential parameters ******** */ + + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("cancelCarnet", params, new HashMap()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } + +} diff --git a/src/main/java/br/com/efi/charges/carnet/map/CancelCarnetParcel.java b/src/main/java/br/com/efi/charges/carnet/map/CancelCarnetParcel.java new file mode 100644 index 0000000..551d62a --- /dev/null +++ b/src/main/java/br/com/efi/charges/carnet/map/CancelCarnetParcel.java @@ -0,0 +1,43 @@ +package br.com.efi.charges.carnet.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class CancelCarnetParcel { + + public static void main(String[] args) { + /* ********* Set credentials parameters ******** */ + + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + params.put("parcel", "1"); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("cancelCarnetParcel", params, new HashMap()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + + } + +} diff --git a/src/main/java/br/com/efi/charges/carnet/map/CreateCarnet.java b/src/main/java/br/com/efi/charges/carnet/map/CreateCarnet.java new file mode 100644 index 0000000..587b1a8 --- /dev/null +++ b/src/main/java/br/com/efi/charges/carnet/map/CreateCarnet.java @@ -0,0 +1,69 @@ +package br.com.efi.charges.carnet.map; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class +CreateCarnet { + + public static void main(String[] args) { + /* ********* Set credentials parameters ******** */ + + Credentials credentials = new Credentials(); + + Map options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + List items = new ArrayList(); + + Map item1 = new HashMap(); + item1.put("name", "Item 1"); + item1.put("amount", 1); + item1.put("value", 1000); + + Map item2 = new HashMap(); + item2.put("name", "Item 2"); + item2.put("amount", 1); + item2.put("value", 2000); + + items.add(item1); + items.add(item2); + + Map customer = new HashMap(); + customer.put("name", "Gorbadoc Oldbuck"); + customer.put("cpf", "94271564656"); + customer.put("phone_number", "5144916523"); + + Map body = new HashMap(); + body.put("items", items); + body.put("customer", customer); + body.put("expire_at", "2020-12-02"); + body.put("repeats", 5); + body.put("split_items", false); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("createCarnet", new HashMap(), body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + + } + +} diff --git a/src/main/java/br/com/efi/charges/carnet/map/CreateCarnetHistory.java b/src/main/java/br/com/efi/charges/carnet/map/CreateCarnetHistory.java new file mode 100644 index 0000000..2a81752 --- /dev/null +++ b/src/main/java/br/com/efi/charges/carnet/map/CreateCarnetHistory.java @@ -0,0 +1,46 @@ +package br.com.efi.charges.carnet.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class CreateCarnetHistory { + + public static void main(String[] args) { + /* ********* Set credentials parameters ******** */ + + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + Map body = new HashMap(); + body.put("description", "This carnet is about a service"); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("createCarnetHistory", params, body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + e.printStackTrace(); + System.out.println(e.getMessage()); + } + + } + +} diff --git a/src/main/java/br/com/efi/charges/carnet/map/DetailCarnet.java b/src/main/java/br/com/efi/charges/carnet/map/DetailCarnet.java new file mode 100644 index 0000000..5cf1db2 --- /dev/null +++ b/src/main/java/br/com/efi/charges/carnet/map/DetailCarnet.java @@ -0,0 +1,43 @@ +package br.com.efi.charges.carnet.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class DetailCarnet { + + public static void main(String[] args) { + /* ********* Set credentials parameters ******** */ + + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("detailCarnet", params, new HashMap()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + e.printStackTrace(); + System.out.println(e.getMessage()); + } + + } + +} diff --git a/src/main/java/br/com/efi/charges/carnet/map/SendCarnetEmail.java b/src/main/java/br/com/efi/charges/carnet/map/SendCarnetEmail.java new file mode 100644 index 0000000..56c9254 --- /dev/null +++ b/src/main/java/br/com/efi/charges/carnet/map/SendCarnetEmail.java @@ -0,0 +1,46 @@ +package br.com.efi.charges.carnet.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class SendCarnetEmail { + + public static void main(String[] args) { + /* ********* Set credentials parameters ******** */ + + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + Map body = new HashMap(); + body.put("email", "client_email@server.com.br"); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("sendCarnetEmail", params, body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + e.printStackTrace(); + System.out.println(e.getMessage()); + } + + } + +} diff --git a/src/main/java/br/com/efi/charges/carnet/map/SendCarnetParcelEmail.java b/src/main/java/br/com/efi/charges/carnet/map/SendCarnetParcelEmail.java new file mode 100644 index 0000000..79f2951 --- /dev/null +++ b/src/main/java/br/com/efi/charges/carnet/map/SendCarnetParcelEmail.java @@ -0,0 +1,46 @@ +package br.com.efi.charges.carnet.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class SendCarnetParcelEmail { + + public static void main(String[] args) { + /* ********* Set credentials parameters ******** */ + + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + params.put("parcel", "1"); + + Map body = new HashMap(); + body.put("email", "client_email@server.com.br"); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("sendCarnetParcelEmail", params, body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + e.printStackTrace(); + System.out.println(e.getMessage()); + } + } + +} diff --git a/src/main/java/br/com/efi/charges/carnet/map/SettleCarnet.java b/src/main/java/br/com/efi/charges/carnet/map/SettleCarnet.java new file mode 100644 index 0000000..01221aa --- /dev/null +++ b/src/main/java/br/com/efi/charges/carnet/map/SettleCarnet.java @@ -0,0 +1,39 @@ +package br.com.efi.charges.carnet.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class SettleCarnet { + public static void main(String[] args) { + /* ********* Set credential parameters ******** */ + + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("settleCarnet", params, new HashMap()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/carnet/map/SettleCarnetParcel.java b/src/main/java/br/com/efi/charges/carnet/map/SettleCarnetParcel.java new file mode 100644 index 0000000..00e6046 --- /dev/null +++ b/src/main/java/br/com/efi/charges/carnet/map/SettleCarnetParcel.java @@ -0,0 +1,43 @@ +package br.com.efi.charges.carnet.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class SettleCarnetParcel { + + public static void main(String[] args) { + /* ********* Set credentials parameters ******** */ + + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + params.put("parcel", "1"); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("settleCarnetParcel", params, new HashMap()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + + } + +} diff --git a/src/main/java/br/com/efi/charges/carnet/map/UpdateCarnetMetadata.java b/src/main/java/br/com/efi/charges/carnet/map/UpdateCarnetMetadata.java new file mode 100644 index 0000000..45c8615 --- /dev/null +++ b/src/main/java/br/com/efi/charges/carnet/map/UpdateCarnetMetadata.java @@ -0,0 +1,47 @@ +package br.com.efi.charges.carnet.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class UpdateCarnetMetadata { + + public static void main(String[] args) { + /* ********* Set credentials parameters ******** */ + + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + Map body = new HashMap(); + body.put("custom_id", "Carnet 0001"); + body.put("notification_url", "http://domain.com/notification"); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("updateCarnetMetadata", params, body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + e.printStackTrace(); + System.out.println(e.getMessage()); + } + + } + +} diff --git a/src/main/java/br/com/efi/charges/carnet/map/UpdateCarnetParcel.java b/src/main/java/br/com/efi/charges/carnet/map/UpdateCarnetParcel.java new file mode 100644 index 0000000..2a1f2a8 --- /dev/null +++ b/src/main/java/br/com/efi/charges/carnet/map/UpdateCarnetParcel.java @@ -0,0 +1,47 @@ +package br.com.efi.charges.carnet.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class UpdateCarnetParcel { + + public static void main(String[] args) { + /* ********* Set credentials parameters ******** */ + + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + params.put("parcel", "1"); + + Map body = new HashMap(); + body.put("expire_at", "2018-01-01"); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("updateCarnetParcel", params, body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + e.printStackTrace(); + System.out.println(e.getMessage()); + } + + } + +} diff --git a/src/main/java/br/com/efi/charges/marketplace/json/CreateOneStepBilletMarketplace.java b/src/main/java/br/com/efi/charges/marketplace/json/CreateOneStepBilletMarketplace.java new file mode 100644 index 0000000..2ce0bb2 --- /dev/null +++ b/src/main/java/br/com/efi/charges/marketplace/json/CreateOneStepBilletMarketplace.java @@ -0,0 +1,107 @@ +package br.com.efi.charges.marketplace.json; + +import java.util.HashMap; + +import org.json.JSONArray; +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class CreateOneStepBilletMarketplace { + public static void main(String[] args) { + /* ********* Set credentials parameters ******** */ + Credentials credentials = new Credentials(); + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + /* ************************************************* */ + + // repasses + + JSONObject repass_1 = new JSONObject(); + repass_1.put("payee_code", "Insira_aqui_o_indentificador_da_conta_destino"); + repass_1.put("percentage", 1500); + + JSONObject repass_2 = new JSONObject(); + repass_2.put("payee_code", "Insira_aqui_o_indentificador_da_conta_destino"); + repass_2.put("percentage", 2500); + + JSONArray repasses = new JSONArray(); + repasses.put(repass_1); + repasses.put(repass_2); + + JSONObject marketplace = new JSONObject(); + // marketplace.put("mode", 1); + marketplace.put("repasses", repasses); + + // items + JSONArray items = new JSONArray(); + JSONObject item1 = new JSONObject(); + item1.put("name", "Item 1"); + item1.put("amount", 1); + item1.put("value", 1000); + item1.put("marketplace",marketplace); + items.put(item1); + + //JSONObject body = new JSONObject(); + //body.put("items", items); + + //customer + JSONObject customer = new JSONObject(); + customer.put("name", "Gorbadoc Oldbuck"); + customer.put("cpf", "94271564656"); + customer.put("phone_number", "5144916523"); + + //URL de notificações + JSONObject metadata = new JSONObject(); + metadata.put("notification_url", "https://seu.dominio/retorno"); + metadata.put("custom_id", "id_0007"); + + //desconto + JSONObject discount = new JSONObject(); + discount.put("type","currency"); + discount.put("value",400); + + //juros e mora + JSONObject configurations = new JSONObject(); + configurations.put("fine", 200); + configurations.put("interest", 33); + + //disconto condicional + JSONObject conditional_discount = new JSONObject(); + conditional_discount.put("type","percentage"); + conditional_discount.put("value", 100); + conditional_discount.put("until_date", "2022-10-13"); + + + JSONObject bankingBillet = new JSONObject(); + bankingBillet.put("expire_at", "2022-10-15"); + bankingBillet.put("customer", customer); + bankingBillet.put("discount", discount); + bankingBillet.put("configurations", configurations); + bankingBillet.put("conditional_discount", conditional_discount); + + JSONObject payment = new JSONObject(); + payment.put("banking_billet", bankingBillet); + JSONObject body = new JSONObject(); + body.put("payment", payment); + body.put("items", items); + body.put("metadata", metadata); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("createOneStepCharge", new HashMap(), body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/marketplace/json/CreateOneStepCardMarketplace.java b/src/main/java/br/com/efi/charges/marketplace/json/CreateOneStepCardMarketplace.java new file mode 100644 index 0000000..e2c7d16 --- /dev/null +++ b/src/main/java/br/com/efi/charges/marketplace/json/CreateOneStepCardMarketplace.java @@ -0,0 +1,109 @@ +package br.com.efi.charges.marketplace.json; + +import java.util.HashMap; + +import org.json.JSONArray; +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class CreateOneStepCardMarketplace { + public static void main(String[] args) { + /* ********* Set credentials parameters ******** */ + Credentials credentials = new Credentials(); + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + /* ************************************************* */ + + // repasses + + JSONObject repass_1 = new JSONObject(); + repass_1.put("payee_code", "Insira_aqui_o_indentificador_da_conta_destino"); + repass_1.put("percentage", 1500); + + JSONObject repass_2 = new JSONObject(); + repass_2.put("payee_code", "Insira_aqui_o_indentificador_da_conta_destino"); + repass_2.put("percentage", 2500); + + JSONArray repass = new JSONArray(); + repass.put(repass_1); + repass.put(repass_2); + + JSONObject repasses = new JSONObject(); + repasses.put("repasses", repass); + + + // items + JSONArray items = new JSONArray(); + JSONObject item1 = new JSONObject(); + item1.put("name", "Item 1"); + item1.put("amount", 1); + item1.put("value", 1000); + item1.put("marketplace",repasses); + items.put(item1); + + //JSONObject body = new JSONObject(); + //body.put("items", items); + + //customer + String paymentToken = "Insira_aqui_o_payment_token"; + + JSONObject customer = new JSONObject(); + customer.put("name", "Gorbadoc Oldbuck"); + customer.put("cpf", "94271564656"); + customer.put("phone_number", "5144916523"); + customer.put("email", "client_email@server.com.br"); + customer.put("birth", "1977-01-15"); + + JSONObject billingAddress = new JSONObject(); + billingAddress.put("street", "Av. JK"); + billingAddress.put("number", 909); + billingAddress.put("neighborhood", "Bauxita"); + billingAddress.put("zipcode", "35400000"); + billingAddress.put("city", "Ouro Preto"); + billingAddress.put("state", "MG"); + + //URL de notificações + JSONObject metadata = new JSONObject(); + metadata.put("notification_url", "https://seu.dominio/retorno"); + metadata.put("custom_id", "id_0007"); + + //desconto + JSONObject discount = new JSONObject(); + discount.put("type","currency"); + discount.put("value",500); + + + JSONObject creditCard = new JSONObject(); + creditCard.put("installments", 1); + creditCard.put("billing_address", billingAddress); + creditCard.put("payment_token", paymentToken); + creditCard.put("customer", customer); + creditCard.put("discount", discount); + + JSONObject payment = new JSONObject(); + payment.put("credit_card", creditCard); + + JSONObject body = new JSONObject(); + body.put("payment", payment); + body.put("items", items); + body.put("metadata", metadata); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("createOneStepCharge", new HashMap(), body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/marketplace/map/CreateOneStepBilletMarketplace.java b/src/main/java/br/com/efi/charges/marketplace/map/CreateOneStepBilletMarketplace.java new file mode 100644 index 0000000..b7054fc --- /dev/null +++ b/src/main/java/br/com/efi/charges/marketplace/map/CreateOneStepBilletMarketplace.java @@ -0,0 +1,85 @@ +package br.com.efi.charges.marketplace.map; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class CreateOneStepBilletMarketplace { + public static void main(String[] args) { + /* ********* Set credentials parameters ******** */ + Credentials credentials = new Credentials(); + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + // repasses + + HashMap repass_1 = new HashMap(); + repass_1.put("payee_code", "Insira_aqui_o_indentificador_da_conta_destino"); + repass_1.put("percentage", 1500); + + HashMap repass_2 = new HashMap(); + repass_2.put("payee_code", "Insira_aqui_o_indentificador_da_conta_destino"); + repass_2.put("percentage", 2500); + + List repass = new ArrayList(); + repass.add(repass_1); + repass.add(repass_1); + + HashMap repasses = new HashMap(); + repasses.put("repasses", repass); + + + + /* ************************************************* */ + + List items = new ArrayList(); + + Map item1 = new HashMap(); + item1.put("name", "Item 1"); + item1.put("amount", 1); + item1.put("value", 1000); + + Map item2 = new HashMap(); + item2.put("name", "Item 2"); + item2.put("amount", 1); + item2.put("value", 2000); + + items.add(item1); + items.add(item2); + + Map customer = new HashMap(); + customer.put("name", "Gorbadoc Oldbuck"); + customer.put("cpf", "94271564656"); + customer.put("phone_number", "5144916523"); + + Map bankingBillet = new HashMap(); + bankingBillet.put("expire_at", "2019-09-29"); + bankingBillet.put("customer", customer); + + Map payment = new HashMap(); + payment.put("banking_billet", bankingBillet); + + Map body = new HashMap(); + body.put("payment", payment); + body.put("items", items); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("createOneStepCharge", new HashMap(), body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/marketplace/map/CreateOneStepCardMarketplace.java b/src/main/java/br/com/efi/charges/marketplace/map/CreateOneStepCardMarketplace.java new file mode 100644 index 0000000..867adf9 --- /dev/null +++ b/src/main/java/br/com/efi/charges/marketplace/map/CreateOneStepCardMarketplace.java @@ -0,0 +1,98 @@ +package br.com.efi.charges.marketplace.map; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class CreateOneStepCardMarketplace { + public static void main(String[] args) { + /* ********* Set credentials parameters ******** */ + + Credentials credentials = new Credentials(); + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + // repasses + + HashMap repass_1 = new HashMap(); + repass_1.put("payee_code", "Insira_aqui_o_indentificador_da_conta_destino"); + repass_1.put("percentage", 1500); + + HashMap repass_2 = new HashMap(); + repass_2.put("payee_code", "Insira_aqui_o_indentificador_da_conta_destino"); + repass_2.put("percentage", 2500); + + List repass = new ArrayList(); + repass.add(repass_1); + repass.add(repass_1); + + HashMap repasses = new HashMap(); + repasses.put("repasses", repass); + + /* ************************************************* */ + + List items = new ArrayList(); + + Map item1 = new HashMap(); + item1.put("name", "Item 1"); + item1.put("amount", 1); + item1.put("value", 1000); + + Map item2 = new HashMap(); + item2.put("name", "Item 2"); + item2.put("amount", 1); + item2.put("value", 2000); + + items.add(item1); + items.add(item2); + + String paymentToken = "Insira_aqui_o_payeemente_token"; + + Map customer = new HashMap(); + customer.put("name", "Gorbadoc Oldbuck"); + customer.put("cpf", "94271564656"); + customer.put("phone_number", "5144916523"); + customer.put("email", "client_email@server.com.br"); + customer.put("birth", "1977-01-15"); + + Map billingAddress = new HashMap(); + billingAddress.put("street", "Av. JK"); + billingAddress.put("number", 909); + billingAddress.put("neighborhood", "Bauxita"); + billingAddress.put("zipcode", "35400000"); + billingAddress.put("city", "Ouro Preto"); + billingAddress.put("state", "MG"); + + Map creditCard = new HashMap(); + creditCard.put("installments", 1); + creditCard.put("billing_address", billingAddress); + creditCard.put("payment_token", paymentToken); + creditCard.put("customer", customer); + + Map payment = new HashMap(); + payment.put("credit_card", creditCard); + + Map body = new HashMap(); + body.put("payment", payment); + body.put("items", items); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("createOneStepCharge", new HashMap(), body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/notification/json/GetNotification.java b/src/main/java/br/com/efi/charges/notification/json/GetNotification.java new file mode 100644 index 0000000..1b9520c --- /dev/null +++ b/src/main/java/br/com/efi/charges/notification/json/GetNotification.java @@ -0,0 +1,39 @@ +package br.com.efi.charges.notification.json; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class GetNotification { + public static void main(String[] args) { + /* ********* Set credential parameters ******** */ + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("token", "token_recebido"); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("getNotification", params, new JSONObject()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + }catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/notification/map/GetNotification.java b/src/main/java/br/com/efi/charges/notification/map/GetNotification.java new file mode 100644 index 0000000..2a3d0aa --- /dev/null +++ b/src/main/java/br/com/efi/charges/notification/map/GetNotification.java @@ -0,0 +1,38 @@ +package br.com.efi.charges.notification.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class GetNotification { + public static void main(String[] args) { + /* ********* Set credential parameters ******** */ + + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("token", "token_recebido"); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("getNotification", params, new HashMap()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + }catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/payment_link/json/CancelLink.java b/src/main/java/br/com/efi/charges/payment_link/json/CancelLink.java new file mode 100644 index 0000000..ffba319 --- /dev/null +++ b/src/main/java/br/com/efi/charges/payment_link/json/CancelLink.java @@ -0,0 +1,40 @@ +package br.com.efi.charges.payment_link.json; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class CancelLink { + public static void main(String[] args) { + /* ********* Set credential parameters ******** */ + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("cancelCharge", params, new JSONObject()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/payment_link/json/CreateCharge.java b/src/main/java/br/com/efi/charges/payment_link/json/CreateCharge.java new file mode 100644 index 0000000..31cc1d3 --- /dev/null +++ b/src/main/java/br/com/efi/charges/payment_link/json/CreateCharge.java @@ -0,0 +1,52 @@ +package br.com.efi.charges.payment_link.json; + +import java.util.HashMap; +import org.json.JSONArray; +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class CreateCharge { + public static void main(String[] args) { + /* ********* Set credentials parameters ******** */ + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + JSONArray items = new JSONArray(); + + JSONObject item1 = new JSONObject(); + item1.put("name", "Item 1"); + item1.put("amount", 1); + item1.put("value", 2000); + + JSONObject item2 = new JSONObject("{\"name\":\"Item 1\", \"amount\":1, \"value\":1}"); + + items.put(item1); + items.put(item2); + + JSONObject body = new JSONObject(); + body.put("items", items); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("createCharge", new HashMap(), body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/payment_link/json/CreateChargeLinkHistory.java b/src/main/java/br/com/efi/charges/payment_link/json/CreateChargeLinkHistory.java new file mode 100644 index 0000000..233dac6 --- /dev/null +++ b/src/main/java/br/com/efi/charges/payment_link/json/CreateChargeLinkHistory.java @@ -0,0 +1,43 @@ +package br.com.efi.charges.payment_link.json; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class CreateChargeLinkHistory { + public static void main(String[] args) { + /* ********* Set credential parameters ******** */ + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + JSONObject body = new JSONObject(); + body.put("description", "This charge was not fully paid"); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("createChargeHistory", params, body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/payment_link/json/CreateOneStepLink.java b/src/main/java/br/com/efi/charges/payment_link/json/CreateOneStepLink.java new file mode 100644 index 0000000..41aa0d4 --- /dev/null +++ b/src/main/java/br/com/efi/charges/payment_link/json/CreateOneStepLink.java @@ -0,0 +1,67 @@ +package br.com.efi.charges.payment_link.json; + +import java.util.HashMap; + +import org.json.JSONArray; +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class CreateOneStepLink { + public static void main(String[] args) { + /* ********* Set credentials parameters ******** */ + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + // items + JSONArray items = new JSONArray(); + + JSONObject item1 = new JSONObject(); + item1.put("name", "Item 4"); + item1.put("amount", 1); + item1.put("value", 500); + + JSONObject item2 = new JSONObject("{\"name\":\"Item 2\", \"amount\":1, \"value\":1000}"); + + items.put(item1); + items.put(item2); + + JSONObject settings = new JSONObject(); + settings.put("payment_method", "all"); + settings.put("billet_discount", 10); + settings.put("card_discount", 10); + settings.put("expire_at", "2022-12-12"); + settings.put("request_delivery_address", false); + + //notification url + JSONObject metadata = new JSONObject(); + metadata.put("notification_url", "https://seu.dominio/retorno"); + + JSONObject body = new JSONObject(); + body.put("items", items); + body.put("settings", settings); + body.put("metadata", metadata); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("createOneStepLink", new HashMap(), body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/payment_link/json/DefineLinkPayMethod.java b/src/main/java/br/com/efi/charges/payment_link/json/DefineLinkPayMethod.java new file mode 100644 index 0000000..7664e9a --- /dev/null +++ b/src/main/java/br/com/efi/charges/payment_link/json/DefineLinkPayMethod.java @@ -0,0 +1,48 @@ +package br.com.efi.charges.payment_link.json; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class DefineLinkPayMethod { + public static void main(String[] args) { + /* ********* Set credentials parameters ******** */ + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + JSONObject body = new JSONObject(); + body.put("billet_discount", 10); + body.put("card_discount", 10); + body.put("message", "link test"); + body.put("expire_at", "2022-12-12"); + body.put("request_delivery_address", false); + body.put("payment_method", "all"); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("defineLinkPayMethod", params, body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/payment_link/json/DetailLink.java b/src/main/java/br/com/efi/charges/payment_link/json/DetailLink.java new file mode 100644 index 0000000..c680e49 --- /dev/null +++ b/src/main/java/br/com/efi/charges/payment_link/json/DetailLink.java @@ -0,0 +1,40 @@ +package br.com.efi.charges.payment_link.json; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class DetailLink { + public static void main(String[] args) { + /* ********* Set credential parameters ******** */ + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("detailCharge", params, new JSONObject()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/payment_link/json/SendLinkEmail.java b/src/main/java/br/com/efi/charges/payment_link/json/SendLinkEmail.java new file mode 100644 index 0000000..4a54efd --- /dev/null +++ b/src/main/java/br/com/efi/charges/payment_link/json/SendLinkEmail.java @@ -0,0 +1,43 @@ +package br.com.efi.charges.payment_link.json; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class SendLinkEmail { + public static void main(String[] args) { + /* ********* Set credential parameters ******** */ + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + JSONObject body = new JSONObject(); + body.put("email", "client_email@server.com.br"); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("sendLinkEmail", params, body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/payment_link/json/UpdateLink.java b/src/main/java/br/com/efi/charges/payment_link/json/UpdateLink.java new file mode 100644 index 0000000..dd3d333 --- /dev/null +++ b/src/main/java/br/com/efi/charges/payment_link/json/UpdateLink.java @@ -0,0 +1,48 @@ +package br.com.efi.charges.payment_link.json; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class UpdateLink { + public static void main(String[] args) { + /* ********* Set credential parameters ******** */ + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + JSONObject body = new JSONObject(); + body.put("billet_discount", 0); + body.put("card_discount", 0); + body.put("message", "link test"); + body.put("expire_at", "2022-12-12"); + body.put("request_delivery_address", false); + body.put("payment_method", "all"); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("updateChargeLink", params, body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/payment_link/json/UpdateLinkMetadata.java b/src/main/java/br/com/efi/charges/payment_link/json/UpdateLinkMetadata.java new file mode 100644 index 0000000..693a957 --- /dev/null +++ b/src/main/java/br/com/efi/charges/payment_link/json/UpdateLinkMetadata.java @@ -0,0 +1,44 @@ +package br.com.efi.charges.payment_link.json; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class UpdateLinkMetadata { + public static void main(String[] args) { + /* ********* Set credential parameters ******** */ + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + JSONObject body = new JSONObject(); + body.put("custom_id", "Product 0001"); + body.put("notification_url", "http://domain.com/notification"); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("updateChargeMetadata", params, body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/payment_link/map/CancelLink.java b/src/main/java/br/com/efi/charges/payment_link/map/CancelLink.java new file mode 100644 index 0000000..f683147 --- /dev/null +++ b/src/main/java/br/com/efi/charges/payment_link/map/CancelLink.java @@ -0,0 +1,39 @@ +package br.com.efi.charges.payment_link.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class CancelLink { + public static void main(String[] args) { + /* ********* Set credential parameters ******** */ + + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("cancelCharge", params, new HashMap()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/payment_link/map/CreateCharge.java b/src/main/java/br/com/efi/charges/payment_link/map/CreateCharge.java new file mode 100644 index 0000000..d456c9e --- /dev/null +++ b/src/main/java/br/com/efi/charges/payment_link/map/CreateCharge.java @@ -0,0 +1,56 @@ +package br.com.efi.charges.payment_link.map; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class CreateCharge { + public static void main(String[] args) { + /* ********* Set credentials parameters ******** */ + + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + List items = new ArrayList(); + + Map item1 = new HashMap(); + item1.put("name", "Item 1"); + item1.put("amount", 1); + item1.put("value", 1000); + + Map item2 = new HashMap(); + item2.put("name", "Item 2"); + item2.put("amount", 1); + item2.put("value", 2000); + + items.add(item1); + items.add(item2); + + Map body = new HashMap(); + body.put("items", items); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("createCharge", new HashMap(), body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/payment_link/map/CreateChargeLinkHistory.java b/src/main/java/br/com/efi/charges/payment_link/map/CreateChargeLinkHistory.java new file mode 100644 index 0000000..737b613 --- /dev/null +++ b/src/main/java/br/com/efi/charges/payment_link/map/CreateChargeLinkHistory.java @@ -0,0 +1,42 @@ +package br.com.efi.charges.payment_link.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class CreateChargeLinkHistory { + public static void main(String[] args) { + /* ********* Set credential parameters ******** */ + + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + Map body = new HashMap(); + body.put("description", "This charge was not fully paid"); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("createChargeHistory", params, body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/payment_link/map/CreateOneStepLink.java b/src/main/java/br/com/efi/charges/payment_link/map/CreateOneStepLink.java new file mode 100644 index 0000000..396c05e --- /dev/null +++ b/src/main/java/br/com/efi/charges/payment_link/map/CreateOneStepLink.java @@ -0,0 +1,60 @@ +package br.com.efi.charges.payment_link.map; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; +public class CreateOneStepLink { + public static void main(String[] args) { + /* ********* Set credentials parameters ******** */ + Credentials credentials = new Credentials(); + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + /* ************************************************* */ + + List items = new ArrayList(); + Map item1 = new HashMap(); + item1.put("name", "Item 1"); + item1.put("amount", 1); + item1.put("value", 1000); + Map item2 = new HashMap(); + item2.put("name", "Item 2"); + item2.put("amount", 1); + item2.put("value", 2000); + items.add(item1); + items.add(item2); + + Map settings = new HashMap(); + settings.put("payment_method", "all"); + settings.put("billet_discount", 0); + settings.put("card_discount", 0); + settings.put("expire_at", "2020-12-12"); + settings.put("request_delivery_address", false); + + Map metadata = new HashMap(); + metadata.put("notification_url", "http://domain.com/notification"); + + Map body = new HashMap(); + body.put("items", items); + body.put("settings", settings); + body.put("metadata", metadata); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("createOneStepLink", new HashMap(), body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} \ No newline at end of file diff --git a/src/main/java/br/com/efi/charges/payment_link/map/DefineLinkPayMethod.java b/src/main/java/br/com/efi/charges/payment_link/map/DefineLinkPayMethod.java new file mode 100644 index 0000000..344d961 --- /dev/null +++ b/src/main/java/br/com/efi/charges/payment_link/map/DefineLinkPayMethod.java @@ -0,0 +1,47 @@ +package br.com.efi.charges.payment_link.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class DefineLinkPayMethod { + public static void main(String[] args) { + /* ********* Set credentials parameters ******** */ + + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + Map body = new HashMap(); + body.put("billet_discount", 0); + body.put("card_discount", 0); + body.put("message", "link test"); + body.put("expire_at", "2018-12-12"); + body.put("request_delivery_address", false); + body.put("payment_method", "all"); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("defineLinkPayMethod", params, body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/payment_link/map/DetailLink.java b/src/main/java/br/com/efi/charges/payment_link/map/DetailLink.java new file mode 100644 index 0000000..59115b0 --- /dev/null +++ b/src/main/java/br/com/efi/charges/payment_link/map/DetailLink.java @@ -0,0 +1,39 @@ +package br.com.efi.charges.payment_link.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class DetailLink { + public static void main(String[] args) { + /* ********* Set credential parameters ******** */ + + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("detailCharge", params, new HashMap()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/payment_link/map/SendLinkEmail.java b/src/main/java/br/com/efi/charges/payment_link/map/SendLinkEmail.java new file mode 100644 index 0000000..65fef76 --- /dev/null +++ b/src/main/java/br/com/efi/charges/payment_link/map/SendLinkEmail.java @@ -0,0 +1,42 @@ +package br.com.efi.charges.payment_link.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class SendLinkEmail { + public static void main(String[] args) { + /* ********* Set credential parameters ******** */ + + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + Map body = new HashMap(); + body.put("email", "client_email@server.com.br"); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("sendLinkEmail", params, body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/payment_link/map/UpdateLink.java b/src/main/java/br/com/efi/charges/payment_link/map/UpdateLink.java new file mode 100644 index 0000000..b65a663 --- /dev/null +++ b/src/main/java/br/com/efi/charges/payment_link/map/UpdateLink.java @@ -0,0 +1,47 @@ +package br.com.efi.charges.payment_link.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class UpdateLink { + public static void main(String[] args) { + /* ********* Set credential parameters ******** */ + + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + Map body = new HashMap(); + body.put("billet_discount", 0); + body.put("card_discount", 0); + body.put("message", "link test"); + body.put("expire_at", "2022-12-12"); + body.put("request_delivery_address", false); + body.put("payment_method", "all"); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("updateChargeLink", params, body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/payment_link/map/UpdateLinkMetadata.java b/src/main/java/br/com/efi/charges/payment_link/map/UpdateLinkMetadata.java new file mode 100644 index 0000000..a3d5eb3 --- /dev/null +++ b/src/main/java/br/com/efi/charges/payment_link/map/UpdateLinkMetadata.java @@ -0,0 +1,43 @@ +package br.com.efi.charges.payment_link.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class UpdateLinkMetadata { + public static void main(String[] args) { + /* ********* Set credential parameters ******** */ + + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + Map body = new HashMap(); + body.put("custom_id", "Product 0001"); + body.put("notification_url", "http://domain.com/notification"); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("updateChargeMetadata", params, body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/subscription/json/CancelSubscription.java b/src/main/java/br/com/efi/charges/subscription/json/CancelSubscription.java new file mode 100644 index 0000000..24dd91b --- /dev/null +++ b/src/main/java/br/com/efi/charges/subscription/json/CancelSubscription.java @@ -0,0 +1,39 @@ +package br.com.efi.charges.subscription.json; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class CancelSubscription { + public static void main(String[] args) { + /* ********* Set credential parameters ******** */ + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "906157"); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("cancelSubscription", params, new JSONObject()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + }catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/subscription/json/CreateCharge.java b/src/main/java/br/com/efi/charges/subscription/json/CreateCharge.java new file mode 100644 index 0000000..b732d98 --- /dev/null +++ b/src/main/java/br/com/efi/charges/subscription/json/CreateCharge.java @@ -0,0 +1,58 @@ +package br.com.efi.charges.subscription.json; + +import java.util.HashMap; + +import org.json.JSONArray; +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class CreateCharge { + public static void main(String[] args) { + /* ********* Set credential parameters ******** */ + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + HashMap params = new HashMap(); + params.put("id", "86205"); + + JSONArray items = new JSONArray(); + + JSONObject item1 = new JSONObject(); + item1.put("name", "Item 1"); + item1.put("amount", 1); + item1.put("value", 2000); + + JSONObject item2 = new JSONObject("{\"name\":\"Item 1\", \"amount\":1, \"value\":1000}"); + + items.put(item1); + items.put(item2); + + JSONObject notification = new JSONObject(); + notification.put("notification_url", "http://domain.com/notification"); + + JSONObject body = new JSONObject(); + body.put("items", items); + body.put("metadata", notification); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("createSubscription", params, body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + }catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/subscription/json/CreateOneStepBilletSubscription.java b/src/main/java/br/com/efi/charges/subscription/json/CreateOneStepBilletSubscription.java new file mode 100644 index 0000000..945ac2a --- /dev/null +++ b/src/main/java/br/com/efi/charges/subscription/json/CreateOneStepBilletSubscription.java @@ -0,0 +1,87 @@ +package br.com.efi.charges.subscription.json; + +import java.util.HashMap; + +import org.json.JSONArray; +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class CreateOneStepBilletSubscription { + public static void main(String[] args) { + /* ********* Set credentials parameters ******** */ + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "6809"); + + // items + JSONArray items = new JSONArray(); + + JSONObject item1 = new JSONObject(); + item1.put("name", "Item 4"); + item1.put("amount", 1); + item1.put("value", 500); + + JSONObject item2 = new JSONObject("{\"name\":\"Item 2\", \"amount\":1, \"value\":1000}"); + + items.put(item1); + items.put(item2); + + // customer + JSONObject customer = new JSONObject(); + customer.put("name", "Gorbadoc Oldbuck"); + customer.put("cpf", "94271564656"); + customer.put("phone_number", "5144916523"); + + // notification url + JSONObject metadata = new JSONObject(); + metadata.put("notification_url", "http://domain.com/notification"); + + //discount + JSONObject discount = new JSONObject(); + discount.put("type","currency"); + discount.put("value",599); + + //configurations + JSONObject configurations = new JSONObject(); + configurations.put("fine", 200); + configurations.put("interest", 33); + + JSONObject bankingBillet = new JSONObject(); + bankingBillet.put("expire_at", "2023-10-15"); + bankingBillet.put("customer", customer); + bankingBillet.put("discount", discount); + bankingBillet.put("configurations", configurations); + + JSONObject payment = new JSONObject(); + payment.put("banking_billet", bankingBillet); + + JSONObject body = new JSONObject(); + body.put("payment", payment); + body.put("items", items); + body.put("metadata", metadata); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("createOneStepSubscription", params, body); + System.out.println(response); + } catch (EfiPayException e) { + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/subscription/json/CreateOneStepCardSubscription.java b/src/main/java/br/com/efi/charges/subscription/json/CreateOneStepCardSubscription.java new file mode 100644 index 0000000..11e1a63 --- /dev/null +++ b/src/main/java/br/com/efi/charges/subscription/json/CreateOneStepCardSubscription.java @@ -0,0 +1,93 @@ +package br.com.efi.charges.subscription.json; + +import java.util.HashMap; + +import org.json.JSONArray; +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class CreateOneStepCardSubscription { + public static void main(String[] args) { + + /* ********* Set credentials parameters ******** */ + Credentials credentials = new Credentials(); + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + String paymentToken = "Insira_aqui_o_payment_token"; + + // items + JSONArray items = new JSONArray(); + JSONObject item1 = new JSONObject(); + item1.put("name", "Item 4"); + item1.put("amount", 1); + item1.put("value", 600); + JSONObject item2 = new JSONObject("{\"name\":\"Item 2\", \"amount\":1, \"value\":1000}"); + items.put(item1); + items.put(item2); + + //customer + JSONObject customer = new JSONObject(); + customer.put("name", "Gorbadoc Oldbuck"); + customer.put("cpf", "94271564656"); + customer.put("phone_number", "5144916523"); + customer.put("email", "client_email@server.com.br"); + customer.put("birth", "1990-05-04"); + + //address + JSONObject billingAddress = new JSONObject(); + billingAddress.put("street", "Av. JK"); + billingAddress.put("number", 909); + billingAddress.put("neighborhood", "Bauxita"); + billingAddress.put("zipcode", "35400000"); + billingAddress.put("city", "Ouro Preto"); + billingAddress.put("state", "MG"); + + //notification URL + JSONObject metadata = new JSONObject(); + metadata.put("notification_url", "https://requestb.in/16rpx6y1"); + metadata.put("custom_id", "id_0007"); + + //discount + JSONObject discount = new JSONObject(); + discount.put("type","currency"); + discount.put("value",599); + + JSONObject creditCard = new JSONObject(); + creditCard.put("installments", 1); + creditCard.put("billing_address", billingAddress); + creditCard.put("payment_token", paymentToken); + creditCard.put("customer", customer); + creditCard.put("discount", discount); + + JSONObject payment = new JSONObject(); + payment.put("credit_card", creditCard); + + JSONObject body = new JSONObject(); + body.put("payment", payment); + body.put("items", items); + body.put("metadata", metadata); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("createOneStepSubscription", params, body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} \ No newline at end of file diff --git a/src/main/java/br/com/efi/charges/subscription/json/CreateOneStepSubscriptionLink.java b/src/main/java/br/com/efi/charges/subscription/json/CreateOneStepSubscriptionLink.java new file mode 100644 index 0000000..43ed7f6 --- /dev/null +++ b/src/main/java/br/com/efi/charges/subscription/json/CreateOneStepSubscriptionLink.java @@ -0,0 +1,71 @@ +package br.com.efi.charges.subscription.json; + +import java.util.HashMap; + +import org.json.JSONArray; +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class CreateOneStepSubscriptionLink { + public static void main(String[] args) { + /* ********* Set credentials parameters ******** */ + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + // items + JSONArray items = new JSONArray(); + + JSONObject item1 = new JSONObject(); + item1.put("name", "Item 4"); + item1.put("amount", 1); + item1.put("value", 500); + + JSONObject item2 = new JSONObject("{\"name\":\"Item 2\", \"amount\":1, \"value\":1000}"); + + items.put(item1); + items.put(item2); + + JSONObject seetings = new JSONObject(); + seetings.put("billet_discount", 10); + seetings.put("card_discount", 10); + seetings.put("message", "link test"); + seetings.put("expire_at", "2022-10-18"); + seetings.put("request_delivery_address", false); + seetings.put("payment_method", "all"); + + //notification url + JSONObject metadata = new JSONObject(); + metadata.put("notification_url", "http://domain.com/notification"); + + JSONObject body = new JSONObject(); + body.put("items", items); + body.put("settings", seetings); + body.put("metadata", metadata); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("createOneStepSubscriptionLink", params, body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/subscription/json/CreatePlan.java b/src/main/java/br/com/efi/charges/subscription/json/CreatePlan.java new file mode 100644 index 0000000..ab6a7cc --- /dev/null +++ b/src/main/java/br/com/efi/charges/subscription/json/CreatePlan.java @@ -0,0 +1,41 @@ +package br.com.efi.charges.subscription.json; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class CreatePlan { + public static void main(String[] args) { + /* ********* Set credential parameters ******** */ + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + JSONObject body = new JSONObject(); + body.put("name", "My plan"); + body.put("interval", 2); + body.put("repeats", 2); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("createPlan", new HashMap(), body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + }catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/subscription/json/CreateSubscriptionHistory.java b/src/main/java/br/com/efi/charges/subscription/json/CreateSubscriptionHistory.java new file mode 100644 index 0000000..018494b --- /dev/null +++ b/src/main/java/br/com/efi/charges/subscription/json/CreateSubscriptionHistory.java @@ -0,0 +1,43 @@ +package br.com.efi.charges.subscription.json; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class CreateSubscriptionHistory { + public static void main(String[] args) { + /* ********* Set credential parameters ******** */ + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + JSONObject body = new JSONObject(); + body.put("description", "This subscription was not fully paid"); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("createSubscriptionHistory", params, body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/subscription/json/DefineSubscriptionBillet.java b/src/main/java/br/com/efi/charges/subscription/json/DefineSubscriptionBillet.java new file mode 100644 index 0000000..1963203 --- /dev/null +++ b/src/main/java/br/com/efi/charges/subscription/json/DefineSubscriptionBillet.java @@ -0,0 +1,55 @@ +package br.com.efi.charges.subscription.json; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class DefineSubscriptionBillet { + public static void main(String[] args) { + /* ********* Set credential parameters ******** */ + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + JSONObject customer = new JSONObject(); + customer.put("name", "Gorbadoc Oldbuck"); + customer.put("cpf", "94271564656"); + customer.put("phone_number", "5144916523"); + + JSONObject bankingBillet = new JSONObject(); + bankingBillet.put("expire_at", "2022-12-12"); + bankingBillet.put("customer", customer); + + JSONObject payment = new JSONObject(); + payment.put("banking_billet", bankingBillet); + + JSONObject body = new JSONObject(); + body.put("payment", payment); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("defineSubscriptionPayMethod", params, body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/subscription/json/DefineSubscriptionCard.java b/src/main/java/br/com/efi/charges/subscription/json/DefineSubscriptionCard.java new file mode 100644 index 0000000..91817f1 --- /dev/null +++ b/src/main/java/br/com/efi/charges/subscription/json/DefineSubscriptionCard.java @@ -0,0 +1,69 @@ +package br.com.efi.charges.subscription.json; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class DefineSubscriptionCard { + public static void main(String[] args) { + /* ********* Set credentials parameters ******** */ + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + String paymentToken = "Insira_aqui_o_payment_token"; + + JSONObject customer = new JSONObject(); + customer.put("name", "Gorbadoc Oldbuck"); + customer.put("cpf", "94271564656"); + customer.put("phone_number", "5144916523"); + customer.put("email", "client_email@server.com.br"); + customer.put("birth", "1977-01-15"); + + JSONObject billingAddress = new JSONObject(); + billingAddress.put("street", "Av. JK"); + billingAddress.put("number", 909); + billingAddress.put("neighborhood", "Bauxita"); + billingAddress.put("zipcode", "5400000"); + billingAddress.put("city", "Ouro Preto"); + billingAddress.put("state", "MG"); + + JSONObject creditCard = new JSONObject(); + creditCard.put("installments", 1); + creditCard.put("billing_address", billingAddress); + creditCard.put("payment_token", paymentToken); + creditCard.put("customer", customer); + + JSONObject payment = new JSONObject(); + payment.put("credit_card", creditCard); + + JSONObject body = new JSONObject(); + body.put("payment", payment); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("defineSubscriptionPayMethod", params, body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/subscription/json/DeletePlan.java b/src/main/java/br/com/efi/charges/subscription/json/DeletePlan.java new file mode 100644 index 0000000..ecf8207 --- /dev/null +++ b/src/main/java/br/com/efi/charges/subscription/json/DeletePlan.java @@ -0,0 +1,39 @@ +package br.com.efi.charges.subscription.json; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class DeletePlan { + public static void main(String[] args) { + /* ********* Set credential parameters ******** */ + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("deletePlan", params, new JSONObject()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + }catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/subscription/json/DetailSubscription.java b/src/main/java/br/com/efi/charges/subscription/json/DetailSubscription.java new file mode 100644 index 0000000..da42089 --- /dev/null +++ b/src/main/java/br/com/efi/charges/subscription/json/DetailSubscription.java @@ -0,0 +1,39 @@ +package br.com.efi.charges.subscription.json; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class DetailSubscription { + public static void main(String[] args) { + /* ********* Set credential parameters ******** */ + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("detailSubscription", params, new JSONObject()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + }catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/subscription/json/ListPlan.java b/src/main/java/br/com/efi/charges/subscription/json/ListPlan.java new file mode 100644 index 0000000..1c21866 --- /dev/null +++ b/src/main/java/br/com/efi/charges/subscription/json/ListPlan.java @@ -0,0 +1,41 @@ +package br.com.efi.charges.subscription.json; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class ListPlan { + public static void main(String[] args) { + /* ********* Set credential parameters ******** */ + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("name", "My plan"); + params.put("limit", "20"); + params.put("offset", "0"); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("listPlans", params, new JSONObject()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + }catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/subscription/json/SendSubscriptionLinkEmail.java b/src/main/java/br/com/efi/charges/subscription/json/SendSubscriptionLinkEmail.java new file mode 100644 index 0000000..c3d98c5 --- /dev/null +++ b/src/main/java/br/com/efi/charges/subscription/json/SendSubscriptionLinkEmail.java @@ -0,0 +1,47 @@ +package br.com.efi.charges.subscription.json; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class SendSubscriptionLinkEmail { + + public static void main(String[] args) { + /* ********* Set credentials parameters ******** */ + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "993257"); + + JSONObject body = new JSONObject(); + body.put("email", "client_email@server.com.br"); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("sendSubscriptionLinkEmail", params, body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + e.printStackTrace(); + System.out.println(e.getMessage()); + } + + } + +} diff --git a/src/main/java/br/com/efi/charges/subscription/json/UpdatePlan.java b/src/main/java/br/com/efi/charges/subscription/json/UpdatePlan.java new file mode 100644 index 0000000..e7a2522 --- /dev/null +++ b/src/main/java/br/com/efi/charges/subscription/json/UpdatePlan.java @@ -0,0 +1,43 @@ +package br.com.efi.charges.subscription.json; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class UpdatePlan { + public static void main(String[] args) { + /* ********* Set credential parameters ******** */ + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + JSONObject body = new JSONObject(); + body.put("name", "My new plan"); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("updatePlan", params, body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/subscription/json/UpdateSubscriptionMetadata.java b/src/main/java/br/com/efi/charges/subscription/json/UpdateSubscriptionMetadata.java new file mode 100644 index 0000000..d9af8f1 --- /dev/null +++ b/src/main/java/br/com/efi/charges/subscription/json/UpdateSubscriptionMetadata.java @@ -0,0 +1,44 @@ +package br.com.efi.charges.subscription.json; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class UpdateSubscriptionMetadata { + public static void main(String[] args) { + /* ********* Set credential parameters ******** */ + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + JSONObject body = new JSONObject(); + body.put("notification_url", "http://domain.com/notification"); + body.put("custom_id", "Custom Subscription 0001"); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("updateSubscriptionMetadata", params, body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + }catch (Exception e) { + System.out.println(e.getMessage()); + } + + } +} diff --git a/src/main/java/br/com/efi/charges/subscription/map/CancelSubscription.java b/src/main/java/br/com/efi/charges/subscription/map/CancelSubscription.java new file mode 100644 index 0000000..d70494d --- /dev/null +++ b/src/main/java/br/com/efi/charges/subscription/map/CancelSubscription.java @@ -0,0 +1,38 @@ +package br.com.efi.charges.subscription.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class CancelSubscription { + public static void main(String[] args) { + /* ********* Set credential parameters ******** */ + + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("cancelSubscription", params, new HashMap()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + }catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/subscription/map/CreateCharge.java b/src/main/java/br/com/efi/charges/subscription/map/CreateCharge.java new file mode 100644 index 0000000..acdda11 --- /dev/null +++ b/src/main/java/br/com/efi/charges/subscription/map/CreateCharge.java @@ -0,0 +1,57 @@ +package br.com.efi.charges.subscription.map; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class CreateCharge { + public static void main(String[] args) { + /* ********* Set credential parameters ******** */ + + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + HashMap params = new HashMap(); + params.put("id", "0"); + + List items = new ArrayList(); + + Map item1 = new HashMap(); + item1.put("name", "Item 1"); + item1.put("amount", 1); + item1.put("value", 1000); + + Map item2 = new HashMap(); + item2.put("name", "Item 2"); + item2.put("amount", 1); + item2.put("value", 2000); + + items.add(item1); + items.add(item2); + + Map body = new HashMap(); + body.put("items", items); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("createSubscription", params, body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + }catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/subscription/map/CreateOneStepBilletSubscription.java b/src/main/java/br/com/efi/charges/subscription/map/CreateOneStepBilletSubscription.java new file mode 100644 index 0000000..330f739 --- /dev/null +++ b/src/main/java/br/com/efi/charges/subscription/map/CreateOneStepBilletSubscription.java @@ -0,0 +1,82 @@ +package br.com.efi.charges.subscription.map; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class CreateOneStepBilletSubscription { + public static void main(String[] args) { + + /* ********* Set credentials parameters ******** */ + Credentials credentials = new Credentials(); + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + HashMap params = new HashMap(); + params.put("id", "0"); + + List items = new ArrayList(); + Map item1 = new HashMap(); + item1.put("name", "Item 1"); + item1.put("amount", 1); + item1.put("value", 1000); + + Map item2 = new HashMap(); + item2.put("name", "Item 2"); + item2.put("amount", 1); + item2.put("value", 2000); + items.add(item1); + items.add(item2); + + Map customer = new HashMap(); + customer.put("name", "Gorbadoc Oldbuck"); + customer.put("cpf", "94271564656"); + customer.put("phone_number", "5144916523"); + + Map metadata = new HashMap(); + metadata.put("notification_url", "http://domain.com/notification"); + + Map discount = new HashMap(); + discount.put("type","currency"); + discount.put("value",599); + + Map configurations = new HashMap(); + configurations.put("fine", 200); + configurations.put("interest", 33); + + Map bankingBillet = new HashMap(); + bankingBillet.put("expire_at", "2022-12-12"); + bankingBillet.put("customer", customer); + bankingBillet.put("discount", discount); + bankingBillet.put("configurations", configurations); + + Map payment = new HashMap(); + payment.put("banking_billet", bankingBillet); + + Map body = new HashMap(); + body.put("payment", payment); + body.put("items", items); + body.put("metadata", metadata); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("createOneStepSubscription", params, body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/subscription/map/CreateOneStepCardSubscription.java b/src/main/java/br/com/efi/charges/subscription/map/CreateOneStepCardSubscription.java new file mode 100644 index 0000000..7b9df56 --- /dev/null +++ b/src/main/java/br/com/efi/charges/subscription/map/CreateOneStepCardSubscription.java @@ -0,0 +1,77 @@ +package br.com.efi.charges.subscription.map; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; +public class CreateOneStepCardSubscription { + public static void main(String[] args) { + /* ********* Set credentials parameters ******** */ + Credentials credentials = new Credentials(); + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + List items = new ArrayList(); + Map item1 = new HashMap(); + item1.put("name", "Item 1"); + item1.put("amount", 1); + item1.put("value", 1000); + Map item2 = new HashMap(); + item2.put("name", "Item 2"); + item2.put("amount", 1); + item2.put("value", 2000); + items.add(item1); + items.add(item2); + + String paymentToken = "Insira_aqui_o_payment_token"; + + Map customer = new HashMap(); + customer.put("name", "Gorbadoc Oldbuck"); + customer.put("cpf", "94271564656"); + customer.put("phone_number", "5144916523"); + customer.put("email", "client_email@server.com.br"); + customer.put("birth", "1977-01-15"); + + Map billingAddress = new HashMap(); + billingAddress.put("street", "Av. JK"); + billingAddress.put("number", 909); + billingAddress.put("neighborhood", "Bauxita"); + billingAddress.put("zipcode", "35400000"); + billingAddress.put("city", "Ouro Preto"); + billingAddress.put("state", "MG"); + + Map creditCard = new HashMap(); + creditCard.put("installments", 1); + creditCard.put("billing_address", billingAddress); + creditCard.put("payment_token", paymentToken); + creditCard.put("customer", customer); + Map payment = new HashMap(); + payment.put("credit_card", creditCard); + Map body = new HashMap(); + body.put("items", items); + body.put("payment", payment); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("createOneStepSubscription", params, body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} \ No newline at end of file diff --git a/src/main/java/br/com/efi/charges/subscription/map/CreateOneStepSubscriptionLink.java b/src/main/java/br/com/efi/charges/subscription/map/CreateOneStepSubscriptionLink.java new file mode 100644 index 0000000..ea45f41 --- /dev/null +++ b/src/main/java/br/com/efi/charges/subscription/map/CreateOneStepSubscriptionLink.java @@ -0,0 +1,69 @@ +package br.com.efi.charges.subscription.map; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class CreateOneStepSubscriptionLink { + public static void main(String[] args) { + + /* ********* Set credentials parameters ******** */ + Credentials credentials = new Credentials(); + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + List items = new ArrayList(); + Map item1 = new HashMap(); + item1.put("name", "Item 1"); + item1.put("amount", 1); + item1.put("value", 1000); + + Map item2 = new HashMap(); + item2.put("name", "Item 2"); + item2.put("amount", 1); + item2.put("value", 2000); + items.add(item1); + items.add(item2); + + Map seetings = new HashMap(); + seetings.put("billet_discount", 10); + seetings.put("card_discount", 10); + seetings.put("message", "link test"); + seetings.put("expire_at", "2022-10-18"); + seetings.put("request_delivery_address", false); + seetings.put("payment_method", "all"); + + Map metadata = new HashMap(); + metadata.put("notification_url", "http://domain.com/notification"); + + Map body = new HashMap(); + body.put("items", items); + body.put("settings", seetings); + body.put("metadata", metadata); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("createOneStepSubscriptionLink", params, body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/subscription/map/CreatePlan.java b/src/main/java/br/com/efi/charges/subscription/map/CreatePlan.java new file mode 100644 index 0000000..b8df2b8 --- /dev/null +++ b/src/main/java/br/com/efi/charges/subscription/map/CreatePlan.java @@ -0,0 +1,40 @@ +package br.com.efi.charges.subscription.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class CreatePlan { + public static void main(String[] args) { + /* ********* Set credential parameters ******** */ + + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + Map body = new HashMap(); + body.put("name", "My plan"); + body.put("interval", 2); + body.put("repeats", 2); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("createPlan", new HashMap(), body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + }catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/subscription/map/CreateSubscriptionHistory.java b/src/main/java/br/com/efi/charges/subscription/map/CreateSubscriptionHistory.java new file mode 100644 index 0000000..72ff085 --- /dev/null +++ b/src/main/java/br/com/efi/charges/subscription/map/CreateSubscriptionHistory.java @@ -0,0 +1,42 @@ +package br.com.efi.charges.subscription.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class CreateSubscriptionHistory { + public static void main(String[] args) { + /* ********* Set credential parameters ******** */ + + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + Map body = new HashMap(); + body.put("description", "This subscription was not fully paid"); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("createSubscriptionHistory", params, body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/subscription/map/DefineSubscriptionBillet.java b/src/main/java/br/com/efi/charges/subscription/map/DefineSubscriptionBillet.java new file mode 100644 index 0000000..4e0e7ed --- /dev/null +++ b/src/main/java/br/com/efi/charges/subscription/map/DefineSubscriptionBillet.java @@ -0,0 +1,54 @@ +package br.com.efi.charges.subscription.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class DefineSubscriptionBillet { + public static void main(String[] args) { + /* ********* Set credential parameters ******** */ + + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + Map customer = new HashMap(); + customer.put("name", "Gorbadoc Oldbuck"); + customer.put("cpf", "94271564656"); + customer.put("phone_number", "5144916523"); + + Map bankingBillet = new HashMap(); + bankingBillet.put("expire_at", "2018-12-12"); + bankingBillet.put("customer", customer); + + Map payment = new HashMap(); + payment.put("banking_billet", bankingBillet); + + Map body = new HashMap(); + body.put("payment", payment); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("defineSubscriptionPayMethod", params, body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/subscription/map/DefineSubscriptionCard.java b/src/main/java/br/com/efi/charges/subscription/map/DefineSubscriptionCard.java new file mode 100644 index 0000000..62c3888 --- /dev/null +++ b/src/main/java/br/com/efi/charges/subscription/map/DefineSubscriptionCard.java @@ -0,0 +1,68 @@ +package br.com.efi.charges.subscription.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class DefineSubscriptionCard { + public static void main(String[] args) { + /* ********* Set credentials parameters ******** */ + + Credentials credentials = new Credentials(); + + Map options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + String paymentToken = "Insira_aqui_o_payment_token"; + + Map customer = new HashMap(); + customer.put("name", "Gorbadoc Oldbuck"); + customer.put("cpf", "94271564656"); + customer.put("phone_number", "5144916523"); + customer.put("email", "client_email@server.com.br"); + customer.put("birth", "1977-01-15"); + + Map billingAddress = new HashMap(); + billingAddress.put("street", "Av. JK"); + billingAddress.put("number", 909); + billingAddress.put("neighborhood", "Bauxita"); + billingAddress.put("zipcode", "5400000"); + billingAddress.put("city", "Ouro Preto"); + billingAddress.put("state", "MG"); + + Map creditCard = new HashMap(); + creditCard.put("installments", 1); + creditCard.put("billing_address", billingAddress); + creditCard.put("payment_token", paymentToken); + creditCard.put("customer", customer); + + Map payment = new HashMap(); + payment.put("credit_card", creditCard); + + Map body = new HashMap(); + body.put("payment", payment); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("defineSubscriptionPayMethod", params, body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/subscription/map/DeletePlan.java b/src/main/java/br/com/efi/charges/subscription/map/DeletePlan.java new file mode 100644 index 0000000..7dfcdcb --- /dev/null +++ b/src/main/java/br/com/efi/charges/subscription/map/DeletePlan.java @@ -0,0 +1,38 @@ +package br.com.efi.charges.subscription.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class DeletePlan { + public static void main(String[] args) { + /* ********* Set credential parameters ******** */ + + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("deletePlan", params, new HashMap()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + }catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/subscription/map/DetailSubscription.java b/src/main/java/br/com/efi/charges/subscription/map/DetailSubscription.java new file mode 100644 index 0000000..e56e29c --- /dev/null +++ b/src/main/java/br/com/efi/charges/subscription/map/DetailSubscription.java @@ -0,0 +1,38 @@ +package br.com.efi.charges.subscription.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class DetailSubscription { + public static void main(String[] args) { + /* ********* Set credential parameters ******** */ + + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("detailSubscription", params, new HashMap()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + }catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/subscription/map/ListPlan.java b/src/main/java/br/com/efi/charges/subscription/map/ListPlan.java new file mode 100644 index 0000000..596c04a --- /dev/null +++ b/src/main/java/br/com/efi/charges/subscription/map/ListPlan.java @@ -0,0 +1,40 @@ +package br.com.efi.charges.subscription.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class ListPlan { + public static void main(String[] args) { + /* ********* Set credential parameters ******** */ + + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("name", "My plan"); + params.put("limit", "20"); + params.put("offset", "0"); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("listPlans", params, new HashMap()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + }catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/subscription/map/SendSubscriptionLinkEmail.java b/src/main/java/br/com/efi/charges/subscription/map/SendSubscriptionLinkEmail.java new file mode 100644 index 0000000..883f8cd --- /dev/null +++ b/src/main/java/br/com/efi/charges/subscription/map/SendSubscriptionLinkEmail.java @@ -0,0 +1,46 @@ +package br.com.efi.charges.subscription.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class SendSubscriptionLinkEmail { + + public static void main(String[] args) { + /* ********* Set credentials parameters ******** */ + + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + Map body = new HashMap(); + body.put("email", "client_email@server.com.br"); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("sendSubscriptionLinkEmail", params, body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + e.printStackTrace(); + System.out.println(e.getMessage()); + } + + } + +} diff --git a/src/main/java/br/com/efi/charges/subscription/map/UpdatePlan.java b/src/main/java/br/com/efi/charges/subscription/map/UpdatePlan.java new file mode 100644 index 0000000..6259c2d --- /dev/null +++ b/src/main/java/br/com/efi/charges/subscription/map/UpdatePlan.java @@ -0,0 +1,42 @@ +package br.com.efi.charges.subscription.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class UpdatePlan { + public static void main(String[] args) { + /* ********* Set credential parameters ******** */ + + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + Map body = new HashMap(); + body.put("name", "My new plan"); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("updatePlan", params, body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/charges/subscription/map/UpdateSubscriptionMetadata.java b/src/main/java/br/com/efi/charges/subscription/map/UpdateSubscriptionMetadata.java new file mode 100644 index 0000000..535c25d --- /dev/null +++ b/src/main/java/br/com/efi/charges/subscription/map/UpdateSubscriptionMetadata.java @@ -0,0 +1,43 @@ +package br.com.efi.charges.subscription.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class UpdateSubscriptionMetadata { + public static void main(String[] args) { + /* ********* Set credential parameters ******** */ + + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("sandbox", credentials.isSandbox()); + + /* ************************************************* */ + + HashMap params = new HashMap(); + params.put("id", "0"); + + Map body = new HashMap(); + body.put("notification_url", "http://domain.com/notification"); + body.put("custom_id", "Custom Subscription 0001"); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("updateSubscriptionMetadata", params, body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getCode()); + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + }catch (Exception e) { + System.out.println(e.getMessage()); + } + + } +} diff --git a/src/main/java/br/com/efi/exclusives/account/json/GetAccountBalance.java b/src/main/java/br/com/efi/exclusives/account/json/GetAccountBalance.java new file mode 100644 index 0000000..bcaa2aa --- /dev/null +++ b/src/main/java/br/com/efi/exclusives/account/json/GetAccountBalance.java @@ -0,0 +1,37 @@ +package br.com.efi.exclusives.account.json; + +import java.io.IOException; + +import java.util.HashMap; + + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class GetAccountBalance { + public static void main(String[] args) throws IOException { + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("getAccountBalance", new HashMap(), new JSONObject()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + + } +} \ No newline at end of file diff --git a/src/main/java/br/com/efi/exclusives/account/json/ListAccountConfig.java b/src/main/java/br/com/efi/exclusives/account/json/ListAccountConfig.java new file mode 100644 index 0000000..c9485d5 --- /dev/null +++ b/src/main/java/br/com/efi/exclusives/account/json/ListAccountConfig.java @@ -0,0 +1,35 @@ +package br.com.efi.exclusives.account.json; + +import java.io.IOException; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class ListAccountConfig { + public static void main(String[] args) throws IOException { + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("listAccountConfig", new HashMap(), new JSONObject()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} \ No newline at end of file diff --git a/src/main/java/br/com/efi/exclusives/account/json/UpdateAccountConfig.java b/src/main/java/br/com/efi/exclusives/account/json/UpdateAccountConfig.java new file mode 100644 index 0000000..c88b1a3 --- /dev/null +++ b/src/main/java/br/com/efi/exclusives/account/json/UpdateAccountConfig.java @@ -0,0 +1,49 @@ +package br.com.efi.exclusives.account.json; + +import java.io.IOException; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class UpdateAccountConfig { + public static void main(String[] args) throws IOException { + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + JSONObject body = new JSONObject(); + body.put("pix", new JSONObject() + .put("receberSemChave", true) + .put("chaves", new JSONObject() + .put("Insira_aqui_sua_chave", new JSONObject() + .put("recebimento", new JSONObject() + .put("txidObrigatorio", true) + .put("qrCodeEstatico", new JSONObject() + .put("recusarTodos", false) + .put("webhook", new JSONObject() + .put("tarifa", true) + .put("pagador", true) + )))))); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("updateAccountConfig", new HashMap(), body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} \ No newline at end of file diff --git a/src/main/java/br/com/efi/exclusives/account/map/GetAccountBalance.java b/src/main/java/br/com/efi/exclusives/account/map/GetAccountBalance.java new file mode 100644 index 0000000..90d4f46 --- /dev/null +++ b/src/main/java/br/com/efi/exclusives/account/map/GetAccountBalance.java @@ -0,0 +1,35 @@ +package br.com.efi.exclusives.account.map; + +import java.io.IOException; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class GetAccountBalance { + public static void main(String[] args) throws IOException { + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("getAccountBalance", new HashMap(), new HashMap()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + + } +} \ No newline at end of file diff --git a/src/main/java/br/com/efi/exclusives/account/map/ListAccountConfig.java b/src/main/java/br/com/efi/exclusives/account/map/ListAccountConfig.java new file mode 100644 index 0000000..38d73e3 --- /dev/null +++ b/src/main/java/br/com/efi/exclusives/account/map/ListAccountConfig.java @@ -0,0 +1,34 @@ +package br.com.efi.exclusives.account.map; + +import java.io.IOException; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class ListAccountConfig { + public static void main(String[] args) throws IOException { + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("listAccountConfig", new HashMap(), new HashMap()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} \ No newline at end of file diff --git a/src/main/java/br/com/efi/exclusives/account/map/UpdateAccountConfig.java b/src/main/java/br/com/efi/exclusives/account/map/UpdateAccountConfig.java new file mode 100644 index 0000000..11786b8 --- /dev/null +++ b/src/main/java/br/com/efi/exclusives/account/map/UpdateAccountConfig.java @@ -0,0 +1,46 @@ +package br.com.efi.exclusives.account.map; + +import java.io.IOException; + +import java.util.HashMap; +import java.util.Map; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class UpdateAccountConfig { + public static void main(String[] args) throws IOException { + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + Map body = new HashMap(); + body.put("pix", new JSONObject() + .put("receberSemChave", true) + .put("chaves", new JSONObject() + .put("Insira_aqui_sua_chave", new JSONObject() + .put("recebimento", new JSONObject() + .put("txidObrigatorio", true) + .put("qrCodeEstatico", new JSONObject() + .put("recusarTodos", false)))))); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("updateAccountConfig", new HashMap(), body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} \ No newline at end of file diff --git a/src/main/java/br/com/efi/exclusives/key/json/PixCreateEvp.java b/src/main/java/br/com/efi/exclusives/key/json/PixCreateEvp.java new file mode 100644 index 0000000..b754653 --- /dev/null +++ b/src/main/java/br/com/efi/exclusives/key/json/PixCreateEvp.java @@ -0,0 +1,35 @@ +package br.com.efi.exclusives.key.json; + +import java.io.IOException; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixCreateEvp { + public static void main(String[] args) throws IOException { + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("pixCreateEvp", new HashMap(), new JSONObject()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} \ No newline at end of file diff --git a/src/main/java/br/com/efi/exclusives/key/json/PixDeleteEvp.java b/src/main/java/br/com/efi/exclusives/key/json/PixDeleteEvp.java new file mode 100644 index 0000000..c26dad1 --- /dev/null +++ b/src/main/java/br/com/efi/exclusives/key/json/PixDeleteEvp.java @@ -0,0 +1,36 @@ +package br.com.efi.exclusives.key.json; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixDeleteEvp { + public static void main(String[] args) { + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("chave", "Insira_aqui_a_chave"); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("pixDeleteEvp", params, new JSONObject()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/exclusives/key/json/PixListEvp.java b/src/main/java/br/com/efi/exclusives/key/json/PixListEvp.java new file mode 100644 index 0000000..83a1ca4 --- /dev/null +++ b/src/main/java/br/com/efi/exclusives/key/json/PixListEvp.java @@ -0,0 +1,35 @@ +package br.com.efi.exclusives.key.json; + +import java.io.IOException; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixListEvp { + public static void main(String[] args) throws IOException { + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("pixListEvp", new HashMap(), new JSONObject()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} \ No newline at end of file diff --git a/src/main/java/br/com/efi/exclusives/key/map/PixCreateEvp.java b/src/main/java/br/com/efi/exclusives/key/map/PixCreateEvp.java new file mode 100644 index 0000000..11715c8 --- /dev/null +++ b/src/main/java/br/com/efi/exclusives/key/map/PixCreateEvp.java @@ -0,0 +1,35 @@ +package br.com.efi.exclusives.key.map; + +import java.io.IOException; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixCreateEvp { + public static void main(String[] args) throws IOException { + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + try { + EfiPay efi = new EfiPay(options); + + Map response = efi.call("pixCreateEvp", new HashMap(), new HashMap()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} \ No newline at end of file diff --git a/src/main/java/br/com/efi/exclusives/key/map/PixDeleteEvp.java b/src/main/java/br/com/efi/exclusives/key/map/PixDeleteEvp.java new file mode 100644 index 0000000..78396f7 --- /dev/null +++ b/src/main/java/br/com/efi/exclusives/key/map/PixDeleteEvp.java @@ -0,0 +1,36 @@ +package br.com.efi.exclusives.key.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixDeleteEvp { + public static void main(String[] args) { + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("chave", "Insira_aqui_a_chave"); + + try { + EfiPay efi = new EfiPay(options); + + Map response = efi.call("pixDeleteEvp", params, new HashMap()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/exclusives/key/map/PixListEvp.java b/src/main/java/br/com/efi/exclusives/key/map/PixListEvp.java new file mode 100644 index 0000000..f1fcd67 --- /dev/null +++ b/src/main/java/br/com/efi/exclusives/key/map/PixListEvp.java @@ -0,0 +1,34 @@ +package br.com.efi.exclusives.key.map; + +import java.io.IOException; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixListEvp { + public static void main(String[] args) throws IOException { + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("pixListEvp", new HashMap(), new HashMap()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} \ No newline at end of file diff --git a/src/main/java/br/com/efi/exclusives/report/json/CreateReport.java b/src/main/java/br/com/efi/exclusives/report/json/CreateReport.java new file mode 100644 index 0000000..0024ded --- /dev/null +++ b/src/main/java/br/com/efi/exclusives/report/json/CreateReport.java @@ -0,0 +1,44 @@ +package br.com.efi.exclusives.report.json; + +import java.io.IOException; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class CreateReport { + public static void main(String[] args) throws IOException { + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + JSONObject body = new JSONObject(); + body.put("dataMovimento", "2022-04-24"); + body.put("tipoRegistros", new JSONObject().put("pixRecebido", true) + .put("pixDevolucaoEnviada", false) + .put("tarifaPixRecebido", true) + .put("pixEnviadoChave", true) + .put("pixEnviadoDadosBancarios", false) + .put("pixDevolucaoRecebida", true)); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("createReport", new HashMap(), body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} \ No newline at end of file diff --git a/src/main/java/br/com/efi/exclusives/report/json/DetailReport.java b/src/main/java/br/com/efi/exclusives/report/json/DetailReport.java new file mode 100644 index 0000000..3c33677 --- /dev/null +++ b/src/main/java/br/com/efi/exclusives/report/json/DetailReport.java @@ -0,0 +1,38 @@ +package br.com.efi.exclusives.report.json; + +import java.io.IOException; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class DetailReport { + public static void main(String[] args) throws IOException { + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("id", "Insira_aqui_o_id_do_relatorio"); + + try { + EfiPay efi = new EfiPay(options); + String response = efi.callString("detailReport", params, new JSONObject()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} \ No newline at end of file diff --git a/src/main/java/br/com/efi/exclusives/report/map/CreateReport.java b/src/main/java/br/com/efi/exclusives/report/map/CreateReport.java new file mode 100644 index 0000000..0773c9a --- /dev/null +++ b/src/main/java/br/com/efi/exclusives/report/map/CreateReport.java @@ -0,0 +1,46 @@ +package br.com.efi.exclusives.report.map; + +import java.io.IOException; + +import java.util.HashMap; +import java.util.Map; +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class CreateReport { + public static void main(String[] args) throws IOException { + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + Map body = new HashMap(); + body.put("dataMovimento", "2022-04-24"); + body.put("tipoRegistros", new JSONObject().put("pixRecebido", true) + .put("pixDevolucaoEnviada", false) + .put("tarifaPixRecebido", true) + .put("pixEnviadoChave", true) + .put("pixEnviadoDadosBancarios", false) + .put("pixDevolucaoRecebida", true)); + + + try { + EfiPay efi = new EfiPay(options); + + Map response = efi.call("createReport", new HashMap(), body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} \ No newline at end of file diff --git a/src/main/java/br/com/efi/exclusives/report/map/DetailReport.java b/src/main/java/br/com/efi/exclusives/report/map/DetailReport.java new file mode 100644 index 0000000..a366816 --- /dev/null +++ b/src/main/java/br/com/efi/exclusives/report/map/DetailReport.java @@ -0,0 +1,37 @@ +package br.com.efi.exclusives.report.map; + +import java.io.IOException; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class DetailReport { + public static void main(String[] args) throws IOException { + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("id", "Insira_aqui_o_id_do_relatorio"); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("detailReport", params, new HashMap()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} \ No newline at end of file diff --git a/src/main/java/br/com/efi/open_finance/config/json/OfConfigDetail.java b/src/main/java/br/com/efi/open_finance/config/json/OfConfigDetail.java new file mode 100644 index 0000000..5226275 --- /dev/null +++ b/src/main/java/br/com/efi/open_finance/config/json/OfConfigDetail.java @@ -0,0 +1,34 @@ +package br.com.efi.open_finance.config.json; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class OfConfigDetail { + public static void main(String[] args) { + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("ofConfigDetail", new HashMap(), new JSONObject()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/open_finance/config/json/OfConfigUpdate.java b/src/main/java/br/com/efi/open_finance/config/json/OfConfigUpdate.java new file mode 100644 index 0000000..59e9b2f --- /dev/null +++ b/src/main/java/br/com/efi/open_finance/config/json/OfConfigUpdate.java @@ -0,0 +1,36 @@ +package br.com.efi.open_finance.config.json; +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class OfConfigUpdate { + public static void main(String[] args) { + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + JSONObject body = new JSONObject(); + body.put("redirectURL", "https://client.com/redirect/here"); + body.put("webhookURL", "https://client.com/send/callback/here"); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("ofConfigUpdate", new HashMap(), body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/open_finance/config/map/OfConfigDetail.java b/src/main/java/br/com/efi/open_finance/config/map/OfConfigDetail.java new file mode 100644 index 0000000..d806539 --- /dev/null +++ b/src/main/java/br/com/efi/open_finance/config/map/OfConfigDetail.java @@ -0,0 +1,34 @@ +package br.com.efi.open_finance.config.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class OfConfigDetail { + public static void main(String[] args) { + + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + try { + EfiPay efi = new EfiPay(options); + + Map response = efi.call("ofConfigDetail", new HashMap(), new HashMap()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/open_finance/config/map/OfConfigUpdate.java b/src/main/java/br/com/efi/open_finance/config/map/OfConfigUpdate.java new file mode 100644 index 0000000..053eaab --- /dev/null +++ b/src/main/java/br/com/efi/open_finance/config/map/OfConfigUpdate.java @@ -0,0 +1,36 @@ +package br.com.efi.open_finance.config.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class OfConfigUpdate { + public static void main(String[] args) { + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + Map body = new HashMap(); + body.put("redirectURL", "https://client.com/redirect/here"); + body.put("webhookURL", "https://client.com/send/callback/here"); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("ofConfigUpdate", new HashMap(), body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/open_finance/devolution/json/OfDevolutionPix.java b/src/main/java/br/com/efi/open_finance/devolution/json/OfDevolutionPix.java new file mode 100644 index 0000000..85bbc18 --- /dev/null +++ b/src/main/java/br/com/efi/open_finance/devolution/json/OfDevolutionPix.java @@ -0,0 +1,39 @@ +package br.com.efi.open_finance.devolution.json; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class OfDevolutionPix { + public static void main(String[] args) { + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("identificadorPagamento", "urn:efi:316df855-b8f5-4bbb-ae65-c97d80549b6f"); + + JSONObject body = new JSONObject(); + body.put("valor", "0.01"); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("ofDevolutionPix", params, body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/open_finance/devolution/map/OfDevolutionPix.java b/src/main/java/br/com/efi/open_finance/devolution/map/OfDevolutionPix.java new file mode 100644 index 0000000..7eeed65 --- /dev/null +++ b/src/main/java/br/com/efi/open_finance/devolution/map/OfDevolutionPix.java @@ -0,0 +1,39 @@ +package br.com.efi.open_finance.devolution.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class OfDevolutionPix { + public static void main(String[] args) { + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("identificadorPagamento", "urn:efi:316df855-b8f5-4bbb-ae65-c97d80549b6f"); + + Map body = new HashMap(); + body.put("valor", "0.01"); + + try { + EfiPay efi = new EfiPay(options); + + Map response = efi.call("ofDevolutionPix", params, body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/open_finance/participants/json/OfListParticipants.java b/src/main/java/br/com/efi/open_finance/participants/json/OfListParticipants.java new file mode 100644 index 0000000..aca1604 --- /dev/null +++ b/src/main/java/br/com/efi/open_finance/participants/json/OfListParticipants.java @@ -0,0 +1,33 @@ +package br.com.efi.open_finance.participants.json; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class OfListParticipants { + public static void main(String[] args) { + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("ofListParticipants", new HashMap(), new JSONObject()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/open_finance/participants/map/OfListParticipants.java b/src/main/java/br/com/efi/open_finance/participants/map/OfListParticipants.java new file mode 100644 index 0000000..f40a9ee --- /dev/null +++ b/src/main/java/br/com/efi/open_finance/participants/map/OfListParticipants.java @@ -0,0 +1,32 @@ +package br.com.efi.open_finance.participants.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class OfListParticipants { + public static void main(String[] args) { + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("ofListParticipants", new HashMap(), new HashMap()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/open_finance/payment/json/OfListPixPayment.java b/src/main/java/br/com/efi/open_finance/payment/json/OfListPixPayment.java new file mode 100644 index 0000000..93076c2 --- /dev/null +++ b/src/main/java/br/com/efi/open_finance/payment/json/OfListPixPayment.java @@ -0,0 +1,37 @@ +package br.com.efi.open_finance.payment.json; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class OfListPixPayment { + public static void main(String[] args) { + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("inicio", "2021-05-01"); + params.put("fim", "2022-12-30"); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("ofListPixPayment", params, new JSONObject()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/open_finance/payment/json/OfStartPixPayment.java b/src/main/java/br/com/efi/open_finance/payment/json/OfStartPixPayment.java new file mode 100644 index 0000000..8ea6e5c --- /dev/null +++ b/src/main/java/br/com/efi/open_finance/payment/json/OfStartPixPayment.java @@ -0,0 +1,49 @@ +package br.com.efi.open_finance.payment.json; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class OfStartPixPayment { + public static void main(String[] args) { + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + options.put("x-idempotency-key", "gbkc18gDqurGJRHIrtGD8NRcFWfignzdWKesdfh"); + + JSONObject body = new JSONObject(); + body.put("pagador", new JSONObject().put("idParticipante", "06c19499-3412-4125-84b7-d0fbc98b5019") + .put("cpf", "45204392050").put("cnpj", "90293071000112"));; + body.put("favorecido", new JSONObject().put("contaBanco", new JSONObject() + .put("codigoBanco", "364") + .put("agencia", "0001") + .put("documento", "11122233344") + .put("nome", "Luiz Silva") + .put("conta", "654984") + .put("tipoConta", "CACC"))); + body.put("valor", "9.90"); + body.put("codigoCidadeIBGE", "3540000"); + body.put("infoPagador", "Compra dia xx"); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("ofStartPixPayment", new HashMap(), body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/open_finance/payment/map/OfListPixPayment.java b/src/main/java/br/com/efi/open_finance/payment/map/OfListPixPayment.java new file mode 100644 index 0000000..2861bee --- /dev/null +++ b/src/main/java/br/com/efi/open_finance/payment/map/OfListPixPayment.java @@ -0,0 +1,36 @@ +package br.com.efi.open_finance.payment.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class OfListPixPayment { + public static void main(String[] args) { + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("inicio", "2022-05-01"); + params.put("fim", "2022-12-30"); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("ofListPixPayment", params, new HashMap()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/open_finance/payment/map/OfStartPixPayment.java b/src/main/java/br/com/efi/open_finance/payment/map/OfStartPixPayment.java new file mode 100644 index 0000000..a5f733d --- /dev/null +++ b/src/main/java/br/com/efi/open_finance/payment/map/OfStartPixPayment.java @@ -0,0 +1,51 @@ +package br.com.efi.open_finance.payment.map; + +import java.util.HashMap; +import java.util.Map; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class OfStartPixPayment { + public static void main(String[] args) { + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + options.put("x-idempotency-key", "ae71713f-875b-4af3-9d85-0bcb43288847"); + + Map body = new HashMap(); + body.put("pagador", new JSONObject().put("idParticipante", "9f4cd202-8f2b-11ec-b909-0242ac120002") + .put("cpf", "45204392050").put("cnpj", "90293071000112")); + body.put("favorecido", new JSONObject().put("contaBanco", new JSONObject() + .put("codigoBanco", "364") + .put("agencia", "0001") + .put("documento", "11122233344") + .put("nome", "Luiz Silva") + .put("conta", "654984") + .put("tipoConta", "CACC"))); + body.put("valor", "9.90"); + body.put("codigoCidadeIBGE", "3540000"); + body.put("infoPagador", "Compra dia xx"); + + try { + EfiPay efi = new EfiPay(options); + + Map response = efi.call("ofStartPixPayment", new HashMap(), body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/payments/billets/json/PayDetailBarCode.java b/src/main/java/br/com/efi/payments/billets/json/PayDetailBarCode.java new file mode 100644 index 0000000..eea754a --- /dev/null +++ b/src/main/java/br/com/efi/payments/billets/json/PayDetailBarCode.java @@ -0,0 +1,36 @@ +package br.com.efi.payments.billets.json; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PayDetailBarCode { + public static void main(String[] args) { + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("codBarras", "Insira_aqui_o_codBarras"); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("payDetailBarCode", params, new JSONObject()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/payments/billets/json/PayDetailPayment.java b/src/main/java/br/com/efi/payments/billets/json/PayDetailPayment.java new file mode 100644 index 0000000..b3f82ae --- /dev/null +++ b/src/main/java/br/com/efi/payments/billets/json/PayDetailPayment.java @@ -0,0 +1,37 @@ +package br.com.efi.payments.billets.json; + +import java.util.HashMap; + + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PayDetailPayment { + public static void main(String[] args) { + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("idPagamento", "1"); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("payDetailPayment", params, new JSONObject()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/payments/billets/json/PayListPayments.java b/src/main/java/br/com/efi/payments/billets/json/PayListPayments.java new file mode 100644 index 0000000..286fe92 --- /dev/null +++ b/src/main/java/br/com/efi/payments/billets/json/PayListPayments.java @@ -0,0 +1,37 @@ +package br.com.efi.payments.billets.json; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PayListPayments { + public static void main(String[] args) { + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("dataInicio", "2022-04-01"); + params.put("dataFim", "2022-10-22"); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("payListPayments", params, new JSONObject()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/payments/billets/json/PayRequestBarCode.java b/src/main/java/br/com/efi/payments/billets/json/PayRequestBarCode.java new file mode 100644 index 0000000..1d5bfa7 --- /dev/null +++ b/src/main/java/br/com/efi/payments/billets/json/PayRequestBarCode.java @@ -0,0 +1,42 @@ +package br.com.efi.payments.billets.json; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PayRequestBarCode { + public static void main(String[] args) { + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("codBarras", "Insira_aqui_o_codBarras"); + + JSONObject body = new JSONObject(); + body.put("dataPagamento", "2022-06-14"); + body.put("valor", 1000); + body.put("descricao", "Pagamento de boleto"); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("payRequestBarCode", params, body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/payments/billets/map/PayDetailBarCode.java b/src/main/java/br/com/efi/payments/billets/map/PayDetailBarCode.java new file mode 100644 index 0000000..ed5ce12 --- /dev/null +++ b/src/main/java/br/com/efi/payments/billets/map/PayDetailBarCode.java @@ -0,0 +1,36 @@ +package br.com.efi.payments.billets.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PayDetailBarCode { + public static void main(String[] args) { + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("codBarras", "Insira_aqui_o_codBarras"); + + try { + EfiPay efi = new EfiPay(options); + + Map response = efi.call("payDetailBarCode", params, new HashMap()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/payments/billets/map/PayDetailPayment.java b/src/main/java/br/com/efi/payments/billets/map/PayDetailPayment.java new file mode 100644 index 0000000..88cc12a --- /dev/null +++ b/src/main/java/br/com/efi/payments/billets/map/PayDetailPayment.java @@ -0,0 +1,35 @@ +package br.com.efi.payments.billets.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PayDetailPayment { + public static void main(String[] args) { + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("idPagamento", "1"); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("payDetailPayment", params, new HashMap()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/payments/billets/map/PayListPayments.java b/src/main/java/br/com/efi/payments/billets/map/PayListPayments.java new file mode 100644 index 0000000..ec1b099 --- /dev/null +++ b/src/main/java/br/com/efi/payments/billets/map/PayListPayments.java @@ -0,0 +1,36 @@ +package br.com.efi.payments.billets.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PayListPayments { + public static void main(String[] args) { + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("dataInicio", "2022-04-01"); + params.put("dataFim", "2022-10-22"); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("payListPayments", params, new HashMap()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/payments/billets/map/PayRequestBarCode.java b/src/main/java/br/com/efi/payments/billets/map/PayRequestBarCode.java new file mode 100644 index 0000000..c9d2ad8 --- /dev/null +++ b/src/main/java/br/com/efi/payments/billets/map/PayRequestBarCode.java @@ -0,0 +1,42 @@ +package br.com.efi.payments.billets.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PayRequestBarCode { + public static void main(String[] args) { + + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("codBarras", "Insira_aqui_o_codBarras"); + + Map body = new HashMap(); + body.put("dataPagamento", "2022-06-14"); + body.put("valor", 1000); + body.put("descricao", "Pagamento de boleto"); + + try { + EfiPay efi = new EfiPay(options); + + Map response = efi.call("payRequestBarCode", params, body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/pix/cob/json/PixCreateCharge.java b/src/main/java/br/com/efi/pix/cob/json/PixCreateCharge.java new file mode 100644 index 0000000..d3c1ce9 --- /dev/null +++ b/src/main/java/br/com/efi/pix/cob/json/PixCreateCharge.java @@ -0,0 +1,51 @@ +package br.com.efi.pix.cob.json; + +import java.util.HashMap; + +import org.json.JSONArray; +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixCreateCharge { + public static void main(String[] args) { + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("txid", "7978c0c97ea847e78e8849634473c1f1"); + + JSONObject body = new JSONObject(); + body.put("calendario", new JSONObject().put("expiracao", 3600)); + body.put("devedor", new JSONObject().put("cpf", "12345678909").put("nome", "Francisco da Silva")); + body.put("valor", new JSONObject().put("original", "123.45")); + body.put("chave", "Insira_aqui_sua_chave"); + body.put("solicitacaoPagador", "Serviço realizado."); + + JSONArray infoAdicionais = new JSONArray(); + infoAdicionais.put(new JSONObject().put("nome", "Campo 1").put("valor", "Informação Adicional1 do PSP-Recebedor")); + infoAdicionais.put(new JSONObject().put("nome", "Campo 2").put("valor", "Informação Adicional2 do PSP-Recebedor")); + body.put("infoAdicionais", infoAdicionais); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("pixCreateCharge", params, body); + System.out.println(response); + + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/pix/cob/json/PixCreateImmediateCharge.java b/src/main/java/br/com/efi/pix/cob/json/PixCreateImmediateCharge.java new file mode 100644 index 0000000..24a3d00 --- /dev/null +++ b/src/main/java/br/com/efi/pix/cob/json/PixCreateImmediateCharge.java @@ -0,0 +1,48 @@ +package br.com.efi.pix.cob.json; + +import java.util.HashMap; + +import org.json.JSONArray; +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixCreateImmediateCharge { + public static void main(String[] args) { + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + + JSONObject body = new JSONObject(); + body.put("calendario", new JSONObject().put("expiracao", 3600)); + body.put("devedor", new JSONObject().put("cpf", "12345678909").put("nome", "Francisco da Silva")); + body.put("valor", new JSONObject().put("original", "0.01")); + body.put("chave", "Insira_aqui_sua_chave"); + body.put("solicitacaoPagador", "Serviço realizado."); + + JSONArray infoAdicionais = new JSONArray(); + infoAdicionais.put(new JSONObject().put("nome", "Campo 1").put("valor", "Informação Adicional1 do PSP-Recebedor")); + infoAdicionais.put(new JSONObject().put("nome", "Campo 2").put("valor", "Informação Adicional2 do PSP-Recebedor")); + body.put("infoAdicionais", infoAdicionais); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("pixCreateImmediateCharge", new HashMap(), body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/pix/cob/json/PixDetailCharge.java b/src/main/java/br/com/efi/pix/cob/json/PixDetailCharge.java new file mode 100644 index 0000000..a9b6916 --- /dev/null +++ b/src/main/java/br/com/efi/pix/cob/json/PixDetailCharge.java @@ -0,0 +1,37 @@ +package br.com.efi.pix.cob.json; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixDetailCharge { + public static void main(String[] args) { + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("txid", "1439dddddbeb4a738754492fd4745fef"); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("pixDetailCharge", params, new JSONObject()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} \ No newline at end of file diff --git a/src/main/java/br/com/efi/pix/cob/json/PixListCharges.java b/src/main/java/br/com/efi/pix/cob/json/PixListCharges.java new file mode 100644 index 0000000..d0399bd --- /dev/null +++ b/src/main/java/br/com/efi/pix/cob/json/PixListCharges.java @@ -0,0 +1,38 @@ +package br.com.efi.pix.cob.json; + +import java.util.HashMap; + + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixListCharges { + public static void main(String[] args) { + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("inicio", "2021-04-01T16:01:35Z"); + params.put("fim", "2021-04-21T16:01:35Z"); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("pixListCharges", params, new JSONObject()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} \ No newline at end of file diff --git a/src/main/java/br/com/efi/pix/cob/json/PixUpdateCharge.java b/src/main/java/br/com/efi/pix/cob/json/PixUpdateCharge.java new file mode 100644 index 0000000..448d9bc --- /dev/null +++ b/src/main/java/br/com/efi/pix/cob/json/PixUpdateCharge.java @@ -0,0 +1,41 @@ +package br.com.efi.pix.cob.json; + +import java.io.IOException; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixUpdateCharge { + public static void main(String[] args) throws IOException { + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("txid", "7978c0c97ea847e78e8849634473c1f1"); + + JSONObject body = new JSONObject(); + body.put("valor", new JSONObject().put("original", "5.00")); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("pixUpdateCharge", params, body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} \ No newline at end of file diff --git a/src/main/java/br/com/efi/pix/cob/map/PixCreateCharge.java b/src/main/java/br/com/efi/pix/cob/map/PixCreateCharge.java new file mode 100644 index 0000000..847a75a --- /dev/null +++ b/src/main/java/br/com/efi/pix/cob/map/PixCreateCharge.java @@ -0,0 +1,53 @@ +package br.com.efi.pix.cob.map; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; +import java.util.List; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixCreateCharge { + public static void main(String[] args) { + + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("txid", "7978c0c97ea847e78e8849634473c1f1"); + + Map body = new HashMap(); + body.put("calendario", new JSONObject().put("expiracao", 3600)); + body.put("devedor", new JSONObject().put("cpf", "12345678909").put("nome", "Francisco da Silva")); + body.put("valor", new JSONObject().put("original", "123.45")); + body.put("chave", "Insira_aqui_sua_chave"); + body.put("solicitacaoPagador", "Serviço realizado."); + + List infoAdicionais = new ArrayList(); + infoAdicionais.add(new JSONObject().put("nome", "Campo 1").put("valor", "Informação Adicional1 do PSP-Recebedor")); + infoAdicionais.add(new JSONObject().put("nome", "Campo 2").put("valor", "Informação Adicional2 do PSP-Recebedor")); + body.put("infoAdicionais", infoAdicionais); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("pixCreateCharge", params, body); + System.out.println(response); + + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/pix/cob/map/PixCreateImmediateCharge.java b/src/main/java/br/com/efi/pix/cob/map/PixCreateImmediateCharge.java new file mode 100644 index 0000000..7f987f2 --- /dev/null +++ b/src/main/java/br/com/efi/pix/cob/map/PixCreateImmediateCharge.java @@ -0,0 +1,50 @@ +package br.com.efi.pix.cob.map; + +import java.util.HashMap; +import java.util.Map; +import java.util.ArrayList; +import java.util.List; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixCreateImmediateCharge { + public static void main(String[] args) { + + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + + Map body = new HashMap(); + body.put("calendario", new JSONObject().put("expiracao", 3600)); + body.put("devedor", new JSONObject().put("cpf", "12345678909").put("nome", "Francisco da Silva")); + body.put("valor", new JSONObject().put("original", "123.45")); + body.put("chave", "Insira_aqui_sua_chave"); + body.put("solicitacaoPagador", "Serviço realizado."); + + List infoAdicionais = new ArrayList(); + infoAdicionais.add(new JSONObject().put("nome", "Campo 1").put("valor", "Informação Adicional1 do PSP-Recebedor")); + infoAdicionais.add(new JSONObject().put("nome", "Campo 2").put("valor", "Informação Adicional2 do PSP-Recebedor")); + body.put("infoAdicionais", infoAdicionais); + + try { + EfiPay efi= new EfiPay(options); + Map response = efi.call("pixCreateImmediateCharge", new HashMap(), body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/pix/cob/map/PixDetailCharge.java b/src/main/java/br/com/efi/pix/cob/map/PixDetailCharge.java new file mode 100644 index 0000000..140486e --- /dev/null +++ b/src/main/java/br/com/efi/pix/cob/map/PixDetailCharge.java @@ -0,0 +1,36 @@ +package br.com.efi.pix.cob.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixDetailCharge { + public static void main(String[] args) { + + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("txid", "7978c0c97ea847e78e8849634473c1f1"); + + try { + EfiPay efi= new EfiPay(options); + Map response = efi.call("pixDetailCharge", params, new HashMap()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} \ No newline at end of file diff --git a/src/main/java/br/com/efi/pix/cob/map/PixListCharges.java b/src/main/java/br/com/efi/pix/cob/map/PixListCharges.java new file mode 100644 index 0000000..ba2f1b9 --- /dev/null +++ b/src/main/java/br/com/efi/pix/cob/map/PixListCharges.java @@ -0,0 +1,36 @@ +package br.com.efi.pix.cob.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixListCharges { + public static void main(String[] args) { + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("inicio", "2021-04-01T16:01:35Z"); + params.put("fim", "2021-04-21T16:01:35Z"); + + try { + EfiPay efi= new EfiPay(options); + Map response = efi.call("pixListCharges", params, new HashMap()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} \ No newline at end of file diff --git a/src/main/java/br/com/efi/pix/cob/map/PixUpdateCharge.java b/src/main/java/br/com/efi/pix/cob/map/PixUpdateCharge.java new file mode 100644 index 0000000..bd379ea --- /dev/null +++ b/src/main/java/br/com/efi/pix/cob/map/PixUpdateCharge.java @@ -0,0 +1,40 @@ +package br.com.efi.pix.cob.map; + +import java.io.IOException; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixUpdateCharge { + public static void main(String[] args) throws IOException { + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("txid", "7978c0c97ea847e78e8849634473c1f1"); + + Map body = new HashMap(); + body.put("valor", new HashMap().put("original", "5.00")); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("pixUpdateCharge", params, body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} \ No newline at end of file diff --git a/src/main/java/br/com/efi/pix/cobv/json/PixCreateDueCharge.java b/src/main/java/br/com/efi/pix/cobv/json/PixCreateDueCharge.java new file mode 100644 index 0000000..bfc2ef8 --- /dev/null +++ b/src/main/java/br/com/efi/pix/cobv/json/PixCreateDueCharge.java @@ -0,0 +1,64 @@ +package br.com.efi.pix.cobv.json; + +import java.util.HashMap; + +import org.json.JSONArray; +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixCreateDueCharge { + public static void main(String[] args) { + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("txid", "7978c0c97ea847e78e8849634473c1d1"); + + JSONObject abatimento = new JSONObject().put("modalidade", 1).put("valorPerc", "0.01"); + JSONObject multa = new JSONObject().put("modalidade", 2).put("valorPerc", "0.01"); + JSONObject juros = new JSONObject().put("modalidade", 2).put("valorPerc", "0.01"); + JSONObject desconto = new JSONObject().put("modalidade", 3).put("valorPerc", "0.01"); + + JSONArray infoAdicionais = new JSONArray(); + infoAdicionais.put(new JSONObject().put("nome", "Campo 1").put("valor", "Informação Adicional1 do PSP-Recebedor")); + + JSONObject body = new JSONObject(); + body.put("calendario", new JSONObject().put("dataDeVencimento", "2023-01-02").put("validadeAposVencimento", 30)); + body.put("devedor", new JSONObject().put("cpf", "12345678909") + .put("nome", "Francisco da Silva") + .put("logradouro", "Alameda Souza, Numero 80, Bairro Braz") + .put("cidade", "Recife") + .put("uf", "PE") + .put("cep", "70011750")); + body.put("valor", new JSONObject().put("original", "0.10") + .put("abatimento", abatimento).put("desconto", desconto) + .put("multa", multa) + .put("juros", juros) + .put("desconto", desconto)); + body.put("chave", "Insira_aqui_sua_chave"); + body.put("solicitacaoPagador", "Serviço realizado."); + body.put("infoAdicionais", infoAdicionais); + + try { + EfiPay efi= new EfiPay(options); + JSONObject response = efi.call("pixCreateDueCharge", params, body); + System.out.println(response); + + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/pix/cobv/json/PixDetailDueCharge.java b/src/main/java/br/com/efi/pix/cobv/json/PixDetailDueCharge.java new file mode 100644 index 0000000..59895f1 --- /dev/null +++ b/src/main/java/br/com/efi/pix/cobv/json/PixDetailDueCharge.java @@ -0,0 +1,38 @@ +package br.com.efi.pix.cobv.json; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixDetailDueCharge { + public static void main(String[] args) { + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("txid", "7978c0c97ea847e78e8849634473c1f1"); + params.put("revisao", "0"); + + try { + EfiPay efi= new EfiPay(options); + JSONObject response = efi.call("pixDetailDueCharge", params, new JSONObject()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} \ No newline at end of file diff --git a/src/main/java/br/com/efi/pix/cobv/json/PixListDueCharges.java b/src/main/java/br/com/efi/pix/cobv/json/PixListDueCharges.java new file mode 100644 index 0000000..7e09889 --- /dev/null +++ b/src/main/java/br/com/efi/pix/cobv/json/PixListDueCharges.java @@ -0,0 +1,38 @@ +package br.com.efi.pix.cobv.json; + +import java.util.HashMap; + + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixListDueCharges { + public static void main(String[] args) { + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("inicio", "2021-12-31T16:01:35Z"); + params.put("fim", "2022-12-31T16:01:35Z"); + + try { + EfiPay efi= new EfiPay(options); + JSONObject response = efi.call("pixListDueCharges", params, new JSONObject()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} \ No newline at end of file diff --git a/src/main/java/br/com/efi/pix/cobv/json/PixUpdateDueCharge.java b/src/main/java/br/com/efi/pix/cobv/json/PixUpdateDueCharge.java new file mode 100644 index 0000000..5137184 --- /dev/null +++ b/src/main/java/br/com/efi/pix/cobv/json/PixUpdateDueCharge.java @@ -0,0 +1,47 @@ +package br.com.efi.pix.cobv.json; + +import java.io.IOException; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixUpdateDueCharge { + public static void main(String[] args) throws IOException { + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("txid", "7978c0c97ea847e78e8849634473c1f1"); + + JSONObject body = new JSONObject(); + body.put("devedor",new JSONObject().put("logradouro", "Alameda Souza, Numero 80, Bairro Braz") + .put("cidade", "Recife") + .put("uf", "PE") + .put("cep", "70011750") + .put("cpf", "12345678909") + .put("nome", "Francisco da Silva")); + body.put("valor", new JSONObject().put("original", "123.45")); + body.put("solicitacaoPagador", "Cobrança dos serviços prestados."); + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("pixUpdateDueCharge", params, body); + System.out.println(response); + } catch (EfiPayException e) { + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} \ No newline at end of file diff --git a/src/main/java/br/com/efi/pix/cobv/map/PixCreateDueCharge.java b/src/main/java/br/com/efi/pix/cobv/map/PixCreateDueCharge.java new file mode 100644 index 0000000..b48ec0a --- /dev/null +++ b/src/main/java/br/com/efi/pix/cobv/map/PixCreateDueCharge.java @@ -0,0 +1,66 @@ +package br.com.efi.pix.cobv.map; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; +import java.util.List; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixCreateDueCharge { + public static void main(String[] args) { + + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("txid", "7978c0c97ea847e78e8849634473c1f1"); + + JSONObject abatimento = new JSONObject().put("modalidade", 1).put("valorPerc", "5.00"); + JSONObject multa = new JSONObject().put("modalidade", 2).put("valorPerc", "15.00"); + JSONObject juros = new JSONObject().put("modalidade", 2).put("valorPerc", "2.00"); + JSONObject desconto = new JSONObject().put("modalidade", 3).put("valorPerc", "1.00"); + + List infoAdicionais = new ArrayList(); + infoAdicionais.add(new JSONObject().put("nome", "Campo 1").put("valor", "Informação Adicional1 do PSP-Recebedor")); + + Map body = new HashMap(); + body.put("calendario", new JSONObject().put("dataDeVencimento", "2022-10-30").put("validadeAposVencimento", 30)); + body.put("devedor", new JSONObject().put("cpf", "12345678909") + .put("nome", "Francisco da Silva") + .put("logradouro", "Alameda Souza, Numero 80, Bairro Braz") + .put("cidade", "Recife") + .put("uf", "PE") + .put("cep", "70011750")); + body.put("valor", new JSONObject().put("original", "123.45") + .put("abatimento", abatimento).put("desconto", desconto) + .put("juros", juros) + .put("multa", multa)); + body.put("chave", "Insira_aqui_sua_chave"); + body.put("solicitacaoPagador", "Serviço realizado."); + body.put("infoAdicionais", infoAdicionais); + + + try { + EfiPay efi= new EfiPay(options); + Map response = efi.call("pixCreateDueCharge", params, body); + System.out.println(response); + + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/pix/cobv/map/PixDetailDueCharge.java b/src/main/java/br/com/efi/pix/cobv/map/PixDetailDueCharge.java new file mode 100644 index 0000000..730442e --- /dev/null +++ b/src/main/java/br/com/efi/pix/cobv/map/PixDetailDueCharge.java @@ -0,0 +1,37 @@ +package br.com.efi.pix.cobv.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixDetailDueCharge { + public static void main(String[] args) { + + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("txid", "7978c0c97ea847e78e8849634473c1f1"); + params.put("revisao", "0"); + + try { + EfiPay efi= new EfiPay(options); + Map response = efi.call("pixDetailDueCharge", params, new HashMap()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} \ No newline at end of file diff --git a/src/main/java/br/com/efi/pix/cobv/map/PixListDueCharges.java b/src/main/java/br/com/efi/pix/cobv/map/PixListDueCharges.java new file mode 100644 index 0000000..a4e8c3b --- /dev/null +++ b/src/main/java/br/com/efi/pix/cobv/map/PixListDueCharges.java @@ -0,0 +1,37 @@ +package br.com.efi.pix.cobv.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixListDueCharges { + public static void main(String[] args) { + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("inicio", "2021-12-31T16:01:35Z"); + params.put("fim", "2022-12-31T16:01:35Z"); + + + try { + EfiPay efi= new EfiPay(options); + Map response = efi.call("pixListDueCharges", params, new HashMap()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} \ No newline at end of file diff --git a/src/main/java/br/com/efi/pix/cobv/map/PixUpdateDueCharge.java b/src/main/java/br/com/efi/pix/cobv/map/PixUpdateDueCharge.java new file mode 100644 index 0000000..89279da --- /dev/null +++ b/src/main/java/br/com/efi/pix/cobv/map/PixUpdateDueCharge.java @@ -0,0 +1,49 @@ +package br.com.efi.pix.cobv.map; + +import java.io.IOException; + +import java.util.HashMap; +import java.util.Map; +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixUpdateDueCharge { + public static void main(String[] args) throws IOException { + + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("txid", "7978c0c97ea847e78e8849634473c1f1"); + + Map body = new HashMap(); + body.put("devedor",new JSONObject().put("logradouro", "Alameda Souza, Numero 80, Bairro Braz") + .put("cidade", "Recife") + .put("uf", "PE") + .put("cep", "70011750") + .put("cpf", "12345678909") + .put("nome", "Francisco da Silva")); + body.put("valor", new JSONObject().put("original", "123.45")); + body.put("solicitacaoPagador", "Cobrança dos serviços prestados."); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("pixUpdateDueCharge", params, body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} \ No newline at end of file diff --git a/src/main/java/br/com/efi/pix/location/json/PixCreateLocation.java b/src/main/java/br/com/efi/pix/location/json/PixCreateLocation.java new file mode 100644 index 0000000..53450f1 --- /dev/null +++ b/src/main/java/br/com/efi/pix/location/json/PixCreateLocation.java @@ -0,0 +1,38 @@ +package br.com.efi.pix.location.json; + +import java.io.IOException; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixCreateLocation { + public static void main(String[] args) throws IOException { + + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + Map body = new HashMap(); + body.put("tipoCob", "cob"); + + try { + EfiPay efi= new EfiPay(options); + Map response = efi.call("pixCreateLocation", new HashMap(), body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} \ No newline at end of file diff --git a/src/main/java/br/com/efi/pix/location/json/PixDetailLocation.java b/src/main/java/br/com/efi/pix/location/json/PixDetailLocation.java new file mode 100644 index 0000000..261df6e --- /dev/null +++ b/src/main/java/br/com/efi/pix/location/json/PixDetailLocation.java @@ -0,0 +1,35 @@ +package br.com.efi.pix.location.json; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixDetailLocation { + public static void main(String[] args) { + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("id", "0"); + + try { + EfiPay efi= new EfiPay(options); + Map response = efi.call("pixDetailLocation", params, new HashMap()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/pix/location/json/PixGenerateQRCode.java b/src/main/java/br/com/efi/pix/location/json/PixGenerateQRCode.java new file mode 100644 index 0000000..c3c8c65 --- /dev/null +++ b/src/main/java/br/com/efi/pix/location/json/PixGenerateQRCode.java @@ -0,0 +1,48 @@ +package br.com.efi.pix.location.json; + +import java.awt.Desktop; +import java.util.HashMap; +import java.util.Map; +import javax.imageio.ImageIO; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +import java.io.ByteArrayInputStream; +import java.io.File; + +public class PixGenerateQRCode { + public static void main(String[] args) { + + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("id", "0"); + + try { + EfiPay efi= new EfiPay(options); + Map response = efi.call("pixGenerateQRCode", params, new HashMap()); + + System.out.println(response); + + File outputfile = new File("qrCodeImage.png"); + ImageIO.write(ImageIO.read(new ByteArrayInputStream(javax.xml.bind.DatatypeConverter.parseBase64Binary(((String) response.get("imagemQrcode")).split(",")[1]))), "png", outputfile); + Desktop desktop = Desktop.getDesktop(); + desktop.open(outputfile); + + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/pix/location/json/PixLocationList.java b/src/main/java/br/com/efi/pix/location/json/PixLocationList.java new file mode 100644 index 0000000..78ce98e --- /dev/null +++ b/src/main/java/br/com/efi/pix/location/json/PixLocationList.java @@ -0,0 +1,40 @@ +package br.com.efi.pix.location.json; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixLocationList { + public static void main(String[] args) { + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("inicio", "2021-04-01T16:01:35Z"); + params.put("fim", "2021-04-21T16:01:35Z"); + params.put("txIdPresente", "true"); + params.put("tipoCob", "cob"); + params.put("paginacao.paginaAtual", "0"); + params.put("paginacao.itensPorPagina", "10"); + + try { + EfiPay efi= new EfiPay(options); + Map response = efi.call("pixLocationList", params, new HashMap()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/pix/location/json/PixUnlinkTxidLocation.java b/src/main/java/br/com/efi/pix/location/json/PixUnlinkTxidLocation.java new file mode 100644 index 0000000..fbb97c5 --- /dev/null +++ b/src/main/java/br/com/efi/pix/location/json/PixUnlinkTxidLocation.java @@ -0,0 +1,35 @@ +package br.com.efi.pix.location.json; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixUnlinkTxidLocation { + public static void main(String[] args) { + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("id", "0"); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("pixUnlinkTxidLocation", params, new HashMap()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/pix/location/map/PixCreateLocation.java b/src/main/java/br/com/efi/pix/location/map/PixCreateLocation.java new file mode 100644 index 0000000..158ab25 --- /dev/null +++ b/src/main/java/br/com/efi/pix/location/map/PixCreateLocation.java @@ -0,0 +1,38 @@ +package br.com.efi.pix.location.map; + +import java.io.IOException; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixCreateLocation { + public static void main(String[] args) throws IOException { + + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + Map body = new HashMap(); + body.put("tipoCob", "cob"); + + try { + EfiPay efi= new EfiPay(options); + Map response = efi.call("pixCreateLocation", new HashMap(), body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} \ No newline at end of file diff --git a/src/main/java/br/com/efi/pix/location/map/PixDetailLocation.java b/src/main/java/br/com/efi/pix/location/map/PixDetailLocation.java new file mode 100644 index 0000000..785308d --- /dev/null +++ b/src/main/java/br/com/efi/pix/location/map/PixDetailLocation.java @@ -0,0 +1,36 @@ +package br.com.efi.pix.location.map; + +import java.util.HashMap; +import java.util.Map; +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixDetailLocation { + public static void main(String[] args) { + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("id", "0"); + + try { + EfiPay efi= new EfiPay(options); + Map response = efi.call("pixDetailLocation", params, new HashMap()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/pix/location/map/PixGenerateQRCode.java b/src/main/java/br/com/efi/pix/location/map/PixGenerateQRCode.java new file mode 100644 index 0000000..ee12f0b --- /dev/null +++ b/src/main/java/br/com/efi/pix/location/map/PixGenerateQRCode.java @@ -0,0 +1,44 @@ +package br.com.efi.pix.location.map; + +import java.util.Date; +import java.util.HashMap; +import java.util.Map; +import javax.imageio.ImageIO; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +import java.io.ByteArrayInputStream; +import java.io.File; +import java.text.SimpleDateFormat; + +public class PixGenerateQRCode { + public static void main(String[] args) { + + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("id", "0"); + + try { + EfiPay efi= new EfiPay(options); + Map response = efi.call("pixGenerateQRCode", params, new HashMap()); + + ImageIO.write(ImageIO.read(new ByteArrayInputStream(javax.xml.bind.DatatypeConverter.parseBase64Binary(((String) response.get("imagemQrcode")).split(",")[1]))), "png", new File("./imagensQrCode/image_" + new SimpleDateFormat("dd-MM_HHmmss").format(new Date()) + ".png")); + + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/pix/location/map/PixLocationList.java b/src/main/java/br/com/efi/pix/location/map/PixLocationList.java new file mode 100644 index 0000000..ed73cf0 --- /dev/null +++ b/src/main/java/br/com/efi/pix/location/map/PixLocationList.java @@ -0,0 +1,40 @@ +package br.com.efi.pix.location.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixLocationList { + public static void main(String[] args) { + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("inicio", "2021-04-01T16:01:35Z"); + params.put("fim", "2021-04-21T16:01:35Z"); + params.put("txIdPresente", "true"); + params.put("tipoCob", "cob"); + params.put("paginacao.paginaAtual", "0"); + params.put("paginacao.itensPorPagina", "10"); + + try { + EfiPay efi= new EfiPay(options); + Map response = efi.call("pixLocationList", params, new HashMap()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/pix/location/map/PixUnlinkTxidLocation.java b/src/main/java/br/com/efi/pix/location/map/PixUnlinkTxidLocation.java new file mode 100644 index 0000000..1842675 --- /dev/null +++ b/src/main/java/br/com/efi/pix/location/map/PixUnlinkTxidLocation.java @@ -0,0 +1,35 @@ +package br.com.efi.pix.location.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixUnlinkTxidLocation { + public static void main(String[] args) { + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("id", "0"); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("pixUnlinkTxidLocation", params, new HashMap()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/pix/pix/json/PixDetailDevolution.java b/src/main/java/br/com/efi/pix/pix/json/PixDetailDevolution.java new file mode 100644 index 0000000..e2fc6c3 --- /dev/null +++ b/src/main/java/br/com/efi/pix/pix/json/PixDetailDevolution.java @@ -0,0 +1,38 @@ +package br.com.efi.pix.pix.json; + +import java.util.HashMap; + + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixDetailDevolution { + public static void main(String[] args) { + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("e2eId", "E12345678202009091221abcdef12345"); + params.put("id", "1"); + + try { + EfiPay efi= new EfiPay(options); + JSONObject response = efi.call("pixDetailDevolution", params, new JSONObject()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/pix/pix/json/PixDetailReceived.java b/src/main/java/br/com/efi/pix/pix/json/PixDetailReceived.java new file mode 100644 index 0000000..c30fb99 --- /dev/null +++ b/src/main/java/br/com/efi/pix/pix/json/PixDetailReceived.java @@ -0,0 +1,36 @@ +package br.com.efi.pix.pix.json; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixDetailReceived { + public static void main(String[] args) { + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("e2eId", "E18236120202212191126s033c2e2e32"); + + try { + EfiPay efi= new EfiPay(options); + JSONObject response = efi.call("pixDetailReceived", params, new JSONObject()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/pix/pix/json/PixDevolution.java b/src/main/java/br/com/efi/pix/pix/json/PixDevolution.java new file mode 100644 index 0000000..cac7f50 --- /dev/null +++ b/src/main/java/br/com/efi/pix/pix/json/PixDevolution.java @@ -0,0 +1,39 @@ +package br.com.efi.pix.pix.json; +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixDevolution { + public static void main(String[] args) { + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("e2eId", "E12345678202009091221abcdef12345"); + params.put("id", "1"); + + JSONObject body = new JSONObject(); + body.put("valor", "7.89"); + + try { + EfiPay efi= new EfiPay(options); + JSONObject response = efi.call("pixDevolution", params, body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/pix/pix/json/PixReceivedList.java b/src/main/java/br/com/efi/pix/pix/json/PixReceivedList.java new file mode 100644 index 0000000..0a04f5d --- /dev/null +++ b/src/main/java/br/com/efi/pix/pix/json/PixReceivedList.java @@ -0,0 +1,37 @@ +package br.com.efi.pix.pix.json; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixReceivedList { + public static void main(String[] args) { + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("inicio", "2021-04-01T16:01:35Z"); + params.put("fim", "2021-04-22T16:01:35Z"); + + try { + EfiPay efi= new EfiPay(options); + JSONObject response = efi.call("pixReceivedList", params, new JSONObject()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/pix/pix/map/PixDetailDevolution.java b/src/main/java/br/com/efi/pix/pix/map/PixDetailDevolution.java new file mode 100644 index 0000000..2ecfefa --- /dev/null +++ b/src/main/java/br/com/efi/pix/pix/map/PixDetailDevolution.java @@ -0,0 +1,36 @@ +package br.com.efi.pix.pix.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixDetailDevolution { + public static void main(String[] args) { + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("e2eId", "E12345678202009091221abcdef12345"); + params.put("id", "1"); + + try { + EfiPay efi= new EfiPay(options); + Map response = efi.call("pixDetailDevolution", params, new HashMap()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/pix/pix/map/PixDetailReceived.java b/src/main/java/br/com/efi/pix/pix/map/PixDetailReceived.java new file mode 100644 index 0000000..68bc0b1 --- /dev/null +++ b/src/main/java/br/com/efi/pix/pix/map/PixDetailReceived.java @@ -0,0 +1,36 @@ +package br.com.efi.pix.pix.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixDetailReceived { + public static void main(String[] args) { + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("e2eId", "E12345678202009091221abcdef12345"); + + try { + EfiPay efi= new EfiPay(options); + + Map response = efi.call("pixDetailReceived", params, new HashMap()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/pix/pix/map/PixDevolution.java b/src/main/java/br/com/efi/pix/pix/map/PixDevolution.java new file mode 100644 index 0000000..4c69ed1 --- /dev/null +++ b/src/main/java/br/com/efi/pix/pix/map/PixDevolution.java @@ -0,0 +1,39 @@ +package br.com.efi.pix.pix.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixDevolution { + public static void main(String[] args) { + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("e2eId", "E18236120202104211819s03585605TS"); + params.put("id", "1"); + + Map body = new HashMap(); + body.put("valor", "7.89"); + + try { + EfiPay efi= new EfiPay(options); + Map response = efi.call("pixDevolution", params, body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/pix/pix/map/PixReceivedList.java b/src/main/java/br/com/efi/pix/pix/map/PixReceivedList.java new file mode 100644 index 0000000..b7a5de5 --- /dev/null +++ b/src/main/java/br/com/efi/pix/pix/map/PixReceivedList.java @@ -0,0 +1,36 @@ +package br.com.efi.pix.pix.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixReceivedList { + public static void main(String[] args) { + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("inicio", "2021-04-01T16:01:35Z"); + params.put("fim", "2021-04-22T16:01:35Z"); + + try { + EfiPay efi= new EfiPay(options); + Map response = efi.call("pixReceivedList", params, new HashMap()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/pix/send/json/PixSend.java b/src/main/java/br/com/efi/pix/send/json/PixSend.java new file mode 100644 index 0000000..910a5d2 --- /dev/null +++ b/src/main/java/br/com/efi/pix/send/json/PixSend.java @@ -0,0 +1,42 @@ +package br.com.efi.pix.send.json; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixSend { + public static void main(String[] args) { + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + //HashMap params = new HashMap(); + //params.put("idEnvio", "12457567890183473799"); + + JSONObject body = new JSONObject(); + body.put("valor", "0.01"); + body.put("pagador", new JSONObject().put("chave", "Insira_aqui_sua_chave")); + body.put("favorecido", new JSONObject().put("chave", "oão@meuemail.com")); + + try { + EfiPay efi= new EfiPay(options); + JSONObject response = efi.call("pixSend", new HashMap(), body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/pix/send/json/PixSendDetail.java b/src/main/java/br/com/efi/pix/send/json/PixSendDetail.java new file mode 100644 index 0000000..ae02996 --- /dev/null +++ b/src/main/java/br/com/efi/pix/send/json/PixSendDetail.java @@ -0,0 +1,36 @@ +package br.com.efi.pix.send.json; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixSendDetail { + public static void main(String[] args) { + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("e2eId", "E09089356202212011428API3f67ec70"); + + try { + EfiPay efi= new EfiPay(options); + JSONObject response = efi.call("pixSendDetail", params, new JSONObject()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/pix/send/json/PixSendList.java b/src/main/java/br/com/efi/pix/send/json/PixSendList.java new file mode 100644 index 0000000..7fd4e29 --- /dev/null +++ b/src/main/java/br/com/efi/pix/send/json/PixSendList.java @@ -0,0 +1,37 @@ +package br.com.efi.pix.send.json; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixSendList { + public static void main(String[] args) { + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("inicio", "2022-11-10T16:01:35Z"); + params.put("fim", "2022-12-10T16:01:35Z"); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("pixSendList", params, new JSONObject()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/pix/send/map/PixSend.java b/src/main/java/br/com/efi/pix/send/map/PixSend.java new file mode 100644 index 0000000..1fb8f7b --- /dev/null +++ b/src/main/java/br/com/efi/pix/send/map/PixSend.java @@ -0,0 +1,42 @@ +package br.com.efi.pix.send.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixSend { + public static void main(String[] args) { + + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("idEnvio", "12453567890123456789"); + + Map body = new HashMap(); + body.put("valor", "99.99"); + body.put("pagador", new HashMap().put("chave", "Insira_aqui_sua_chave")); + body.put("favorecido", new HashMap().put("chave", "joão@meuemail.com")); + + try { + EfiPay efi= new EfiPay(options); + + Map response = efi.call("pixSend", params, body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/pix/send/map/PixSendDetail.java b/src/main/java/br/com/efi/pix/send/map/PixSendDetail.java new file mode 100644 index 0000000..f5f7a31 --- /dev/null +++ b/src/main/java/br/com/efi/pix/send/map/PixSendDetail.java @@ -0,0 +1,36 @@ +package br.com.efi.pix.send.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixSendDetail { + public static void main(String[] args) { + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("e2eId", "E12345678202009091221abcdef12345"); + + try { + EfiPay efi = new EfiPay(options); + + Map response = efi.call("pixSendDetail", params, new HashMap()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/pix/send/map/PixSendList.java b/src/main/java/br/com/efi/pix/send/map/PixSendList.java new file mode 100644 index 0000000..f08c051 --- /dev/null +++ b/src/main/java/br/com/efi/pix/send/map/PixSendList.java @@ -0,0 +1,36 @@ +package br.com.efi.pix.send.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixSendList { + public static void main(String[] args) { + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("inicio", "2021-04-01T16:01:35Z"); + params.put("fim", "2021-04-22T16:01:35Z"); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("pixSendList", params, new HashMap()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/pix/split/cob/json/PixSplitDetailCharge.java b/src/main/java/br/com/efi/pix/split/cob/json/PixSplitDetailCharge.java new file mode 100644 index 0000000..cef55f0 --- /dev/null +++ b/src/main/java/br/com/efi/pix/split/cob/json/PixSplitDetailCharge.java @@ -0,0 +1,37 @@ +package br.com.efi.pix.split.cob.json; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixSplitDetailCharge { + public static void main(String[] args) { + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("txid", "7978c0c97ea847e78e8849634473c1f1"); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("pixSplitDetailCharge", params, new JSONObject()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} \ No newline at end of file diff --git a/src/main/java/br/com/efi/pix/split/cob/json/PixSplitLinkCharge.java b/src/main/java/br/com/efi/pix/split/cob/json/PixSplitLinkCharge.java new file mode 100644 index 0000000..fc09c26 --- /dev/null +++ b/src/main/java/br/com/efi/pix/split/cob/json/PixSplitLinkCharge.java @@ -0,0 +1,38 @@ +package br.com.efi.pix.split.cob.json; + +import java.util.HashMap; + + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixSplitLinkCharge { + public static void main(String[] args) { + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("txid", "7978c0c97ea847e78e8849634473c1f2"); + params.put("splitConfigId", "6aeddee74dd1a890c0ace71f53f70002"); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("pixSplitLinkCharge", params, new JSONObject()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/pix/split/cob/json/PixSplitUnlinkCharge.java b/src/main/java/br/com/efi/pix/split/cob/json/PixSplitUnlinkCharge.java new file mode 100644 index 0000000..cd1cea4 --- /dev/null +++ b/src/main/java/br/com/efi/pix/split/cob/json/PixSplitUnlinkCharge.java @@ -0,0 +1,37 @@ +package br.com.efi.pix.split.cob.json; + +import java.util.HashMap; + + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixSplitUnlinkCharge { + public static void main(String[] args) { + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("txid", "7978c0c97ea847e78e8849634473c1f2"); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("pixSplitUnlinkCharge", params, new JSONObject()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/pix/split/cob/map/PixSplitDetailCharge.java b/src/main/java/br/com/efi/pix/split/cob/map/PixSplitDetailCharge.java new file mode 100644 index 0000000..0bbe8da --- /dev/null +++ b/src/main/java/br/com/efi/pix/split/cob/map/PixSplitDetailCharge.java @@ -0,0 +1,36 @@ +package br.com.efi.pix.split.cob.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixSplitDetailCharge { + public static void main(String[] args) { + + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("txid", "7978c0c97ea847e78e8849634473c1f1"); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("pixSplitDetailCharge", params, new HashMap()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} \ No newline at end of file diff --git a/src/main/java/br/com/efi/pix/split/cob/map/PixSplitLinkCharge.java b/src/main/java/br/com/efi/pix/split/cob/map/PixSplitLinkCharge.java new file mode 100644 index 0000000..5739462 --- /dev/null +++ b/src/main/java/br/com/efi/pix/split/cob/map/PixSplitLinkCharge.java @@ -0,0 +1,36 @@ +package br.com.efi.pix.split.cob.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixSplitLinkCharge { + public static void main(String[] args) { + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("txid", "7978c0c97ea847e78e8849634473c1f2"); + params.put("splitConfigId", "6aeddee74dd1a890c0ace71f53f70002"); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("pixSplitLinkCharge", params, new HashMap()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/pix/split/cob/map/PixSplitUnlinkCharge.java b/src/main/java/br/com/efi/pix/split/cob/map/PixSplitUnlinkCharge.java new file mode 100644 index 0000000..b589e9d --- /dev/null +++ b/src/main/java/br/com/efi/pix/split/cob/map/PixSplitUnlinkCharge.java @@ -0,0 +1,35 @@ +package br.com.efi.pix.split.cob.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixSplitUnlinkCharge { + public static void main(String[] args) { + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("txid", "7978c0c97ea847e78e8849634473c1f2"); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("pixSplitUnlinkCharge", params, new HashMap()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/pix/split/cobv/json/PixSplitDetailDueCharge.java b/src/main/java/br/com/efi/pix/split/cobv/json/PixSplitDetailDueCharge.java new file mode 100644 index 0000000..a16d199 --- /dev/null +++ b/src/main/java/br/com/efi/pix/split/cobv/json/PixSplitDetailDueCharge.java @@ -0,0 +1,38 @@ +package br.com.efi.pix.split.cobv.json; + +import java.io.IOException; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixSplitDetailDueCharge { + public static void main(String[] args) throws IOException { + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("txid", "7978c0c97ea847e78e8849634473c1f1"); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("pixSplitDetailDueCharge", params, new JSONObject()); + System.out.println(response); + } catch (EfiPayException e) { + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} \ No newline at end of file diff --git a/src/main/java/br/com/efi/pix/split/cobv/json/PixSplitLinkDueCharge.java b/src/main/java/br/com/efi/pix/split/cobv/json/PixSplitLinkDueCharge.java new file mode 100644 index 0000000..4bdf871 --- /dev/null +++ b/src/main/java/br/com/efi/pix/split/cobv/json/PixSplitLinkDueCharge.java @@ -0,0 +1,38 @@ +package br.com.efi.pix.split.cobv.json; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixSplitLinkDueCharge{ + public static void main(String[] args) { + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("txid", "7978c0c97ea847e78e8849634473c1f1"); + params.put("splitConfigId", "6aeddee74dd1a890c0ace81f53f7002"); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("pixSplitLinkDueCharge", params, new JSONObject()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} \ No newline at end of file diff --git a/src/main/java/br/com/efi/pix/split/cobv/json/PixSplitUnlinkDueCharge.java b/src/main/java/br/com/efi/pix/split/cobv/json/PixSplitUnlinkDueCharge.java new file mode 100644 index 0000000..8c7cb01 --- /dev/null +++ b/src/main/java/br/com/efi/pix/split/cobv/json/PixSplitUnlinkDueCharge.java @@ -0,0 +1,37 @@ +package br.com.efi.pix.split.cobv.json; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixSplitUnlinkDueCharge{ + public static void main(String[] args) { + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("txid", "7978c0c97ea847e78e8849634473c1f1"); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("pixSplitUnlinkDueCharge", params, new JSONObject()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} \ No newline at end of file diff --git a/src/main/java/br/com/efi/pix/split/cobv/map/PixSplitDetailDueCharge.java b/src/main/java/br/com/efi/pix/split/cobv/map/PixSplitDetailDueCharge.java new file mode 100644 index 0000000..b158c61 --- /dev/null +++ b/src/main/java/br/com/efi/pix/split/cobv/map/PixSplitDetailDueCharge.java @@ -0,0 +1,38 @@ +package br.com.efi.pix.split.cobv.map; + +import java.io.IOException; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixSplitDetailDueCharge { + public static void main(String[] args) throws IOException { + + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("txid", "7978c0c97ea847e78e8849634473c1f1"); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("pixSplitDetailDueCharge", params, new HashMap()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} \ No newline at end of file diff --git a/src/main/java/br/com/efi/pix/split/cobv/map/PixSplitLinkDueCharge.java b/src/main/java/br/com/efi/pix/split/cobv/map/PixSplitLinkDueCharge.java new file mode 100644 index 0000000..11f570d --- /dev/null +++ b/src/main/java/br/com/efi/pix/split/cobv/map/PixSplitLinkDueCharge.java @@ -0,0 +1,37 @@ +package br.com.efi.pix.split.cobv.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixSplitLinkDueCharge { + public static void main(String[] args) { + + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("txid", "7978c0c97ea847e78e8849634473c1f1"); + params.put("splitConfigId", "6aeddee74dd1a890c0ace71f53f70001"); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("pixSplitLinkDueCharge", params, new HashMap()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} \ No newline at end of file diff --git a/src/main/java/br/com/efi/pix/split/cobv/map/PixSplitUnlinkDueCharge.java b/src/main/java/br/com/efi/pix/split/cobv/map/PixSplitUnlinkDueCharge.java new file mode 100644 index 0000000..5697f6e --- /dev/null +++ b/src/main/java/br/com/efi/pix/split/cobv/map/PixSplitUnlinkDueCharge.java @@ -0,0 +1,36 @@ +package br.com.efi.pix.split.cobv.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixSplitUnlinkDueCharge { + public static void main(String[] args) { + + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("txid", "7978c0c97ea847e78e8849634473c1f1"); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("pixSplitUnlinkDueCharge", params, new HashMap()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} \ No newline at end of file diff --git a/src/main/java/br/com/efi/pix/split/config/json/PixSplitConfig.java b/src/main/java/br/com/efi/pix/split/config/json/PixSplitConfig.java new file mode 100644 index 0000000..9f53eae --- /dev/null +++ b/src/main/java/br/com/efi/pix/split/config/json/PixSplitConfig.java @@ -0,0 +1,49 @@ +package br.com.efi.pix.split.config.json; +//falta esse +import java.util.HashMap; + +import org.json.JSONArray; +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixSplitConfig { + public static void main(String[] args) { + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + JSONObject minhaParte = new JSONObject().put("tipo", "porcentagem").put("valor", "50.00"); + JSONObject favorecido_1 = new JSONObject().put("cpf", "12345678909").put("conta", "1234567"); + JSONObject favorecido_2 = new JSONObject().put("cpf", "94271564656").put("conta", "7654321"); + + JSONArray repasses = new JSONArray(); + repasses.put(new JSONObject().put("tipo", "porcentagem").put("valor", "25.00").put("favorecido", favorecido_1)); + repasses.put(new JSONObject().put("tipo", "porcentagem").put("valor", "25.00").put("favorecido", favorecido_2)); + + JSONObject body = new JSONObject(); + body.put("descricao", "Batatinha frita 1, 2, 3"); + body.put("lancamento", new JSONObject().put("imediato", true)); + body.put("split", new JSONObject().put("divisaoTarifa", "assumir_total") + .put("minhaParte", minhaParte) + .put("repasses", repasses)); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("pixSplitConfig", new HashMap(), body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/pix/split/config/json/PixSplitConfigId.java b/src/main/java/br/com/efi/pix/split/config/json/PixSplitConfigId.java new file mode 100644 index 0000000..4658fcb --- /dev/null +++ b/src/main/java/br/com/efi/pix/split/config/json/PixSplitConfigId.java @@ -0,0 +1,52 @@ +package br.com.efi.pix.split.config.json; +//falta esse +import java.util.HashMap; + +import org.json.JSONArray; +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixSplitConfigId { + public static void main(String[] args) { + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("id", "6aeddee74dd1a890c0ace81f53f7002"); + + JSONObject minhaParte = new JSONObject().put("tipo", "porcentagem").put("valor", "50.00"); + JSONObject favorecido_1 = new JSONObject().put("cpf", "12345678909").put("conta", "1234567"); + JSONObject favorecido_2 = new JSONObject().put("cpf", "94271564656").put("conta", "7654321"); + + JSONArray repasses = new JSONArray(); + repasses.put(new JSONObject().put("tipo", "porcentagem").put("valor", "25.00").put("favorecido", favorecido_1)); + repasses.put(new JSONObject().put("tipo", "porcentagem").put("valor", "25.00").put("favorecido", favorecido_2)); + + JSONObject body = new JSONObject(); + body.put("descricao", "Batatinha frita 1, 2, 3"); + body.put("lancamento", new JSONObject().put("imediato", true)); + body.put("split", new JSONObject().put("divisaoTarifa", "assumir_total") + .put("minhaParte", minhaParte) + .put("repasses", repasses)); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("pixSplitConfigId", params, body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/pix/split/config/json/PixSplitDetailConfig.java b/src/main/java/br/com/efi/pix/split/config/json/PixSplitDetailConfig.java new file mode 100644 index 0000000..7be298a --- /dev/null +++ b/src/main/java/br/com/efi/pix/split/config/json/PixSplitDetailConfig.java @@ -0,0 +1,37 @@ +package br.com.efi.pix.split.config.json; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixSplitDetailConfig { + public static void main(String[] args) { + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("id", "6aeddee74dd1a890c0ace81f53f7002"); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("pixSplitDetailConfig", params, new JSONObject()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} \ No newline at end of file diff --git a/src/main/java/br/com/efi/pix/split/config/map/PixSplitConfig.java b/src/main/java/br/com/efi/pix/split/config/map/PixSplitConfig.java new file mode 100644 index 0000000..fed77cc --- /dev/null +++ b/src/main/java/br/com/efi/pix/split/config/map/PixSplitConfig.java @@ -0,0 +1,52 @@ +package br.com.efi.pix.split.config.map; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixSplitConfig { + public static void main(String[] args) { + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + JSONObject minhaParte = new JSONObject().put("tipo", "porcentagem").put("valor", "50.00"); + JSONObject favorecido_1 = new JSONObject().put("cpf", "12345678909").put("conta", "1234567"); + JSONObject favorecido_2 = new JSONObject().put("cpf", "94271564656").put("conta", "7654321"); + + List repasses = new ArrayList(); + repasses.add(new JSONObject().put("tipo", "porcentagem").put("valor", "25.00").put("favorecido", favorecido_1)); + repasses.add(new JSONObject().put("tipo", "porcentagem").put("valor", "25.00").put("favorecido", favorecido_2)); + + Map body = new HashMap(); + body.put("descricao", "Batatinha frita 1, 2, 3"); + body.put("lancamento", new JSONObject().put("imediato", true)); + body.put("split", new JSONObject().put("divisaoTarifa", "assumir_total") + .put("minhaParte", minhaParte) + .put("repasses", repasses)); + + try { + EfiPay efi = new EfiPay(options); + + Map response = efi.call("pixSplitConfig", new HashMap(), body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/pix/split/config/map/PixSplitConfigId.java b/src/main/java/br/com/efi/pix/split/config/map/PixSplitConfigId.java new file mode 100644 index 0000000..5008ea5 --- /dev/null +++ b/src/main/java/br/com/efi/pix/split/config/map/PixSplitConfigId.java @@ -0,0 +1,55 @@ +package br.com.efi.pix.split.config.map; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; +import java.util.List; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixSplitConfigId { + public static void main(String[] args) { + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("id", "6aeddee74dd1a890c0ace71f53f70002"); + + JSONObject minhaParte = new JSONObject().put("tipo", "porcentagem").put("valor", "50.00"); + JSONObject favorecido_1 = new JSONObject().put("cpf", "12345678909").put("conta", "1234567"); + JSONObject favorecido_2 = new JSONObject().put("cpf", "94271564656").put("conta", "7654321"); + + List repasses = new ArrayList(); + repasses.add(new JSONObject().put("tipo", "porcentagem").put("valor", "25.00").put("favorecido", favorecido_1)); + repasses.add(new JSONObject().put("tipo", "porcentagem").put("valor", "25.00").put("favorecido", favorecido_2)); + + Map body = new HashMap(); + body.put("descricao", "Batatinha frita 1, 2, 3"); + body.put("lancamento", new JSONObject().put("imediato", true)); + body.put("split", new JSONObject().put("divisaoTarifa", "assumir_total") + .put("minhaParte", minhaParte) + .put("repasses", repasses)); + + try { + EfiPay efi = new EfiPay(options); + + Map response = efi.call("pixSplitConfigId", params, body); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/pix/split/config/map/PixSplitDetailConfig.java b/src/main/java/br/com/efi/pix/split/config/map/PixSplitDetailConfig.java new file mode 100644 index 0000000..428489a --- /dev/null +++ b/src/main/java/br/com/efi/pix/split/config/map/PixSplitDetailConfig.java @@ -0,0 +1,36 @@ +package br.com.efi.pix.split.config.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixSplitDetailConfig { + public static void main(String[] args) { + + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("id", "6aeddee74dd1a890c0ace71f53f70001"); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("pixSplitDetailConfig", params, new HashMap()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} \ No newline at end of file diff --git a/src/main/java/br/com/efi/pix/webhooks/json/PixConfigWebhook.java b/src/main/java/br/com/efi/pix/webhooks/json/PixConfigWebhook.java new file mode 100644 index 0000000..0ba7e6c --- /dev/null +++ b/src/main/java/br/com/efi/pix/webhooks/json/PixConfigWebhook.java @@ -0,0 +1,43 @@ +package br.com.efi.pix.webhooks.json; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixConfigWebhook { + public static void main(String[] args) { + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + options.put("x-skip-mtls-checking", "true"); + + HashMap params = new HashMap(); + params.put("chave", "Insira_aqui_sua_chave"); + + JSONObject body = new JSONObject(); + body.put("webhookUrl", "https://seudominio.com.br/webhook/"); + + try { + EfiPay efi = new EfiPay(options); + JSONObject response = efi.call("pixConfigWebhook", params, body); + System.out.println(response); + + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/pix/webhooks/json/PixDeleteWebhook.java b/src/main/java/br/com/efi/pix/webhooks/json/PixDeleteWebhook.java new file mode 100644 index 0000000..d85b6eb --- /dev/null +++ b/src/main/java/br/com/efi/pix/webhooks/json/PixDeleteWebhook.java @@ -0,0 +1,36 @@ +package br.com.efi.pix.webhooks.json; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixDeleteWebhook { + public static void main(String[] args) { + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("chave", "Insira_aqui_sua_chave"); + + try { + EfiPay efi= new EfiPay(options); + JSONObject response = efi.call("pixDeleteWebhook", params, new JSONObject()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/pix/webhooks/json/PixDetailWebhook.java b/src/main/java/br/com/efi/pix/webhooks/json/PixDetailWebhook.java new file mode 100644 index 0000000..e297b69 --- /dev/null +++ b/src/main/java/br/com/efi/pix/webhooks/json/PixDetailWebhook.java @@ -0,0 +1,38 @@ +package br.com.efi.pix.webhooks.json; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixDetailWebhook { + public static void main(String[] args) { + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("chave", "Insira_aqui_sua_chave"); + + try { + EfiPay efi= new EfiPay(options); + JSONObject response = efi.call("pixDetailWebhook", params, new JSONObject()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} + diff --git a/src/main/java/br/com/efi/pix/webhooks/json/PixListWebhook.java b/src/main/java/br/com/efi/pix/webhooks/json/PixListWebhook.java new file mode 100644 index 0000000..5748651 --- /dev/null +++ b/src/main/java/br/com/efi/pix/webhooks/json/PixListWebhook.java @@ -0,0 +1,38 @@ +package br.com.efi.pix.webhooks.json; + +import java.util.HashMap; + +import org.json.JSONObject; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixListWebhook { + public static void main(String[] args) { + + Credentials credentials = new Credentials(); + + JSONObject options = new JSONObject(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("inicio", "2021-01-01T16:01:35Z"); + params.put("fim", "2022-06-30T16:01:35Z"); + + try { + EfiPay efi= new EfiPay(options); + JSONObject response = efi.call("pixListWebhook", params, new JSONObject()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/pix/webhooks/map/PixConfigWebhook.java b/src/main/java/br/com/efi/pix/webhooks/map/PixConfigWebhook.java new file mode 100644 index 0000000..e9a1e34 --- /dev/null +++ b/src/main/java/br/com/efi/pix/webhooks/map/PixConfigWebhook.java @@ -0,0 +1,42 @@ +package br.com.efi.pix.webhooks.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixConfigWebhook { + public static void main(String[] args) { + + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + options.put("x-skip-mtls-checking", "true"); + + HashMap params = new HashMap(); + params.put("chave", "Insira_aqui_sua_chave"); + + Map body = new HashMap(); + body.put("webhookUrl", "https://seudominio.com.br/webhook/"); + + try { + EfiPay efi = new EfiPay(options); + Map response = efi.call("pixConfigWebhook", params, body); + System.out.println(response); + + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/pix/webhooks/map/PixDeleteWebhook.java b/src/main/java/br/com/efi/pix/webhooks/map/PixDeleteWebhook.java new file mode 100644 index 0000000..f605b36 --- /dev/null +++ b/src/main/java/br/com/efi/pix/webhooks/map/PixDeleteWebhook.java @@ -0,0 +1,36 @@ +package br.com.efi.pix.webhooks.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixDeleteWebhook { + public static void main(String[] args) { + Credentials credentials = new Credentials(); + + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("chave", "Insira_aqui_sua_chave"); + + try { + EfiPay efi= new EfiPay(options); + Map response = efi.call("pixDeleteWebhook", params, new HashMap()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/java/br/com/efi/pix/webhooks/map/PixDetailWebhook.java b/src/main/java/br/com/efi/pix/webhooks/map/PixDetailWebhook.java new file mode 100644 index 0000000..a9437cd --- /dev/null +++ b/src/main/java/br/com/efi/pix/webhooks/map/PixDetailWebhook.java @@ -0,0 +1,37 @@ +package br.com.efi.pix.webhooks.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixDetailWebhook { + public static void main(String[] args) { + + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("chave", "Insira_aqui_sua_chave"); + + try { + EfiPay efi= new EfiPay(options); + Map response = efi.call("pixDetailWebhook", params, new HashMap()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} + diff --git a/src/main/java/br/com/efi/pix/webhooks/map/PixListWebhook.java b/src/main/java/br/com/efi/pix/webhooks/map/PixListWebhook.java new file mode 100644 index 0000000..4335216 --- /dev/null +++ b/src/main/java/br/com/efi/pix/webhooks/map/PixListWebhook.java @@ -0,0 +1,37 @@ +package br.com.efi.pix.webhooks.map; + +import java.util.HashMap; +import java.util.Map; + +import br.com.efi.Credentials; +import br.com.efi.efisdk.EfiPay; +import br.com.efi.efisdk.exceptions.EfiPayException; + +public class PixListWebhook { + public static void main(String[] args) { + + Credentials credentials = new Credentials(); + + HashMap options = new HashMap(); + options.put("client_id", credentials.getClientId()); + options.put("client_secret", credentials.getClientSecret()); + options.put("certificate", credentials.getCertificate()); + options.put("sandbox", credentials.isSandbox()); + + HashMap params = new HashMap(); + params.put("inicio", "2021-04-01T16:01:35Z"); + params.put("fim", "2021-04-22T16:01:35Z"); + + try { + EfiPay efi= new EfiPay(options); + Map response = efi.call("pixListWebhook", params, new HashMap()); + System.out.println(response); + }catch (EfiPayException e){ + System.out.println(e.getError()); + System.out.println(e.getErrorDescription()); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/src/main/resources/credentials.json b/src/main/resources/credentials.json new file mode 100644 index 0000000..a575afc --- /dev/null +++ b/src/main/resources/credentials.json @@ -0,0 +1,7 @@ +{ + "client_id": "client_id", + "client_secret": "client_secret", + "certificate": "./certs/developmentCertificate.p12", + "sandbox": true, + "debug": false +} \ No newline at end of file