Directa 24 SDK


License

License

Categories

Categories

Java Languages
GroupId

GroupId

com.directa24
ArtifactId

ArtifactId

cashin-java-sdk
Last Version

Last Version

1.0.14
Release Date

Release Date

Type

Type

jar
Description

Description

Directa 24 SDK
Directa 24 SDK
Project URL

Project URL

https://directa24.com
Source Code Management

Source Code Management

http://github.com/directa24/cashin-java-sdk/tree/master

Download cashin-java-sdk

How to add to project

<!-- https://jarcasting.com/artifacts/com.directa24/cashin-java-sdk/ -->
<dependency>
    <groupId>com.directa24</groupId>
    <artifactId>cashin-java-sdk</artifactId>
    <version>1.0.14</version>
</dependency>
// https://jarcasting.com/artifacts/com.directa24/cashin-java-sdk/
implementation 'com.directa24:cashin-java-sdk:1.0.14'
// https://jarcasting.com/artifacts/com.directa24/cashin-java-sdk/
implementation ("com.directa24:cashin-java-sdk:1.0.14")
'com.directa24:cashin-java-sdk:jar:1.0.14'
<dependency org="com.directa24" name="cashin-java-sdk" rev="1.0.14">
  <artifact name="cashin-java-sdk" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.directa24', module='cashin-java-sdk', version='1.0.14')
)
libraryDependencies += "com.directa24" % "cashin-java-sdk" % "1.0.14"
[com.directa24/cashin-java-sdk "1.0.14"]

Dependencies

compile (3)

Group / Artifact Type Version
com.squareup.okhttp3 : okhttp jar 4.8.1
com.fasterxml.jackson.core : jackson-databind jar 2.11.2
com.fasterxml.jackson.datatype : jackson-datatype-jsr310 jar 2.11.2

provided (1)

Group / Artifact Type Version
org.projectlombok : lombok jar 1.18.12

test (2)

Group / Artifact Type Version
junit : junit jar 4.13
com.github.tomakehurst : wiremock-jre8 jar 2.26.3

Project Modules

There are no modules declared in this project.

Directa 24 Java client library

The official Directa 24 Java client library.

Installation

Requirements

  • Java 1.8 or later

Gradle users

Add this dependency to your project's build file:

implementation "com.directa24:cashin-java-sdk:1.0.13"

Maven users

Add this dependency to your project's POM:

<dependency>
  <groupId>com.directa24</groupId>
  <artifactId>cashin-java-sdk</artifactId>
  <version>1.0.13</version>
</dependency>

Documentation

Please see the Java API docs for the most up-to-date documentation.

Usage

Deposit Credentials

String depositKeySbx = "1955f2d";
String secretKeySbx = "4lph0ns3";

Directa24 directa24Sandbox = new Directa24.Sandbox(depositKeySbx, secretKeySbx);

Read Only Credentials

String readOnlyKeySbx = "EgIECaVuyW";

Directa24 directa24Sandbox = new Directa24.Sandbox(readOnlyKeySbx);

Create Deposit

public class CreateDepositExample {

   public static void main(String[] args) {

      Address address = Address.builder()
                               .street("Rua Dr. Franco Ribeiro, 52")
                               .city("Rio Branco")
                               .state("AC")
                               .zipCode("11600-234")
                               .build();

      Payer payer = Payer
            .builder()
            .id("4-9934519")
            .address(address)
            .document("21329039050")
            .documentType("CPF")
            .email("[email protected]")
            .firstName("Ricardo")
            .lastName("Carlos")
            .phone("+598 99730878")
            .build();

      BankAccount bankAccount = BankAccount
            .builder()
            .bankCode("01")
            .accountNumber("3242342")
            .accountType("SAVING")
            .beneficiary("Ricardo Carlos")
            .branch("12")
            .build();

      CreateDepositRequest createDepositRequest = CreateDepositRequest
            .builder()
            .invoiceId("108")
            .amount(new BigDecimal(100))
            .country("BR")
            .currency("BRL")
            .payer(payer)
            .paymentMethod("BB")
            .paymentType("BANK_TRANSFER")
            .bankAccount(bankAccount)
            .earlyRelease(false)
            .feeOnPayer(false)
            .surchargeOnPayer(false)
            .bonusAmount(BigDecimal.ONE)
            .bonusRelative(false)
            .strikethroughPrice(BigDecimal.ONE)
            .description("Test")
            .clientIp("186.51.171.84")
            .language("es")
            .deviceId("00000000-00000000-01234567-89ABCDEF")
            .backUrl("https://yoursite.com/deposit/108/cancel")
            .successUrl("https://yoursite.com/deposit/108/confirm")
            .errorUrl("https://yoursite.com/deposit/108/error")
            .notificationUrl("https://yoursite.com/ipn")
            .logo("https://yoursite.com/logo.png")
            .test(true)
            .mobile(false)
            .idempotency("")
            .build();

      try {
         CreateDepositResponse createDepositResponse = directa24Sandbox.client.createDeposit(createDepositRequest);
         
         // Handle response

      } catch (Directa24Exception e) {
         // Handle errors
      }
   }
}

Deposit Status

public class DepositStatusExample {

   public static void main(String[] args) {
      DepositStatusRequest depositStatusRequest = DepositStatusRequest
                                                  .builder()
                                                  .id(300000001)
                                                  .build();
      try {
         DepositStatusResponse depositStatusResponse = directa24Sandbox.client.depositStatus(depositStatusRequest);
      
         // Handle response

      } catch (Directa24Exception e) {
         // Handle errors
      }
   }
}

Payment Methods

public class PaymentMethodsExample {

   public static void main(String[] args) {
      PaymentMethodRequest paymentMethodRequest = PaymentMethodRequest
                                                  .builder()
                                                  .country("BR")
                                                  .build();
      try {
         List<PaymentMethodResponse> paymentMethodResponse = directa24Sandbox.client.paymentMethods(paymentMethodRequest);
      
         // Handle response

      } catch (Directa24Exception e) {
         // Handle errors
      }
   }
}

Exchange rates

public class ExchangeRateExample {

   public static void main(String[] args) {
      ExchangeRateRequest exchangeRatesRequest = ExchangeRateRequest
                                                 .builder()
                                                 .country("BR")
                                                 .amount(BigDecimal.TEN)
                                                 .build();
      try {
         ExchangeRateResponse exchangeRateResponse = directa24Test.client.exchangeRates(exchangeRateRequest);
         
         // Handle response

      } catch (Directa24Exception e) {
         // Handle errors
      }
   }
}

For more examples see the bundled tests.

Dependencies

The library uses Project Lombok. While it is not a requirement, you might want to install a plugin for your favorite IDE to facilitate development.

JUnit 4 and Wiremock library are needed to run the bundled tests.

Versions

Version
1.0.14
1.0.13
1.0.12
1.0.11
1.0.10
1.0.9
1.0.8
1.0.7
1.0.6
1.0.5
1.0.4
1.0.3
1.0.2
1.0.1
1.0.0