Skip to content

Commit

Permalink
Merge pull request #182 from TransbankDevelopers/chore/prepare-releas…
Browse files Browse the repository at this point in the history
…e-5.0.0

chore: prepare release 5.0.0
  • Loading branch information
tribiec authored Mar 25, 2024
2 parents a64c8d4 + f9a7670 commit a2348c1
Show file tree
Hide file tree
Showing 120 changed files with 3,975 additions and 1,585 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ Todos los cambios notables a este proyecto serán documentados en este archivo.
El formato está basado en [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
y este proyecto adhiere a [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [5.0.0] - 2024-03-15

### Changed
- Downgrade del API de la versión 1.3 a la versión 1.2

### Added
- Javadocs para todas las clases e interfaces publicas
- Mejora de manejo de excepciones SSL

## [4.0.0] - 2022-09-01

### Changed
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

<groupId>com.github.transbankdevelopers</groupId>
<artifactId>transbank-sdk-java</artifactId>
<version>4.0.1-SNAPSHOT</version>
<version>5.0.0</version>
<name>Transbank Java SDK</name>

<inceptionYear>2018</inceptionYear>
Expand Down
45 changes: 31 additions & 14 deletions src/main/java/cl/transbank/common/ApiConstants.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,36 @@
package cl.transbank.common;

/**
* This class contains the constants used in the API.
*/
public class ApiConstants {
public static String WEBPAY_ENDPOINT = "rswebpaytransaction/api/webpay/v1.2";
public static String ONECLICK_ENDPOINT = "rswebpaytransaction/api/oneclick/v1.2";
public static String PATPASS_COMERCIO_ENDPOINT = "restpatpass/v1/services";

public static int BUY_ORDER_LENGTH = 26;
public static int SESSION_ID_LENGTH = 61;
public static int RETURN_URL_LENGTH = 255;
public static int AUTHORIZATION_CODE_LENGTH = 6;
public static int CARD_EXPIRATION_DATE_LENGTH = 5;
public static int CARD_NUMBER_LENGTH = 19;
public static int TBK_USER_LENGTH = 40;
public static int USER_NAME_LENGTH = 40;
public static int COMMERCE_CODE_LENGTH = 12;
public static int TOKEN_LENGTH = 64;
public static int EMAIL_LENGTH = 100;
public static final String WEBPAY_ENDPOINT =
"rswebpaytransaction/api/webpay/v1.2";
public static final String ONECLICK_ENDPOINT =
"rswebpaytransaction/api/oneclick/v1.2";
public static final String PATPASS_COMERCIO_ENDPOINT =
"restpatpass/v1/services";
public static final String HEADER_COMMERCE_CODE_NAME = "Tbk-Api-Key-Id";
public static final String HEADER_API_KEY_NAME = "Tbk-Api-Key-Secret";
public static final int BUY_ORDER_LENGTH = 26;
public static final int SESSION_ID_LENGTH = 61;
public static final int RETURN_URL_LENGTH = 255;
public static final int AUTHORIZATION_CODE_LENGTH = 6;
public static final int CARD_EXPIRATION_DATE_LENGTH = 5;
public static final int CARD_NUMBER_LENGTH = 19;
public static final int TBK_USER_LENGTH = 40;
public static final int USER_NAME_LENGTH = 40;
public static final int COMMERCE_CODE_LENGTH = 12;
public static final int TOKEN_LENGTH = 64;
public static final int EMAIL_LENGTH = 100;
public static final String TOKEN_TEXT = "token";
public static final String BUY_ORDER_TEXT = "buyOrder";

/**
* Private constructor to prevent instantiation.
*/
private ApiConstants() {
// This constructor is intentionally empty. Nothing to see here.
}
}
8 changes: 7 additions & 1 deletion src/main/java/cl/transbank/common/BaseTransaction.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@

import cl.transbank.model.Options;

/**
* This abstract class represents a base transaction with common properties and methods.
*/
public abstract class BaseTransaction {
protected Options options = null;

/**
* The options for the transaction.
*/
protected Options options = null;
}
23 changes: 21 additions & 2 deletions src/main/java/cl/transbank/common/IntegrationApiKeys.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
package cl.transbank.common;

/**
* This class holds the API keys for the integration environment.
*/
public class IntegrationApiKeys {
public static String WEBPAY = "579B532A7440BB0C9079DED94D31EA1615BACEB56610332264630D42D0A36B1C";
public static String PATPASS_COMERCIO = "cxxXQgGD9vrVe4M41FIt";

/**
* The API key for Webpay in the integration environment.
*/
public static final String WEBPAY =
"579B532A7440BB0C9079DED94D31EA1615BACEB56610332264630D42D0A36B1C";

/**
* The API key for Patpass Comercio in the integration environment.
*/
public static final String PATPASS_COMERCIO = "cxxXQgGD9vrVe4M41FIt";

/**
* Private constructor to prevent instantiation.
*/
private IntegrationApiKeys() {
// This constructor is intentionally empty.
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package cl.transbank.common;

/**
* This class contains the commerce codes for integration.
*/
public class IntegrationCommerceCodes {
public static String WEBPAY_PLUS = "597055555532";
public static String WEBPAY_PLUS_MODAL = "597055555584";
Expand Down
65 changes: 43 additions & 22 deletions src/main/java/cl/transbank/common/IntegrationTypeHelper.java
Original file line number Diff line number Diff line change
@@ -1,30 +1,51 @@
package cl.transbank.common;

/**
* This class provides helper methods to get the integration type for Webpay and Patpass.
*/
public class IntegrationTypeHelper {
public static String getWebpayIntegrationType(IntegrationType integrationType){
switch(integrationType){
case LIVE:
return "https://webpay3g.transbank.cl";
case MOCK:
return "";
case TEST:
return "https://webpay3gint.transbank.cl";
case SERVER_MOCK:
return "http://localhost:8888";
}

/**
* Returns the Webpay integration type based on the provided integration type.
* @param integrationType The integration type.
* @return The Webpay integration URL.
*/
public static String getWebpayIntegrationType(
IntegrationType integrationType
) {
switch (integrationType) {
case LIVE:
return "https://webpay3g.transbank.cl";
case MOCK:
return "";
case TEST:
return "https://webpay3gint.transbank.cl";
case SERVER_MOCK:
return "http://localhost:8888";
default:
return "https://webpay3gint.transbank.cl";
}
public static String getPatpassIntegrationType(IntegrationType integrationType){
switch(integrationType){
case LIVE:
return "https://www.pagoautomaticocontarjetas.cl";
case MOCK:
return "";
case TEST:
return "https://pagoautomaticocontarjetasint.transbank.cl";
case SERVER_MOCK:
return "http://localhost:8888";
}
}

/**
* Returns the Patpass integration type based on the provided integration type.
* @param integrationType The integration type.
* @return The Patpass integration URL.
*/
public static String getPatpassIntegrationType(
IntegrationType integrationType
) {
switch (integrationType) {
case LIVE:
return "https://www.pagoautomaticocontarjetas.cl";
case MOCK:
return "";
case TEST:
return "https://pagoautomaticocontarjetasint.transbank.cl";
case SERVER_MOCK:
return "http://localhost:8888";
default:
return "https://pagoautomaticocontarjetasint.transbank.cl";
}
}
}
116 changes: 82 additions & 34 deletions src/main/java/cl/transbank/exception/TransbankException.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,87 @@

import lombok.Getter;

/**
* This class represents a general exception that is thrown when a Transbank operation fails.
*/
public class TransbankException extends Exception {
@Getter private int code;

public TransbankException() {
super();
}

public TransbankException(String message) {
super(message);
this.code = -1;
}

public TransbankException(int code, String message) {
super(message);
this.code = code;
}

public TransbankException(int code, String message, Throwable cause) {
super(message, cause);
this.code = code;
}

public TransbankException(Throwable cause) {
super(cause);
}

public TransbankException(int code, Throwable cause) {
super(cause);
this.code = code;
}

public TransbankException(int code, String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
this.code = code;
}

@Getter
private final int code;

/**
* Constructs a new TransbankException with no detail message.
*/
public TransbankException() {
super();
this.code = -1;
}

/**
* Constructs a new TransbankException with the specified detail message.
* @param message The detail message.
*/
public TransbankException(String message) {
super(message);
this.code = -1;
}

/**
* Constructs a new TransbankException with the specified detail message and error code.
* @param code The error code.
* @param message The detail message.
*/
public TransbankException(int code, String message) {
super(message);
this.code = code;
}

/**
* Constructs a new TransbankException with the specified detail message, error code, and cause.
* @param code The error code.
* @param message The detail message.
* @param cause The cause.
*/
public TransbankException(int code, String message, Throwable cause) {
super(message, cause);
this.code = code;
}

/**
* Constructs a new TransbankException with the specified cause.
* @param cause The cause.
*/
public TransbankException(Throwable cause) {
super(cause);
this.code = -1;
}

/**
* Constructs a new TransbankException with the specified Ccode and cause.
* @param code The error code.
* @param cause The cause.
*/
public TransbankException(int code, Throwable cause) {
super(cause);
this.code = code;
}

/**
* Constructs a new TransbankException with the specified error code and cause.
* @param code The error code.
* @param message The detail message.
* @param cause The cause.
* @param enableSuppression Whether or not suppression is enabled or disabled.
* @param writableStackTrace Whether or not the stack trace should be writable.
*/
public TransbankException(
int code,
String message,
Throwable cause,
boolean enableSuppression,
boolean writableStackTrace
) {
super(message, cause, enableSuppression, writableStackTrace);
this.code = code;
}
}
26 changes: 17 additions & 9 deletions src/main/java/cl/transbank/model/BaseRefundResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,22 @@

import lombok.*;

@NoArgsConstructor @AllArgsConstructor
@Getter @Setter @ToString
/**
* This class represents a base response for a refund operation.
* It is abstract and should be extended by specific refund response classes.
*/
@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
@ToString
public abstract class BaseRefundResponse {
private String type;
private double balance;
private String authorizationCode;
private byte responseCode;
private String authorizationDate;
private double nullifiedAmount;
private Double prepaidBalance;

private String type;
private double balance;
private String authorizationCode;
private byte responseCode;
private String authorizationDate;
private double nullifiedAmount;
private Double prepaidBalance;
}
12 changes: 9 additions & 3 deletions src/main/java/cl/transbank/model/CardDetail.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@

import lombok.*;

@NoArgsConstructor @AllArgsConstructor
@Getter @Setter
/**
* This class represents the details of a card.
*/
@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
@ToString
public class CardDetail {
private String cardNumber;

private String cardNumber;
}
Loading

0 comments on commit a2348c1

Please sign in to comment.