diff --git a/CHANGELOG.md b/CHANGELOG.md
index 24c56ac5..296a6ef0 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -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
diff --git a/pom.xml b/pom.xml
index d10ab6ca..d0e2b77a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -29,7 +29,7 @@
com.github.transbankdevelopers
transbank-sdk-java
- 4.0.1-SNAPSHOT
+ 5.0.0
Transbank Java SDK
2018
diff --git a/src/main/java/cl/transbank/common/ApiConstants.java b/src/main/java/cl/transbank/common/ApiConstants.java
index f032d8f6..877afeaa 100644
--- a/src/main/java/cl/transbank/common/ApiConstants.java
+++ b/src/main/java/cl/transbank/common/ApiConstants.java
@@ -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.
+ }
}
diff --git a/src/main/java/cl/transbank/common/BaseTransaction.java b/src/main/java/cl/transbank/common/BaseTransaction.java
index 1c66a353..42a72b71 100644
--- a/src/main/java/cl/transbank/common/BaseTransaction.java
+++ b/src/main/java/cl/transbank/common/BaseTransaction.java
@@ -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;
}
diff --git a/src/main/java/cl/transbank/common/IntegrationApiKeys.java b/src/main/java/cl/transbank/common/IntegrationApiKeys.java
index 8e4aa940..1909838b 100644
--- a/src/main/java/cl/transbank/common/IntegrationApiKeys.java
+++ b/src/main/java/cl/transbank/common/IntegrationApiKeys.java
@@ -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.
+ }
}
diff --git a/src/main/java/cl/transbank/common/IntegrationCommerceCodes.java b/src/main/java/cl/transbank/common/IntegrationCommerceCodes.java
index 37f8ebbe..7bf713ea 100644
--- a/src/main/java/cl/transbank/common/IntegrationCommerceCodes.java
+++ b/src/main/java/cl/transbank/common/IntegrationCommerceCodes.java
@@ -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";
diff --git a/src/main/java/cl/transbank/common/IntegrationTypeHelper.java b/src/main/java/cl/transbank/common/IntegrationTypeHelper.java
index 41042b27..42b5719c 100644
--- a/src/main/java/cl/transbank/common/IntegrationTypeHelper.java
+++ b/src/main/java/cl/transbank/common/IntegrationTypeHelper.java
@@ -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";
}
+ }
}
diff --git a/src/main/java/cl/transbank/exception/TransbankException.java b/src/main/java/cl/transbank/exception/TransbankException.java
index 3637851c..1c77938f 100644
--- a/src/main/java/cl/transbank/exception/TransbankException.java
+++ b/src/main/java/cl/transbank/exception/TransbankException.java
@@ -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;
+ }
}
diff --git a/src/main/java/cl/transbank/model/BaseRefundResponse.java b/src/main/java/cl/transbank/model/BaseRefundResponse.java
index 4bcc7352..936b52f0 100644
--- a/src/main/java/cl/transbank/model/BaseRefundResponse.java
+++ b/src/main/java/cl/transbank/model/BaseRefundResponse.java
@@ -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;
}
diff --git a/src/main/java/cl/transbank/model/CardDetail.java b/src/main/java/cl/transbank/model/CardDetail.java
index 72723860..8400625e 100644
--- a/src/main/java/cl/transbank/model/CardDetail.java
+++ b/src/main/java/cl/transbank/model/CardDetail.java
@@ -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;
}
diff --git a/src/main/java/cl/transbank/model/MallTransactionCreateDetails.java b/src/main/java/cl/transbank/model/MallTransactionCreateDetails.java
index 80e15b2a..f7998bc5 100644
--- a/src/main/java/cl/transbank/model/MallTransactionCreateDetails.java
+++ b/src/main/java/cl/transbank/model/MallTransactionCreateDetails.java
@@ -1,53 +1,122 @@
package cl.transbank.model;
-import lombok.*;
-
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import java.util.Objects;
+import lombok.*;
+/**
+ * This class represents the details of the FullTransaction installment response.
+ */
public class MallTransactionCreateDetails {
- private List detailList = new ArrayList<>();
- private MallTransactionCreateDetails() {}
+ private List detailList = new ArrayList<>();
- public static MallTransactionCreateDetails build() {
- return new MallTransactionCreateDetails();
- }
+ /**
+ * This class represents the details of the FullTransaction installment response.
+ */
+ private MallTransactionCreateDetails() {}
- public static MallTransactionCreateDetails build(double amount, String commerceCode, String buyOrder) {
- return MallTransactionCreateDetails.build().add(amount, commerceCode, buyOrder);
- }
+ /**
+ * Builds a new MallTransactionCreateDetails instance.
+ * @return A new MallTransactionCreateDetails instance.
+ */
+ public static MallTransactionCreateDetails build() {
+ return new MallTransactionCreateDetails();
+ }
- public MallTransactionCreateDetails add(double amount, String commerceCode, String buyOrder) {
- detailList.add(new MallTransactionCreateDetails.Detail(amount, commerceCode, buyOrder));
- return this;
- }
+ /**
+ * Builds a new MallTransactionCreateDetails instance and adds the provided detail.
+ * @param amount The amount of the transaction.
+ * @param commerceCode The commerce code.
+ * @param buyOrder The buy order.
+ * @return A new MallTransactionCreateDetails instance with the provided detail added.
+ */
+ public static MallTransactionCreateDetails build(
+ double amount,
+ String commerceCode,
+ String buyOrder
+ ) {
+ return MallTransactionCreateDetails
+ .build()
+ .add(amount, commerceCode, buyOrder);
+ }
- public boolean remove(double amount, String commerceCode, String buyOrder) {
- return getDetails().remove(new MallTransactionCreateDetails.Detail(amount, commerceCode, buyOrder));
- }
+ /**
+ * Adds a new detail to this MallTransactionCreateDetails.
+ * @param amount The amount of the transaction.
+ * @param commerceCode The commerce code.
+ * @param buyOrder The buy order.
+ * @return This MallTransactionCreateDetails instance.
+ */
+ public MallTransactionCreateDetails add(
+ double amount,
+ String commerceCode,
+ String buyOrder
+ ) {
+ detailList.add(
+ new MallTransactionCreateDetails.Detail(amount, commerceCode, buyOrder)
+ );
+ return this;
+ }
- public List getDetails() {
- return Collections.unmodifiableList(detailList);
+ /**
+ * Removes a detail from this MallTransactionCreateDetails.
+ * @param amount The amount of the transaction.
+ * @param commerceCode The commerce code.
+ * @param buyOrder The buy order.
+ * @return True if the detail was removed, false otherwise.
+ */
+ public boolean remove(double amount, String commerceCode, String buyOrder) {
+ return getDetails()
+ .remove(
+ new MallTransactionCreateDetails.Detail(amount, commerceCode, buyOrder)
+ );
+ }
+
+ /**
+ * Gets the details of this MallTransactionCreateDetails.
+ * @return The details of this MallTransactionCreateDetails.
+ */
+ public List getDetails() {
+ return Collections.unmodifiableList(detailList);
+ }
+
+ /**
+ * Gets the details of this MallTransactionCreateDetails.
+ */
+ @NoArgsConstructor
+ @AllArgsConstructor
+ @Getter
+ @Setter
+ @ToString
+ public class Detail {
+
+ private double amount;
+ private String commerceCode;
+ private String buyOrder;
+
+ /**
+ * Checks if this Detail is equal to another object.
+ * @param obj The object to compare with.
+ * @return True if the objects are equal, false otherwise.
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (!(obj instanceof MallTransactionCreateDetails.Detail)) return false;
+
+ MallTransactionCreateDetails.Detail another = (MallTransactionCreateDetails.Detail) obj;
+ return (
+ getAmount() == another.getAmount() &&
+ getCommerceCode().equals(another.getBuyOrder()) &&
+ getBuyOrder().equals(another.getBuyOrder())
+ );
}
- @NoArgsConstructor @AllArgsConstructor
- @Getter @Setter @ToString
- public class Detail {
- private double amount;
- private String commerceCode;
- private String buyOrder;
-
- @Override
- public boolean equals(Object obj) {
- if (!(obj instanceof MallTransactionCreateDetails.Detail))
- return false;
-
- MallTransactionCreateDetails.Detail another = (MallTransactionCreateDetails.Detail) obj;
- return getAmount() == another.getAmount() && getCommerceCode().equals(another.getBuyOrder()) &&
- getBuyOrder().equals(another.getBuyOrder());
- }
+ @Override
+ public int hashCode() {
+ return Objects.hash(commerceCode, buyOrder, amount);
}
+ }
}
-
diff --git a/src/main/java/cl/transbank/model/Options.java b/src/main/java/cl/transbank/model/Options.java
index 0c13fcb7..f784e092 100644
--- a/src/main/java/cl/transbank/model/Options.java
+++ b/src/main/java/cl/transbank/model/Options.java
@@ -3,52 +3,95 @@
import cl.transbank.common.IntegrationType;
import lombok.*;
+/**
+ * This abstract class represents the options that can be set for a transaction.
+ */
@NoArgsConstructor
@AllArgsConstructor
-public abstract class Options implements Cloneable{
- @Setter @Getter private String commerceCode;
- @Setter @Getter private String apiKey;
- @Setter @Getter private IntegrationType integrationType;
+public abstract class Options implements Cloneable {
- public abstract String getHeaderCommerceCodeName();
- public abstract String getHeaderApiKeyName();
+ @Setter
+ @Getter
+ private String commerceCode;
- public Options buildOptions(Options options){
- Options alt = clone();
+ @Setter
+ @Getter
+ private String apiKey;
- // If the method receives an options object then rewrite each property, this is mandatory
- if (null != options) {
- if (null != options.getCommerceCode() && !options.getCommerceCode().trim().isEmpty())
- alt.setCommerceCode(options.getCommerceCode());
+ @Setter
+ @Getter
+ private IntegrationType integrationType;
- if (null != options.getApiKey() && !options.getApiKey().trim().isEmpty())
- alt.setApiKey(options.getApiKey());
+ /**
+ * Builds the options for a transaction.
+ * @param options The options to set.
+ * @return The built options.
+ */
+ public Options buildOptions(Options options) {
+ Options alt = clone();
- if (null != options.getIntegrationType())
- alt.setIntegrationType(options.getIntegrationType());
- }
+ // If the method receives an options object then rewrite each property, this is mandatory
+ if (null != options) {
+ if (
+ null != options.getCommerceCode() &&
+ !options.getCommerceCode().trim().isEmpty()
+ ) alt.setCommerceCode(options.getCommerceCode());
- return alt;
- }
+ if (
+ null != options.getApiKey() && !options.getApiKey().trim().isEmpty()
+ ) alt.setApiKey(options.getApiKey());
- @Override
- public Options clone() {
- try {
- return (Options) super.clone();
- } catch (CloneNotSupportedException e) {
- return null;
- }
+ if (null != options.getIntegrationType()) alt.setIntegrationType(
+ options.getIntegrationType()
+ );
}
- public boolean isEmpty() {
- return (null == this.getCommerceCode() || this.getCommerceCode().trim().isEmpty()) &&
- (null == this.getApiKey() || this.getApiKey().trim().isEmpty()) &&
- (null == this.getIntegrationType() || this.getIntegrationType().toString().isEmpty());
- }
+ return alt;
+ }
- public static boolean isEmpty(Options options) {
- return (null == options || (null == options.getCommerceCode() || options.getCommerceCode().trim().isEmpty()) &&
- (null == options.getApiKey() || options.getApiKey().trim().isEmpty()) &&
- (null == options.getIntegrationType() || options.getIntegrationType().toString().isEmpty()));
+ /**
+ * Creates and returns a copy of this object.
+ * @return A clone of this instance.
+ */
+ @Override
+ public Options clone() {
+ try {
+ return (Options) super.clone();
+ } catch (CloneNotSupportedException e) {
+ return (Options) new Object();
}
+ }
+
+ /**
+ * Checks if the options are empty.
+ * @return true if the options are empty, false otherwise.
+ */
+ public boolean isEmpty() {
+ return (
+ (
+ null == this.getCommerceCode() ||
+ this.getCommerceCode().trim().isEmpty()
+ ) &&
+ (null == this.getApiKey() || this.getApiKey().trim().isEmpty()) &&
+ (
+ null == this.getIntegrationType() ||
+ this.getIntegrationType().toString().isEmpty()
+ )
+ );
+ }
+
+ public static boolean isEmpty(Options options) {
+ return (
+ null == options ||
+ (
+ null == options.getCommerceCode() ||
+ options.getCommerceCode().trim().isEmpty()
+ ) &&
+ (null == options.getApiKey() || options.getApiKey().trim().isEmpty()) &&
+ (
+ null == options.getIntegrationType() ||
+ options.getIntegrationType().toString().isEmpty()
+ )
+ );
+ }
}
diff --git a/src/main/java/cl/transbank/model/WebpayApiRequest.java b/src/main/java/cl/transbank/model/WebpayApiRequest.java
index 03557917..7d316542 100644
--- a/src/main/java/cl/transbank/model/WebpayApiRequest.java
+++ b/src/main/java/cl/transbank/model/WebpayApiRequest.java
@@ -2,7 +2,11 @@
import lombok.*;
+/**
+ * This abstract class represents a Webpay API request.
+ */
@NoArgsConstructor
-@Getter @Setter @ToString
-public abstract class WebpayApiRequest {
-}
+@Getter
+@Setter
+@ToString
+public abstract class WebpayApiRequest {}
diff --git a/src/main/java/cl/transbank/patpass/PatpassByWebpay.java b/src/main/java/cl/transbank/patpass/PatpassByWebpay.java
index c73b3bc2..539805f4 100644
--- a/src/main/java/cl/transbank/patpass/PatpassByWebpay.java
+++ b/src/main/java/cl/transbank/patpass/PatpassByWebpay.java
@@ -5,42 +5,95 @@
import cl.transbank.patpass.model.PatpassOptions;
import cl.transbank.webpay.common.WebpayOptions;
+/**
+ * This class provides methods to configure and perform transactions with the PatpassByWebpay service.
+ */
public class PatpassByWebpay {
- private static Options options;
- public static class Transaction extends PatpassByWebpayTransaction {
- public Transaction() {
- this.options = PatpassByWebpay.options!=null ? PatpassByWebpay.options : new WebpayOptions(IntegrationCommerceCodes.PATPASS_BY_WEBPAY, IntegrationApiKeys.WEBPAY, IntegrationType.TEST);
- }
- public Transaction(Options options) {
- this.options = options;
- }
+ private static Options options;
+ /**
+ * This class provides methods to configure and perform transactions with the PatpassByWebpay service.
+ */
+ public static class Transaction extends PatpassByWebpayTransaction {
+
+ public Transaction() {
+ this.options =
+ PatpassByWebpay.options != null
+ ? PatpassByWebpay.options
+ : new WebpayOptions(
+ IntegrationCommerceCodes.PATPASS_BY_WEBPAY,
+ IntegrationApiKeys.WEBPAY,
+ IntegrationType.TEST
+ );
+ }
+
+ public Transaction(Options options) {
+ this.options = options;
}
+ }
- /*
+ /*
|--------------------------------------------------------------------------
| Environment Configuration
|--------------------------------------------------------------------------
*/
- public static void configureForIntegration(String commerceCode, String apiKey){
- PatpassByWebpay.options = new PatpassOptions(commerceCode, apiKey, IntegrationType.TEST);
- }
+ /**
+ * Configures the environment for integration.
+ * @param commerceCode The commerce code.
+ * @param apiKey The API key.
+ */
+ public static void configureForIntegration(
+ String commerceCode,
+ String apiKey
+ ) {
+ PatpassByWebpay.options =
+ new PatpassOptions(commerceCode, apiKey, IntegrationType.TEST);
+ }
- public static void configureForProduction(String commerceCode, String apiKey){
- PatpassByWebpay.options = new PatpassOptions(commerceCode, apiKey, IntegrationType.LIVE);
- }
+ /**
+ * Configures the environment for integration.
+ * @param commerceCode The commerce code.
+ * @param apiKey The API key.
+ */
+ public static void configureForProduction(
+ String commerceCode,
+ String apiKey
+ ) {
+ PatpassByWebpay.options =
+ new PatpassOptions(commerceCode, apiKey, IntegrationType.LIVE);
+ }
- public static void configureForTesting(){
- configureForIntegration(IntegrationCommerceCodes.PATPASS_BY_WEBPAY, IntegrationApiKeys.WEBPAY);
- }
+ /**
+ * Configures the environment for testing.
+ */
+ public static void configureForTesting() {
+ configureForIntegration(
+ IntegrationCommerceCodes.PATPASS_BY_WEBPAY,
+ IntegrationApiKeys.WEBPAY
+ );
+ }
- public static void configureForTestingDeferred(){
- configureForIntegration(IntegrationCommerceCodes.PATPASS_BY_WEBPAY, IntegrationApiKeys.WEBPAY);
- }
+ /**
+ * Configures the environment for testing deferred transactions.
+ */
+ public static void configureForTestingDeferred() {
+ configureForIntegration(
+ IntegrationCommerceCodes.PATPASS_BY_WEBPAY,
+ IntegrationApiKeys.WEBPAY
+ );
+ }
- public static void configureForMock(){
- PatpassByWebpay.options = new PatpassOptions(IntegrationCommerceCodes.PATPASS_BY_WEBPAY, IntegrationApiKeys.WEBPAY, IntegrationType.SERVER_MOCK);
- }
+ /**
+ * Configures the environment for mock testing.
+ */
+ public static void configureForMock() {
+ PatpassByWebpay.options =
+ new PatpassOptions(
+ IntegrationCommerceCodes.PATPASS_BY_WEBPAY,
+ IntegrationApiKeys.WEBPAY,
+ IntegrationType.SERVER_MOCK
+ );
+ }
}
diff --git a/src/main/java/cl/transbank/patpass/PatpassComercio.java b/src/main/java/cl/transbank/patpass/PatpassComercio.java
index 7380b703..c7283427 100644
--- a/src/main/java/cl/transbank/patpass/PatpassComercio.java
+++ b/src/main/java/cl/transbank/patpass/PatpassComercio.java
@@ -4,43 +4,102 @@
import cl.transbank.model.Options;
import cl.transbank.patpass.model.PatpassOptions;
-public class PatpassComercio {
- private static Options options;
+/**
+ * This class represents the details of a MallTransactionCommit.
+ */
+public class PatpassComercio {
- public static class Inscription extends PatpassComercioInscription {
- public Inscription() {
- this.options = PatpassComercio.options!=null ? PatpassComercio.options : new PatpassOptions(IntegrationCommerceCodes.PATPASS_COMERCIO, IntegrationApiKeys.PATPASS_COMERCIO, IntegrationType.TEST);
- }
+ private static Options options;
- public Inscription(Options options) {
- this.options = options;
- }
+ /**
+ * This class represents the details of a MallTransactionCommit.
+ */
+ public static class Inscription extends PatpassComercioInscription {
+ /**
+ * Default constructor. Uses default options if none are provided.
+ */
+ public Inscription() {
+ this.options =
+ PatpassComercio.options != null
+ ? PatpassComercio.options
+ : new PatpassOptions(
+ IntegrationCommerceCodes.PATPASS_COMERCIO,
+ IntegrationApiKeys.PATPASS_COMERCIO,
+ IntegrationType.TEST
+ );
}
- /*
+ /**
+ * Constructor with options. Uses provided options.
+ * @param options The options to use for this transaction.
+ */
+ public Inscription(Options options) {
+ this.options = options;
+ }
+ }
+
+ /*
|--------------------------------------------------------------------------
| Environment Configuration
|--------------------------------------------------------------------------
*/
- public static void configureForIntegration(String commerceCode, String apiKey){
- PatpassComercio.options = new PatpassOptions(commerceCode, apiKey, IntegrationType.TEST);
- }
+ /**
+ * Configures the environment for integration.
+ * @param commerceCode The commerce code.
+ * @param apiKey The API key.
+ */
+ public static void configureForIntegration(
+ String commerceCode,
+ String apiKey
+ ) {
+ PatpassComercio.options =
+ new PatpassOptions(commerceCode, apiKey, IntegrationType.TEST);
+ }
- public static void configureForProduction(String commerceCode, String apiKey){
- PatpassComercio.options = new PatpassOptions(commerceCode, apiKey, IntegrationType.LIVE);
- }
+ /**
+ * Configures the environment for integration.
+ * @param commerceCode The commerce code.
+ * @param apiKey The API key.
+ */
+ public static void configureForProduction(
+ String commerceCode,
+ String apiKey
+ ) {
+ PatpassComercio.options =
+ new PatpassOptions(commerceCode, apiKey, IntegrationType.LIVE);
+ }
- public static void configureForTesting(){
- configureForIntegration(IntegrationCommerceCodes.PATPASS_COMERCIO, IntegrationApiKeys.PATPASS_COMERCIO);
- }
+ /**
+ * Configures the environment for testing.
+ */
+ public static void configureForTesting() {
+ configureForIntegration(
+ IntegrationCommerceCodes.PATPASS_COMERCIO,
+ IntegrationApiKeys.PATPASS_COMERCIO
+ );
+ }
- public static void configureForTestingDeferred(){
- configureForIntegration(IntegrationCommerceCodes.PATPASS_COMERCIO, IntegrationApiKeys.PATPASS_COMERCIO);
- }
+ /**
+ * Configures the environment for testing deferred transactions.
+ */
+ public static void configureForTestingDeferred() {
+ configureForIntegration(
+ IntegrationCommerceCodes.PATPASS_COMERCIO,
+ IntegrationApiKeys.PATPASS_COMERCIO
+ );
+ }
- public static void configureForMock(){
- PatpassComercio.options = new PatpassOptions(IntegrationCommerceCodes.PATPASS_COMERCIO, IntegrationApiKeys.PATPASS_COMERCIO, IntegrationType.SERVER_MOCK);
- }
+ /**
+ * Configures the environment for mock testing.
+ */
+ public static void configureForMock() {
+ PatpassComercio.options =
+ new PatpassOptions(
+ IntegrationCommerceCodes.PATPASS_COMERCIO,
+ IntegrationApiKeys.PATPASS_COMERCIO,
+ IntegrationType.SERVER_MOCK
+ );
+ }
}
diff --git a/src/main/java/cl/transbank/patpass/model/PatPassInfo.java b/src/main/java/cl/transbank/patpass/model/PatPassInfo.java
index 0566d9b0..dfd46530 100644
--- a/src/main/java/cl/transbank/patpass/model/PatPassInfo.java
+++ b/src/main/java/cl/transbank/patpass/model/PatPassInfo.java
@@ -1,23 +1,26 @@
package cl.transbank.patpass.model;
+import java.util.GregorianCalendar;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
-import java.util.GregorianCalendar;
-
+/**
+ * This class represents the information of a PatPass.
+ */
@Getter
@Setter
@Accessors(chain = true)
@NoArgsConstructor
public class PatPassInfo {
- private String serviceId;
- private String cardHolderId;
- private String cardHolderName;
- private String cardHolderLastName1;
- private String cardHolderLastName2;
- private String cardHolderMail;
- private String cellPhoneNumber;
- private GregorianCalendar expirationDate;
+
+ private String serviceId;
+ private String cardHolderId;
+ private String cardHolderName;
+ private String cardHolderLastName1;
+ private String cardHolderLastName2;
+ private String cardHolderMail;
+ private String cellPhoneNumber;
+ private GregorianCalendar expirationDate;
}
diff --git a/src/main/java/cl/transbank/patpass/model/PatpassOptions.java b/src/main/java/cl/transbank/patpass/model/PatpassOptions.java
index 1e50dde2..3d3c6a44 100644
--- a/src/main/java/cl/transbank/patpass/model/PatpassOptions.java
+++ b/src/main/java/cl/transbank/patpass/model/PatpassOptions.java
@@ -4,13 +4,24 @@
import cl.transbank.model.Options;
import lombok.*;
-@ToString @AllArgsConstructor
-public class PatpassOptions extends Options {
- @Getter final String headerCommerceCodeName = "commercecode";
- @Getter final String headerApiKeyName = "Authorization";
+/**
+ * This class represents the options for a Patpass transaction.
+ */
+@ToString
+@AllArgsConstructor
+public class PatpassOptions extends Options {
- public PatpassOptions(String commerceCode, String apiKey,IntegrationType integrationType ){
- super(commerceCode,apiKey,integrationType);
- }
+ /**
+ * Constructs a new PatpassOptions with the specified commerce code, API key, and integration type.
+ * @param commerceCode The commerce code.
+ * @param apiKey The API key.
+ * @param integrationType The integration type.
+ */
+ public PatpassOptions(
+ String commerceCode,
+ String apiKey,
+ IntegrationType integrationType
+ ) {
+ super(commerceCode, apiKey, integrationType);
+ }
}
-
diff --git a/src/main/java/cl/transbank/patpass/requests/PatpassComercioInscriptionStartRequest.java b/src/main/java/cl/transbank/patpass/requests/PatpassComercioInscriptionStartRequest.java
index a0a64b9c..81e92044 100644
--- a/src/main/java/cl/transbank/patpass/requests/PatpassComercioInscriptionStartRequest.java
+++ b/src/main/java/cl/transbank/patpass/requests/PatpassComercioInscriptionStartRequest.java
@@ -4,6 +4,9 @@
import com.google.gson.annotations.SerializedName;
import lombok.*;
+/**
+ * This class represents a request to start an inscription for a Patpass Comercio transaction.
+ */
@NoArgsConstructor
@RequiredArgsConstructor
@AllArgsConstructor
diff --git a/src/main/java/cl/transbank/patpass/requests/PatpassComercioTransactionStatusRequest.java b/src/main/java/cl/transbank/patpass/requests/PatpassComercioTransactionStatusRequest.java
index 81baf807..268187cc 100644
--- a/src/main/java/cl/transbank/patpass/requests/PatpassComercioTransactionStatusRequest.java
+++ b/src/main/java/cl/transbank/patpass/requests/PatpassComercioTransactionStatusRequest.java
@@ -3,11 +3,16 @@
import cl.transbank.model.WebpayApiRequest;
import lombok.*;
+/**
+ * This class represents a request to get the status of a Patpass Comercio transaction.
+ */
@NoArgsConstructor
@RequiredArgsConstructor
@Data
-@EqualsAndHashCode(callSuper=true)
-@ToString(callSuper=true)
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
public class PatpassComercioTransactionStatusRequest extends WebpayApiRequest {
- @NonNull private String token;
+
+ @NonNull
+ private String token;
}
diff --git a/src/main/java/cl/transbank/patpass/requests/TransactionCreateRequest.java b/src/main/java/cl/transbank/patpass/requests/TransactionCreateRequest.java
index 9bea2785..0f49a1e7 100644
--- a/src/main/java/cl/transbank/patpass/requests/TransactionCreateRequest.java
+++ b/src/main/java/cl/transbank/patpass/requests/TransactionCreateRequest.java
@@ -1,35 +1,92 @@
package cl.transbank.patpass.requests;
import cl.transbank.model.WebpayApiRequest;
-import com.google.gson.annotations.SerializedName;
import lombok.*;
-@NoArgsConstructor @RequiredArgsConstructor
-@Getter @Setter @ToString
+/**
+ * This class represents a request to create a transaction.
+ */
+@NoArgsConstructor
+@RequiredArgsConstructor
+@Getter
+@Setter
+@ToString
public class TransactionCreateRequest extends WebpayApiRequest {
- @NonNull private String buyOrder;
- @NonNull private String sessionId;
- @NonNull private double amount;
- @NonNull private String returnUrl;
- private Detail wpmDetail;
-
- public void setDetails(String serviceId, String cardHolderId, String cardHolderName, String cardHolderLastName1,
- String cardHolderLastName2, String cardHolderMail, String cellphoneNumber, String expirationDate, String commerceMail, boolean ufFlag) {
- wpmDetail = new Detail(serviceId, cardHolderId, cardHolderName, cardHolderLastName1, cardHolderLastName2, cardHolderMail, cellphoneNumber, expirationDate, commerceMail, ufFlag);
- }
-
- @NoArgsConstructor @AllArgsConstructor
- @Getter @Setter @ToString
- public class Detail {
- private String serviceId;
- private String cardHolderId;
- private String cardHolderName;
- private String cardHolderLastName1;
- private String cardHolderLastName2;
- private String cardHolderMail;
- private String cellphoneNumber;
- private String expirationDate;
- private String commerceMail;
- private boolean ufFlag;
- }
+
+ @NonNull
+ private String buyOrder;
+
+ @NonNull
+ private String sessionId;
+
+ @NonNull
+ private double amount;
+
+ @NonNull
+ private String returnUrl;
+
+ private Detail wpmDetail;
+
+ /**
+ * Sets the details for the transaction.
+ * @param serviceId The service ID.
+ * @param cardHolderId The card holder ID.
+ * @param cardHolderName The card holder name.
+ * @param cardHolderLastName1 The card holder's first last name.
+ * @param cardHolderLastName2 The card holder's second last name.
+ * @param cardHolderMail The card holder's mail.
+ * @param cellphoneNumber The cellphone number.
+ * @param expirationDate The expiration date.
+ * @param commerceMail The commerce mail.
+ * @param ufFlag The UF flag.
+ */
+
+ public void setDetails(
+ String serviceId,
+ String cardHolderId,
+ String cardHolderName,
+ String cardHolderLastName1,
+ String cardHolderLastName2,
+ String cardHolderMail,
+ String cellphoneNumber,
+ String expirationDate,
+ String commerceMail,
+ boolean ufFlag
+ ) {
+ wpmDetail =
+ new Detail(
+ serviceId,
+ cardHolderId,
+ cardHolderName,
+ cardHolderLastName1,
+ cardHolderLastName2,
+ cardHolderMail,
+ cellphoneNumber,
+ expirationDate,
+ commerceMail,
+ ufFlag
+ );
+ }
+
+ /**
+ * This class represents the detail of a transaction.
+ */
+ @NoArgsConstructor
+ @AllArgsConstructor
+ @Getter
+ @Setter
+ @ToString
+ public class Detail {
+
+ private String serviceId;
+ private String cardHolderId;
+ private String cardHolderName;
+ private String cardHolderLastName1;
+ private String cardHolderLastName2;
+ private String cardHolderMail;
+ private String cellphoneNumber;
+ private String expirationDate;
+ private String commerceMail;
+ private boolean ufFlag;
+ }
}
diff --git a/src/main/java/cl/transbank/patpass/responses/PatpassByWebpayTransactionCommitResponse.java b/src/main/java/cl/transbank/patpass/responses/PatpassByWebpayTransactionCommitResponse.java
index f4b88365..93d14386 100644
--- a/src/main/java/cl/transbank/patpass/responses/PatpassByWebpayTransactionCommitResponse.java
+++ b/src/main/java/cl/transbank/patpass/responses/PatpassByWebpayTransactionCommitResponse.java
@@ -3,19 +3,26 @@
import cl.transbank.model.CardDetail;
import lombok.*;
-@NoArgsConstructor @AllArgsConstructor
-@Getter @Setter @ToString
+/**
+ * This class represents a response to a commit operation for a Patpass By Webpay transaction.
+ */
+@NoArgsConstructor
+@AllArgsConstructor
+@Getter
+@Setter
+@ToString
public class PatpassByWebpayTransactionCommitResponse {
- private String vci;
- private double amount;
- private String status;
- private String buyOrder;
- private String sessionId;
- private CardDetail cardDetail;
- private String accountingDate;
- private String transactionDate;
- private String authorizationCode;
- private String paymentTypeCode;
- private byte responseCode;
- private byte installmentsNumber;
+
+ private String vci;
+ private double amount;
+ private String status;
+ private String buyOrder;
+ private String sessionId;
+ private CardDetail cardDetail;
+ private String accountingDate;
+ private String transactionDate;
+ private String authorizationCode;
+ private String paymentTypeCode;
+ private byte responseCode;
+ private byte installmentsNumber;
}
diff --git a/src/main/java/cl/transbank/patpass/responses/PatpassByWebpayTransactionCreateResponse.java b/src/main/java/cl/transbank/patpass/responses/PatpassByWebpayTransactionCreateResponse.java
index f94965e7..652ba2b7 100644
--- a/src/main/java/cl/transbank/patpass/responses/PatpassByWebpayTransactionCreateResponse.java
+++ b/src/main/java/cl/transbank/patpass/responses/PatpassByWebpayTransactionCreateResponse.java
@@ -2,9 +2,16 @@
import lombok.*;
-@NoArgsConstructor @AllArgsConstructor
-@Getter @Setter @ToString
+/**
+ * This class represents a response to a create operation for a Patpass by Webpay transaction.
+ */
+@NoArgsConstructor
+@AllArgsConstructor
+@Getter
+@Setter
+@ToString
public class PatpassByWebpayTransactionCreateResponse {
- private String token;
- private String url;
+
+ private String token;
+ private String url;
}
diff --git a/src/main/java/cl/transbank/patpass/responses/PatpassByWebpayTransactionRefundResponse.java b/src/main/java/cl/transbank/patpass/responses/PatpassByWebpayTransactionRefundResponse.java
index b6b94e9f..d9b6d8e8 100644
--- a/src/main/java/cl/transbank/patpass/responses/PatpassByWebpayTransactionRefundResponse.java
+++ b/src/main/java/cl/transbank/patpass/responses/PatpassByWebpayTransactionRefundResponse.java
@@ -2,5 +2,8 @@
import cl.transbank.model.BaseRefundResponse;
-public class PatpassByWebpayTransactionRefundResponse extends BaseRefundResponse {
-}
+/**
+ * This class represents the response of a refund transaction in Patpass by Webpay.
+ */
+public class PatpassByWebpayTransactionRefundResponse
+ extends BaseRefundResponse {}
diff --git a/src/main/java/cl/transbank/patpass/responses/PatpassByWebpayTransactionStatusResponse.java b/src/main/java/cl/transbank/patpass/responses/PatpassByWebpayTransactionStatusResponse.java
index b847d6d3..361a389c 100644
--- a/src/main/java/cl/transbank/patpass/responses/PatpassByWebpayTransactionStatusResponse.java
+++ b/src/main/java/cl/transbank/patpass/responses/PatpassByWebpayTransactionStatusResponse.java
@@ -3,19 +3,26 @@
import cl.transbank.model.CardDetail;
import lombok.*;
-@NoArgsConstructor @AllArgsConstructor
-@Getter @Setter @ToString
+/**
+ * This class represents a response to a status request for a Patpass by Webpay transaction.
+ */
+@NoArgsConstructor
+@AllArgsConstructor
+@Getter
+@Setter
+@ToString
public class PatpassByWebpayTransactionStatusResponse {
- private String vci;
- private double amount;
- private String status;
- private double balance;
- private String buyOrder;
- private String sessionId;
- private CardDetail cardDetail;
- private String accountingDate;
- private String transactionDate;
- private String authorizationCode;
- private String paymentTypeCode;
- private byte installmentsNumber;
+
+ private String vci;
+ private double amount;
+ private String status;
+ private double balance;
+ private String buyOrder;
+ private String sessionId;
+ private CardDetail cardDetail;
+ private String accountingDate;
+ private String transactionDate;
+ private String authorizationCode;
+ private String paymentTypeCode;
+ private byte installmentsNumber;
}
diff --git a/src/main/java/cl/transbank/patpass/responses/PatpassComercioInscriptionStartResponse.java b/src/main/java/cl/transbank/patpass/responses/PatpassComercioInscriptionStartResponse.java
index f6fa6194..0c92e401 100644
--- a/src/main/java/cl/transbank/patpass/responses/PatpassComercioInscriptionStartResponse.java
+++ b/src/main/java/cl/transbank/patpass/responses/PatpassComercioInscriptionStartResponse.java
@@ -4,10 +4,14 @@
import lombok.Data;
import lombok.NoArgsConstructor;
+/**
+ * This class represents the response of starting an inscription in Patpass Comercio.
+ */
@NoArgsConstructor
@AllArgsConstructor
@Data
public class PatpassComercioInscriptionStartResponse {
- private String token;
- private String url;
+
+ private String token;
+ private String url;
}
diff --git a/src/main/java/cl/transbank/patpass/responses/PatpassComercioTransactionStatusResponse.java b/src/main/java/cl/transbank/patpass/responses/PatpassComercioTransactionStatusResponse.java
index f44bdbb6..8da4272b 100644
--- a/src/main/java/cl/transbank/patpass/responses/PatpassComercioTransactionStatusResponse.java
+++ b/src/main/java/cl/transbank/patpass/responses/PatpassComercioTransactionStatusResponse.java
@@ -5,10 +5,16 @@
import lombok.Data;
import lombok.NoArgsConstructor;
+/**
+ * This class represents a response to a status check operation for a Patpass Comercio transaction.
+ */
@NoArgsConstructor
@AllArgsConstructor
@Data
public class PatpassComercioTransactionStatusResponse {
- private boolean authorized;
- @SerializedName("voucherUrl") private String voucherUrl;
+
+ private boolean authorized;
+
+ @SerializedName("voucherUrl")
+ private String voucherUrl;
}
diff --git a/src/main/java/cl/transbank/patpass/responses/PatpassTransactionCreateDetails.java b/src/main/java/cl/transbank/patpass/responses/PatpassTransactionCreateDetails.java
index 9e0767e2..ea55339a 100644
--- a/src/main/java/cl/transbank/patpass/responses/PatpassTransactionCreateDetails.java
+++ b/src/main/java/cl/transbank/patpass/responses/PatpassTransactionCreateDetails.java
@@ -1,52 +1,138 @@
package cl.transbank.patpass.responses;
-import com.google.gson.annotations.SerializedName;
-import lombok.*;
-
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import lombok.*;
+/**
+ * Configures the environment for mock testing.
+ */
public class PatpassTransactionCreateDetails {
- private List detailList = new ArrayList<>();
-
- private PatpassTransactionCreateDetails() {}
-
- public static PatpassTransactionCreateDetails build() {
- return new PatpassTransactionCreateDetails();
- }
-
- public static PatpassTransactionCreateDetails build(
- String serviceId, String cardHolderId, String cardHolderName, String cardHolderLastName1, String cardHolderLastName2,
- String cardHolderMail, String cellphoneNumber, String expirationDate, String commerceMail, boolean ufFlag) {
- return PatpassTransactionCreateDetails.build().add(
- serviceId, cardHolderId, cardHolderName, cardHolderLastName1, cardHolderLastName2, cardHolderMail, cellphoneNumber, expirationDate, commerceMail, ufFlag);
- }
-
- public PatpassTransactionCreateDetails add(
- String serviceId, String cardHolderId, String cardHolderName, String cardHolderLastName1, String cardHolderLastName2,
- String cardHolderMail, String cellphoneNumber, String expirationDate, String commerceMail, boolean ufFlag) {
- detailList.add(new Detail(
- serviceId, cardHolderId, cardHolderName, cardHolderLastName1, cardHolderLastName2, cardHolderMail, cellphoneNumber, expirationDate, commerceMail, ufFlag));
- return this;
- }
-
- public List getDetails() {
- return Collections.unmodifiableList(detailList);
- }
-
- @NoArgsConstructor @AllArgsConstructor
- @Getter @Setter @ToString
- public class Detail {
- private String serviceId;
- private String cardHolderId;
- private String cardHolderName;
- private String cardHolderLastName1;
- private String cardHolderLastName2;
- private String cardHolderMail;
- private String cellphoneNumber;
- private String expirationDate;
- private String commerceMail;
- private boolean ufFlag;
- }
+
+ private List detailList = new ArrayList<>();
+
+ /**
+ * Configures the environment for mock testing.
+ */
+ private PatpassTransactionCreateDetails() {}
+
+ /**
+ * Configures the environment for mock testing.
+ * @return A new PatpassTransactionCreateDetails.
+ */
+ public static PatpassTransactionCreateDetails build() {
+ return new PatpassTransactionCreateDetails();
+ }
+
+ /**
+ * Builds a new PatpassTransactionCreateDetails with the provided parameters.
+ * @param serviceId The service ID.
+ * @param cardHolderId The card holder ID.
+ * @param cardHolderName The card holder name.
+ * @param cardHolderLastName1 The card holder's first last name.
+ * @param cardHolderLastName2 The card holder's second last name.
+ * @param cardHolderMail The card holder's mail.
+ * @param cellphoneNumber The cellphone number.
+ * @param expirationDate The expiration date.
+ * @param commerceMail The commerce mail.
+ * @param ufFlag The UF flag.
+ * @return A new PatpassTransactionCreateDetails.
+ */
+ public static PatpassTransactionCreateDetails build(
+ String serviceId,
+ String cardHolderId,
+ String cardHolderName,
+ String cardHolderLastName1,
+ String cardHolderLastName2,
+ String cardHolderMail,
+ String cellphoneNumber,
+ String expirationDate,
+ String commerceMail,
+ boolean ufFlag
+ ) {
+ return PatpassTransactionCreateDetails
+ .build()
+ .add(
+ serviceId,
+ cardHolderId,
+ cardHolderName,
+ cardHolderLastName1,
+ cardHolderLastName2,
+ cardHolderMail,
+ cellphoneNumber,
+ expirationDate,
+ commerceMail,
+ ufFlag
+ );
+ }
+
+ /**
+ * Adds a new detail to the PatpassTransactionCreateDetails.
+ * @param serviceId The service ID.
+ * @param cardHolderId The card holder ID.
+ * @param cardHolderName The card holder name.
+ * @param cardHolderLastName1 The card holder's first last name.
+ * @param cardHolderLastName2 The card holder's second last name.
+ * @param cardHolderMail The card holder's mail.
+ * @param cellphoneNumber The cellphone number.
+ * @param expirationDate The expiration date.
+ * @param commerceMail The commerce mail.
+ * @param ufFlag The UF flag.
+ * @return The PatpassTransactionCreateDetails with the new detail added.
+ */
+ public PatpassTransactionCreateDetails add(
+ String serviceId,
+ String cardHolderId,
+ String cardHolderName,
+ String cardHolderLastName1,
+ String cardHolderLastName2,
+ String cardHolderMail,
+ String cellphoneNumber,
+ String expirationDate,
+ String commerceMail,
+ boolean ufFlag
+ ) {
+ detailList.add(
+ new Detail(
+ serviceId,
+ cardHolderId,
+ cardHolderName,
+ cardHolderLastName1,
+ cardHolderLastName2,
+ cardHolderMail,
+ cellphoneNumber,
+ expirationDate,
+ commerceMail,
+ ufFlag
+ )
+ );
+ return this;
+ }
+
+ public List getDetails() {
+ return Collections.unmodifiableList(detailList);
+ }
+
+ /**
+ * This class represents the details of a PatpassTransactionCreate.
+ */
+ @NoArgsConstructor
+ @AllArgsConstructor
+ @Getter
+ @Setter
+ @ToString
+ public class Detail {
+
+ private String serviceId;
+ private String cardHolderId;
+ private String cardHolderName;
+ private String cardHolderLastName1;
+ private String cardHolderLastName2;
+ private String cardHolderMail;
+ private String cellphoneNumber;
+ private String expirationDate;
+ private String commerceMail;
+ private boolean ufFlag;
+ }
}
diff --git a/src/main/java/cl/transbank/util/HttpUtil.java b/src/main/java/cl/transbank/util/HttpUtil.java
index 3e46eb89..e906cffe 100644
--- a/src/main/java/cl/transbank/util/HttpUtil.java
+++ b/src/main/java/cl/transbank/util/HttpUtil.java
@@ -1,40 +1,66 @@
package cl.transbank.util;
import cl.transbank.webpay.exception.WebpayException;
-import lombok.AllArgsConstructor;
-import lombok.Getter;
-import lombok.NonNull;
-
import java.io.IOException;
import java.net.URL;
import java.util.List;
import java.util.Map;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.NonNull;
+/**
+ * This interface provides methods for HTTP requests.
+ */
public interface HttpUtil {
- T request(@NonNull URL url, RequestMethod method, Object request, Map headers,
- Class clazz) throws IOException, WebpayException;
- List requestList(@NonNull URL url, RequestMethod method, Object request, Map headers,
- Class clazz) throws IOException, WebpayException;
- String request(URL url, HttpUtilImpl.RequestMethod method, String query) throws IOException, WebpayException;
- String request(URL url, HttpUtilImpl.RequestMethod method, String query, HttpUtil.ContentType contentType)
- throws IOException, WebpayException;
- String request(@NonNull URL url, RequestMethod method, String query, Map headers)
- throws IOException, WebpayException;
- String request(@NonNull URL url, RequestMethod method, String query, ContentType contentType, Map headers) throws IOException, WebpayException;
+ T request(
+ @NonNull URL url,
+ RequestMethod method,
+ Object request,
+ Map headers,
+ Class clazz
+ ) throws IOException, WebpayException;
+ List requestList(
+ @NonNull URL url,
+ RequestMethod method,
+ Object request,
+ Map headers,
+ Class clazz
+ ) throws IOException, WebpayException;
+ String request(URL url, HttpUtil.RequestMethod method, String query)
+ throws IOException, WebpayException;
+ String request(
+ URL url,
+ HttpUtil.RequestMethod method,
+ String query,
+ HttpUtil.ContentType contentType
+ ) throws IOException, WebpayException;
+ String request(
+ @NonNull URL url,
+ RequestMethod method,
+ String query,
+ Map headers
+ ) throws IOException, WebpayException;
+ String request(
+ @NonNull URL url,
+ RequestMethod method,
+ String query,
+ ContentType contentType,
+ Map headers
+ ) throws IOException, WebpayException;
- @AllArgsConstructor
- enum ContentType {
- JSON("application/json");
+ @AllArgsConstructor
+ enum ContentType {
+ JSON("application/json");
- @Getter
- private String contentType;
- }
+ @Getter
+ private String contentType;
+ }
- enum RequestMethod {
- GET,
- POST,
- DELETE,
- PUT
- }
+ enum RequestMethod {
+ GET,
+ POST,
+ DELETE,
+ PUT,
+ }
}
diff --git a/src/main/java/cl/transbank/util/HttpUtilImpl.java b/src/main/java/cl/transbank/util/HttpUtilImpl.java
index 2bc5feda..0cc56f5a 100644
--- a/src/main/java/cl/transbank/util/HttpUtilImpl.java
+++ b/src/main/java/cl/transbank/util/HttpUtilImpl.java
@@ -1,12 +1,9 @@
package cl.transbank.util;
+import static cl.transbank.util.HttpUtil.RequestMethod.*;
+
import cl.transbank.webpay.exception.TransbankHttpApiException;
import cl.transbank.webpay.exception.WebpayException;
-import lombok.AccessLevel;
-import lombok.Getter;
-import lombok.NonNull;
-import lombok.Setter;
-
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
@@ -17,211 +14,360 @@
import java.util.Scanner;
import java.util.logging.Level;
import java.util.logging.Logger;
+import javax.net.ssl.SSLException;
+import lombok.AccessLevel;
+import lombok.Getter;
+import lombok.NonNull;
+import lombok.Setter;
-import static cl.transbank.util.HttpUtil.RequestMethod.*;
-
+/**
+ * This class provides utility methods for HTTP requests.
+ */
public class HttpUtilImpl implements HttpUtil {
- private static Logger logger = Logger.getLogger(HttpUtilImpl.class.getName());
-
- private static volatile HttpUtilImpl instance;
-
- @Setter @Getter(AccessLevel.PRIVATE) private JsonUtil jsonUtil = JsonUtilImpl.getInstance();
-
- public T request(@NonNull URL url, RequestMethod method, Object request, Map headers,
- Class clazz) throws IOException, WebpayException {
- final String jsonIn = getJsonUtil().jsonEncode(request);
- final String jsonOut = request(url, method, jsonIn, headers, true);
- return getJsonUtil().jsonDecode(jsonOut, clazz);
- }
-
- public List requestList(@NonNull URL url, RequestMethod method, Object request, Map headers,
- Class clazz) throws IOException, WebpayException {
- final String jsonIn = getJsonUtil().jsonEncode(request);
- final String jsonOut = request(url, method, jsonIn, headers, true);
- return getJsonUtil().jsonDecodeToList(jsonOut, clazz);
- }
-
- public String request(@NonNull URL url, RequestMethod method, String query)
- throws IOException, WebpayException {
- return request(url, method, query, (ContentType) null, (Map) null);
- }
-
- public String request(@NonNull URL url, RequestMethod method, String query,
- ContentType contentType) throws IOException, WebpayException {
- return request(url, method, query, contentType, null);
- }
-
- public String request(@NonNull URL url, RequestMethod method, String query, Map headers)
- throws IOException, WebpayException {
- return request(url, method, query, null, headers);
- }
- public String request(@NonNull URL url, RequestMethod method, String query, Map headers, boolean useException)
- throws IOException, WebpayException {
- return request(url, method, query, null, headers);
+ private static Logger logger = Logger.getLogger(HttpUtilImpl.class.getName());
+
+ private static volatile HttpUtilImpl instance;
+ private static final String ERROR_MESSAGE = "error_message";
+
+ @Setter
+ @Getter(AccessLevel.PRIVATE)
+ private JsonUtil jsonUtil = JsonUtilImpl.getInstance();
+
+ /**
+ * Sends a HTTP request and returns the response.
+ * This method uses the provided URL, request method, request body, headers, and response type to send the request.
+ */
+ public T request(
+ @NonNull URL url,
+ RequestMethod method,
+ Object request,
+ Map headers,
+ Class clazz
+ ) throws IOException, WebpayException {
+ final String jsonIn = getJsonUtil().jsonEncode(request);
+ final String jsonOut = request(url, method, jsonIn, headers);
+ return getJsonUtil().jsonDecode(jsonOut, clazz);
+ }
+
+ public List requestList(
+ @NonNull URL url,
+ RequestMethod method,
+ Object request,
+ Map headers,
+ Class clazz
+ ) throws IOException, WebpayException {
+ final String jsonIn = getJsonUtil().jsonEncode(request);
+ final String jsonOut = request(url, method, jsonIn, headers);
+ return getJsonUtil().jsonDecodeToList(jsonOut, clazz);
+ }
+
+ /**
+ * Sends a HTTP request and returns the response.
+ * This method uses the provided URL, request method, request body, and response type to send the request.
+ * It uses default headers.
+ */
+ public String request(@NonNull URL url, RequestMethod method, String query)
+ throws IOException, WebpayException {
+ return request(
+ url,
+ method,
+ query,
+ (ContentType) null,
+ (Map) null
+ );
+ }
+
+ /**
+ * Sends a HTTP request and returns the response.
+ * This method uses the provided URL, request method, and response type to send the request.
+ * It uses default headers and does not send a request body.
+ */
+ public String request(
+ @NonNull URL url,
+ RequestMethod method,
+ String query,
+ ContentType contentType
+ ) throws IOException, WebpayException {
+ return request(url, method, query, contentType, null);
+ }
+
+ /**
+ * Sends a HTTP request and returns the response.
+ * This method uses the provided URL, request method, and response type to send the request.
+ * It uses default headers and a default request body.
+ */
+ public String request(
+ @NonNull URL url,
+ RequestMethod method,
+ String query,
+ Map headers
+ ) throws IOException, WebpayException {
+ return request(url, method, query, null, headers);
+ }
+
+ /**
+ * Sends a HTTP request and returns the response.
+ * This method uses the provided URL to send the request.
+ * It uses a default request method, default headers, a default response type, and does not send a request body.
+ */
+ public String request(
+ @NonNull URL url,
+ RequestMethod method,
+ String query,
+ ContentType contentType,
+ Map headers
+ ) throws IOException, WebpayException {
+ if (null == method) method = GET;
+ if (null == contentType) contentType = ContentType.JSON;
+
+ logRequestDetails(url, method, headers, query);
+
+ HttpURLConnection conn = null;
+ int responseCode = 0;
+ String responseBody = "";
+ try {
+ conn = createConnection(url, method, query, contentType, headers);
+ responseCode = conn.getResponseCode();
+
+ logger.log(Level.FINE, "HTTP Response Code : {0}", responseCode);
+
+ final boolean isHttpErrorCode =
+ !(responseCode >= 200 && responseCode < 300);
+ InputStream input = !isHttpErrorCode
+ ? conn.getInputStream()
+ : conn.getErrorStream();
+
+ responseBody = getResponseBody(input);
+ handleResponse(responseCode, responseBody, isHttpErrorCode);
+ } catch (SSLException e) {
+ throw new IOException("SSL error", e);
}
- public String request(@NonNull URL url, RequestMethod method, String query,
- ContentType contentType, Map headers) throws IOException, WebpayException {
- if (null == method)
- method = GET;
-
- if (null == contentType)
- contentType = ContentType.JSON;
-
- HttpURLConnection conn = null;
-
- try {
- logger.log(Level.FINE, String.format("HTTP URL : %s", url));
- logger.log(Level.FINE, String.format("HTTP Method : %s", method));
-
- if (null != headers) {
- for (String key : headers.keySet()) {
- if (!StringUtils.isEmpty(key)) {
- String value = headers.get(key);
-
- if (key.equalsIgnoreCase("Tbk-Api-Key-Secret")) {
- value = "NOT DISPLAYED BY SECURITY REASON";
- }
-
- logger.log(Level.FINE, String.format("HTTP Header [%s] : %s", key, value));
- }
- }
- }
-
- logger.log(Level.FINE, String.format("HTTP Request Query : %s", query));
- switch (method) {
- case POST:
- conn = createPOSTConnection(url, query, contentType, headers);
- break;
- case DELETE:
- conn = createDeleteConnection(url, query, contentType, headers);
- break;
- case PUT:
- conn = createPUTConnection(url, query, contentType, headers);
- break;
- case GET:
- default:
- conn = createGETConnection(url, query, headers);
- }
-
- int responseCode = conn.getResponseCode();
-
- logger.log(Level.FINE, String.format("HTTP Response Code : %s", responseCode));
- final boolean isHttpErrorCode = !(responseCode >= 200 && responseCode < 300);
- InputStream input = !isHttpErrorCode ?
- conn.getInputStream() :
- conn.getErrorStream();
-
- final String responseBody = getResponseBody(input);
- if (isHttpErrorCode) {
- Object errorMessage = "Could not obtain a response message from Webpay API";
- if (responseBody != null) {
- final Map errorMap = getJsonUtil().jsonDecode(responseBody, HashMap.class);
- errorMessage = errorMap.get("error_message");
- }
-
- if (null == errorMessage)
- errorMessage = "Unspecified message by Webpay API";
- throw new TransbankHttpApiException(responseCode, errorMessage.toString());
- }
-
- if (responseBody != null && !responseBody.trim().startsWith("[")) {
- final Map tempMap = getJsonUtil().jsonDecode(responseBody, HashMap.class);
- if (tempMap.containsKey("error_message") && tempMap.get("error_message")!=null){
- throw new WebpayException(tempMap.get("error_message").toString());
- }
- }
-
- return responseBody;
- } finally {
- if (null != conn)
- conn.disconnect();
+ return responseBody;
+ }
+
+ private void logRequestDetails(
+ URL url,
+ RequestMethod method,
+ Map headers,
+ String query
+ ) {
+ logger.log(Level.FINE, "HTTP URL : {0}", url);
+ logger.log(Level.FINE, "HTTP Method : {0}", method);
+
+ if (null != headers) {
+ for (String key : headers.keySet()) {
+ if (!StringUtils.isEmpty(key)) {
+ String value = headers.get(key);
+
+ if (key.equalsIgnoreCase("Tbk-Api-Key-Secret")) {
+ value = "NOT DISPLAYED BY SECURITY REASON";
+ }
+
+ logger.log(
+ Level.FINE,
+ "HTTP Header [{0}] : {1}",
+ new Object[] { key, value }
+ );
}
+ }
}
- private HttpURLConnection createPOSTConnection(URL url, String query, ContentType contentType, Map headers)
- throws IOException {
- return createSendingDataConnection(POST, url, query, contentType, headers);
+ logger.log(Level.FINE, "HTTP Request Query : {0}", query);
+ }
+
+ private HttpURLConnection createConnection(
+ URL url,
+ RequestMethod method,
+ String query,
+ ContentType contentType,
+ Map headers
+ ) throws IOException {
+ HttpURLConnection conn;
+ switch (method) {
+ case POST:
+ conn = createPOSTConnection(url, query, contentType, headers);
+ break;
+ case DELETE:
+ conn = createDeleteConnection(url, query, contentType, headers);
+ break;
+ case PUT:
+ conn = createPUTConnection(url, query, contentType, headers);
+ break;
+ case GET:
+ conn = createGETConnection(url, query, headers);
+ break;
+ default:
+ conn = createGETConnection(url, query, headers);
+ break;
}
-
- private HttpURLConnection createGETConnection(URL url, String query, Map headers) throws IOException {
- String getUrl = formatUrl(url.toString(), query);
- HttpURLConnection conn = (HttpURLConnection) new URL(getUrl).openConnection();
- conn.setRequestMethod(GET.toString());
-
- if (null != headers) {
- for (Map.Entry header : headers.entrySet()) {
- conn.setRequestProperty(header.getKey(), header.getValue());
- }
- }
-
- return conn;
+ return conn;
+ }
+
+ private void handleResponse(
+ int responseCode,
+ String responseBody,
+ boolean isHttpErrorCode
+ ) throws WebpayException {
+ if (isHttpErrorCode) {
+ Object errorMessage =
+ "Could not obtain a response message from Webpay API";
+ if (responseBody != null) {
+ @SuppressWarnings("unchecked")
+ final Map errorMap = (Map) getJsonUtil()
+ .jsonDecode(responseBody, HashMap.class);
+
+ errorMessage = errorMap.get(ERROR_MESSAGE);
+ }
+
+ if (null == errorMessage) errorMessage =
+ "Unspecified message by Webpay API";
+ throw new TransbankHttpApiException(
+ responseCode,
+ errorMessage.toString()
+ );
}
- private HttpURLConnection createDeleteConnection(URL url, String query, ContentType contentType, Map headers) throws IOException {
- return createSendingDataConnection(DELETE, url, query, contentType, headers);
+ if (responseBody != null && !responseBody.trim().startsWith("[")) {
+ final Map tempMap = getJsonUtil().jsonDecode(responseBody, HashMap.class);
+ if (
+ tempMap.containsKey(ERROR_MESSAGE) && tempMap.get(ERROR_MESSAGE) != null
+ ) {
+ throw new WebpayException(tempMap.get(ERROR_MESSAGE).toString());
+ }
}
-
- private HttpURLConnection createPUTConnection(
- URL url, String query, ContentType contentType, Map headers) throws IOException {
- return createSendingDataConnection(PUT, url, query, contentType, headers);
+ }
+
+ private HttpURLConnection createPOSTConnection(
+ URL url,
+ String query,
+ ContentType contentType,
+ Map headers
+ ) throws IOException {
+ return createSendingDataConnection(POST, url, query, contentType, headers);
+ }
+
+ private HttpURLConnection createGETConnection(
+ URL url,
+ String query,
+ Map headers
+ ) throws IOException {
+ String getUrl = formatUrl(url.toString(), query);
+ HttpURLConnection conn = (HttpURLConnection) new URL(getUrl)
+ .openConnection();
+ conn.setRequestMethod(GET.toString());
+
+ if (null != headers) {
+ for (Map.Entry header : headers.entrySet()) {
+ conn.setRequestProperty(header.getKey(), header.getValue());
+ }
}
- private HttpURLConnection createSendingDataConnection(
- RequestMethod method, URL url, String query, ContentType contentType, Map headers) throws IOException {
- HttpURLConnection conn = (HttpURLConnection) url.openConnection();
- conn.setUseCaches(false);
- conn.setDoOutput(true);
- conn.setRequestMethod(method.toString());
- conn.setRequestProperty("Accept-Charset", StandardCharsets.UTF_8.name());
- conn.setRequestProperty("Accept", "application/json");
- conn.setRequestProperty("Content-Type", String.format(
- "%s;charset=%s", contentType.getContentType(), StandardCharsets.UTF_8.name().toLowerCase()));
-
- if (null != headers) {
- for (Map.Entry header : headers.entrySet()) {
- conn.setRequestProperty(header.getKey(), header.getValue());
- }
+ return conn;
+ }
+
+ private HttpURLConnection createDeleteConnection(
+ URL url,
+ String query,
+ ContentType contentType,
+ Map headers
+ ) throws IOException {
+ return createSendingDataConnection(
+ DELETE,
+ url,
+ query,
+ contentType,
+ headers
+ );
+ }
+
+ private HttpURLConnection createPUTConnection(
+ URL url,
+ String query,
+ ContentType contentType,
+ Map headers
+ ) throws IOException {
+ return createSendingDataConnection(PUT, url, query, contentType, headers);
+ }
+
+ private HttpURLConnection createSendingDataConnection(
+ RequestMethod method,
+ URL url,
+ String query,
+ ContentType contentType,
+ Map headers
+ ) throws IOException {
+ OutputStream out = null;
+ HttpURLConnection conn = null;
+ try {
+ conn = (HttpURLConnection) url.openConnection();
+ conn.setUseCaches(false);
+ conn.setDoOutput(true);
+ conn.setRequestMethod(method.toString());
+ conn.setRequestProperty("Accept-Charset", StandardCharsets.UTF_8.name());
+ conn.setRequestProperty("Accept", "application/json");
+ conn.setRequestProperty(
+ "Content-Type",
+ String.format(
+ "%s;charset=%s",
+ contentType.getContentType(),
+ StandardCharsets.UTF_8.name().toLowerCase()
+ )
+ );
+
+ if (null != headers) {
+ for (Map.Entry header : headers.entrySet()) {
+ conn.setRequestProperty(header.getKey(), header.getValue());
}
+ }
- try (OutputStream out = conn.getOutputStream()) {
- out.write(query.getBytes(StandardCharsets.UTF_8));
- }
-
- return conn;
- }
-
- private String formatUrl(String url, String query) {
- if (null == query || query.trim().isEmpty())
- return url;
-
- String separator = url.contains("?") ? "&" : "?";
- return String.format("%s%s%s", url, separator, query);
+ out = conn.getOutputStream();
+ out.write(query.getBytes(StandardCharsets.UTF_8));
+ } catch (SSLException e) {
+ throw new IOException("SSL error", e);
}
- private static String getResponseBody(InputStream responseStream) {
- try (final Scanner scanner = new Scanner(responseStream, StandardCharsets.UTF_8.name())) {
- final String responseBody = scanner.useDelimiter("\\A").next();
- responseStream.close();
-
- logger.log(Level.FINE, String.format("HTTP Response Body : %s", responseBody));
- return responseBody;
- } catch (Exception e) {
- return null;
- }
+ return conn;
+ }
+
+ private String formatUrl(String url, String query) {
+ if (null == query || query.trim().isEmpty()) return url;
+
+ String separator = url.contains("?") ? "&" : "?";
+ return String.format("%s%s%s", url, separator, query);
+ }
+
+ private static String getResponseBody(InputStream responseStream) {
+ try (
+ final Scanner scanner = new Scanner(
+ responseStream,
+ StandardCharsets.UTF_8.name()
+ )
+ ) {
+ final String responseBody = scanner.useDelimiter("\\A").next();
+ responseStream.close();
+
+ return responseBody;
+ } catch (Exception e) {
+ return null;
}
-
- private HttpUtilImpl() {
- super();
+ }
+
+ private HttpUtilImpl() {
+ super();
+ }
+
+ /**
+ * Returns the singleton instance of HttpUtilImpl.
+ * If the instance does not exist, it is created.
+ * @return The singleton instance of HttpUtilImpl.
+ */
+ public static HttpUtilImpl getInstance() {
+ if (null == instance) synchronized (HttpUtilImpl.class) {
+ instance = new HttpUtilImpl();
}
- public static HttpUtilImpl getInstance() {
- if (null == instance)
- synchronized (HttpUtilImpl.class) {
- instance = new HttpUtilImpl();
- }
-
- return instance;
- }
+ return instance;
+ }
}
diff --git a/src/main/java/cl/transbank/util/JsonUtil.java b/src/main/java/cl/transbank/util/JsonUtil.java
index 854c94a8..0dd64b9f 100644
--- a/src/main/java/cl/transbank/util/JsonUtil.java
+++ b/src/main/java/cl/transbank/util/JsonUtil.java
@@ -2,8 +2,32 @@
import java.util.List;
+/**
+ * This interface provides methods for JSON encoding and decoding.
+ */
public interface JsonUtil {
- String jsonEncode(Object o);
- T jsonDecode(String json, Class clazz);
- List jsonDecodeToList(String json, Class clazz);
+ /**
+ * Encodes an object into a JSON string.
+ * @param o The object to encode.
+ * @return The JSON string.
+ */
+ String jsonEncode(Object o);
+
+ /**
+ * Decodes a JSON string into an object of the specified class.
+ * @param json The JSON string.
+ * @param clazz The class of the object.
+ * @param The type of the object.
+ * @return The decoded object.
+ */
+ T jsonDecode(String json, Class clazz);
+
+ /**
+ * Decodes a JSON string into a list of objects of the specified class.
+ * @param json The JSON string.
+ * @param clazz The class of the objects.
+ * @param The type of the objects.
+ * @return The list of decoded objects.
+ */
+ List jsonDecodeToList(String json, Class clazz);
}
diff --git a/src/main/java/cl/transbank/util/JsonUtilImpl.java b/src/main/java/cl/transbank/util/JsonUtilImpl.java
index cbb53c39..b1347da2 100644
--- a/src/main/java/cl/transbank/util/JsonUtilImpl.java
+++ b/src/main/java/cl/transbank/util/JsonUtilImpl.java
@@ -3,40 +3,69 @@
import com.google.gson.FieldNamingPolicy;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
-
import java.util.Arrays;
import java.util.List;
+/**
+ * This class provides utility methods for JSON encoding and decoding.
+ */
public final class JsonUtilImpl implements JsonUtil {
- private static volatile JsonUtilImpl instance;
- private Gson gson;
-
- private JsonUtilImpl() {
- super();
- gson = new GsonBuilder()
- .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
- .create();
- }
- public String jsonEncode(Object o) {
- return gson.toJson(o);
- }
+ private static volatile JsonUtilImpl instance;
+ private Gson gson;
- public T jsonDecode(String json, Class clazz) {
- return gson.fromJson(json, clazz);
- }
+ /**
+ * Private constructor. Initializes the Gson object with specific settings.
+ */
+ private JsonUtilImpl() {
+ super();
+ gson =
+ new GsonBuilder()
+ .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
+ .create();
+ }
- public List jsonDecodeToList(String json, Class clazz) {
- return Arrays.asList(gson.fromJson(json, clazz));
- }
+ /**
+ * Encodes an object into a JSON string.
+ * @param o The object to encode.
+ * @return The JSON string representation of the object.
+ */
+ public String jsonEncode(Object o) {
+ return gson.toJson(o);
+ }
+
+ /**
+ * Decodes a JSON string into an object of the specified class.
+ * @param json The JSON string to decode.
+ * @param clazz The class of the object.
+ * @return The object decoded from the JSON string.
+ */
+ public T jsonDecode(String json, Class clazz) {
+ return gson.fromJson(json, clazz);
+ }
- public static JsonUtilImpl getInstance() {
- if (null == instance) {
- synchronized (JsonUtilImpl.class) {
- instance = new JsonUtilImpl();
- }
- }
+ /**
+ * Decodes a JSON string into a list of objects of the specified class.
+ * @param json The JSON string to decode.
+ * @param clazz The class of the objects.
+ * @return The list of objects decoded from the JSON string.
+ */
+ public List jsonDecodeToList(String json, Class clazz) {
+ return Arrays.asList(gson.fromJson(json, clazz));
+ }
- return instance;
+ /**
+ * This method provides a global access point to the instance of the JsonUtilImpl class.
+ * It follows the singleton pattern.
+ * @return The single instance of JsonUtilImpl.
+ */
+ public static JsonUtilImpl getInstance() {
+ if (null == instance) {
+ synchronized (JsonUtilImpl.class) {
+ instance = new JsonUtilImpl();
+ }
}
+
+ return instance;
+ }
}
diff --git a/src/main/java/cl/transbank/util/StringUtils.java b/src/main/java/cl/transbank/util/StringUtils.java
index f058eb24..d3ba4b91 100644
--- a/src/main/java/cl/transbank/util/StringUtils.java
+++ b/src/main/java/cl/transbank/util/StringUtils.java
@@ -1,10 +1,16 @@
package cl.transbank.util;
+/**
+ * This class provides utility methods for string operations.
+ */
public class StringUtils {
- public static boolean isEmpty(String str) {
- return str == null || str.trim().length() == 0;
- }
-
-
+ /**
+ * Checks if a string is null or empty after trimming.
+ * @param str The string to check.
+ * @return True if the string is null or empty after trimming, false otherwise.
+ */
+ public static boolean isEmpty(String str) {
+ return str == null || str.trim().length() == 0;
+ }
}
diff --git a/src/main/java/cl/transbank/util/ValidationUtil.java b/src/main/java/cl/transbank/util/ValidationUtil.java
index 2247b888..b4b25636 100644
--- a/src/main/java/cl/transbank/util/ValidationUtil.java
+++ b/src/main/java/cl/transbank/util/ValidationUtil.java
@@ -2,27 +2,73 @@
import java.util.List;
+/**
+ * This class provides utility methods for validation.
+ */
public class ValidationUtil {
- public static void hasText(String value, String valueName){
- if (StringUtils.isEmpty(value))
- throw new IllegalArgumentException("'" + valueName + "'" + " can't be null or white space");
- }
+ /**
+ * Checks if the specified string has text.
+ * @param value The string to check.
+ * @param valueName The name of the string.
+ * @throws IllegalArgumentException If the string is null or white space.
+ */
+ public static void hasText(String value, String valueName) {
+ if (StringUtils.isEmpty(value)) throw new IllegalArgumentException(
+ "'" + valueName + "'" + " can't be null or white space"
+ );
+ }
- public static void hasTextWithMaxLength(String value, int length, String valueName){
- ValidationUtil.hasText(value, valueName);
- if (value.length() > length)
- throw new IllegalArgumentException ("'" + valueName + "'" + " is too long, the maximum length is " + length);
- }
- public static void hasTextTrimWithMaxLength(String value, int length, String valueName){
- ValidationUtil.hasText(value, valueName);
- if (value.length() > value.trim().length())
- throw new IllegalArgumentException ("'" + valueName + "'" + " has spaces at the begining or the end");
- if (value.length() > length)
- throw new IllegalArgumentException ("'" + valueName + "'" + " is too long, the maximum length is " + length);
- }
- public static void hasElements(List value, String valueName){
- if (value == null || value.size() == 0)
- throw new IllegalArgumentException ("list '" + valueName + "'" + " can't be null or empty");
- }
+ /**
+ * Checks if the specified string has text and does not exceed the specified length.
+ * @param value The string to check.
+ * @param length The maximum length.
+ * @param valueName The name of the string.
+ * @throws IllegalArgumentException If the string is null, white space, or too long.
+ */
+ public static void hasTextWithMaxLength(
+ String value,
+ int length,
+ String valueName
+ ) {
+ ValidationUtil.hasText(value, valueName);
+ if (value.length() > length) throw new IllegalArgumentException(
+ "'" + valueName + "'" + " is too long, the maximum length is " + length
+ );
+ }
+
+ /**
+ * Checks if the specified string has text, does not exceed the specified length, and does not have leading or trailing spaces.
+ * @param value The string to check.
+ * @param length The maximum length.
+ * @param valueName The name of the string.
+ * @throws IllegalArgumentException If the string is null, white space, too long, or has leading or trailing spaces.
+ */
+ public static void hasTextTrimWithMaxLength(
+ String value,
+ int length,
+ String valueName
+ ) {
+ ValidationUtil.hasText(value, valueName);
+ if (
+ value.length() > value.trim().length()
+ ) throw new IllegalArgumentException(
+ "'" + valueName + "'" + " has spaces at the begining or the end"
+ );
+ if (value.length() > length) throw new IllegalArgumentException(
+ "'" + valueName + "'" + " is too long, the maximum length is " + length
+ );
+ }
+
+ /**
+ * Checks if the specified list has elements.
+ * @param value The list to check.
+ * @param valueName The name of the list.
+ * @throws IllegalArgumentException If the list is null or empty.
+ */
+ public static void hasElements(List value, String valueName) {
+ if (value == null || value.isEmpty()) throw new IllegalArgumentException(
+ "list '" + valueName + "'" + " can't be null or empty"
+ );
+ }
}
diff --git a/src/main/java/cl/transbank/util/WebpayApiResource.java b/src/main/java/cl/transbank/util/WebpayApiResource.java
index 75bad83c..4a7f562c 100644
--- a/src/main/java/cl/transbank/util/WebpayApiResource.java
+++ b/src/main/java/cl/transbank/util/WebpayApiResource.java
@@ -1,91 +1,204 @@
package cl.transbank.util;
+import cl.transbank.common.ApiConstants;
import cl.transbank.common.IntegrationTypeHelper;
-import cl.transbank.model.Options;
import cl.transbank.exception.TransbankException;
+import cl.transbank.model.Options;
import cl.transbank.model.WebpayApiRequest;
import cl.transbank.webpay.common.WebpayOptions;
-import lombok.Getter;
-import lombok.Setter;
-
import java.io.IOException;
import java.net.URL;
-import java.util.Arrays;
+import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import lombok.Getter;
+import lombok.Setter;
+/**
+ * This abstract class represents a resource for the Webpay API.
+ */
public abstract class WebpayApiResource {
- @Getter @Setter private static HttpUtil httpUtil = HttpUtilImpl.getInstance();
-
- public static Map buildHeaders(Options options) {
- if (null == options)
- return null;
-
- Map headers = new HashMap<>();
- headers.put(options.getHeaderCommerceCodeName(), options.getCommerceCode());
- headers.put(options.getHeaderApiKeyName(), options.getApiKey());
- return headers;
+ @Getter
+ @Setter
+ private static HttpUtil httpUtil = HttpUtilImpl.getInstance();
+
+ /**
+ * Builds the headers for a Webpay API request.
+ * @param options The options for the request.
+ * @return A map of headers for the request.
+ */
+ public static Map buildHeaders(Options options) {
+ if (null == options) return Collections.emptyMap();
+
+ Map headers = new HashMap<>();
+ headers.put(
+ ApiConstants.HEADER_COMMERCE_CODE_NAME,
+ options.getCommerceCode()
+ );
+ headers.put(ApiConstants.HEADER_API_KEY_NAME, options.getApiKey());
+
+ return headers;
+ }
+
+ /**
+ * Executes a Webpay API request.
+ * @param The type of the response.
+ * @param endpoint The endpoint for the request.
+ * @param method The HTTP method for the request.
+ * @param options The options for the request.
+ * @param clazz The class of the response.
+ * @return The response to the request.
+ * @throws TransbankException If an error occurs during the request.
+ * @throws IOException If an error occurs during the request.
+ */
+ public static T execute(
+ final String endpoint,
+ HttpUtil.RequestMethod method,
+ final Options options,
+ Class clazz
+ ) throws TransbankException, IOException {
+ return execute(endpoint, method, null, options, clazz);
+ }
+
+ /**
+ * Executes a Webpay API request with a request body.
+ * @param The type of the response.
+ * @param endpoint The endpoint for the request.
+ * @param method The HTTP method for the request.
+ * @param request The request body.
+ * @param options The options for the request.
+ * @return The response to the request.
+ * @throws TransbankException If an error occurs during the request.
+ * @throws IOException If an error occurs during the request.
+ */
+ public static T execute(
+ final String endpoint,
+ HttpUtil.RequestMethod method,
+ final WebpayApiRequest request,
+ final Options options
+ ) throws TransbankException, IOException {
+ return execute(endpoint, method, request, options, null);
+ }
+
+ /**
+ * Executes a Webpay API request with a request body.
+ * @param The type of the response.
+ * @param endpoint The endpoint for the request.
+ * @param method The HTTP method for the request.
+ * @param request The request body.
+ * @param options The options for the request.
+ * @param clazz The class of the response.
+ * @return The response to the request.
+ * @throws TransbankException If an error occurs during the request.
+ * @throws IOException If an error occurs during the request.
+ */
+ public static T execute(
+ final String endpoint,
+ HttpUtil.RequestMethod method,
+ final WebpayApiRequest request,
+ final Options options,
+ Class clazz
+ ) throws TransbankException, IOException {
+ String urlBase = null;
+ if (options instanceof WebpayOptions) {
+ urlBase =
+ IntegrationTypeHelper.getWebpayIntegrationType(
+ options.getIntegrationType()
+ );
+ } else {
+ urlBase =
+ IntegrationTypeHelper.getPatpassIntegrationType(
+ options.getIntegrationType()
+ );
}
-
- public static T execute(final String endpoint, HttpUtil.RequestMethod method, final Options options, Class clazz)
- throws TransbankException, IOException {
- return execute(endpoint, method, null, options, clazz);
- }
-
- public static T execute(final String endpoint, HttpUtil.RequestMethod method, final WebpayApiRequest request, final Options options)
- throws TransbankException, IOException {
- return execute(endpoint, method, request, options, null);
+ final URL url = new URL(String.format("%s/%s", urlBase, endpoint));
+
+ final T out = WebpayApiResource
+ .getHttpUtil()
+ .request(
+ url,
+ method,
+ request,
+ WebpayApiResource.buildHeaders(options),
+ clazz
+ );
+
+ if (null == out) return null;
+
+ if (null == clazz) return null;
+
+ return out;
+ }
+
+ /**
+ * Executes a Webpay API request and returns a list of responses.
+ * @param The type of the response.
+ * @param endpoint The endpoint for the request.
+ * @param method The HTTP method for the request.
+ * @param options The options for the request.
+ * @param clazz The class of the response.
+ * @return A list of responses to the request.
+ * @throws TransbankException If an error occurs during the request.
+ * @throws IOException If an error occurs during the request.
+ */
+ public static List executeToList(
+ final String endpoint,
+ HttpUtil.RequestMethod method,
+ final Options options,
+ Class clazz
+ ) throws TransbankException, IOException {
+ return executeToList(endpoint, method, null, options, clazz);
+ }
+
+ /**
+ * Executes a Webpay API request with a request body and returns a list of responses.
+ * @param The type of the response.
+ * @param endpoint The endpoint for the request.
+ * @param method The HTTP method for the request.
+ * @param request The request body.
+ * @param options The options for the request.
+ * @param clazz The class of the response.
+ * @return A list of responses to the request.
+ * @throws TransbankException If an error occurs during the request.
+ * @throws IOException If an error occurs during the request.
+ */
+ public static List executeToList(
+ final String endpoint,
+ HttpUtil.RequestMethod method,
+ final WebpayApiRequest request,
+ final Options options,
+ Class clazz
+ ) throws TransbankException, IOException {
+ String urlBase = null;
+ if (options instanceof WebpayOptions) {
+ urlBase =
+ IntegrationTypeHelper.getWebpayIntegrationType(
+ options.getIntegrationType()
+ );
+ } else {
+ urlBase =
+ IntegrationTypeHelper.getPatpassIntegrationType(
+ options.getIntegrationType()
+ );
}
+ final URL url = new URL(String.format("%s/%s", urlBase, endpoint));
- public static T execute(final String endpoint, HttpUtil.RequestMethod method, final WebpayApiRequest request, final Options options, Class clazz)
- throws TransbankException, IOException {
+ final List out = WebpayApiResource
+ .getHttpUtil()
+ .requestList(
+ url,
+ method,
+ request,
+ WebpayApiResource.buildHeaders(options),
+ clazz
+ );
- String urlBase = null;
- if(options instanceof WebpayOptions){
- urlBase = IntegrationTypeHelper.getWebpayIntegrationType(options.getIntegrationType());
- }
- else{
- urlBase = IntegrationTypeHelper.getPatpassIntegrationType(options.getIntegrationType());
- }
- final URL url = new URL(String.format("%s/%s", urlBase, endpoint));
+ if (null == out) return Collections.emptyList();
- final T out = WebpayApiResource.getHttpUtil().request(url, method, request, WebpayApiResource.buildHeaders(options), clazz);
-
- if (null == out)
- return null;
-
- if (null == clazz)
- return null;
-
- return out;
- }
- public static List executeToList(final String endpoint, HttpUtil.RequestMethod method, final Options options, Class clazz)
- throws TransbankException, IOException {
- return executeToList(endpoint, method, null, options, clazz);
- }
- public static List executeToList(final String endpoint, HttpUtil.RequestMethod method, final WebpayApiRequest request, final Options options, Class clazz)
- throws TransbankException, IOException {
-
- String urlBase = null;
- if(options instanceof WebpayOptions){
- urlBase = IntegrationTypeHelper.getWebpayIntegrationType(options.getIntegrationType());
- }
- else{
- urlBase = IntegrationTypeHelper.getPatpassIntegrationType(options.getIntegrationType());
- }
- final URL url = new URL(String.format("%s/%s", urlBase, endpoint));
-
- final List out = WebpayApiResource.getHttpUtil().requestList(url, method, request, WebpayApiResource.buildHeaders(options), clazz);
-
- if (null == out)
- return null;
-
- if (null == clazz)
- return null;
-
- return out;
- }
+ if (null == clazz) return Collections.emptyList();
+ return out;
+ }
}
diff --git a/src/main/java/cl/transbank/webpay/common/MallTransactionCaptureRequest.java b/src/main/java/cl/transbank/webpay/common/MallTransactionCaptureRequest.java
index 35db2433..25300b4c 100644
--- a/src/main/java/cl/transbank/webpay/common/MallTransactionCaptureRequest.java
+++ b/src/main/java/cl/transbank/webpay/common/MallTransactionCaptureRequest.java
@@ -3,12 +3,18 @@
import cl.transbank.model.WebpayApiRequest;
import lombok.*;
-@NoArgsConstructor @AllArgsConstructor
-@Getter @Setter
+/**
+ * This class represents a request to capture a mall transaction.
+ */
+@NoArgsConstructor
+@AllArgsConstructor
+@Getter
+@Setter
@ToString
public class MallTransactionCaptureRequest extends WebpayApiRequest {
- private String commerceCode;
- private String buyOrder;
- private String authorizationCode;
- private double captureAmount;
+
+ private String commerceCode;
+ private String buyOrder;
+ private String authorizationCode;
+ private double captureAmount;
}
diff --git a/src/main/java/cl/transbank/webpay/common/MallTransactionRefundRequest.java b/src/main/java/cl/transbank/webpay/common/MallTransactionRefundRequest.java
index ee22ba5c..112ef564 100644
--- a/src/main/java/cl/transbank/webpay/common/MallTransactionRefundRequest.java
+++ b/src/main/java/cl/transbank/webpay/common/MallTransactionRefundRequest.java
@@ -3,13 +3,17 @@
import cl.transbank.model.WebpayApiRequest;
import lombok.*;
+/**
+ * This class represents a request to refund a Mall transaction.
+ */
@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
@ToString
public class MallTransactionRefundRequest extends WebpayApiRequest {
- private String buyOrder;
- private String commerceCode;
- private double amount;
+
+ private String buyOrder;
+ private String commerceCode;
+ private double amount;
}
diff --git a/src/main/java/cl/transbank/webpay/common/TransactionCaptureRequest.java b/src/main/java/cl/transbank/webpay/common/TransactionCaptureRequest.java
index 9ddf3bb7..c40ac65b 100644
--- a/src/main/java/cl/transbank/webpay/common/TransactionCaptureRequest.java
+++ b/src/main/java/cl/transbank/webpay/common/TransactionCaptureRequest.java
@@ -3,11 +3,17 @@
import cl.transbank.model.WebpayApiRequest;
import lombok.*;
-@NoArgsConstructor @AllArgsConstructor
-@Getter @Setter
+/**
+ * This class represents a request to capture a transaction.
+ */
+@NoArgsConstructor
+@AllArgsConstructor
+@Getter
+@Setter
@ToString
public class TransactionCaptureRequest extends WebpayApiRequest {
- private String buyOrder;
- private String authorizationCode;
- private double captureAmount;
+
+ private String buyOrder;
+ private String authorizationCode;
+ private double captureAmount;
}
diff --git a/src/main/java/cl/transbank/webpay/common/TransactionRefundRequest.java b/src/main/java/cl/transbank/webpay/common/TransactionRefundRequest.java
index 4895735d..3e8a66a5 100644
--- a/src/main/java/cl/transbank/webpay/common/TransactionRefundRequest.java
+++ b/src/main/java/cl/transbank/webpay/common/TransactionRefundRequest.java
@@ -3,9 +3,15 @@
import cl.transbank.model.WebpayApiRequest;
import lombok.*;
-@NoArgsConstructor @AllArgsConstructor
-@Getter @Setter
+/**
+ * This class represents a request to refund a transaction.
+ */
+@NoArgsConstructor
+@AllArgsConstructor
+@Getter
+@Setter
@ToString
public class TransactionRefundRequest extends WebpayApiRequest {
- private double amount;
+
+ private double amount;
}
diff --git a/src/main/java/cl/transbank/webpay/common/WebpayOptions.java b/src/main/java/cl/transbank/webpay/common/WebpayOptions.java
index f830fa0c..e2ddfdff 100644
--- a/src/main/java/cl/transbank/webpay/common/WebpayOptions.java
+++ b/src/main/java/cl/transbank/webpay/common/WebpayOptions.java
@@ -4,13 +4,24 @@
import cl.transbank.model.Options;
import lombok.*;
-@ToString @AllArgsConstructor
+/**
+ * This class represents the options for a Webpay transaction.
+ */
+@ToString
+@AllArgsConstructor
public class WebpayOptions extends Options {
- @Getter final String headerCommerceCodeName = "Tbk-Api-Key-Id";
- @Getter final String headerApiKeyName = "Tbk-Api-Key-Secret";
- public WebpayOptions(String commerceCode, String apiKey,IntegrationType integrationType ){
- super(commerceCode,apiKey,integrationType);
-
- }
+ /**
+ * Constructs a new WebpayOptions with the specified commerce code, API key, and integration type.
+ * @param commerceCode The commerce code.
+ * @param apiKey The API key.
+ * @param integrationType The integration type.
+ */
+ public WebpayOptions(
+ String commerceCode,
+ String apiKey,
+ IntegrationType integrationType
+ ) {
+ super(commerceCode, apiKey, integrationType);
+ }
}
diff --git a/src/main/java/cl/transbank/webpay/exception/InscriptionDeleteException.java b/src/main/java/cl/transbank/webpay/exception/InscriptionDeleteException.java
index 46b484b0..12f1ed1d 100644
--- a/src/main/java/cl/transbank/webpay/exception/InscriptionDeleteException.java
+++ b/src/main/java/cl/transbank/webpay/exception/InscriptionDeleteException.java
@@ -1,14 +1,28 @@
package cl.transbank.webpay.exception;
+/**
+ * This class represents an exception that is thrown when an inscription deletion operation fails.
+ */
public class InscriptionDeleteException extends WebpayException {
- public InscriptionDeleteException() {
- }
- public InscriptionDeleteException(Exception e) {
- super(e);
- }
+ /**
+ * Constructs a new InscriptionDeleteException with no detail message.
+ */
+ public InscriptionDeleteException() {}
- public InscriptionDeleteException(String message) {
- super(message);
- }
+ /**
+ * Constructs a new InscriptionDeleteException with the specified cause.
+ * @param e The cause of the exception.
+ */
+ public InscriptionDeleteException(Exception e) {
+ super(e);
+ }
+
+ /**
+ * Constructs a new InscriptionDeleteException with the specified detail message.
+ * @param message The detail message.
+ */
+ public InscriptionDeleteException(String message) {
+ super(message);
+ }
}
diff --git a/src/main/java/cl/transbank/webpay/exception/InscriptionFinishException.java b/src/main/java/cl/transbank/webpay/exception/InscriptionFinishException.java
index ad65b714..1d7e0c20 100644
--- a/src/main/java/cl/transbank/webpay/exception/InscriptionFinishException.java
+++ b/src/main/java/cl/transbank/webpay/exception/InscriptionFinishException.java
@@ -1,14 +1,28 @@
package cl.transbank.webpay.exception;
+/**
+ * This class represents an exception that is thrown when an inscription finish operation fails.
+ */
public class InscriptionFinishException extends WebpayException {
- public InscriptionFinishException() {
- }
- public InscriptionFinishException(Exception e) {
- super(e);
- }
+ /**
+ * Constructs a new InscriptionFinishException with no detail message.
+ */
+ public InscriptionFinishException() {}
- public InscriptionFinishException(String message) {
- super(message);
- }
+ /**
+ * Constructs a new InscriptionFinishException with the specified cause.
+ * @param e Exception that caused the error.
+ */
+ public InscriptionFinishException(Exception e) {
+ super(e);
+ }
+
+ /**
+ * Constructs a new InscriptionFinishException with the specified detail message.
+ * @param message The detail message.
+ */
+ public InscriptionFinishException(String message) {
+ super(message);
+ }
}
diff --git a/src/main/java/cl/transbank/webpay/exception/InscriptionStartException.java b/src/main/java/cl/transbank/webpay/exception/InscriptionStartException.java
index 495d5ffb..fb1293c2 100644
--- a/src/main/java/cl/transbank/webpay/exception/InscriptionStartException.java
+++ b/src/main/java/cl/transbank/webpay/exception/InscriptionStartException.java
@@ -1,7 +1,30 @@
package cl.transbank.webpay.exception;
+/**
+ * This class represents an exception that is thrown when an inscription start operation fails.
+ */
public class InscriptionStartException extends WebpayException {
- public InscriptionStartException() { super(); }
- public InscriptionStartException(Exception e) { super(e); }
- public InscriptionStartException(String message) { super(message); }
+
+ /**
+ * Constructs a new InscriptionStartException with no detail message.
+ */
+ public InscriptionStartException() {
+ super();
+ }
+
+ /**
+ * Constructs a new InscriptionStartException with the specified cause.
+ * @param e The cause of the exception.
+ */
+ public InscriptionStartException(Exception e) {
+ super(e);
+ }
+
+ /**
+ * Constructs a new InscriptionStartException with the specified detail message.
+ * @param message The detail message.
+ */
+ public InscriptionStartException(String message) {
+ super(message);
+ }
}
diff --git a/src/main/java/cl/transbank/webpay/exception/TransactionAuthorizeException.java b/src/main/java/cl/transbank/webpay/exception/TransactionAuthorizeException.java
index c41f60de..e0c555e3 100644
--- a/src/main/java/cl/transbank/webpay/exception/TransactionAuthorizeException.java
+++ b/src/main/java/cl/transbank/webpay/exception/TransactionAuthorizeException.java
@@ -1,14 +1,28 @@
package cl.transbank.webpay.exception;
+/**
+ * This class represents an exception that is thrown when a transaction authorization fails.
+ */
public class TransactionAuthorizeException extends WebpayException {
- public TransactionAuthorizeException() {
- }
- public TransactionAuthorizeException(Exception e) {
- super(e);
- }
+ /**
+ * Constructs a new TransactionAuthorizeException with no detail message.
+ */
+ public TransactionAuthorizeException() {}
- public TransactionAuthorizeException(String message) {
- super(message);
- }
+ /**
+ * Constructs a new TransactionAuthorizeException with the specified cause.
+ * @param e The cause of the exception.
+ */
+ public TransactionAuthorizeException(Exception e) {
+ super(e);
+ }
+
+ /**
+ * Constructs a new TransactionAuthorizeException with the specified detail message.
+ * @param message The detail message.
+ */
+ public TransactionAuthorizeException(String message) {
+ super(message);
+ }
}
diff --git a/src/main/java/cl/transbank/webpay/exception/TransactionCaptureException.java b/src/main/java/cl/transbank/webpay/exception/TransactionCaptureException.java
index c609a9dd..87343a04 100644
--- a/src/main/java/cl/transbank/webpay/exception/TransactionCaptureException.java
+++ b/src/main/java/cl/transbank/webpay/exception/TransactionCaptureException.java
@@ -1,15 +1,30 @@
package cl.transbank.webpay.exception;
+/**
+ * This class represents an exception that is thrown when a transaction capture operation fails.
+ */
public class TransactionCaptureException extends WebpayException {
- public TransactionCaptureException() {
- super();
- }
- public TransactionCaptureException(Exception e) {
- super(e);
- }
+ /**
+ * Constructs a new TransactionCaptureException with null as its detail message.
+ */
+ public TransactionCaptureException() {
+ super();
+ }
- public TransactionCaptureException(String message) {
- super(message);
- }
+ /**
+ * Constructs a new TransactionCaptureException with the specified cause.
+ * @param e The cause of the exception.
+ */
+ public TransactionCaptureException(Exception e) {
+ super(e);
+ }
+
+ /**
+ * Constructs a new TransactionCaptureException with the specified detail message.
+ * @param message The detail message.
+ */
+ public TransactionCaptureException(String message) {
+ super(message);
+ }
}
diff --git a/src/main/java/cl/transbank/webpay/exception/TransactionCommitException.java b/src/main/java/cl/transbank/webpay/exception/TransactionCommitException.java
index 35f034fc..1194c4b2 100644
--- a/src/main/java/cl/transbank/webpay/exception/TransactionCommitException.java
+++ b/src/main/java/cl/transbank/webpay/exception/TransactionCommitException.java
@@ -1,15 +1,30 @@
package cl.transbank.webpay.exception;
+/**
+ * This class represents an exception that is thrown when a transaction commit operation fails.
+ */
public class TransactionCommitException extends WebpayException {
- public TransactionCommitException() {
- super();
- }
- public TransactionCommitException(Exception e) {
- super(e);
- }
+ /**
+ * Constructs a new TransactionCommitException with no detail message.
+ */
+ public TransactionCommitException() {
+ super();
+ }
- public TransactionCommitException(String message) {
- super(message);
- }
+ /**
+ * Constructs a new TransactionCommitException with the specified cause.
+ * @param e The cause of the exception.
+ */
+ public TransactionCommitException(Exception e) {
+ super(e);
+ }
+
+ /**
+ * Constructs a new TransactionCommitException with the specified detail message.
+ * @param message The detail message.
+ */
+ public TransactionCommitException(String message) {
+ super(message);
+ }
}
diff --git a/src/main/java/cl/transbank/webpay/exception/TransactionCreateException.java b/src/main/java/cl/transbank/webpay/exception/TransactionCreateException.java
index 0311b43c..6a4b8f70 100644
--- a/src/main/java/cl/transbank/webpay/exception/TransactionCreateException.java
+++ b/src/main/java/cl/transbank/webpay/exception/TransactionCreateException.java
@@ -1,15 +1,30 @@
package cl.transbank.webpay.exception;
+/**
+ * This class represents an exception that is thrown when a transaction creation fails.
+ */
public class TransactionCreateException extends WebpayException {
- public TransactionCreateException() {
- super();
- }
- public TransactionCreateException(Exception e) {
- super(e);
- }
+ /**
+ * Constructs a new TransactionCreateException with no detail message.
+ */
+ public TransactionCreateException() {
+ super();
+ }
- public TransactionCreateException(String message) {
- super(message);
- }
+ /**
+ * Constructs a new TransactionCreateException with the specified cause.
+ * @param e Exception that caused the error.
+ */
+ public TransactionCreateException(Exception e) {
+ super(e);
+ }
+
+ /**
+ * Constructs a new TransactionCreateException with the specified detail message.
+ * @param message The detail message.
+ */
+ public TransactionCreateException(String message) {
+ super(message);
+ }
}
diff --git a/src/main/java/cl/transbank/webpay/exception/TransactionInstallmentException.java b/src/main/java/cl/transbank/webpay/exception/TransactionInstallmentException.java
index ecfa14c0..009e91ff 100644
--- a/src/main/java/cl/transbank/webpay/exception/TransactionInstallmentException.java
+++ b/src/main/java/cl/transbank/webpay/exception/TransactionInstallmentException.java
@@ -1,15 +1,30 @@
package cl.transbank.webpay.exception;
+/**
+ * This class represents an exception that is thrown when a transaction installment operation fails.
+ */
public class TransactionInstallmentException extends WebpayException {
- public TransactionInstallmentException() {
- super();
- }
- public TransactionInstallmentException(Exception e) {
- super(e);
- }
+ /**
+ * Constructs a new TransactionInstallmentException with no detail message.
+ */
+ public TransactionInstallmentException() {
+ super();
+ }
- public TransactionInstallmentException(String message) {
- super(message);
- }
+ /**
+ * Constructs a new TransactionInstallmentException with the specified cause.
+ * @param e The cause of the exception.
+ */
+ public TransactionInstallmentException(Exception e) {
+ super(e);
+ }
+
+ /**
+ * Constructs a new TransactionInstallmentException with the specified detail message.
+ * @param message The detail message.
+ */
+ public TransactionInstallmentException(String message) {
+ super(message);
+ }
}
diff --git a/src/main/java/cl/transbank/webpay/exception/TransactionRefundException.java b/src/main/java/cl/transbank/webpay/exception/TransactionRefundException.java
index 56481fd4..0af364a5 100644
--- a/src/main/java/cl/transbank/webpay/exception/TransactionRefundException.java
+++ b/src/main/java/cl/transbank/webpay/exception/TransactionRefundException.java
@@ -1,15 +1,30 @@
package cl.transbank.webpay.exception;
+/**
+ * This class represents an exception that is thrown when a transaction refund operation fails.
+ */
public class TransactionRefundException extends WebpayException {
- public TransactionRefundException() {
- super();
- }
- public TransactionRefundException(Exception e) {
- super(e);
- }
+ /**
+ * Constructs a new TransactionRefundException with no detail message.
+ */
+ public TransactionRefundException() {
+ super();
+ }
- public TransactionRefundException(String message) {
- super(message);
- }
+ /**
+ * Constructs a new TransactionRefundException with the specified cause.
+ * @param e The cause of the exception.
+ */
+ public TransactionRefundException(Exception e) {
+ super(e);
+ }
+
+ /**
+ * Constructs a new TransactionRefundException with the specified detail message.
+ * @param message The detail message.
+ */
+ public TransactionRefundException(String message) {
+ super(message);
+ }
}
diff --git a/src/main/java/cl/transbank/webpay/exception/TransactionStatusException.java b/src/main/java/cl/transbank/webpay/exception/TransactionStatusException.java
index 30c71082..3b527ee2 100644
--- a/src/main/java/cl/transbank/webpay/exception/TransactionStatusException.java
+++ b/src/main/java/cl/transbank/webpay/exception/TransactionStatusException.java
@@ -1,15 +1,30 @@
package cl.transbank.webpay.exception;
+/**
+ * This class represents an exception that is thrown when a transaction status operation fails.
+ */
public class TransactionStatusException extends WebpayException {
- public TransactionStatusException() {
- super();
- }
- public TransactionStatusException(Exception e) {
- super(e);
- }
+ /**
+ * Constructs a new TransactionStatusException with no detail message.
+ */
+ public TransactionStatusException() {
+ super();
+ }
- public TransactionStatusException(String message) {
- super(message);
- }
+ /**
+ * Constructs a new TransactionStatusException with the specified cause.
+ * @param e The cause of the exception.
+ */
+ public TransactionStatusException(Exception e) {
+ super(e);
+ }
+
+ /**
+ * Constructs a new TransactionStatusException with the specified detail message.
+ * @param message The detail message.
+ */
+ public TransactionStatusException(String message) {
+ super(message);
+ }
}
diff --git a/src/main/java/cl/transbank/webpay/exception/TransbankHttpApiException.java b/src/main/java/cl/transbank/webpay/exception/TransbankHttpApiException.java
index 077cca87..88f16c34 100644
--- a/src/main/java/cl/transbank/webpay/exception/TransbankHttpApiException.java
+++ b/src/main/java/cl/transbank/webpay/exception/TransbankHttpApiException.java
@@ -1,21 +1,37 @@
package cl.transbank.webpay.exception;
-import cl.transbank.exception.TransbankException;
-import lombok.Getter;
-
+/**
+ * This class represents an exception that is thrown when a Transbank HTTP API operation fails.
+ */
public class TransbankHttpApiException extends WebpayException {
- public TransbankHttpApiException() {
- }
- public TransbankHttpApiException(Exception e) {
- super(e);
- }
+ /**
+ * Constructs a new TransbankHttpApiException with no detail message.
+ */
+ public TransbankHttpApiException() {}
+
+ /**
+ * Constructs a new TransbankHttpApiException with the specified cause.
+ * @param e Exception that caused the error.
+ */
+ public TransbankHttpApiException(Exception e) {
+ super(e);
+ }
- public TransbankHttpApiException(String message) {
- super(message);
- }
+ /**
+ * Constructs a new TransbankHttpApiException with the specified detail message.
+ * @param message The detail message.
+ */
+ public TransbankHttpApiException(String message) {
+ super(message);
+ }
- public TransbankHttpApiException(int code, String message) {
- super(code, message);
- }
+ /**
+ * Constructs a new TransbankHttpApiException with the specified detail message and error code.
+ * @param code The error code.
+ * @param message The detail message.
+ */
+ public TransbankHttpApiException(int code, String message) {
+ super(code, message);
+ }
}
diff --git a/src/main/java/cl/transbank/webpay/exception/WebpayException.java b/src/main/java/cl/transbank/webpay/exception/WebpayException.java
index 1d0ad159..d1e5115d 100644
--- a/src/main/java/cl/transbank/webpay/exception/WebpayException.java
+++ b/src/main/java/cl/transbank/webpay/exception/WebpayException.java
@@ -2,25 +2,48 @@
import cl.transbank.exception.TransbankException;
+/**
+ * This class represents an exception that is thrown when a Webpay operation fails.
+ */
public class WebpayException extends TransbankException {
- public WebpayException() {
- super();
- }
- public WebpayException(Exception e) {
- super(e);
- }
+ /**
+ * Constructs a new WebpayException with no detail message.
+ */
+ public WebpayException() {
+ super();
+ }
- public WebpayException(String message) {
- super(message);
- }
+ /**
+ * Constructs a new WebpayException with the specified cause.
+ * @param e Exception that caused the error.
+ */
+ public WebpayException(Exception e) {
+ super(e);
+ }
- public WebpayException(int code, String message) {
- super(code, message);
- }
+ /**
+ * Constructs a new WebpayException with the specified detail message.
+ * @param message The detail message.
+ */
+ public WebpayException(String message) {
+ super(message);
+ }
- @Override
- public String toString() {
- return super.toString().concat(String.format(" | code : %s", getCode()));
- }
+ /**
+ * Constructs a new WebpayException with the specified detail message and error code.
+ * @param code The error code.
+ * @param message The detail message.
+ */
+ public WebpayException(int code, String message) {
+ super(code, message);
+ }
+
+ /**
+ * Returns a string representation of this exception.
+ */
+ @Override
+ public String toString() {
+ return super.toString().concat(String.format(" | code : %s", getCode()));
+ }
}
diff --git a/src/main/java/cl/transbank/webpay/modal/WebpayModalTransaction.java b/src/main/java/cl/transbank/webpay/modal/WebpayModalTransaction.java
index 1e18864e..ece080d1 100644
--- a/src/main/java/cl/transbank/webpay/modal/WebpayModalTransaction.java
+++ b/src/main/java/cl/transbank/webpay/modal/WebpayModalTransaction.java
@@ -35,7 +35,7 @@ public ModalTransactionCreateResponse create(String buyOrder, String sessionId,
}
public ModalTransactionCommitResponse commit(String token) throws IOException, TransactionCommitException {
- ValidationUtil.hasTextWithMaxLength(token, ApiConstants.TOKEN_LENGTH, "token");
+ ValidationUtil.hasTextWithMaxLength(token, ApiConstants.TOKEN_LENGTH, ApiConstants.TOKEN_TEXT);
String endpoint = String.format("%s/transactions/%s", ApiConstants.WEBPAY_ENDPOINT,token);
try {
@@ -46,7 +46,7 @@ public ModalTransactionCommitResponse commit(String token) throws IOException, T
}
public ModalTransactionStatusResponse status(String token) throws IOException, TransactionStatusException {
- ValidationUtil.hasTextWithMaxLength(token, ApiConstants.TOKEN_LENGTH, "token");
+ ValidationUtil.hasTextWithMaxLength(token, ApiConstants.TOKEN_LENGTH, ApiConstants.TOKEN_TEXT);
String endpoint = String.format("%s/transactions/%s", ApiConstants.WEBPAY_ENDPOINT,token);
try {
@@ -57,7 +57,7 @@ public ModalTransactionStatusResponse status(String token) throws IOException, T
}
public ModalTransactionRefundResponse refund(String token, double amount) throws IOException, TransactionRefundException {
- ValidationUtil.hasTextWithMaxLength(token, ApiConstants.TOKEN_LENGTH, "token");
+ ValidationUtil.hasTextWithMaxLength(token, ApiConstants.TOKEN_LENGTH, ApiConstants.TOKEN_TEXT);
String endpoint = String.format("%s/transactions/%s/refunds", ApiConstants.WEBPAY_ENDPOINT,token);
try {
diff --git a/src/main/java/cl/transbank/webpay/modal/WebpayPlusModal.java b/src/main/java/cl/transbank/webpay/modal/WebpayPlusModal.java
index b374f8ec..c18c9452 100644
--- a/src/main/java/cl/transbank/webpay/modal/WebpayPlusModal.java
+++ b/src/main/java/cl/transbank/webpay/modal/WebpayPlusModal.java
@@ -6,37 +6,80 @@
import cl.transbank.model.Options;
import cl.transbank.webpay.common.WebpayOptions;
+/**
+ * This class provides methods to configure and perform transactions with the PatpassByWebpay service.
+ */
public class WebpayPlusModal {
- private static Options options;
-
- public static class Transaction extends WebpayModalTransaction {
- public Transaction() {
- super(WebpayPlusModal.options!=null ? WebpayPlusModal.options : new WebpayOptions(IntegrationCommerceCodes.WEBPAY_PLUS_MODAL, IntegrationApiKeys.WEBPAY, IntegrationType.TEST));
- }
- public Transaction(Options options) {
- super(options);
- }
+
+ private static Options options;
+
+ /**
+ * This class provides methods to configure and perform transactions with the WebpayPlusModal service.
+ */
+ public static class Transaction extends WebpayModalTransaction {
+
+ /**
+ * Default constructor. Uses default options if none are provided.
+ */
+ public Transaction() {
+ super(
+ WebpayPlusModal.options != null
+ ? WebpayPlusModal.options
+ : new WebpayOptions(
+ IntegrationCommerceCodes.WEBPAY_PLUS_MODAL,
+ IntegrationApiKeys.WEBPAY,
+ IntegrationType.TEST
+ )
+ );
+ }
+
+ /**
+ * Constructor with options. Uses provided options.
+ * @param options The options to use for this transaction.
+ */
+ public Transaction(Options options) {
+ super(options);
}
+ }
- /*
+ /*
|--------------------------------------------------------------------------
| Environment Configuration
|--------------------------------------------------------------------------
*/
- public static void configureForIntegration(String commerceCode, String apiKey){
- options = new WebpayOptions(commerceCode, apiKey, IntegrationType.TEST);
- }
+ /**
+ * Configures the environment for integration.
+ * @param commerceCode The commerce code.
+ * @param apiKey The API key.
+ */
+ public static void configureForIntegration(
+ String commerceCode,
+ String apiKey
+ ) {
+ options = new WebpayOptions(commerceCode, apiKey, IntegrationType.TEST);
+ }
- public static void configureForProduction(String commerceCode, String apiKey){
- options = new WebpayOptions(commerceCode, apiKey, IntegrationType.LIVE);
- }
+ public static void configureForProduction(
+ String commerceCode,
+ String apiKey
+ ) {
+ options = new WebpayOptions(commerceCode, apiKey, IntegrationType.LIVE);
+ }
- public static void configureForTesting(){
- configureForIntegration(IntegrationCommerceCodes.WEBPAY_PLUS_MODAL, IntegrationApiKeys.WEBPAY);
- }
+ public static void configureForTesting() {
+ configureForIntegration(
+ IntegrationCommerceCodes.WEBPAY_PLUS_MODAL,
+ IntegrationApiKeys.WEBPAY
+ );
+ }
- public static void configureForMock(){
- options = new WebpayOptions(IntegrationCommerceCodes.WEBPAY_PLUS_MODAL, IntegrationApiKeys.WEBPAY, IntegrationType.SERVER_MOCK);
- }
-}
\ No newline at end of file
+ public static void configureForMock() {
+ options =
+ new WebpayOptions(
+ IntegrationCommerceCodes.WEBPAY_PLUS_MODAL,
+ IntegrationApiKeys.WEBPAY,
+ IntegrationType.SERVER_MOCK
+ );
+ }
+}
diff --git a/src/main/java/cl/transbank/webpay/modal/requests/ModalTransactionCreateRequest.java b/src/main/java/cl/transbank/webpay/modal/requests/ModalTransactionCreateRequest.java
index cc8a09be..501ee57e 100644
--- a/src/main/java/cl/transbank/webpay/modal/requests/ModalTransactionCreateRequest.java
+++ b/src/main/java/cl/transbank/webpay/modal/requests/ModalTransactionCreateRequest.java
@@ -3,11 +3,17 @@
import cl.transbank.model.WebpayApiRequest;
import lombok.*;
-@NoArgsConstructor @AllArgsConstructor
-@Getter @Setter
+/**
+ * This class represents a request to create a modal transaction.
+ */
+@NoArgsConstructor
+@AllArgsConstructor
+@Getter
+@Setter
@ToString
public class ModalTransactionCreateRequest extends WebpayApiRequest {
- private String buyOrder;
- private String sessionId;
- private double amount;
+
+ private String buyOrder;
+ private String sessionId;
+ private double amount;
}
diff --git a/src/main/java/cl/transbank/webpay/modal/responses/ModalTransactionCommitResponse.java b/src/main/java/cl/transbank/webpay/modal/responses/ModalTransactionCommitResponse.java
index 1411d1ad..f3f3b774 100644
--- a/src/main/java/cl/transbank/webpay/modal/responses/ModalTransactionCommitResponse.java
+++ b/src/main/java/cl/transbank/webpay/modal/responses/ModalTransactionCommitResponse.java
@@ -2,5 +2,8 @@
import cl.transbank.webpay.webpayplus.responses.WebpayPlusTransactionCommitResponse;
-public class ModalTransactionCommitResponse extends WebpayPlusTransactionCommitResponse {
-}
+/**
+ * This class represents a response to a commit operation for a Modal transaction.
+ */
+public class ModalTransactionCommitResponse
+ extends WebpayPlusTransactionCommitResponse {}
diff --git a/src/main/java/cl/transbank/webpay/modal/responses/ModalTransactionCreateResponse.java b/src/main/java/cl/transbank/webpay/modal/responses/ModalTransactionCreateResponse.java
index 8216e405..ea2b03c6 100644
--- a/src/main/java/cl/transbank/webpay/modal/responses/ModalTransactionCreateResponse.java
+++ b/src/main/java/cl/transbank/webpay/modal/responses/ModalTransactionCreateResponse.java
@@ -2,9 +2,15 @@
import lombok.*;
-@NoArgsConstructor @AllArgsConstructor
-@Getter @Setter
+/**
+ * This class represents a response to a create operation for a Modal transaction.
+ */
+@NoArgsConstructor
+@AllArgsConstructor
+@Getter
+@Setter
@ToString
public class ModalTransactionCreateResponse {
- private String token;
+
+ private String token;
}
diff --git a/src/main/java/cl/transbank/webpay/modal/responses/ModalTransactionRefundResponse.java b/src/main/java/cl/transbank/webpay/modal/responses/ModalTransactionRefundResponse.java
index 843ab4f4..a3a5c312 100644
--- a/src/main/java/cl/transbank/webpay/modal/responses/ModalTransactionRefundResponse.java
+++ b/src/main/java/cl/transbank/webpay/modal/responses/ModalTransactionRefundResponse.java
@@ -2,5 +2,8 @@
import cl.transbank.webpay.webpayplus.responses.WebpayPlusTransactionRefundResponse;
-public class ModalTransactionRefundResponse extends WebpayPlusTransactionRefundResponse {
-}
+/**
+ * This class represents a response to a refund operation for a Modal transaction.
+ */
+public class ModalTransactionRefundResponse
+ extends WebpayPlusTransactionRefundResponse {}
diff --git a/src/main/java/cl/transbank/webpay/modal/responses/ModalTransactionStatusResponse.java b/src/main/java/cl/transbank/webpay/modal/responses/ModalTransactionStatusResponse.java
index b7415469..79d6184a 100644
--- a/src/main/java/cl/transbank/webpay/modal/responses/ModalTransactionStatusResponse.java
+++ b/src/main/java/cl/transbank/webpay/modal/responses/ModalTransactionStatusResponse.java
@@ -2,5 +2,8 @@
import cl.transbank.webpay.webpayplus.responses.WebpayPlusTransactionStatusResponse;
-public class ModalTransactionStatusResponse extends WebpayPlusTransactionStatusResponse {
-}
+/**
+ * This class represents a response to a status request for a modal transaction.
+ */
+public class ModalTransactionStatusResponse
+ extends WebpayPlusTransactionStatusResponse {}
diff --git a/src/main/java/cl/transbank/webpay/oneclick/Oneclick.java b/src/main/java/cl/transbank/webpay/oneclick/Oneclick.java
index 4866c43e..7eed1c19 100644
--- a/src/main/java/cl/transbank/webpay/oneclick/Oneclick.java
+++ b/src/main/java/cl/transbank/webpay/oneclick/Oneclick.java
@@ -6,50 +6,97 @@
import cl.transbank.model.Options;
import cl.transbank.webpay.common.WebpayOptions;
-public class Oneclick{
- private static Options options;
-
- public static class MallInscription extends OneclickMallInscription{
- public MallInscription() {
- super(Oneclick.options!=null ? Oneclick.options : new WebpayOptions(IntegrationCommerceCodes.ONECLICK_MALL, IntegrationApiKeys.WEBPAY, IntegrationType.TEST));
- }
- public MallInscription(Options options) {
- super(options);
- }
+/**
+ * This class provides methods to configure and perform transactions with the Oneclick service.
+ */
+public class Oneclick {
+
+ private static Options options;
+
+ /**
+ * This class provides methods to perform Oneclick Mall Inscriptions.
+ */
+ public static class MallInscription extends OneclickMallInscription {
+
+ public MallInscription() {
+ super(
+ Oneclick.options != null
+ ? Oneclick.options
+ : new WebpayOptions(
+ IntegrationCommerceCodes.ONECLICK_MALL,
+ IntegrationApiKeys.WEBPAY,
+ IntegrationType.TEST
+ )
+ );
}
- public static class MallTransaction extends OneclickMallTransaction {
- public MallTransaction() {
- super(Oneclick.options!=null ? Oneclick.options : new WebpayOptions(IntegrationCommerceCodes.ONECLICK_MALL, IntegrationApiKeys.WEBPAY, IntegrationType.TEST));
- }
- public MallTransaction(Options options) {
- super(options);
- }
+ public MallInscription(Options options) {
+ super(options);
}
+ }
+
+ /**
+ * Default constructor. Uses default options if none are provided.
+ */
+ public static class MallTransaction extends OneclickMallTransaction {
- /*
+ public MallTransaction() {
+ super(
+ Oneclick.options != null
+ ? Oneclick.options
+ : new WebpayOptions(
+ IntegrationCommerceCodes.ONECLICK_MALL,
+ IntegrationApiKeys.WEBPAY,
+ IntegrationType.TEST
+ )
+ );
+ }
+
+ public MallTransaction(Options options) {
+ super(options);
+ }
+ }
+
+ /*
|--------------------------------------------------------------------------
| Environment Configuration
|--------------------------------------------------------------------------
*/
- public static void configureForIntegration(String commerceCode, String apiKey){
- options = new WebpayOptions(commerceCode, apiKey, IntegrationType.TEST);
- }
+ public static void configureForIntegration(
+ String commerceCode,
+ String apiKey
+ ) {
+ options = new WebpayOptions(commerceCode, apiKey, IntegrationType.TEST);
+ }
- public static void configureForProduction(String commerceCode, String apiKey){
- options = new WebpayOptions(commerceCode, apiKey, IntegrationType.LIVE);
- }
+ public static void configureForProduction(
+ String commerceCode,
+ String apiKey
+ ) {
+ options = new WebpayOptions(commerceCode, apiKey, IntegrationType.LIVE);
+ }
- public static void configureForTesting(){
- configureForIntegration(IntegrationCommerceCodes.ONECLICK_MALL, IntegrationApiKeys.WEBPAY);
- }
+ public static void configureForTesting() {
+ configureForIntegration(
+ IntegrationCommerceCodes.ONECLICK_MALL,
+ IntegrationApiKeys.WEBPAY
+ );
+ }
- public static void configureForTestingDeferred(){
- configureForIntegration(IntegrationCommerceCodes.ONECLICK_MALL_DEFERRED, IntegrationApiKeys.WEBPAY);
- }
+ public static void configureForTestingDeferred() {
+ configureForIntegration(
+ IntegrationCommerceCodes.ONECLICK_MALL_DEFERRED,
+ IntegrationApiKeys.WEBPAY
+ );
+ }
- public static void configureForMock(){
- options = new WebpayOptions(IntegrationCommerceCodes.ONECLICK_MALL, IntegrationApiKeys.WEBPAY, IntegrationType.SERVER_MOCK);
- }
+ public static void configureForMock() {
+ options =
+ new WebpayOptions(
+ IntegrationCommerceCodes.ONECLICK_MALL,
+ IntegrationApiKeys.WEBPAY,
+ IntegrationType.SERVER_MOCK
+ );
+ }
}
diff --git a/src/main/java/cl/transbank/webpay/oneclick/OneclickMallInscription.java b/src/main/java/cl/transbank/webpay/oneclick/OneclickMallInscription.java
index ceb72ccb..b32013c6 100644
--- a/src/main/java/cl/transbank/webpay/oneclick/OneclickMallInscription.java
+++ b/src/main/java/cl/transbank/webpay/oneclick/OneclickMallInscription.java
@@ -2,8 +2,8 @@
import cl.transbank.common.ApiConstants;
import cl.transbank.common.BaseTransaction;
-import cl.transbank.model.Options;
import cl.transbank.exception.TransbankException;
+import cl.transbank.model.Options;
import cl.transbank.model.WebpayApiRequest;
import cl.transbank.util.HttpUtil;
import cl.transbank.util.ValidationUtil;
@@ -15,47 +15,122 @@
import cl.transbank.webpay.oneclick.requests.InscriptionStartRequest;
import cl.transbank.webpay.oneclick.responses.OneclickMallInscriptionFinishResponse;
import cl.transbank.webpay.oneclick.responses.OneclickMallInscriptionStartResponse;
-
import java.io.IOException;
+/**
+ * This abstract class represents the OneclickMallInscription and provides methods to handle Oneclick Mall Inscriptions.
+ */
abstract class OneclickMallInscription extends BaseTransaction {
- public OneclickMallInscription(Options options){
- this.options = options;
- }
- public OneclickMallInscriptionStartResponse start(String username, String email, String responseUrl) throws IOException, InscriptionStartException {
- ValidationUtil.hasTextTrimWithMaxLength(username, ApiConstants.USER_NAME_LENGTH, "username");
- ValidationUtil.hasTextTrimWithMaxLength(email, ApiConstants.EMAIL_LENGTH, "email");
- ValidationUtil.hasTextWithMaxLength(responseUrl, ApiConstants.RETURN_URL_LENGTH, "responseUrl");
+ /**
+ * This abstract class represents the OneclickMallInscription and provides methods to handle Oneclick Mall Inscriptions.
+ */
+ public OneclickMallInscription(Options options) {
+ this.options = options;
+ }
+
+ /**
+ * Starts a new Oneclick Mall Inscription.
+ * @param username The username of the user.
+ * @param email The email of the user.
+ * @param responseUrl The URL to redirect the user to after the inscription is completed.
+ * @return The response from the start inscription request.
+ * @throws IOException If there is an error during the execution of the request.
+ * @throws InscriptionStartException If there is an error during the start of the inscription.
+ */
+ public OneclickMallInscriptionStartResponse start(
+ String username,
+ String email,
+ String responseUrl
+ ) throws IOException, InscriptionStartException {
+ ValidationUtil.hasTextTrimWithMaxLength(
+ username,
+ ApiConstants.USER_NAME_LENGTH,
+ "username"
+ );
+ ValidationUtil.hasTextTrimWithMaxLength(
+ email,
+ ApiConstants.EMAIL_LENGTH,
+ "email"
+ );
+ ValidationUtil.hasTextWithMaxLength(
+ responseUrl,
+ ApiConstants.RETURN_URL_LENGTH,
+ "responseUrl"
+ );
- final WebpayApiRequest request = new InscriptionStartRequest(username, email, responseUrl);
- String endpoint = String.format("%s/inscriptions", ApiConstants.ONECLICK_ENDPOINT);
- try {
- return WebpayApiResource.execute(endpoint, HttpUtil.RequestMethod.POST, request, options, OneclickMallInscriptionStartResponse.class);
- } catch (TransbankException e) {
- throw new InscriptionStartException(e);
- }
+ final WebpayApiRequest request = new InscriptionStartRequest(
+ username,
+ email,
+ responseUrl
+ );
+ String endpoint = String.format(
+ "%s/inscriptions",
+ ApiConstants.ONECLICK_ENDPOINT
+ );
+ try {
+ return WebpayApiResource.execute(
+ endpoint,
+ HttpUtil.RequestMethod.POST,
+ request,
+ options,
+ OneclickMallInscriptionStartResponse.class
+ );
+ } catch (TransbankException e) {
+ throw new InscriptionStartException(e);
}
+ }
- public OneclickMallInscriptionFinishResponse finish(String token) throws IOException, InscriptionFinishException {
- ValidationUtil.hasTextWithMaxLength(token, ApiConstants.TOKEN_LENGTH, "token");
- String endpoint = String.format("%s/inscriptions/%s", ApiConstants.ONECLICK_ENDPOINT, token);
- try {
- return WebpayApiResource.execute(endpoint, HttpUtil.RequestMethod.PUT, options, OneclickMallInscriptionFinishResponse.class);
- } catch (TransbankException e) {
- throw new InscriptionFinishException(e);
- }
+ public OneclickMallInscriptionFinishResponse finish(String token)
+ throws IOException, InscriptionFinishException {
+ ValidationUtil.hasTextWithMaxLength(
+ token,
+ ApiConstants.TOKEN_LENGTH,
+ ApiConstants.TOKEN_TEXT
+ );
+ String endpoint = String.format(
+ "%s/inscriptions/%s",
+ ApiConstants.ONECLICK_ENDPOINT,
+ token
+ );
+ try {
+ return WebpayApiResource.execute(
+ endpoint,
+ HttpUtil.RequestMethod.PUT,
+ options,
+ OneclickMallInscriptionFinishResponse.class
+ );
+ } catch (TransbankException e) {
+ throw new InscriptionFinishException(e);
}
+ }
- public void delete(String tbkUser, String username) throws IOException, InscriptionDeleteException {
- ValidationUtil.hasTextTrimWithMaxLength(username, ApiConstants.USER_NAME_LENGTH, "username");
- ValidationUtil.hasTextWithMaxLength(tbkUser, ApiConstants.TBK_USER_LENGTH, "tbkUser");
- WebpayApiRequest request = new InscriptionDeleteRequest(username, tbkUser);
- String endpoint = String.format("%s/inscriptions", ApiConstants.ONECLICK_ENDPOINT);
- try {
- WebpayApiResource.execute(endpoint, HttpUtil.RequestMethod.DELETE, request, options);
- } catch (TransbankException e) {
- throw new InscriptionDeleteException(e);
- }
+ public void delete(String tbkUser, String username)
+ throws IOException, InscriptionDeleteException {
+ ValidationUtil.hasTextTrimWithMaxLength(
+ username,
+ ApiConstants.USER_NAME_LENGTH,
+ "username"
+ );
+ ValidationUtil.hasTextWithMaxLength(
+ tbkUser,
+ ApiConstants.TBK_USER_LENGTH,
+ "tbkUser"
+ );
+ WebpayApiRequest request = new InscriptionDeleteRequest(username, tbkUser);
+ String endpoint = String.format(
+ "%s/inscriptions",
+ ApiConstants.ONECLICK_ENDPOINT
+ );
+ try {
+ WebpayApiResource.execute(
+ endpoint,
+ HttpUtil.RequestMethod.DELETE,
+ request,
+ options
+ );
+ } catch (TransbankException e) {
+ throw new InscriptionDeleteException(e);
}
+ }
}
diff --git a/src/main/java/cl/transbank/webpay/oneclick/model/MallTransactionCreateDetails.java b/src/main/java/cl/transbank/webpay/oneclick/model/MallTransactionCreateDetails.java
index ad5940ca..0b976031 100644
--- a/src/main/java/cl/transbank/webpay/oneclick/model/MallTransactionCreateDetails.java
+++ b/src/main/java/cl/transbank/webpay/oneclick/model/MallTransactionCreateDetails.java
@@ -1,50 +1,116 @@
package cl.transbank.webpay.oneclick.model;
-import lombok.*;
-
import java.util.ArrayList;
import java.util.List;
+import java.util.Objects;
+import lombok.*;
+/**
+ * This class represents the details for creating a mall transaction.
+ */
@ToString
public class MallTransactionCreateDetails {
- @Getter
- private List details = new ArrayList<>();
- private MallTransactionCreateDetails() {}
+ @Getter
+ private List details = new ArrayList<>();
- public static MallTransactionCreateDetails build() {
- return new MallTransactionCreateDetails();
- }
+ private MallTransactionCreateDetails() {}
- public static MallTransactionCreateDetails build(double amount, String commerceCode, String buyOrder, byte installmentsNumber) {
- return MallTransactionCreateDetails.build().add(amount, commerceCode, buyOrder, installmentsNumber);
- }
+ /**
+ * Builds a new MallTransactionCreateDetails.
+ * @return A new MallTransactionCreateDetails.
+ */
+ public static MallTransactionCreateDetails build() {
+ return new MallTransactionCreateDetails();
+ }
- public MallTransactionCreateDetails add(double amount, String commerceCode, String buyOrder, byte installmentsNumber) {
- getDetails().add(new Detail(amount, commerceCode, buyOrder, installmentsNumber));
- return this;
- }
+ /**
+ * Builds a new MallTransactionCreateDetails with the specified amount, commerce code, buy order, and installments number.
+ * @param amount The amount of the transaction.
+ * @param commerceCode The commerce code of the transaction.
+ * @param buyOrder The buy order of the transaction.
+ * @param installmentsNumber The number of installments for the transaction.
+ * @return A new MallTransactionCreateDetails.
+ */
+ public static MallTransactionCreateDetails build(
+ double amount,
+ String commerceCode,
+ String buyOrder,
+ byte installmentsNumber
+ ) {
+ return MallTransactionCreateDetails
+ .build()
+ .add(amount, commerceCode, buyOrder, installmentsNumber);
+ }
+
+ /**
+ * Adds a new detail to the details of the transaction.
+ * @param amount The amount of the detail.
+ * @param commerceCode The commerce code of the detail.
+ * @param buyOrder The buy order of the detail.
+ * @param installmentsNumber The number of installments for the detail.
+ * @return This MallTransactionCreateDetails.
+ */
+ public MallTransactionCreateDetails add(
+ double amount,
+ String commerceCode,
+ String buyOrder,
+ byte installmentsNumber
+ ) {
+ getDetails()
+ .add(new Detail(amount, commerceCode, buyOrder, installmentsNumber));
+ return this;
+ }
+
+ /**
+ * Removes a detail from the details of the transaction.
+ * @param amount The amount of the detail.
+ * @param commerceCode The commerce code of the detail.
+ * @param buyOrder The buy order of the detail.
+ * @param installmentsNumber The number of installments for the detail.
+ * @return True if the detail was removed, false otherwise.
+ */
+ public boolean remove(
+ double amount,
+ String commerceCode,
+ String buyOrder,
+ byte installmentsNumber
+ ) {
+ return getDetails()
+ .remove(new Detail(amount, commerceCode, buyOrder, installmentsNumber));
+ }
+
+ /**
+ * This class represents a detail of a mall transaction.
+ */
+ @NoArgsConstructor
+ @AllArgsConstructor
+ @Getter
+ @Setter
+ @ToString
+ public class Detail {
+
+ private double amount;
+ private String commerceCode;
+ private String buyOrder;
+ private byte installmentsNumber;
+
+ @Override
+ public boolean equals(Object obj) {
+ if (!(obj instanceof Detail)) return false;
- public boolean remove(double amount, String commerceCode, String buyOrder, byte installmentsNumber) {
- return getDetails().remove(new Detail(amount, commerceCode, buyOrder, installmentsNumber));
+ Detail another = (Detail) obj;
+ return (
+ getAmount() == another.getAmount() &&
+ getCommerceCode().equals(another.getBuyOrder()) &&
+ getBuyOrder().equals(another.getBuyOrder()) &&
+ getInstallmentsNumber() == another.getInstallmentsNumber()
+ );
}
- @NoArgsConstructor @AllArgsConstructor
- @Getter @Setter @ToString
- public class Detail {
- private double amount;
- private String commerceCode;
- private String buyOrder;
- private byte installmentsNumber;
-
- @Override
- public boolean equals(Object obj) {
- if (!(obj instanceof Detail))
- return false;
-
- Detail another = (Detail) obj;
- return getAmount() == another.getAmount() && getCommerceCode().equals(another.getBuyOrder()) &&
- getBuyOrder().equals(another.getBuyOrder()) && getInstallmentsNumber() == another.getInstallmentsNumber();
- }
+ @Override
+ public int hashCode() {
+ return Objects.hash(commerceCode, buyOrder, amount, installmentsNumber);
}
+ }
}
diff --git a/src/main/java/cl/transbank/webpay/oneclick/requests/InscriptionDeleteRequest.java b/src/main/java/cl/transbank/webpay/oneclick/requests/InscriptionDeleteRequest.java
index 7c8f85ea..90611ecf 100644
--- a/src/main/java/cl/transbank/webpay/oneclick/requests/InscriptionDeleteRequest.java
+++ b/src/main/java/cl/transbank/webpay/oneclick/requests/InscriptionDeleteRequest.java
@@ -1,12 +1,18 @@
package cl.transbank.webpay.oneclick.requests;
import cl.transbank.model.WebpayApiRequest;
-import com.google.gson.annotations.SerializedName;
import lombok.*;
-@NoArgsConstructor @AllArgsConstructor
-@Getter @Setter @ToString
+/**
+ * This class represents a request to delete an inscription.
+ */
+@NoArgsConstructor
+@AllArgsConstructor
+@Getter
+@Setter
+@ToString
public class InscriptionDeleteRequest extends WebpayApiRequest {
- private String username;
- private String tbkUser;
+
+ private String username;
+ private String tbkUser;
}
diff --git a/src/main/java/cl/transbank/webpay/oneclick/requests/InscriptionStartRequest.java b/src/main/java/cl/transbank/webpay/oneclick/requests/InscriptionStartRequest.java
index abcbc183..2430fbcb 100644
--- a/src/main/java/cl/transbank/webpay/oneclick/requests/InscriptionStartRequest.java
+++ b/src/main/java/cl/transbank/webpay/oneclick/requests/InscriptionStartRequest.java
@@ -1,14 +1,30 @@
package cl.transbank.webpay.oneclick.requests;
import cl.transbank.model.WebpayApiRequest;
-import com.google.gson.annotations.SerializedName;
import lombok.*;
-@NoArgsConstructor @AllArgsConstructor
-@Getter @Setter
+/**
+ * This class represents a request to start an inscription.
+ */
+@NoArgsConstructor
+@AllArgsConstructor
+@Getter
+@Setter
@ToString
public class InscriptionStartRequest extends WebpayApiRequest {
- private String username;
- private String email;
- private String responseUrl;
+
+ /**
+ * The username for the inscription.
+ */
+ private String username;
+
+ /**
+ * The email for the inscription.
+ */
+ private String email;
+
+ /**
+ * The response URL for the inscription.
+ */
+ private String responseUrl;
}
diff --git a/src/main/java/cl/transbank/webpay/oneclick/requests/MallTransactionRefundRequest.java b/src/main/java/cl/transbank/webpay/oneclick/requests/MallTransactionRefundRequest.java
index 509ddf78..9fc3d2de 100644
--- a/src/main/java/cl/transbank/webpay/oneclick/requests/MallTransactionRefundRequest.java
+++ b/src/main/java/cl/transbank/webpay/oneclick/requests/MallTransactionRefundRequest.java
@@ -3,10 +3,17 @@
import cl.transbank.model.WebpayApiRequest;
import lombok.*;
-@NoArgsConstructor @AllArgsConstructor
-@Getter @Setter @ToString
+/**
+ * This class represents a request to refund a transaction for a mall.
+ */
+@NoArgsConstructor
+@AllArgsConstructor
+@Getter
+@Setter
+@ToString
public class MallTransactionRefundRequest extends WebpayApiRequest {
- private String commerceCode;
- private String detailBuyOrder;
- private double amount;
+
+ private String commerceCode;
+ private String detailBuyOrder;
+ private double amount;
}
diff --git a/src/main/java/cl/transbank/webpay/oneclick/requests/TransactionAuthorizeRequest.java b/src/main/java/cl/transbank/webpay/oneclick/requests/TransactionAuthorizeRequest.java
index c640a74b..51e863bc 100644
--- a/src/main/java/cl/transbank/webpay/oneclick/requests/TransactionAuthorizeRequest.java
+++ b/src/main/java/cl/transbank/webpay/oneclick/requests/TransactionAuthorizeRequest.java
@@ -2,15 +2,21 @@
import cl.transbank.model.WebpayApiRequest;
import cl.transbank.webpay.oneclick.model.MallTransactionCreateDetails;
-import lombok.*;
-
import java.util.List;
+import lombok.*;
-@NoArgsConstructor @AllArgsConstructor
-@Getter @Setter @ToString
+/**
+ * This class represents a request to authorize a transaction.
+ */
+@NoArgsConstructor
+@AllArgsConstructor
+@Getter
+@Setter
+@ToString
public class TransactionAuthorizeRequest extends WebpayApiRequest {
- private String username;
- private String tbkUser;
- private String buyOrder;
- private List details;
+
+ private String username;
+ private String tbkUser;
+ private String buyOrder;
+ private List details;
}
diff --git a/src/main/java/cl/transbank/webpay/oneclick/responses/InscriptionStartResponse.java b/src/main/java/cl/transbank/webpay/oneclick/responses/InscriptionStartResponse.java
index ec0d1606..ccbf6fda 100644
--- a/src/main/java/cl/transbank/webpay/oneclick/responses/InscriptionStartResponse.java
+++ b/src/main/java/cl/transbank/webpay/oneclick/responses/InscriptionStartResponse.java
@@ -1,13 +1,18 @@
package cl.transbank.webpay.oneclick.responses;
-import com.google.gson.annotations.SerializedName;
import lombok.*;
-@NoArgsConstructor @AllArgsConstructor
-@Getter @Setter
+/**
+ * This class represents a response to a start operation for an inscription.
+ */
+@NoArgsConstructor
+@AllArgsConstructor
+@Getter
+@Setter
@ToString
public class InscriptionStartResponse {
- private String token;
- private String urlWebpay;
- private String errorMessage;
+
+ private String token;
+ private String urlWebpay;
+ private String errorMessage;
}
diff --git a/src/main/java/cl/transbank/webpay/oneclick/responses/OneclickMallInscriptionDeleteResponse.java b/src/main/java/cl/transbank/webpay/oneclick/responses/OneclickMallInscriptionDeleteResponse.java
index 3ac3f7df..1dcf3dfd 100644
--- a/src/main/java/cl/transbank/webpay/oneclick/responses/OneclickMallInscriptionDeleteResponse.java
+++ b/src/main/java/cl/transbank/webpay/oneclick/responses/OneclickMallInscriptionDeleteResponse.java
@@ -5,7 +5,11 @@
import lombok.Setter;
import lombok.ToString;
+/**
+ * This class represents a response to a delete operation for a OneClick Mall inscription.
+ */
@NoArgsConstructor
-@Getter @Setter @ToString
-public class OneclickMallInscriptionDeleteResponse {
-}
+@Getter
+@Setter
+@ToString
+public class OneclickMallInscriptionDeleteResponse {}
diff --git a/src/main/java/cl/transbank/webpay/oneclick/responses/OneclickMallInscriptionFinishResponse.java b/src/main/java/cl/transbank/webpay/oneclick/responses/OneclickMallInscriptionFinishResponse.java
index c49b6c4c..154e378a 100644
--- a/src/main/java/cl/transbank/webpay/oneclick/responses/OneclickMallInscriptionFinishResponse.java
+++ b/src/main/java/cl/transbank/webpay/oneclick/responses/OneclickMallInscriptionFinishResponse.java
@@ -2,12 +2,19 @@
import lombok.*;
-@NoArgsConstructor @AllArgsConstructor
-@Getter @Setter @ToString
+/**
+ * This class represents a response to a finish operation for a OneClick Mall inscription.
+ */
+@NoArgsConstructor
+@AllArgsConstructor
+@Getter
+@Setter
+@ToString
public class OneclickMallInscriptionFinishResponse {
- private byte responseCode;
- private String tbkUser;
- private String authorizationCode;
- private String cardType;
- private String cardNumber;
+
+ private byte responseCode;
+ private String tbkUser;
+ private String authorizationCode;
+ private String cardType;
+ private String cardNumber;
}
diff --git a/src/main/java/cl/transbank/webpay/oneclick/responses/OneclickMallInscriptionStartResponse.java b/src/main/java/cl/transbank/webpay/oneclick/responses/OneclickMallInscriptionStartResponse.java
index 1b9343b3..74e2dcde 100644
--- a/src/main/java/cl/transbank/webpay/oneclick/responses/OneclickMallInscriptionStartResponse.java
+++ b/src/main/java/cl/transbank/webpay/oneclick/responses/OneclickMallInscriptionStartResponse.java
@@ -2,9 +2,16 @@
import lombok.*;
-@NoArgsConstructor @AllArgsConstructor
-@Getter @Setter @ToString
+/**
+ * This class represents a response to a start operation for a OneClick Mall inscription.
+ */
+@NoArgsConstructor
+@AllArgsConstructor
+@Getter
+@Setter
+@ToString
public class OneclickMallInscriptionStartResponse {
- private String token;
- private String urlWebpay;
+
+ private String token;
+ private String urlWebpay;
}
diff --git a/src/main/java/cl/transbank/webpay/oneclick/responses/OneclickMallTransactionAuthorizeResponse.java b/src/main/java/cl/transbank/webpay/oneclick/responses/OneclickMallTransactionAuthorizeResponse.java
index 91968d16..ec1033bd 100644
--- a/src/main/java/cl/transbank/webpay/oneclick/responses/OneclickMallTransactionAuthorizeResponse.java
+++ b/src/main/java/cl/transbank/webpay/oneclick/responses/OneclickMallTransactionAuthorizeResponse.java
@@ -1,30 +1,43 @@
package cl.transbank.webpay.oneclick.responses;
import cl.transbank.model.CardDetail;
-import lombok.*;
-
import java.util.List;
+import lombok.*;
-@NoArgsConstructor @AllArgsConstructor
-@Getter @Setter @ToString
+/**
+ * This class represents the response from the OneclickMallTransaction authorization request.
+ */
+@NoArgsConstructor
+@AllArgsConstructor
+@Getter
+@Setter
+@ToString
public class OneclickMallTransactionAuthorizeResponse {
- private String transactionDate;
- private String accountingDate;
- private CardDetail cardDetail;
- private String buyOrder;
- private List details;
- @NoArgsConstructor @AllArgsConstructor
- @Getter @Setter @ToString
- public class Detail {
- private double amount;
- private String status;
- private String authorizationCode;
- private String paymentTypeCode;
- private byte installmentsNumber;
- private String commerceCode;
- private String buyOrder;
- private byte responseCode;
- private double installmentsAmount;
- }
+ private String transactionDate;
+ private String accountingDate;
+ private CardDetail cardDetail;
+ private String buyOrder;
+ private List details;
+
+ /**
+ * This class represents the details of the OneclickMallTransaction authorization response.
+ */
+ @NoArgsConstructor
+ @AllArgsConstructor
+ @Getter
+ @Setter
+ @ToString
+ public class Detail {
+
+ private double amount;
+ private String status;
+ private String authorizationCode;
+ private String paymentTypeCode;
+ private byte installmentsNumber;
+ private String commerceCode;
+ private String buyOrder;
+ private byte responseCode;
+ private double installmentsAmount;
+ }
}
diff --git a/src/main/java/cl/transbank/webpay/oneclick/responses/OneclickMallTransactionCaptureResponse.java b/src/main/java/cl/transbank/webpay/oneclick/responses/OneclickMallTransactionCaptureResponse.java
index 18200f2b..2f8c47af 100644
--- a/src/main/java/cl/transbank/webpay/oneclick/responses/OneclickMallTransactionCaptureResponse.java
+++ b/src/main/java/cl/transbank/webpay/oneclick/responses/OneclickMallTransactionCaptureResponse.java
@@ -6,11 +6,18 @@
import lombok.Setter;
import lombok.ToString;
-@NoArgsConstructor @AllArgsConstructor
-@Getter @Setter @ToString
+/**
+ * This class represents a response to a capture operation for a OneClick Mall transaction.
+ */
+@NoArgsConstructor
+@AllArgsConstructor
+@Getter
+@Setter
+@ToString
public class OneclickMallTransactionCaptureResponse {
- private String authorizationCode;
- private String authorizationDate;
- private double capturedAmount;
- private byte responseCode;
+
+ private String authorizationCode;
+ private String authorizationDate;
+ private double capturedAmount;
+ private byte responseCode;
}
diff --git a/src/main/java/cl/transbank/webpay/oneclick/responses/OneclickMallTransactionRefundResponse.java b/src/main/java/cl/transbank/webpay/oneclick/responses/OneclickMallTransactionRefundResponse.java
index 01c58ed8..9c6892cd 100644
--- a/src/main/java/cl/transbank/webpay/oneclick/responses/OneclickMallTransactionRefundResponse.java
+++ b/src/main/java/cl/transbank/webpay/oneclick/responses/OneclickMallTransactionRefundResponse.java
@@ -1,7 +1,8 @@
package cl.transbank.webpay.oneclick.responses;
-
import cl.transbank.model.BaseRefundResponse;
-public class OneclickMallTransactionRefundResponse extends BaseRefundResponse {
-}
+/**
+ * This class represents a response to a refund operation for a OneClick Mall transaction.
+ */
+public class OneclickMallTransactionRefundResponse extends BaseRefundResponse {}
diff --git a/src/main/java/cl/transbank/webpay/oneclick/responses/OneclickMallTransactionStatusResponse.java b/src/main/java/cl/transbank/webpay/oneclick/responses/OneclickMallTransactionStatusResponse.java
index 12c9f2ed..97722dc4 100644
--- a/src/main/java/cl/transbank/webpay/oneclick/responses/OneclickMallTransactionStatusResponse.java
+++ b/src/main/java/cl/transbank/webpay/oneclick/responses/OneclickMallTransactionStatusResponse.java
@@ -1,31 +1,44 @@
package cl.transbank.webpay.oneclick.responses;
import cl.transbank.model.CardDetail;
-import lombok.*;
-
import java.util.List;
+import lombok.*;
-@NoArgsConstructor @AllArgsConstructor
-@Getter @Setter @ToString
+/**
+ * This class represents the response from the transaction status request in the Oneclick Mall service.
+ */
+@NoArgsConstructor
+@AllArgsConstructor
+@Getter
+@Setter
+@ToString
public class OneclickMallTransactionStatusResponse {
- private String buyOrder;
- private CardDetail cardDetail;
- private String accountingDate;
- private String transactionDate;
- private List details;
- @NoArgsConstructor @AllArgsConstructor
- @Getter @Setter @ToString
- public class Detail {
- private double amount;
- private String status;
- private String authorizationCode;
- private String paymentTypeCode;
- private byte responseCode;
- private byte installmentsNumber;
- private String commerceCode;
- private String buyOrder;
- private Double balance;
- private double installmentsAmount;
- }
+ private String buyOrder;
+ private CardDetail cardDetail;
+ private String accountingDate;
+ private String transactionDate;
+ private List details;
+
+ /**
+ * This class represents the details of a transaction in the Oneclick Mall service.
+ */
+ @NoArgsConstructor
+ @AllArgsConstructor
+ @Getter
+ @Setter
+ @ToString
+ public class Detail {
+
+ private double amount;
+ private String status;
+ private String authorizationCode;
+ private String paymentTypeCode;
+ private byte responseCode;
+ private byte installmentsNumber;
+ private String commerceCode;
+ private String buyOrder;
+ private Double balance;
+ private double installmentsAmount;
+ }
}
diff --git a/src/main/java/cl/transbank/webpay/transaccioncompleta/FullTransaction.java b/src/main/java/cl/transbank/webpay/transaccioncompleta/FullTransaction.java
index 65606dcc..f1459553 100644
--- a/src/main/java/cl/transbank/webpay/transaccioncompleta/FullTransaction.java
+++ b/src/main/java/cl/transbank/webpay/transaccioncompleta/FullTransaction.java
@@ -4,123 +4,367 @@
import cl.transbank.exception.TransbankException;
import cl.transbank.model.Options;
import cl.transbank.model.WebpayApiRequest;
+import cl.transbank.util.HttpUtil;
import cl.transbank.util.ValidationUtil;
+import cl.transbank.util.WebpayApiResource;
import cl.transbank.webpay.common.TransactionCaptureRequest;
import cl.transbank.webpay.common.TransactionRefundRequest;
-import cl.transbank.webpay.transaccioncompleta.requests.*;
-import cl.transbank.webpay.transaccioncompleta.responses.*;
-import cl.transbank.util.HttpUtil;
-import cl.transbank.util.WebpayApiResource;
import cl.transbank.webpay.common.WebpayOptions;
import cl.transbank.webpay.exception.*;
-
+import cl.transbank.webpay.transaccioncompleta.requests.*;
+import cl.transbank.webpay.transaccioncompleta.responses.*;
import java.io.IOException;
+/**
+ * The FullTransaction class extends the BaseTransaction class and provides methods for creating, committing,
+ * checking the status of, refunding, and capturing transactions. It also provides methods for creating installments
+ * for a transaction. This class also provides methods for configuring the transaction for different environments
+ * such as integration, production, testing, and testing deferred.
+ *
+ */
public class FullTransaction extends BaseTransaction {
- private static Options defaultOptions = null;
+ private static Options defaultOptions = null;
- public FullTransaction() {
- this.options = FullTransaction.defaultOptions!=null ? FullTransaction.defaultOptions : new WebpayOptions(IntegrationCommerceCodes.TRANSACCION_COMPLETA, IntegrationApiKeys.WEBPAY, IntegrationType.TEST);
- }
+ /**
+ * Default constructor. Uses default options if none are provided.
+ */
+ public FullTransaction() {
+ this.options =
+ FullTransaction.defaultOptions != null
+ ? FullTransaction.defaultOptions
+ : new WebpayOptions(
+ IntegrationCommerceCodes.TRANSACCION_COMPLETA,
+ IntegrationApiKeys.WEBPAY,
+ IntegrationType.TEST
+ );
+ }
- public FullTransaction(Options options) {
- this.options = options;
- }
+ /**
+ * Constructor with options. Uses provided options.
+ * @param options The options to use for this transaction.
+ */
+ public FullTransaction(Options options) {
+ this.options = options;
+ }
- public FullTransactionCreateResponse create(String buyOrder, String sessionId, double amount, short cvv, String cardNumber, String cardExpirationDate) throws IOException, TransactionCreateException {
- ValidationUtil.hasTextWithMaxLength(buyOrder, ApiConstants.BUY_ORDER_LENGTH, "buyOrder");
- ValidationUtil.hasTextWithMaxLength(sessionId, ApiConstants.SESSION_ID_LENGTH, "sessionId");
- ValidationUtil.hasTextWithMaxLength(cardNumber, ApiConstants.CARD_NUMBER_LENGTH, "cardNumber");
- ValidationUtil.hasTextWithMaxLength(cardExpirationDate, ApiConstants.CARD_EXPIRATION_DATE_LENGTH, "cardExpirationDate");
-
- String endpoint = String.format("%s/transactions", ApiConstants.WEBPAY_ENDPOINT);
- final WebpayApiRequest request = new TransactionCreateRequest(buyOrder, sessionId, amount, cardNumber, cvv, cardExpirationDate);
- try {
- return WebpayApiResource.execute(endpoint, HttpUtil.RequestMethod.POST, request, options, FullTransactionCreateResponse.class);
- } catch (TransbankException e) {
- throw new TransactionCreateException(e);
- }
- }
+ /**
+ * Creates a new FullTransaction.
+ * @param buyOrder The buy order.
+ * @param sessionId The session id.
+ * @param amount The amount.
+ * @param cvv The cvv of the card.
+ * @param cardNumber The number of the card.
+ * @param cardExpirationDate The expiration date of the card.
+ * @return The response of the FullTransaction creation.
+ * @throws IOException If there's an error in the communication with the server.
+ * @throws TransactionCreateException If there's an error in the creation of the transaction.
+ */
+ public FullTransactionCreateResponse create(
+ String buyOrder,
+ String sessionId,
+ double amount,
+ short cvv,
+ String cardNumber,
+ String cardExpirationDate
+ ) throws IOException, TransactionCreateException {
+ ValidationUtil.hasTextWithMaxLength(
+ buyOrder,
+ ApiConstants.BUY_ORDER_LENGTH,
+ "buyOrder"
+ );
+ ValidationUtil.hasTextWithMaxLength(
+ sessionId,
+ ApiConstants.SESSION_ID_LENGTH,
+ "sessionId"
+ );
+ ValidationUtil.hasTextWithMaxLength(
+ cardNumber,
+ ApiConstants.CARD_NUMBER_LENGTH,
+ "cardNumber"
+ );
+ ValidationUtil.hasTextWithMaxLength(
+ cardExpirationDate,
+ ApiConstants.CARD_EXPIRATION_DATE_LENGTH,
+ "cardExpirationDate"
+ );
- public FullTransactionInstallmentResponse installments(String token, byte installmentsNumber) throws IOException, TransactionInstallmentException {
- ValidationUtil.hasTextWithMaxLength(token, ApiConstants.TOKEN_LENGTH, "token");
- String endpoint = String.format("%s/transactions/%s/installments", ApiConstants.WEBPAY_ENDPOINT, token);
- final WebpayApiRequest request = new TransactionInstallmentsRequest(installmentsNumber);
- try {
- return WebpayApiResource.execute(endpoint, HttpUtil.RequestMethod.POST, request, options, FullTransactionInstallmentResponse.class);
- } catch (TransbankException e) {
- throw new TransactionInstallmentException(e);
- }
+ String endpoint = String.format(
+ "%s/transactions",
+ ApiConstants.WEBPAY_ENDPOINT
+ );
+ final WebpayApiRequest request = new TransactionCreateRequest(
+ buyOrder,
+ sessionId,
+ amount,
+ cardNumber,
+ cvv,
+ cardExpirationDate
+ );
+ try {
+ return WebpayApiResource.execute(
+ endpoint,
+ HttpUtil.RequestMethod.POST,
+ request,
+ options,
+ FullTransactionCreateResponse.class
+ );
+ } catch (TransbankException e) {
+ throw new TransactionCreateException(e);
}
+ }
- public FullTransactionCommitResponse commit(String token, Long idQueryInstallments, Byte deferredPeriodIndex, Boolean gracePeriod) throws IOException, TransactionCommitException {
- ValidationUtil.hasTextWithMaxLength(token, ApiConstants.TOKEN_LENGTH, "token");
- String endpoint = String.format("%s/transactions/%s", ApiConstants.WEBPAY_ENDPOINT, token);
- final WebpayApiRequest request = new TransactionCommitRequest(idQueryInstallments, deferredPeriodIndex, gracePeriod);
- try {
- return WebpayApiResource.execute(endpoint, HttpUtil.RequestMethod.PUT, request, options, FullTransactionCommitResponse.class);
- } catch (TransbankException e) {
- throw new TransactionCommitException(e);
- }
+ /**
+ * Starts the process of creating installments for the transaction.
+ * @param token The token of the transaction.
+ * @param installmentsNumber The number of installments.
+ * @return The response of the installments creation process.
+ * @throws TransactionInstallmentException If there's an error in the creation of the installments.
+ * @throws IOException If there's an error in the communication with the server.
+ */
+ public FullTransactionInstallmentResponse installments(
+ String token,
+ byte installmentsNumber
+ ) throws IOException, TransactionInstallmentException {
+ ValidationUtil.hasTextWithMaxLength(
+ token,
+ ApiConstants.TOKEN_LENGTH,
+ ApiConstants.TOKEN_TEXT
+ );
+ String endpoint = String.format(
+ "%s/transactions/%s/installments",
+ ApiConstants.WEBPAY_ENDPOINT,
+ token
+ );
+ final WebpayApiRequest request = new TransactionInstallmentsRequest(
+ installmentsNumber
+ );
+ try {
+ return WebpayApiResource.execute(
+ endpoint,
+ HttpUtil.RequestMethod.POST,
+ request,
+ options,
+ FullTransactionInstallmentResponse.class
+ );
+ } catch (TransbankException e) {
+ throw new TransactionInstallmentException(e);
}
+ }
- public FullTransactionStatusResponse status(String token) throws IOException, TransactionStatusException {
- ValidationUtil.hasTextWithMaxLength(token, ApiConstants.TOKEN_LENGTH, "token");
- String endpoint = String.format("%s/transactions/%s", ApiConstants.WEBPAY_ENDPOINT, token);
- try {
- return WebpayApiResource.execute(endpoint, HttpUtil.RequestMethod.GET, options, FullTransactionStatusResponse.class);
- } catch (TransbankException e) {
- throw new TransactionStatusException(e);
- }
+ /**
+ * Commits the transaction.
+ * @param token The token of the transaction.
+ * @param idQueryInstallments The id of the query installments.
+ * @param deferredPeriodIndex The index of the deferred period.
+ * @param gracePeriod The grace period.
+ * @return The response of the commit process.
+ * @throws IOException If there's an error in the communication with the server.
+ * @throws TransactionCommitException If there's an error in the commit process.
+ */
+ public FullTransactionCommitResponse commit(
+ String token,
+ Long idQueryInstallments,
+ Byte deferredPeriodIndex,
+ Boolean gracePeriod
+ ) throws IOException, TransactionCommitException {
+ ValidationUtil.hasTextWithMaxLength(
+ token,
+ ApiConstants.TOKEN_LENGTH,
+ ApiConstants.TOKEN_TEXT
+ );
+ String endpoint = String.format(
+ "%s/transactions/%s",
+ ApiConstants.WEBPAY_ENDPOINT,
+ token
+ );
+ final WebpayApiRequest request = new TransactionCommitRequest(
+ idQueryInstallments,
+ deferredPeriodIndex,
+ gracePeriod
+ );
+ try {
+ return WebpayApiResource.execute(
+ endpoint,
+ HttpUtil.RequestMethod.PUT,
+ request,
+ options,
+ FullTransactionCommitResponse.class
+ );
+ } catch (TransbankException e) {
+ throw new TransactionCommitException(e);
}
+ }
- public FullTransactionRefundResponse refund(String token, double amount) throws IOException, TransactionRefundException {
- ValidationUtil.hasTextWithMaxLength(token, ApiConstants.TOKEN_LENGTH, "token");
- String endpoint = String.format("%s/transactions/%s/refunds", ApiConstants.WEBPAY_ENDPOINT, token);
- final WebpayApiRequest request = new TransactionRefundRequest(amount);
- try {
- return WebpayApiResource.execute(endpoint, HttpUtil.RequestMethod.POST, request, options, FullTransactionRefundResponse.class);
- } catch (TransbankException e) {
- throw new TransactionRefundException(e);
- }
+ /**
+ * Gets the status of the transaction.
+ * @param token The token of the transaction.
+ * @return The status of the transaction.
+ * @throws IOException If there's an error in the communication with the server.
+ * @throws TransactionStatusException If there's an error in the status process.
+ */
+ public FullTransactionStatusResponse status(String token)
+ throws IOException, TransactionStatusException {
+ ValidationUtil.hasTextWithMaxLength(
+ token,
+ ApiConstants.TOKEN_LENGTH,
+ ApiConstants.TOKEN_TEXT
+ );
+ String endpoint = String.format(
+ "%s/transactions/%s",
+ ApiConstants.WEBPAY_ENDPOINT,
+ token
+ );
+ try {
+ return WebpayApiResource.execute(
+ endpoint,
+ HttpUtil.RequestMethod.GET,
+ options,
+ FullTransactionStatusResponse.class
+ );
+ } catch (TransbankException e) {
+ throw new TransactionStatusException(e);
}
+ }
- public FullTransactionCaptureResponse capture(String token, String buyOrder, String authorizationCode, double captureAmount) throws IOException, TransactionCaptureException {
- ValidationUtil.hasTextWithMaxLength(token, ApiConstants.TOKEN_LENGTH, "token");
- ValidationUtil.hasTextWithMaxLength(buyOrder, ApiConstants.BUY_ORDER_LENGTH, "buyOrder");
- ValidationUtil.hasTextWithMaxLength(authorizationCode, ApiConstants.AUTHORIZATION_CODE_LENGTH, "authorizationCode");
-
- String endpoint = String.format("%s/transactions/%s/capture", ApiConstants.WEBPAY_ENDPOINT, token);
- final WebpayApiRequest request = new TransactionCaptureRequest(buyOrder, authorizationCode, captureAmount);
- try {
- return WebpayApiResource.execute(endpoint, HttpUtil.RequestMethod.PUT, request, options, FullTransactionCaptureResponse.class);
- } catch (TransbankException e){
- throw new TransactionCaptureException(e);
- }
+ /**
+ * Starts the process of refunding the transaction.
+ * @param token The token of the transaction.
+ * @param amount The amount to be refunded.
+ * @return The response of the refund process.
+ * @throws IOException If there's an error in the communication with the server.
+ * @throws TransactionRefundException If there's an error in the refund process.
+ */
+ public FullTransactionRefundResponse refund(String token, double amount)
+ throws IOException, TransactionRefundException {
+ ValidationUtil.hasTextWithMaxLength(
+ token,
+ ApiConstants.TOKEN_LENGTH,
+ ApiConstants.TOKEN_TEXT
+ );
+ String endpoint = String.format(
+ "%s/transactions/%s/refunds",
+ ApiConstants.WEBPAY_ENDPOINT,
+ token
+ );
+ final WebpayApiRequest request = new TransactionRefundRequest(amount);
+ try {
+ return WebpayApiResource.execute(
+ endpoint,
+ HttpUtil.RequestMethod.POST,
+ request,
+ options,
+ FullTransactionRefundResponse.class
+ );
+ } catch (TransbankException e) {
+ throw new TransactionRefundException(e);
}
+ }
+ /**
+ * Captures the transaction.
+ * @param token The token of the transaction.
+ * @param buyOrder The buy order of the transaction.
+ * @param authorizationCode The authorization code of the transaction.
+ * @param captureAmount The amount to be captured.
+ * @return The response of the capture process.
+ * @throws IOException If there's an error in the communication with the server.
+ * @throws TransactionCaptureException If there's an error in the capture process.
+ */
+ public FullTransactionCaptureResponse capture(
+ String token,
+ String buyOrder,
+ String authorizationCode,
+ double captureAmount
+ ) throws IOException, TransactionCaptureException {
+ ValidationUtil.hasTextWithMaxLength(
+ token,
+ ApiConstants.TOKEN_LENGTH,
+ ApiConstants.TOKEN_TEXT
+ );
+ ValidationUtil.hasTextWithMaxLength(
+ buyOrder,
+ ApiConstants.BUY_ORDER_LENGTH,
+ "buyOrder"
+ );
+ ValidationUtil.hasTextWithMaxLength(
+ authorizationCode,
+ ApiConstants.AUTHORIZATION_CODE_LENGTH,
+ "authorizationCode"
+ );
- /*
+ String endpoint = String.format(
+ "%s/transactions/%s/capture",
+ ApiConstants.WEBPAY_ENDPOINT,
+ token
+ );
+ final WebpayApiRequest request = new TransactionCaptureRequest(
+ buyOrder,
+ authorizationCode,
+ captureAmount
+ );
+ try {
+ return WebpayApiResource.execute(
+ endpoint,
+ HttpUtil.RequestMethod.PUT,
+ request,
+ options,
+ FullTransactionCaptureResponse.class
+ );
+ } catch (TransbankException e) {
+ throw new TransactionCaptureException(e);
+ }
+ }
+
+ /*
|--------------------------------------------------------------------------
| Environment Configuration
|--------------------------------------------------------------------------
*/
- public static void configureForIntegration(String commerceCode, String apiKey){
- FullTransaction.defaultOptions = new WebpayOptions(commerceCode, apiKey, IntegrationType.TEST);
- }
+ /**
+ * Configures the transaction for integration environment.
+ * @param commerceCode The commerce code.
+ * @param apiKey The api key.
+ */
+ public static void configureForIntegration(
+ String commerceCode,
+ String apiKey
+ ) {
+ FullTransaction.defaultOptions =
+ new WebpayOptions(commerceCode, apiKey, IntegrationType.TEST);
+ }
- public static void configureForProduction(String commerceCode, String apiKey){
- FullTransaction.defaultOptions = new WebpayOptions(commerceCode, apiKey, IntegrationType.LIVE);
- }
-
- public static void configureForTesting(){
- configureForIntegration(IntegrationCommerceCodes.TRANSACCION_COMPLETA, IntegrationApiKeys.WEBPAY);
- }
+ /**
+ * Configures the transaction for production environment.
+ * @param commerceCode The commerce code.
+ * @param apiKey The api key.
+ */
+ public static void configureForProduction(
+ String commerceCode,
+ String apiKey
+ ) {
+ FullTransaction.defaultOptions =
+ new WebpayOptions(commerceCode, apiKey, IntegrationType.LIVE);
+ }
- public static void configureForTestingDeferred(){
- configureForIntegration(IntegrationCommerceCodes.TRANSACCION_COMPLETA_DEFERRED, IntegrationApiKeys.WEBPAY);
- }
+ /**
+ * Configures the transaction for testing environment.
+ */
+ public static void configureForTesting() {
+ configureForIntegration(
+ IntegrationCommerceCodes.TRANSACCION_COMPLETA,
+ IntegrationApiKeys.WEBPAY
+ );
+ }
+ /**
+ * Configures the transaction for testing deferred environment.
+ */
+ public static void configureForTestingDeferred() {
+ configureForIntegration(
+ IntegrationCommerceCodes.TRANSACCION_COMPLETA_DEFERRED,
+ IntegrationApiKeys.WEBPAY
+ );
+ }
}
diff --git a/src/main/java/cl/transbank/webpay/transaccioncompleta/MallFullTransaction.java b/src/main/java/cl/transbank/webpay/transaccioncompleta/MallFullTransaction.java
index 82a6c0a5..b0224ed9 100644
--- a/src/main/java/cl/transbank/webpay/transaccioncompleta/MallFullTransaction.java
+++ b/src/main/java/cl/transbank/webpay/transaccioncompleta/MallFullTransaction.java
@@ -5,144 +5,358 @@
import cl.transbank.model.MallTransactionCreateDetails;
import cl.transbank.model.Options;
import cl.transbank.model.WebpayApiRequest;
+import cl.transbank.util.HttpUtil;
import cl.transbank.util.ValidationUtil;
+import cl.transbank.util.WebpayApiResource;
import cl.transbank.webpay.common.MallTransactionCaptureRequest;
import cl.transbank.webpay.common.MallTransactionRefundRequest;
+import cl.transbank.webpay.common.WebpayOptions;
+import cl.transbank.webpay.exception.*;
import cl.transbank.webpay.transaccioncompleta.model.*;
import cl.transbank.webpay.transaccioncompleta.requests.*;
import cl.transbank.webpay.transaccioncompleta.responses.*;
-import cl.transbank.util.HttpUtil;
-import cl.transbank.util.WebpayApiResource;
-import cl.transbank.webpay.common.WebpayOptions;
-import cl.transbank.webpay.exception.*;
import java.io.IOException;
+/**
+ * This class provides methods to configure and perform transactions with the MallFullTransaction service.
+ */
public class MallFullTransaction extends BaseTransaction {
- private static Options defaultOptions = null;
+ private static Options defaultOptions = null;
- public MallFullTransaction() {
- this.options = MallFullTransaction.defaultOptions!=null ? MallFullTransaction.defaultOptions : new WebpayOptions(IntegrationCommerceCodes.TRANSACCION_COMPLETA_MALL, IntegrationApiKeys.WEBPAY, IntegrationType.TEST);
- }
+ /**
+ * Default constructor. Uses default options if none are provided.
+ */
+ public MallFullTransaction() {
+ this.options =
+ MallFullTransaction.defaultOptions != null
+ ? MallFullTransaction.defaultOptions
+ : new WebpayOptions(
+ IntegrationCommerceCodes.TRANSACCION_COMPLETA_MALL,
+ IntegrationApiKeys.WEBPAY,
+ IntegrationType.TEST
+ );
+ }
- public MallFullTransaction(Options options) {
- this.options = options;
- }
+ /**
+ * Constructor with options. Uses provided options.
+ * @param options The options to use for this transaction.
+ */
+ public MallFullTransaction(Options options) {
+ this.options = options;
+ }
- public MallFullTransactionCreateResponse create(String buyOrder, String sessionId, String cardNumber, String cardExpirationDate, MallTransactionCreateDetails details) throws IOException, TransactionCreateException {
- return create(buyOrder, sessionId, cardNumber, cardExpirationDate, details, null);
- }
+ public MallFullTransactionCreateResponse create(
+ String buyOrder,
+ String sessionId,
+ String cardNumber,
+ String cardExpirationDate,
+ MallTransactionCreateDetails details
+ ) throws IOException, TransactionCreateException {
+ return create(
+ buyOrder,
+ sessionId,
+ cardNumber,
+ cardExpirationDate,
+ details,
+ null
+ );
+ }
+
+ public MallFullTransactionCreateResponse create(
+ String buyOrder,
+ String sessionId,
+ String cardNumber,
+ String cardExpirationDate,
+ MallTransactionCreateDetails details,
+ Short cvv
+ ) throws IOException, TransactionCreateException {
+ ValidationUtil.hasTextWithMaxLength(
+ buyOrder,
+ ApiConstants.BUY_ORDER_LENGTH,
+ ApiConstants.BUY_ORDER_TEXT
+ );
+ ValidationUtil.hasTextWithMaxLength(
+ sessionId,
+ ApiConstants.SESSION_ID_LENGTH,
+ "sessionId"
+ );
+ ValidationUtil.hasTextWithMaxLength(
+ cardNumber,
+ ApiConstants.CARD_NUMBER_LENGTH,
+ "cardNumber"
+ );
+ ValidationUtil.hasTextWithMaxLength(
+ cardExpirationDate,
+ ApiConstants.CARD_EXPIRATION_DATE_LENGTH,
+ "cardExpirationDate"
+ );
+ ValidationUtil.hasElements(details.getDetails(), "details");
- public MallFullTransactionCreateResponse create(String buyOrder, String sessionId, String cardNumber, String cardExpirationDate, MallTransactionCreateDetails details, Short cvv) throws IOException, TransactionCreateException {
- ValidationUtil.hasTextWithMaxLength(buyOrder, ApiConstants.BUY_ORDER_LENGTH, "buyOrder");
- ValidationUtil.hasTextWithMaxLength(sessionId, ApiConstants.SESSION_ID_LENGTH, "sessionId");
- ValidationUtil.hasTextWithMaxLength(cardNumber, ApiConstants.CARD_NUMBER_LENGTH, "cardNumber");
- ValidationUtil.hasTextWithMaxLength(cardExpirationDate, ApiConstants.CARD_EXPIRATION_DATE_LENGTH, "cardExpirationDate");
- ValidationUtil.hasElements(details.getDetails(), "details");
-
- for(int i=0; i detailList = new ArrayList<>();
- private MallTransactionCommitDetails() {}
+ private List detailList = new ArrayList<>();
- public static MallTransactionCommitDetails build() {
- return new MallTransactionCommitDetails();
- }
+ private MallTransactionCommitDetails() {}
- public static MallTransactionCommitDetails build(String commerceCode, String buyOrder,Long idQueryInstallments,Byte deferredPeriodIndex, boolean gracePeriod) {
- return MallTransactionCommitDetails.build().add(commerceCode, buyOrder, idQueryInstallments, deferredPeriodIndex, gracePeriod);
- }
+ /**
+ * Builds a new MallTransactionCommitDetails.
+ * @return A new MallTransactionCommitDetails.
+ */
+ public static MallTransactionCommitDetails build() {
+ return new MallTransactionCommitDetails();
+ }
- public MallTransactionCommitDetails add(String commerceCode, String buyOrder, Long idQueryInstallments,Byte deferredPeriodIndex, boolean gracePeriod) {
- detailList.add(new MallTransactionCommitDetails.Detail(commerceCode, buyOrder, idQueryInstallments, deferredPeriodIndex, gracePeriod));
- return this;
- }
+ /**
+ * Builds a new MallTransactionCommitDetails with the provided parameters.
+ * @param commerceCode The commerce code.
+ * @param buyOrder The buy order.
+ * @param idQueryInstallments The id query installments.
+ * @param deferredPeriodIndex The deferred period index.
+ * @param gracePeriod The grace period.
+ * @return A new MallTransactionCommitDetails.
+ */
+ public static MallTransactionCommitDetails build(
+ String commerceCode,
+ String buyOrder,
+ Long idQueryInstallments,
+ Byte deferredPeriodIndex,
+ boolean gracePeriod
+ ) {
+ return MallTransactionCommitDetails
+ .build()
+ .add(
+ commerceCode,
+ buyOrder,
+ idQueryInstallments,
+ deferredPeriodIndex,
+ gracePeriod
+ );
+ }
- public boolean remove(String commerceCode, String buyOrder, Long idQueryInstallments,Byte deferredPeriodIndex, boolean gracePeriod) {
- return getDetails().remove(new MallTransactionCommitDetails.Detail(commerceCode, buyOrder, idQueryInstallments, deferredPeriodIndex, gracePeriod));
- }
+ /**
+ * Adds a new detail to the MallTransactionCommitDetails.
+ * @param commerceCode The commerce code.
+ * @param buyOrder The buy order.
+ * @param idQueryInstallments The id query installments.
+ * @param deferredPeriodIndex The deferred period index.
+ * @param gracePeriod The grace period.
+ * @return The MallTransactionCommitDetails with the new detail added.
+ */
+ public MallTransactionCommitDetails add(
+ String commerceCode,
+ String buyOrder,
+ Long idQueryInstallments,
+ Byte deferredPeriodIndex,
+ boolean gracePeriod
+ ) {
+ detailList.add(
+ new MallTransactionCommitDetails.Detail(
+ commerceCode,
+ buyOrder,
+ idQueryInstallments,
+ deferredPeriodIndex,
+ gracePeriod
+ )
+ );
+ return this;
+ }
- public List getDetails() {
- return Collections.unmodifiableList(detailList);
- }
+ /**
+ * Removes a detail from the MallTransactionCommitDetails.
+ * @param commerceCode The commerce code.
+ * @param buyOrder The buy order.
+ * @param idQueryInstallments The id query installments.
+ * @param deferredPeriodIndex The deferred period index.
+ * @param gracePeriod The grace period.
+ * @return True if the detail was removed, false otherwise.
+ */
+ public boolean remove(
+ String commerceCode,
+ String buyOrder,
+ Long idQueryInstallments,
+ Byte deferredPeriodIndex,
+ boolean gracePeriod
+ ) {
+ return getDetails()
+ .remove(
+ new MallTransactionCommitDetails.Detail(
+ commerceCode,
+ buyOrder,
+ idQueryInstallments,
+ deferredPeriodIndex,
+ gracePeriod
+ )
+ );
+ }
+
+ /**
+ * Gets the details of the MallTransactionCommitDetails.
+ * @return The details of the MallTransactionCommitDetails.
+ */
+ public List getDetails() {
+ return Collections.unmodifiableList(detailList);
+ }
- @Data
- @EqualsAndHashCode(callSuper=true)
- @ToString(callSuper=true)
- @AllArgsConstructor
- public class Detail extends TransactionCommitRequest {
- private String commerceCode;
- private String buyOrder;
+ /**
+ * This class represents the details of a MallTransactionCommit.
+ */
+ @Data
+ @EqualsAndHashCode(callSuper = true)
+ @ToString(callSuper = true)
+ @AllArgsConstructor
+ public class Detail extends TransactionCommitRequest {
- Detail(String commerceCode, String buyOrder,Long idQueryInstallments,Byte deferredPeriodIndex,boolean gracePeriod){
- super(idQueryInstallments, deferredPeriodIndex, gracePeriod);
- this.commerceCode = commerceCode;
- this.buyOrder = buyOrder;
- }
+ private String commerceCode;
+ private String buyOrder;
+ Detail(
+ String commerceCode,
+ String buyOrder,
+ Long idQueryInstallments,
+ Byte deferredPeriodIndex,
+ boolean gracePeriod
+ ) {
+ super(idQueryInstallments, deferredPeriodIndex, gracePeriod);
+ this.commerceCode = commerceCode;
+ this.buyOrder = buyOrder;
}
+ }
}
diff --git a/src/main/java/cl/transbank/webpay/transaccioncompleta/requests/MallFullTransactionCommitRequest.java b/src/main/java/cl/transbank/webpay/transaccioncompleta/requests/MallFullTransactionCommitRequest.java
index 845d2c72..335a2053 100644
--- a/src/main/java/cl/transbank/webpay/transaccioncompleta/requests/MallFullTransactionCommitRequest.java
+++ b/src/main/java/cl/transbank/webpay/transaccioncompleta/requests/MallFullTransactionCommitRequest.java
@@ -2,16 +2,18 @@
import cl.transbank.model.WebpayApiRequest;
import cl.transbank.webpay.transaccioncompleta.model.MallTransactionCommitDetails;
-import lombok.*;
-
import java.util.List;
+import lombok.*;
+/**
+ * This class represents a request to commit a full transaction in the mall.
+ */
@NoArgsConstructor
@AllArgsConstructor
@Data
-@EqualsAndHashCode(callSuper=true)
-@ToString(callSuper=true)
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
public class MallFullTransactionCommitRequest extends WebpayApiRequest {
- private List details;
+ private List details;
}
diff --git a/src/main/java/cl/transbank/webpay/transaccioncompleta/requests/MallFullTransactionCreateRequest.java b/src/main/java/cl/transbank/webpay/transaccioncompleta/requests/MallFullTransactionCreateRequest.java
index 67cd1745..6964eb4a 100644
--- a/src/main/java/cl/transbank/webpay/transaccioncompleta/requests/MallFullTransactionCreateRequest.java
+++ b/src/main/java/cl/transbank/webpay/transaccioncompleta/requests/MallFullTransactionCreateRequest.java
@@ -2,20 +2,23 @@
import cl.transbank.model.MallTransactionCreateDetails;
import cl.transbank.model.WebpayApiRequest;
-import lombok.*;
-
import java.util.List;
+import lombok.*;
+/**
+ * This class represents a request to create a full transaction for a mall.
+ */
@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
@ToString
public class MallFullTransactionCreateRequest extends WebpayApiRequest {
- private String buyOrder;
- private String sessionId;
- private String cardNumber;
- private String cardExpirationDate;
- private List details;
- private Short cvv;
+
+ private String buyOrder;
+ private String sessionId;
+ private String cardNumber;
+ private String cardExpirationDate;
+ private List details;
+ private Short cvv;
}
diff --git a/src/main/java/cl/transbank/webpay/transaccioncompleta/requests/MallFullTransactionInstallmentsRequest.java b/src/main/java/cl/transbank/webpay/transaccioncompleta/requests/MallFullTransactionInstallmentsRequest.java
index 2bd5dfa9..bd5a6651 100644
--- a/src/main/java/cl/transbank/webpay/transaccioncompleta/requests/MallFullTransactionInstallmentsRequest.java
+++ b/src/main/java/cl/transbank/webpay/transaccioncompleta/requests/MallFullTransactionInstallmentsRequest.java
@@ -3,13 +3,17 @@
import cl.transbank.model.WebpayApiRequest;
import lombok.*;
+/**
+ * This class represents a request to get the installments information for a Mall Full Transaction.
+ */
@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
@ToString
public class MallFullTransactionInstallmentsRequest extends WebpayApiRequest {
- private String commerceCode;
- private String buyOrder;
- private byte installmentsNumber;
+
+ private String commerceCode;
+ private String buyOrder;
+ private byte installmentsNumber;
}
diff --git a/src/main/java/cl/transbank/webpay/transaccioncompleta/requests/TransactionCommitRequest.java b/src/main/java/cl/transbank/webpay/transaccioncompleta/requests/TransactionCommitRequest.java
index f5d62022..24cfba37 100644
--- a/src/main/java/cl/transbank/webpay/transaccioncompleta/requests/TransactionCommitRequest.java
+++ b/src/main/java/cl/transbank/webpay/transaccioncompleta/requests/TransactionCommitRequest.java
@@ -3,13 +3,17 @@
import cl.transbank.model.WebpayApiRequest;
import lombok.*;
+/**
+ * This class represents a request to commit a transaction.
+ */
@Data
-@EqualsAndHashCode(callSuper=true)
-@ToString(callSuper=true)
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
@AllArgsConstructor
@NoArgsConstructor
public class TransactionCommitRequest extends WebpayApiRequest {
- private Long idQueryInstallments;
- private Byte deferredPeriodIndex;
- private Boolean gracePeriod;
+
+ private Long idQueryInstallments;
+ private Byte deferredPeriodIndex;
+ private Boolean gracePeriod;
}
diff --git a/src/main/java/cl/transbank/webpay/transaccioncompleta/requests/TransactionCreateRequest.java b/src/main/java/cl/transbank/webpay/transaccioncompleta/requests/TransactionCreateRequest.java
index 5bed49e4..55457080 100644
--- a/src/main/java/cl/transbank/webpay/transaccioncompleta/requests/TransactionCreateRequest.java
+++ b/src/main/java/cl/transbank/webpay/transaccioncompleta/requests/TransactionCreateRequest.java
@@ -3,14 +3,20 @@
import cl.transbank.model.WebpayApiRequest;
import lombok.*;
-@NoArgsConstructor @AllArgsConstructor @Getter @Setter @ToString
-public
-class TransactionCreateRequest extends WebpayApiRequest {
- private String buyOrder;
- private String sessionId;
- private double amount;
- private String cardNumber;
- private short cvv;
- private String cardExpirationDate;
-
+/**
+ * This class represents a request to create a transaction.
+ */
+@NoArgsConstructor
+@AllArgsConstructor
+@Getter
+@Setter
+@ToString
+public class TransactionCreateRequest extends WebpayApiRequest {
+
+ private String buyOrder;
+ private String sessionId;
+ private double amount;
+ private String cardNumber;
+ private short cvv;
+ private String cardExpirationDate;
}
diff --git a/src/main/java/cl/transbank/webpay/transaccioncompleta/requests/TransactionInstallmentsRequest.java b/src/main/java/cl/transbank/webpay/transaccioncompleta/requests/TransactionInstallmentsRequest.java
index f5c00ae5..ee3d76bd 100644
--- a/src/main/java/cl/transbank/webpay/transaccioncompleta/requests/TransactionInstallmentsRequest.java
+++ b/src/main/java/cl/transbank/webpay/transaccioncompleta/requests/TransactionInstallmentsRequest.java
@@ -3,11 +3,15 @@
import cl.transbank.model.WebpayApiRequest;
import lombok.*;
+/**
+ * This class represents a request to get the installments information for a Transaccion Completa transaction.
+ */
@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
@ToString
public class TransactionInstallmentsRequest extends WebpayApiRequest {
- private byte installmentsNumber;
+
+ private byte installmentsNumber;
}
diff --git a/src/main/java/cl/transbank/webpay/transaccioncompleta/responses/FullTransactionCaptureResponse.java b/src/main/java/cl/transbank/webpay/transaccioncompleta/responses/FullTransactionCaptureResponse.java
index d8ebc138..4fdd463c 100644
--- a/src/main/java/cl/transbank/webpay/transaccioncompleta/responses/FullTransactionCaptureResponse.java
+++ b/src/main/java/cl/transbank/webpay/transaccioncompleta/responses/FullTransactionCaptureResponse.java
@@ -2,13 +2,18 @@
import lombok.*;
+/**
+ * This class represents a response to a capture operation for a full transaction.
+ */
@NoArgsConstructor
@AllArgsConstructor
-@Getter @Setter
+@Getter
+@Setter
@ToString
public class FullTransactionCaptureResponse {
- private String authorizationCode;
- private String authorizationDate;
- private double capturedAmount;
- private byte responseCode;
+
+ private String authorizationCode;
+ private String authorizationDate;
+ private double capturedAmount;
+ private byte responseCode;
}
diff --git a/src/main/java/cl/transbank/webpay/transaccioncompleta/responses/FullTransactionCommitResponse.java b/src/main/java/cl/transbank/webpay/transaccioncompleta/responses/FullTransactionCommitResponse.java
index b677903c..1e609cbf 100644
--- a/src/main/java/cl/transbank/webpay/transaccioncompleta/responses/FullTransactionCommitResponse.java
+++ b/src/main/java/cl/transbank/webpay/transaccioncompleta/responses/FullTransactionCommitResponse.java
@@ -1,6 +1,7 @@
package cl.transbank.webpay.transaccioncompleta.responses;
-public class FullTransactionCommitResponse extends FullTransactionStatusResponse {
-
-}
-
+/**
+ * This class represents a response to a commit operation for a Full transaction.
+ */
+public class FullTransactionCommitResponse
+ extends FullTransactionStatusResponse {}
diff --git a/src/main/java/cl/transbank/webpay/transaccioncompleta/responses/FullTransactionCreateResponse.java b/src/main/java/cl/transbank/webpay/transaccioncompleta/responses/FullTransactionCreateResponse.java
index 1c13e124..74bdf180 100644
--- a/src/main/java/cl/transbank/webpay/transaccioncompleta/responses/FullTransactionCreateResponse.java
+++ b/src/main/java/cl/transbank/webpay/transaccioncompleta/responses/FullTransactionCreateResponse.java
@@ -2,11 +2,15 @@
import lombok.*;
+/**
+ * This class represents a response to a create operation for a Full Transaction.
+ */
@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
@ToString
public class FullTransactionCreateResponse {
- private String token;
+
+ private String token;
}
diff --git a/src/main/java/cl/transbank/webpay/transaccioncompleta/responses/FullTransactionInstallmentResponse.java b/src/main/java/cl/transbank/webpay/transaccioncompleta/responses/FullTransactionInstallmentResponse.java
index 90017269..1db8419b 100644
--- a/src/main/java/cl/transbank/webpay/transaccioncompleta/responses/FullTransactionInstallmentResponse.java
+++ b/src/main/java/cl/transbank/webpay/transaccioncompleta/responses/FullTransactionInstallmentResponse.java
@@ -1,23 +1,33 @@
package cl.transbank.webpay.transaccioncompleta.responses;
-import lombok.*;
-
import java.util.List;
+import lombok.*;
+/**
+ * This class represents the details of the OneclickMallTransaction authorization response.
+ */
@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
@ToString
public class FullTransactionInstallmentResponse {
- private double installmentsAmount;
- private Long idQueryInstallments;
- private List deferredPeriods;
- @NoArgsConstructor @AllArgsConstructor
- @Getter @Setter @ToString
- public class DeferredPeriod {
- private double amount;
- private byte period;
- }
+ private double installmentsAmount;
+ private Long idQueryInstallments;
+ private List deferredPeriods;
+
+ /**
+ * This class represents the details of the FullTransaction installment response.
+ */
+ @NoArgsConstructor
+ @AllArgsConstructor
+ @Getter
+ @Setter
+ @ToString
+ public class DeferredPeriod {
+
+ private double amount;
+ private byte period;
+ }
}
diff --git a/src/main/java/cl/transbank/webpay/transaccioncompleta/responses/FullTransactionRefundResponse.java b/src/main/java/cl/transbank/webpay/transaccioncompleta/responses/FullTransactionRefundResponse.java
index a8edbde3..9bbf8adc 100644
--- a/src/main/java/cl/transbank/webpay/transaccioncompleta/responses/FullTransactionRefundResponse.java
+++ b/src/main/java/cl/transbank/webpay/transaccioncompleta/responses/FullTransactionRefundResponse.java
@@ -2,17 +2,21 @@
import lombok.*;
+/**
+ * This class represents the response of a refund operation in a Full Transaction.
+ */
@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
@ToString
public class FullTransactionRefundResponse {
- private String type;
- private String authorizationCode;
- private String authorizationDate;
- private double nullifiedAmount;
- private double balance;
- private byte responseCode;
- private Double prepaidBalance;
+
+ private String type;
+ private String authorizationCode;
+ private String authorizationDate;
+ private double nullifiedAmount;
+ private double balance;
+ private byte responseCode;
+ private Double prepaidBalance;
}
diff --git a/src/main/java/cl/transbank/webpay/transaccioncompleta/responses/FullTransactionStatusResponse.java b/src/main/java/cl/transbank/webpay/transaccioncompleta/responses/FullTransactionStatusResponse.java
index 4603090b..98be90e7 100644
--- a/src/main/java/cl/transbank/webpay/transaccioncompleta/responses/FullTransactionStatusResponse.java
+++ b/src/main/java/cl/transbank/webpay/transaccioncompleta/responses/FullTransactionStatusResponse.java
@@ -3,26 +3,30 @@
import cl.transbank.model.CardDetail;
import lombok.*;
+/**
+ * This class represents the status response of a full transaction.
+ */
@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
@ToString
public class FullTransactionStatusResponse {
- private String vci;
- private double amount;
- private String status;
- private String buyOrder;
- private String sessionId;
- private String cardNumber;
- private String accountingDate;
- private String transactionDate;
- private String authorizationCode;
- private String paymentTypeCode;
- private byte responseCode;
- private byte installmentsNumber;
- private double installmentsAmount;
- private String balance;
- private Double prepaidBalance;
- private CardDetail cardDetail;
+
+ private String vci;
+ private double amount;
+ private String status;
+ private String buyOrder;
+ private String sessionId;
+ private String cardNumber;
+ private String accountingDate;
+ private String transactionDate;
+ private String authorizationCode;
+ private String paymentTypeCode;
+ private byte responseCode;
+ private byte installmentsNumber;
+ private double installmentsAmount;
+ private String balance;
+ private Double prepaidBalance;
+ private CardDetail cardDetail;
}
diff --git a/src/main/java/cl/transbank/webpay/transaccioncompleta/responses/MallFullTransactionCaptureResponse.java b/src/main/java/cl/transbank/webpay/transaccioncompleta/responses/MallFullTransactionCaptureResponse.java
index 673f9aec..0fba1d3e 100644
--- a/src/main/java/cl/transbank/webpay/transaccioncompleta/responses/MallFullTransactionCaptureResponse.java
+++ b/src/main/java/cl/transbank/webpay/transaccioncompleta/responses/MallFullTransactionCaptureResponse.java
@@ -1,4 +1,7 @@
package cl.transbank.webpay.transaccioncompleta.responses;
-public class MallFullTransactionCaptureResponse extends FullTransactionCaptureResponse{
-}
+/**
+ * This class represents a response to a capture operation for a Mall Full transaction.
+ */
+public class MallFullTransactionCaptureResponse
+ extends FullTransactionCaptureResponse {}
diff --git a/src/main/java/cl/transbank/webpay/transaccioncompleta/responses/MallFullTransactionCommitResponse.java b/src/main/java/cl/transbank/webpay/transaccioncompleta/responses/MallFullTransactionCommitResponse.java
index 03ae5a19..ad3c8190 100644
--- a/src/main/java/cl/transbank/webpay/transaccioncompleta/responses/MallFullTransactionCommitResponse.java
+++ b/src/main/java/cl/transbank/webpay/transaccioncompleta/responses/MallFullTransactionCommitResponse.java
@@ -1,6 +1,7 @@
package cl.transbank.webpay.transaccioncompleta.responses;
-public class MallFullTransactionCommitResponse extends MallFullTransactionStatusResponse {
-
-}
-
+/**
+ * This class represents a response to a commit request for a mall full transaction.
+ */
+public class MallFullTransactionCommitResponse
+ extends MallFullTransactionStatusResponse {}
diff --git a/src/main/java/cl/transbank/webpay/transaccioncompleta/responses/MallFullTransactionCreateResponse.java b/src/main/java/cl/transbank/webpay/transaccioncompleta/responses/MallFullTransactionCreateResponse.java
index d01d5941..0f478039 100644
--- a/src/main/java/cl/transbank/webpay/transaccioncompleta/responses/MallFullTransactionCreateResponse.java
+++ b/src/main/java/cl/transbank/webpay/transaccioncompleta/responses/MallFullTransactionCreateResponse.java
@@ -1,4 +1,7 @@
package cl.transbank.webpay.transaccioncompleta.responses;
-public class MallFullTransactionCreateResponse extends FullTransactionCreateResponse {
-}
+/**
+ * This class represents the response of a refund operation in a Full Transaction.
+ */
+public class MallFullTransactionCreateResponse
+ extends FullTransactionCreateResponse {}
diff --git a/src/main/java/cl/transbank/webpay/transaccioncompleta/responses/MallFullTransactionInstallmentResponse.java b/src/main/java/cl/transbank/webpay/transaccioncompleta/responses/MallFullTransactionInstallmentResponse.java
index 4d982ab8..1ff21528 100644
--- a/src/main/java/cl/transbank/webpay/transaccioncompleta/responses/MallFullTransactionInstallmentResponse.java
+++ b/src/main/java/cl/transbank/webpay/transaccioncompleta/responses/MallFullTransactionInstallmentResponse.java
@@ -1,12 +1,26 @@
package cl.transbank.webpay.transaccioncompleta.responses;
-import lombok.NoArgsConstructor;
-
import java.util.List;
+import lombok.NoArgsConstructor;
+/**
+ * This class represents the response of an installment operation in a Mall Full Transaction.
+ */
@NoArgsConstructor
-public class MallFullTransactionInstallmentResponse extends FullTransactionInstallmentResponse {
- MallFullTransactionInstallmentResponse(double installmentsAmount, Long idQueryInstallments, List deferredPeriods){
- super(installmentsAmount, idQueryInstallments, deferredPeriods);
- }
+public class MallFullTransactionInstallmentResponse
+ extends FullTransactionInstallmentResponse {
+
+ /**
+ * Constructs a new MallFullTransactionInstallmentResponse with the specified parameters.
+ * @param installmentsAmount The amount of the installments.
+ * @param idQueryInstallments The ID of the query installments.
+ * @param deferredPeriods The list of deferred periods.
+ */
+ MallFullTransactionInstallmentResponse(
+ double installmentsAmount,
+ Long idQueryInstallments,
+ List deferredPeriods
+ ) {
+ super(installmentsAmount, idQueryInstallments, deferredPeriods);
+ }
}
diff --git a/src/main/java/cl/transbank/webpay/transaccioncompleta/responses/MallFullTransactionInstallmentsDetails.java b/src/main/java/cl/transbank/webpay/transaccioncompleta/responses/MallFullTransactionInstallmentsDetails.java
index deeeb03d..ae005f86 100644
--- a/src/main/java/cl/transbank/webpay/transaccioncompleta/responses/MallFullTransactionInstallmentsDetails.java
+++ b/src/main/java/cl/transbank/webpay/transaccioncompleta/responses/MallFullTransactionInstallmentsDetails.java
@@ -1,41 +1,112 @@
package cl.transbank.webpay.transaccioncompleta.responses;
import cl.transbank.webpay.transaccioncompleta.requests.MallFullTransactionInstallmentsRequest;
-
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+/**
+ * This class represents the details of a MallFullTransactionInstallments.
+ */
public class MallFullTransactionInstallmentsDetails {
- private List detailList = new ArrayList<>();
- private MallFullTransactionInstallmentsDetails() {}
+ private List detailList = new ArrayList<>();
- public static MallFullTransactionInstallmentsDetails build() {
- return new MallFullTransactionInstallmentsDetails();
- }
+ /**
+ * Private constructor. Prevents direct instantiation.
+ */
+ private MallFullTransactionInstallmentsDetails() {}
- public static MallFullTransactionInstallmentsDetails build(String commerceCode, String buyOrder,byte installmentsNumber) {
- return MallFullTransactionInstallmentsDetails.build().add(commerceCode, buyOrder, installmentsNumber);
- }
+ /**
+ * Builds a new MallFullTransactionInstallmentsDetails.
+ * @return A new MallFullTransactionInstallmentsDetails.
+ */
+ public static MallFullTransactionInstallmentsDetails build() {
+ return new MallFullTransactionInstallmentsDetails();
+ }
- public MallFullTransactionInstallmentsDetails add(String commerceCode, String buyOrder,byte installmentsNumber) {
- detailList.add(new MallFullTransactionInstallmentsDetails.Detail(commerceCode, buyOrder, installmentsNumber));
- return this;
- }
+ /**
+ * Builds a new MallFullTransactionInstallmentsDetails with the provided parameters.
+ * @param commerceCode The commerce code.
+ * @param buyOrder The buy order.
+ * @param installmentsNumber The number of installments.
+ * @return A new MallFullTransactionInstallmentsDetails.
+ */
+ public static MallFullTransactionInstallmentsDetails build(
+ String commerceCode,
+ String buyOrder,
+ byte installmentsNumber
+ ) {
+ return MallFullTransactionInstallmentsDetails
+ .build()
+ .add(commerceCode, buyOrder, installmentsNumber);
+ }
- public boolean remove(String commerceCode, String buyOrder,byte installmentsNumber) {
- return getDetails().remove(new MallFullTransactionInstallmentsDetails.Detail(commerceCode, buyOrder, installmentsNumber));
- }
+ /**
+ * Adds a new detail to the MallFullTransactionInstallmentsDetails.
+ * @param commerceCode The commerce code.
+ * @param buyOrder The buy order.
+ * @param installmentsNumber The number of installments.
+ * @return The MallFullTransactionInstallmentsDetails with the new detail added.
+ */
+ public MallFullTransactionInstallmentsDetails add(
+ String commerceCode,
+ String buyOrder,
+ byte installmentsNumber
+ ) {
+ detailList.add(
+ new MallFullTransactionInstallmentsDetails.Detail(
+ commerceCode,
+ buyOrder,
+ installmentsNumber
+ )
+ );
+ return this;
+ }
- public List getDetails() {
- return Collections.unmodifiableList(detailList);
- }
+ /**
+ * Removes a detail from the MallFullTransactionInstallmentsDetails.
+ * @param commerceCode The commerce code.
+ * @param buyOrder The buy order.
+ * @param installmentsNumber The number of installments.
+ * @return True if the detail was removed, false otherwise.
+ */
+ public boolean remove(
+ String commerceCode,
+ String buyOrder,
+ byte installmentsNumber
+ ) {
+ return getDetails()
+ .remove(
+ new MallFullTransactionInstallmentsDetails.Detail(
+ commerceCode,
+ buyOrder,
+ installmentsNumber
+ )
+ );
+ }
+
+ /**
+ * Gets the details of the MallFullTransactionInstallmentsDetails.
+ * @return The details of the MallFullTransactionInstallmentsDetails.
+ */
+ public List getDetails() {
+ return Collections.unmodifiableList(detailList);
+ }
+ /**
+ * This class represents the detail of a MallFullTransactionInstallments.
+ */
+ public class Detail extends MallFullTransactionInstallmentsRequest {
- public class Detail extends MallFullTransactionInstallmentsRequest {
- Detail(String commerceCode, String buyOrder,byte installmentsNumber){
- super(commerceCode, buyOrder, installmentsNumber);
- }
+ /**
+ * Constructor with parameters.
+ * @param commerceCode The commerce code.
+ * @param buyOrder The buy order.
+ * @param installmentsNumber The number of installments.
+ */
+ Detail(String commerceCode, String buyOrder, byte installmentsNumber) {
+ super(commerceCode, buyOrder, installmentsNumber);
}
+ }
}
diff --git a/src/main/java/cl/transbank/webpay/transaccioncompleta/responses/MallFullTransactionInstallmentsResponse.java b/src/main/java/cl/transbank/webpay/transaccioncompleta/responses/MallFullTransactionInstallmentsResponse.java
index e73ab0be..524f6e58 100644
--- a/src/main/java/cl/transbank/webpay/transaccioncompleta/responses/MallFullTransactionInstallmentsResponse.java
+++ b/src/main/java/cl/transbank/webpay/transaccioncompleta/responses/MallFullTransactionInstallmentsResponse.java
@@ -4,31 +4,60 @@
import java.util.Collections;
import java.util.List;
-
+/**
+ * This class represents a response to an installments operation for a Mall Full transaction.
+ */
public class MallFullTransactionInstallmentsResponse {
- private List responseList = new ArrayList<>();
-
- private MallFullTransactionInstallmentsResponse() {}
-
- public static MallFullTransactionInstallmentsResponse build() {
- return new MallFullTransactionInstallmentsResponse();
- }
-
- public static MallFullTransactionInstallmentsResponse build(MallFullTransactionInstallmentResponse response) {
- return MallFullTransactionInstallmentsResponse.build().add(response);
- }
-
- public MallFullTransactionInstallmentsResponse add(MallFullTransactionInstallmentResponse response) {
- responseList.add(response);
- return this;
- }
-
- public boolean remove(MallFullTransactionInstallmentResponse response) {
- return getResponseList().remove(response);
- }
-
- public List getResponseList() {
- return Collections.unmodifiableList(responseList);
- }
+ private List responseList = new ArrayList<>();
+
+ private MallFullTransactionInstallmentsResponse() {}
+
+ /**
+ * Builds a new MallFullTransactionInstallmentsResponse.
+ * @return A new MallFullTransactionInstallmentsResponse.
+ */
+ public static MallFullTransactionInstallmentsResponse build() {
+ return new MallFullTransactionInstallmentsResponse();
+ }
+
+ /**
+ * Builds a new MallFullTransactionInstallmentsResponse with the provided list of responses.
+ * @param response The list of responses.
+ * @return A new MallFullTransactionInstallmentsResponse.
+ */
+ public static MallFullTransactionInstallmentsResponse build(
+ MallFullTransactionInstallmentResponse response
+ ) {
+ return MallFullTransactionInstallmentsResponse.build().add(response);
+ }
+
+ /**
+ * Adds a new item to the response list.
+ * @param response The response to add.
+ * @return The same MallFullTransactionInstallmentsResponse instance.
+ */
+ public MallFullTransactionInstallmentsResponse add(
+ MallFullTransactionInstallmentResponse response
+ ) {
+ responseList.add(response);
+ return this;
+ }
+
+ /**
+ * Removes an item from the response list.
+ * @param response The response to remove.
+ * @return True if the response was removed, false otherwise.
+ */
+ public boolean remove(MallFullTransactionInstallmentResponse response) {
+ return getResponseList().remove(response);
+ }
+
+ /**
+ * Returns the response list.
+ * @return The response list.
+ */
+ public List getResponseList() {
+ return Collections.unmodifiableList(responseList);
+ }
}
diff --git a/src/main/java/cl/transbank/webpay/transaccioncompleta/responses/MallFullTransactionRefundResponse.java b/src/main/java/cl/transbank/webpay/transaccioncompleta/responses/MallFullTransactionRefundResponse.java
index 654cdf90..7df2958b 100644
--- a/src/main/java/cl/transbank/webpay/transaccioncompleta/responses/MallFullTransactionRefundResponse.java
+++ b/src/main/java/cl/transbank/webpay/transaccioncompleta/responses/MallFullTransactionRefundResponse.java
@@ -1,4 +1,7 @@
package cl.transbank.webpay.transaccioncompleta.responses;
-public class MallFullTransactionRefundResponse extends FullTransactionRefundResponse {
-}
+/**
+ * This class represents the response of a refund operation in a Mall Full Transaction.
+ */
+public class MallFullTransactionRefundResponse
+ extends FullTransactionRefundResponse {}
diff --git a/src/main/java/cl/transbank/webpay/transaccioncompleta/responses/MallFullTransactionStatusResponse.java b/src/main/java/cl/transbank/webpay/transaccioncompleta/responses/MallFullTransactionStatusResponse.java
index 8bea1286..23b983b4 100644
--- a/src/main/java/cl/transbank/webpay/transaccioncompleta/responses/MallFullTransactionStatusResponse.java
+++ b/src/main/java/cl/transbank/webpay/transaccioncompleta/responses/MallFullTransactionStatusResponse.java
@@ -1,38 +1,46 @@
package cl.transbank.webpay.transaccioncompleta.responses;
import cl.transbank.model.CardDetail;
-import lombok.*;
-
import java.util.List;
+import lombok.*;
+/**
+ * This class represents the response from the MallFullTransaction status request.
+ */
@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
@ToString
public class MallFullTransactionStatusResponse {
- private String buyOrder;
- private String sessionId;
- private String cardNumber;
- private String expirationDate;
- private String accountingDate;
- private String transactionDate;
- private List details;
- private Double prepaidBalance;
- private CardDetail cardDetail;
- @NoArgsConstructor @AllArgsConstructor
- @Data
- public class Detail {
- private String authorizationCode;
- private String paymentTypeCode;
- private byte responseCode;
- private double installmentsAmount;
- private byte installmentsNumber;
- private double amount;
- private String commerceCode;
- private String buyOrder;
- private String status;
- private double balance;
- }
+ private String buyOrder;
+ private String sessionId;
+ private String cardNumber;
+ private String expirationDate;
+ private String accountingDate;
+ private String transactionDate;
+ private List details;
+ private Double prepaidBalance;
+ private CardDetail cardDetail;
+
+ /**
+ * This class represents the details of the MallFullTransaction status response.
+ */
+ @NoArgsConstructor
+ @AllArgsConstructor
+ @Data
+ public class Detail {
+
+ private String authorizationCode;
+ private String paymentTypeCode;
+ private byte responseCode;
+ private double installmentsAmount;
+ private byte installmentsNumber;
+ private double amount;
+ private String commerceCode;
+ private String buyOrder;
+ private String status;
+ private double balance;
+ }
}
diff --git a/src/main/java/cl/transbank/webpay/webpayplus/WebpayMallTransaction.java b/src/main/java/cl/transbank/webpay/webpayplus/WebpayMallTransaction.java
index 064f7643..622ee85b 100644
--- a/src/main/java/cl/transbank/webpay/webpayplus/WebpayMallTransaction.java
+++ b/src/main/java/cl/transbank/webpay/webpayplus/WebpayMallTransaction.java
@@ -44,7 +44,7 @@ public WebpayPlusMallTransactionCreateResponse create(String buyOrder, String se
}
public WebpayPlusMallTransactionCommitResponse commit(String token) throws IOException, TransactionCommitException {
- ValidationUtil.hasTextWithMaxLength(token, ApiConstants.TOKEN_LENGTH, "token");
+ ValidationUtil.hasTextWithMaxLength(token, ApiConstants.TOKEN_LENGTH, ApiConstants.TOKEN_TEXT);
String endpoint = String.format("%s/transactions/%s", ApiConstants.WEBPAY_ENDPOINT,token);
try {
@@ -55,7 +55,7 @@ public WebpayPlusMallTransactionCommitResponse commit(String token) throws IOExc
}
public WebpayPlusMallTransactionStatusResponse status(String token) throws IOException, TransactionStatusException {
- ValidationUtil.hasTextWithMaxLength(token, ApiConstants.TOKEN_LENGTH, "token");
+ ValidationUtil.hasTextWithMaxLength(token, ApiConstants.TOKEN_LENGTH, ApiConstants.TOKEN_TEXT);
String endpoint = String.format("%s/transactions/%s", ApiConstants.WEBPAY_ENDPOINT,token);
try {
return WebpayApiResource.execute(endpoint, HttpUtil.RequestMethod.GET, options, WebpayPlusMallTransactionStatusResponse.class);
@@ -65,7 +65,7 @@ public WebpayPlusMallTransactionStatusResponse status(String token) throws IOExc
}
public WebpayPlusMallTransactionRefundResponse refund(String token, String buyOrder, String childCommerceCode, double amount) throws IOException, TransactionRefundException {
- ValidationUtil.hasTextWithMaxLength(token, ApiConstants.TOKEN_LENGTH, "token");
+ ValidationUtil.hasTextWithMaxLength(token, ApiConstants.TOKEN_LENGTH, ApiConstants.TOKEN_TEXT);
ValidationUtil.hasTextWithMaxLength(childCommerceCode, ApiConstants.COMMERCE_CODE_LENGTH, "childCommerceCode");
ValidationUtil.hasTextWithMaxLength(buyOrder, ApiConstants.BUY_ORDER_LENGTH, "buyOrder");
@@ -78,7 +78,7 @@ public WebpayPlusMallTransactionRefundResponse refund(String token, String buyOr
}
public WebpayPlusMallTransactionCaptureResponse capture(String childCommerceCode, String token, String buyOrder, String authorizationCode, double captureAmount) throws IOException, TransactionCaptureException {
- ValidationUtil.hasTextWithMaxLength(token, ApiConstants.TOKEN_LENGTH, "token");
+ ValidationUtil.hasTextWithMaxLength(token, ApiConstants.TOKEN_LENGTH, ApiConstants.TOKEN_TEXT);
ValidationUtil.hasTextWithMaxLength(childCommerceCode, ApiConstants.COMMERCE_CODE_LENGTH, "childCommerceCode");
ValidationUtil.hasTextWithMaxLength(buyOrder, ApiConstants.BUY_ORDER_LENGTH, "buyOrder");
ValidationUtil.hasTextWithMaxLength(authorizationCode, ApiConstants.AUTHORIZATION_CODE_LENGTH, "authorizationCode");
diff --git a/src/main/java/cl/transbank/webpay/webpayplus/WebpayPlus.java b/src/main/java/cl/transbank/webpay/webpayplus/WebpayPlus.java
index 8f2f7fd9..d6769bd1 100644
--- a/src/main/java/cl/transbank/webpay/webpayplus/WebpayPlus.java
+++ b/src/main/java/cl/transbank/webpay/webpayplus/WebpayPlus.java
@@ -6,28 +6,72 @@
import cl.transbank.model.Options;
import cl.transbank.webpay.common.WebpayOptions;
+/**
+ * This class provides methods to configure and perform transactions with the WebpayPlus service.
+ */
public class WebpayPlus {
- private static Options options;
-
- public static class Transaction extends WebpayTransaction {
- public Transaction() {
- super(WebpayPlus.options!=null ? WebpayPlus.options : new WebpayOptions(IntegrationCommerceCodes.WEBPAY_PLUS, IntegrationApiKeys.WEBPAY, IntegrationType.TEST));
- }
- public Transaction(Options options) {
- super(options);
- }
+
+ private static Options options;
+
+ /**
+ * This class provides methods to perform WebpayPlus Transactions.
+ */
+ public static class Transaction extends WebpayTransaction {
+
+ /**
+ * Default constructor. Uses default options if none are provided.
+ */
+ public Transaction() {
+ super(
+ WebpayPlus.options != null
+ ? WebpayPlus.options
+ : new WebpayOptions(
+ IntegrationCommerceCodes.WEBPAY_PLUS,
+ IntegrationApiKeys.WEBPAY,
+ IntegrationType.TEST
+ )
+ );
+ }
+
+ /**
+ * Constructor with options. Uses provided options.
+ * @param options The options to use for this transaction.
+ */
+ public Transaction(Options options) {
+ super(options);
+ }
+ }
+
+ /**
+ * This class provides methods to perform WebpayPlus Mall Transactions.
+ */
+ public static class MallTransaction extends WebpayMallTransaction {
+
+ /**
+ * Default constructor. Uses default options if none are provided.
+ */
+ public MallTransaction() {
+ super(
+ WebpayPlus.options != null
+ ? WebpayPlus.options
+ : new WebpayOptions(
+ IntegrationCommerceCodes.WEBPAY_PLUS_MALL,
+ IntegrationApiKeys.WEBPAY,
+ IntegrationType.TEST
+ )
+ );
}
- public static class MallTransaction extends WebpayMallTransaction {
- public MallTransaction() {
- super(WebpayPlus.options!=null ? WebpayPlus.options : new WebpayOptions(IntegrationCommerceCodes.WEBPAY_PLUS_MALL, IntegrationApiKeys.WEBPAY, IntegrationType.TEST));
- }
- public MallTransaction(Options options) {
- super(options);
- }
+ /**
+ * Constructor with options. Uses provided options.
+ * @param options The options to use for this transaction.
+ */
+ public MallTransaction(Options options) {
+ super(options);
}
+ }
- /*
+ /*
@@ -36,31 +80,54 @@ public MallTransaction(Options options) {
|--------------------------------------------------------------------------
*/
- public static void configureForIntegration(String commerceCode, String apiKey){
- options = new WebpayOptions(commerceCode, apiKey, IntegrationType.TEST);
- }
+ public static void configureForIntegration(
+ String commerceCode,
+ String apiKey
+ ) {
+ options = new WebpayOptions(commerceCode, apiKey, IntegrationType.TEST);
+ }
- public static void configureForProduction(String commerceCode, String apiKey){
- options = new WebpayOptions(commerceCode, apiKey, IntegrationType.LIVE);
- }
+ public static void configureForProduction(
+ String commerceCode,
+ String apiKey
+ ) {
+ options = new WebpayOptions(commerceCode, apiKey, IntegrationType.LIVE);
+ }
- public static void configureForTesting(){
- configureForIntegration(IntegrationCommerceCodes.WEBPAY_PLUS, IntegrationApiKeys.WEBPAY);
- }
+ public static void configureForTesting() {
+ configureForIntegration(
+ IntegrationCommerceCodes.WEBPAY_PLUS,
+ IntegrationApiKeys.WEBPAY
+ );
+ }
- public static void configureForTestingDeferred(){
- configureForIntegration(IntegrationCommerceCodes.WEBPAY_PLUS_DEFERRED, IntegrationApiKeys.WEBPAY);
- }
+ public static void configureForTestingDeferred() {
+ configureForIntegration(
+ IntegrationCommerceCodes.WEBPAY_PLUS_DEFERRED,
+ IntegrationApiKeys.WEBPAY
+ );
+ }
- public static void configureForTestingMall(){
- configureForIntegration(IntegrationCommerceCodes.WEBPAY_PLUS_MALL, IntegrationApiKeys.WEBPAY);
- }
+ public static void configureForTestingMall() {
+ configureForIntegration(
+ IntegrationCommerceCodes.WEBPAY_PLUS_MALL,
+ IntegrationApiKeys.WEBPAY
+ );
+ }
- public static void configureForTestingMallDeferred(){
- configureForIntegration(IntegrationCommerceCodes.WEBPAY_PLUS_MALL_DEFERRED, IntegrationApiKeys.WEBPAY);
- }
+ public static void configureForTestingMallDeferred() {
+ configureForIntegration(
+ IntegrationCommerceCodes.WEBPAY_PLUS_MALL_DEFERRED,
+ IntegrationApiKeys.WEBPAY
+ );
+ }
- public static void configureForMock(){
- options = new WebpayOptions(IntegrationCommerceCodes.WEBPAY_PLUS, IntegrationApiKeys.WEBPAY, IntegrationType.SERVER_MOCK);
- }
-}
\ No newline at end of file
+ public static void configureForMock() {
+ options =
+ new WebpayOptions(
+ IntegrationCommerceCodes.WEBPAY_PLUS,
+ IntegrationApiKeys.WEBPAY,
+ IntegrationType.SERVER_MOCK
+ );
+ }
+}
diff --git a/src/main/java/cl/transbank/webpay/webpayplus/WebpayTransaction.java b/src/main/java/cl/transbank/webpay/webpayplus/WebpayTransaction.java
index 5557d5a8..c411e654 100644
--- a/src/main/java/cl/transbank/webpay/webpayplus/WebpayTransaction.java
+++ b/src/main/java/cl/transbank/webpay/webpayplus/WebpayTransaction.java
@@ -38,7 +38,7 @@ public WebpayPlusTransactionCreateResponse create(String buyOrder, String sessio
public WebpayPlusTransactionCommitResponse commit(String token) throws IOException, TransactionCommitException {
- ValidationUtil.hasTextWithMaxLength(token, ApiConstants.TOKEN_LENGTH, "token");
+ ValidationUtil.hasTextWithMaxLength(token, ApiConstants.TOKEN_LENGTH, ApiConstants.TOKEN_TEXT);
String endpoint = String.format("%s/transactions/%s", ApiConstants.WEBPAY_ENDPOINT,token);
try {
@@ -49,7 +49,7 @@ public WebpayPlusTransactionCommitResponse commit(String token) throws IOExcepti
}
public WebpayPlusTransactionStatusResponse status(String token) throws IOException, TransactionStatusException {
- ValidationUtil.hasTextWithMaxLength(token, ApiConstants.TOKEN_LENGTH, "token");
+ ValidationUtil.hasTextWithMaxLength(token, ApiConstants.TOKEN_LENGTH, ApiConstants.TOKEN_TEXT);
String endpoint = String.format("%s/transactions/%s", ApiConstants.WEBPAY_ENDPOINT,token);
try {
return WebpayApiResource.execute(endpoint, HttpUtil.RequestMethod.GET, options, WebpayPlusTransactionStatusResponse.class);
@@ -59,7 +59,7 @@ public WebpayPlusTransactionStatusResponse status(String token) throws IOExcepti
}
public WebpayPlusTransactionRefundResponse refund(String token, double amount) throws IOException, TransactionRefundException {
- ValidationUtil.hasTextWithMaxLength(token, ApiConstants.TOKEN_LENGTH, "token");
+ ValidationUtil.hasTextWithMaxLength(token, ApiConstants.TOKEN_LENGTH, ApiConstants.TOKEN_TEXT);
String endpoint = String.format("%s/transactions/%s/refunds", ApiConstants.WEBPAY_ENDPOINT,token);
try {
return WebpayApiResource.execute(endpoint, HttpUtil.RequestMethod.POST, new TransactionRefundRequest(amount), options, WebpayPlusTransactionRefundResponse.class);
@@ -69,7 +69,7 @@ public WebpayPlusTransactionRefundResponse refund(String token, double amount) t
}
public WebpayPlusTransactionCaptureResponse capture(String token, String buyOrder, String authorizationCode, double captureAmount) throws IOException, TransactionCaptureException {
- ValidationUtil.hasTextWithMaxLength(token, ApiConstants.TOKEN_LENGTH, "token");
+ ValidationUtil.hasTextWithMaxLength(token, ApiConstants.TOKEN_LENGTH, ApiConstants.TOKEN_TEXT);
ValidationUtil.hasTextWithMaxLength(buyOrder, ApiConstants.BUY_ORDER_LENGTH, "buyOrder");
ValidationUtil.hasTextWithMaxLength(authorizationCode, ApiConstants.AUTHORIZATION_CODE_LENGTH, "authorizationCode");
String endpoint = String.format("%s/transactions/%s/capture", ApiConstants.WEBPAY_ENDPOINT, token);
diff --git a/src/main/java/cl/transbank/webpay/webpayplus/requests/MallTransactionCreateRequest.java b/src/main/java/cl/transbank/webpay/webpayplus/requests/MallTransactionCreateRequest.java
index 3fa63eba..aaf90548 100644
--- a/src/main/java/cl/transbank/webpay/webpayplus/requests/MallTransactionCreateRequest.java
+++ b/src/main/java/cl/transbank/webpay/webpayplus/requests/MallTransactionCreateRequest.java
@@ -2,16 +2,21 @@
import cl.transbank.model.MallTransactionCreateDetails;
import cl.transbank.model.WebpayApiRequest;
-import lombok.*;
-
import java.util.List;
+import lombok.*;
-@NoArgsConstructor @AllArgsConstructor
-@Getter @Setter
+/**
+ * This class represents a request to create a Mall Transaction.
+ */
+@NoArgsConstructor
+@AllArgsConstructor
+@Getter
+@Setter
@ToString
public class MallTransactionCreateRequest extends WebpayApiRequest {
- private String buyOrder;
- private String sessionId;
- private String returnUrl;
- private List details;
+
+ private String buyOrder;
+ private String sessionId;
+ private String returnUrl;
+ private List details;
}
diff --git a/src/main/java/cl/transbank/webpay/webpayplus/requests/TransactionCreateRequest.java b/src/main/java/cl/transbank/webpay/webpayplus/requests/TransactionCreateRequest.java
index ab2e0fd5..f119181c 100644
--- a/src/main/java/cl/transbank/webpay/webpayplus/requests/TransactionCreateRequest.java
+++ b/src/main/java/cl/transbank/webpay/webpayplus/requests/TransactionCreateRequest.java
@@ -3,12 +3,33 @@
import cl.transbank.model.WebpayApiRequest;
import lombok.*;
-@NoArgsConstructor @AllArgsConstructor
-@Getter @Setter
+/**
+ * This class represents a request to create a transaction.
+ */
+@NoArgsConstructor
+@AllArgsConstructor
+@Getter
+@Setter
@ToString
public class TransactionCreateRequest extends WebpayApiRequest {
- private String buyOrder;
- private String sessionId;
- private double amount;
- private String returnUrl;
+
+ /**
+ * The buy order of the transaction.
+ */
+ private String buyOrder;
+
+ /**
+ * The session ID of the transaction.
+ */
+ private String sessionId;
+
+ /**
+ * The amount of the transaction.
+ */
+ private double amount;
+
+ /**
+ * The return URL of the transaction.
+ */
+ private String returnUrl;
}
diff --git a/src/main/java/cl/transbank/webpay/webpayplus/responses/WebpayPlusMallTransactionCaptureResponse.java b/src/main/java/cl/transbank/webpay/webpayplus/responses/WebpayPlusMallTransactionCaptureResponse.java
index 6dc32b9f..f74017c7 100644
--- a/src/main/java/cl/transbank/webpay/webpayplus/responses/WebpayPlusMallTransactionCaptureResponse.java
+++ b/src/main/java/cl/transbank/webpay/webpayplus/responses/WebpayPlusMallTransactionCaptureResponse.java
@@ -1,5 +1,7 @@
package cl.transbank.webpay.webpayplus.responses;
-public class WebpayPlusMallTransactionCaptureResponse extends WebpayPlusTransactionCaptureResponse {
-
-}
+/**
+ * This class represents a response to a capture operation for a Webpay Plus Mall transaction.
+ */
+public class WebpayPlusMallTransactionCaptureResponse
+ extends WebpayPlusTransactionCaptureResponse {}
diff --git a/src/main/java/cl/transbank/webpay/webpayplus/responses/WebpayPlusMallTransactionCommitResponse.java b/src/main/java/cl/transbank/webpay/webpayplus/responses/WebpayPlusMallTransactionCommitResponse.java
index 821a2637..1b4cf022 100644
--- a/src/main/java/cl/transbank/webpay/webpayplus/responses/WebpayPlusMallTransactionCommitResponse.java
+++ b/src/main/java/cl/transbank/webpay/webpayplus/responses/WebpayPlusMallTransactionCommitResponse.java
@@ -1,7 +1,7 @@
package cl.transbank.webpay.webpayplus.responses;
-public class WebpayPlusMallTransactionCommitResponse extends WebpayPlusMallTransactionStatusResponse {
-
-}
-
-
+/**
+ * This class represents a response to a commit operation for a Webpay Plus Mall transaction.
+ */
+public class WebpayPlusMallTransactionCommitResponse
+ extends WebpayPlusMallTransactionStatusResponse {}
diff --git a/src/main/java/cl/transbank/webpay/webpayplus/responses/WebpayPlusMallTransactionCreateResponse.java b/src/main/java/cl/transbank/webpay/webpayplus/responses/WebpayPlusMallTransactionCreateResponse.java
index daad1771..3469b9cc 100644
--- a/src/main/java/cl/transbank/webpay/webpayplus/responses/WebpayPlusMallTransactionCreateResponse.java
+++ b/src/main/java/cl/transbank/webpay/webpayplus/responses/WebpayPlusMallTransactionCreateResponse.java
@@ -1,5 +1,7 @@
package cl.transbank.webpay.webpayplus.responses;
-public class WebpayPlusMallTransactionCreateResponse extends WebpayPlusTransactionCreateResponse {
-
-}
+/**
+ * This class represents a response to a create operation for a Webpay Plus Mall transaction.
+ */
+public class WebpayPlusMallTransactionCreateResponse
+ extends WebpayPlusTransactionCreateResponse {}
diff --git a/src/main/java/cl/transbank/webpay/webpayplus/responses/WebpayPlusMallTransactionRefundResponse.java b/src/main/java/cl/transbank/webpay/webpayplus/responses/WebpayPlusMallTransactionRefundResponse.java
index 3a446e7d..779e886a 100644
--- a/src/main/java/cl/transbank/webpay/webpayplus/responses/WebpayPlusMallTransactionRefundResponse.java
+++ b/src/main/java/cl/transbank/webpay/webpayplus/responses/WebpayPlusMallTransactionRefundResponse.java
@@ -1,4 +1,7 @@
package cl.transbank.webpay.webpayplus.responses;
-public class WebpayPlusMallTransactionRefundResponse extends WebpayPlusTransactionRefundResponse {
-}
+/**
+ * This class represents a response to a refund operation for a Webpay Plus Mall transaction.
+ */
+public class WebpayPlusMallTransactionRefundResponse
+ extends WebpayPlusTransactionRefundResponse {}
diff --git a/src/main/java/cl/transbank/webpay/webpayplus/responses/WebpayPlusMallTransactionStatusResponse.java b/src/main/java/cl/transbank/webpay/webpayplus/responses/WebpayPlusMallTransactionStatusResponse.java
index e5c42712..3abae08e 100644
--- a/src/main/java/cl/transbank/webpay/webpayplus/responses/WebpayPlusMallTransactionStatusResponse.java
+++ b/src/main/java/cl/transbank/webpay/webpayplus/responses/WebpayPlusMallTransactionStatusResponse.java
@@ -1,34 +1,47 @@
package cl.transbank.webpay.webpayplus.responses;
import cl.transbank.model.CardDetail;
-import lombok.*;
-
import java.util.List;
+import lombok.*;
-@NoArgsConstructor @AllArgsConstructor
-@Getter @Setter @ToString
+/**
+ * This class represents the response of a WebpayPlusMallTransactionStatus.
+ */
+@NoArgsConstructor
+@AllArgsConstructor
+@Getter
+@Setter
+@ToString
public class WebpayPlusMallTransactionStatusResponse {
- private String vci;
- private String buyOrder;
- private String sessionId;
- private CardDetail cardDetail;
- private String accountingDate;
- private String transactionDate;
- private List details;
- @NoArgsConstructor @AllArgsConstructor
- @Getter @Setter @ToString
- public class Detail {
- private double amount;
- private String status;
- private String authorizationCode;
- private String paymentTypeCode;
- private byte responseCode;
- private double installmentsAmount;
- private byte installmentsNumber;
- private String commerceCode;
- private String buyOrder;
- private Double prepaidBalance;
- private Double balance;
- }
+ private String vci;
+ private String buyOrder;
+ private String sessionId;
+ private CardDetail cardDetail;
+ private String accountingDate;
+ private String transactionDate;
+ private List details;
+
+ /**
+ * This class represents the detail of a WebpayPlusMallTransactionStatus.
+ */
+ @NoArgsConstructor
+ @AllArgsConstructor
+ @Getter
+ @Setter
+ @ToString
+ public class Detail {
+
+ private double amount;
+ private String status;
+ private String authorizationCode;
+ private String paymentTypeCode;
+ private byte responseCode;
+ private double installmentsAmount;
+ private byte installmentsNumber;
+ private String commerceCode;
+ private String buyOrder;
+ private Double prepaidBalance;
+ private Double balance;
+ }
}
diff --git a/src/main/java/cl/transbank/webpay/webpayplus/responses/WebpayPlusTransactionCaptureResponse.java b/src/main/java/cl/transbank/webpay/webpayplus/responses/WebpayPlusTransactionCaptureResponse.java
index 8f749703..5aae0df4 100644
--- a/src/main/java/cl/transbank/webpay/webpayplus/responses/WebpayPlusTransactionCaptureResponse.java
+++ b/src/main/java/cl/transbank/webpay/webpayplus/responses/WebpayPlusTransactionCaptureResponse.java
@@ -2,12 +2,18 @@
import lombok.*;
-@NoArgsConstructor @AllArgsConstructor
-@Getter @Setter
+/**
+ * This class represents a response to a capture operation for a Webpay Plus transaction.
+ */
+@NoArgsConstructor
+@AllArgsConstructor
+@Getter
+@Setter
@ToString
public class WebpayPlusTransactionCaptureResponse {
- private String authorizationCode;
- private String authorizationDate;
- private double capturedAmount;
- private byte responseCode;
+
+ private String authorizationCode;
+ private String authorizationDate;
+ private double capturedAmount;
+ private byte responseCode;
}
diff --git a/src/main/java/cl/transbank/webpay/webpayplus/responses/WebpayPlusTransactionCommitResponse.java b/src/main/java/cl/transbank/webpay/webpayplus/responses/WebpayPlusTransactionCommitResponse.java
index 1c9a4f84..bcbbf679 100644
--- a/src/main/java/cl/transbank/webpay/webpayplus/responses/WebpayPlusTransactionCommitResponse.java
+++ b/src/main/java/cl/transbank/webpay/webpayplus/responses/WebpayPlusTransactionCommitResponse.java
@@ -1,5 +1,7 @@
package cl.transbank.webpay.webpayplus.responses;
-public class WebpayPlusTransactionCommitResponse extends WebpayPlusTransactionStatusResponse {
-
-}
+/**
+ * This class represents a response to a commit operation for a Webpay Plus transaction.
+ */
+public class WebpayPlusTransactionCommitResponse
+ extends WebpayPlusTransactionStatusResponse {}
diff --git a/src/main/java/cl/transbank/webpay/webpayplus/responses/WebpayPlusTransactionCreateResponse.java b/src/main/java/cl/transbank/webpay/webpayplus/responses/WebpayPlusTransactionCreateResponse.java
index 9ecde1dd..c6f76e01 100644
--- a/src/main/java/cl/transbank/webpay/webpayplus/responses/WebpayPlusTransactionCreateResponse.java
+++ b/src/main/java/cl/transbank/webpay/webpayplus/responses/WebpayPlusTransactionCreateResponse.java
@@ -2,10 +2,16 @@
import lombok.*;
-@NoArgsConstructor @AllArgsConstructor
-@Getter @Setter
+/**
+ * This class represents a response to a create operation for a Webpay Plus transaction.
+ */
+@NoArgsConstructor
+@AllArgsConstructor
+@Getter
+@Setter
@ToString
public class WebpayPlusTransactionCreateResponse {
- private String token;
- private String url;
+
+ private String token;
+ private String url;
}
diff --git a/src/main/java/cl/transbank/webpay/webpayplus/responses/WebpayPlusTransactionRefundResponse.java b/src/main/java/cl/transbank/webpay/webpayplus/responses/WebpayPlusTransactionRefundResponse.java
index ec303c16..fe7b0527 100644
--- a/src/main/java/cl/transbank/webpay/webpayplus/responses/WebpayPlusTransactionRefundResponse.java
+++ b/src/main/java/cl/transbank/webpay/webpayplus/responses/WebpayPlusTransactionRefundResponse.java
@@ -2,5 +2,7 @@
import cl.transbank.model.BaseRefundResponse;
-public class WebpayPlusTransactionRefundResponse extends BaseRefundResponse {
-}
+/**
+ * This class represents a response to a refund operation for a Webpay Plus transaction.
+ */
+public class WebpayPlusTransactionRefundResponse extends BaseRefundResponse {}
diff --git a/src/main/java/cl/transbank/webpay/webpayplus/responses/WebpayPlusTransactionStatusResponse.java b/src/main/java/cl/transbank/webpay/webpayplus/responses/WebpayPlusTransactionStatusResponse.java
index 519489fe..b05455d4 100644
--- a/src/main/java/cl/transbank/webpay/webpayplus/responses/WebpayPlusTransactionStatusResponse.java
+++ b/src/main/java/cl/transbank/webpay/webpayplus/responses/WebpayPlusTransactionStatusResponse.java
@@ -1,25 +1,30 @@
package cl.transbank.webpay.webpayplus.responses;
import cl.transbank.model.CardDetail;
-import com.google.gson.annotations.SerializedName;
import lombok.*;
-@NoArgsConstructor @AllArgsConstructor
-@Getter @Setter
+/**
+ * This class represents the status response of a Webpay Plus Transaction.
+ */
+@NoArgsConstructor
+@AllArgsConstructor
+@Getter
+@Setter
@ToString
public class WebpayPlusTransactionStatusResponse {
- private String vci;
- private double amount;
- private String status;
- private String buyOrder;
- private String sessionId;
- private CardDetail cardDetail;
- private String accountingDate;
- private String transactionDate;
- private String authorizationCode;
- private String paymentTypeCode;
- private byte responseCode;
- private double installmentsAmount;
- private byte installmentsNumber;
- private double balance;
-}
\ No newline at end of file
+
+ private String vci;
+ private double amount;
+ private String status;
+ private String buyOrder;
+ private String sessionId;
+ private CardDetail cardDetail;
+ private String accountingDate;
+ private String transactionDate;
+ private String authorizationCode;
+ private String paymentTypeCode;
+ private byte responseCode;
+ private double installmentsAmount;
+ private byte installmentsNumber;
+ private double balance;
+}
diff --git a/src/test/java/webpayplus/OneclickMallDeferredTest.java b/src/test/java/webpayplus/OneclickMallDeferredTest.java
index 88b766a3..9099ce49 100644
--- a/src/test/java/webpayplus/OneclickMallDeferredTest.java
+++ b/src/test/java/webpayplus/OneclickMallDeferredTest.java
@@ -67,7 +67,7 @@ public void start() throws IOException, InscriptionStartException {
String urlResponse = "https://webpay3gint.transbank.cl/webpayserver/bp_multicode_inscription.cgi";
Map mapResponse = new HashMap();
- mapResponse.put("token", testToken);
+ mapResponse.put(ApiConstants.TOKEN_TEXT, testToken);
mapResponse.put("url_webpay", urlResponse);
Gson gson = new GsonBuilder().create();
diff --git a/src/test/java/webpayplus/OneclickMallTest.java b/src/test/java/webpayplus/OneclickMallTest.java
index 25331af5..5f85a69c 100644
--- a/src/test/java/webpayplus/OneclickMallTest.java
+++ b/src/test/java/webpayplus/OneclickMallTest.java
@@ -67,7 +67,7 @@ public void start() throws IOException, InscriptionStartException {
String urlResponse = "https://webpay3gint.transbank.cl/webpayserver/bp_multicode_inscription.cgi";
Map mapResponse = new HashMap();
- mapResponse.put("token", testToken);
+ mapResponse.put(ApiConstants.TOKEN_TEXT, testToken);
mapResponse.put("url_webpay", urlResponse);
Gson gson = new GsonBuilder().create();
diff --git a/src/test/java/webpayplus/PatpassByWebpayTest.java b/src/test/java/webpayplus/PatpassByWebpayTest.java
index 8df8e767..8379b3c6 100644
--- a/src/test/java/webpayplus/PatpassByWebpayTest.java
+++ b/src/test/java/webpayplus/PatpassByWebpayTest.java
@@ -72,7 +72,7 @@ public void start() throws IOException, TransactionCreateException {
String urlResponse = "https://webpay3gint.transbank.cl/webpayserver/initTransaction";
Map mapResponse = new HashMap();
- mapResponse.put("token", testToken);
+ mapResponse.put(ApiConstants.TOKEN_TEXT, testToken);
mapResponse.put("url", urlResponse);
Gson gson = new GsonBuilder().create();
diff --git a/src/test/java/webpayplus/PatpassComercioTest.java b/src/test/java/webpayplus/PatpassComercioTest.java
index 073535ec..f60e2725 100644
--- a/src/test/java/webpayplus/PatpassComercioTest.java
+++ b/src/test/java/webpayplus/PatpassComercioTest.java
@@ -41,7 +41,7 @@ public void start() throws IOException, InscriptionStartException {
String urlResponse = "https://pagoautomaticocontarjetasint.transbank.cl/nuevo-ic-rest/tokenComercioLogin";
Map mapResponse = new HashMap();
- mapResponse.put("token", testToken);
+ mapResponse.put(ApiConstants.TOKEN_TEXT, testToken);
mapResponse.put("url", urlResponse);
Gson gson = new GsonBuilder().create();
diff --git a/src/test/java/webpayplus/WebpayModalTest.java b/src/test/java/webpayplus/WebpayModalTest.java
index fd7a6615..0a9adabb 100644
--- a/src/test/java/webpayplus/WebpayModalTest.java
+++ b/src/test/java/webpayplus/WebpayModalTest.java
@@ -57,7 +57,7 @@ public void create() throws IOException, TransactionCreateException {
String urlResponse = "https://webpay3gint.transbank.cl/webpayserver/initTransaction";
Map mapResponse = new HashMap();
- mapResponse.put("token", testToken);
+ mapResponse.put(ApiConstants.TOKEN_TEXT, testToken);
Gson gson = new GsonBuilder().create();
String jsonResponse = gson.toJson(mapResponse);
diff --git a/src/test/java/webpayplus/WebpayPlusDeferredTest.java b/src/test/java/webpayplus/WebpayPlusDeferredTest.java
index ffbc8cf7..28c39fcd 100644
--- a/src/test/java/webpayplus/WebpayPlusDeferredTest.java
+++ b/src/test/java/webpayplus/WebpayPlusDeferredTest.java
@@ -57,7 +57,7 @@ public void create() throws IOException, TransactionCreateException {
String urlResponse = "https://webpay3gint.transbank.cl/webpayserver/initTransaction";
Map mapResponse = new HashMap();
- mapResponse.put("token", testToken);
+ mapResponse.put(ApiConstants.TOKEN_TEXT, testToken);
mapResponse.put("url", urlResponse);
Gson gson = new GsonBuilder().create();
diff --git a/src/test/java/webpayplus/WebpayPlusMallDeferredTest.java b/src/test/java/webpayplus/WebpayPlusMallDeferredTest.java
index accda33e..4a1a12ab 100644
--- a/src/test/java/webpayplus/WebpayPlusMallDeferredTest.java
+++ b/src/test/java/webpayplus/WebpayPlusMallDeferredTest.java
@@ -68,7 +68,7 @@ public void create() throws IOException, TransactionCreateException {
String urlResponse = "https://webpay3gint.transbank.cl/webpayserver/initTransaction";
Map mapResponse = new HashMap();
- mapResponse.put("token", testToken);
+ mapResponse.put(ApiConstants.TOKEN_TEXT, testToken);
mapResponse.put("url", urlResponse);
Gson gson = new GsonBuilder().create();
diff --git a/src/test/java/webpayplus/WebpayPlusMallTest.java b/src/test/java/webpayplus/WebpayPlusMallTest.java
index 43a1b02e..c3199196 100644
--- a/src/test/java/webpayplus/WebpayPlusMallTest.java
+++ b/src/test/java/webpayplus/WebpayPlusMallTest.java
@@ -73,7 +73,7 @@ public void create() throws IOException, TransactionCreateException {
String urlResponse = "https://webpay3gint.transbank.cl/webpayserver/initTransaction";
Map mapResponse = new HashMap();
- mapResponse.put("token", testToken);
+ mapResponse.put(ApiConstants.TOKEN_TEXT, testToken);
mapResponse.put("url", urlResponse);
Gson gson = new GsonBuilder().create();
diff --git a/src/test/java/webpayplus/WebpayPlusTest.java b/src/test/java/webpayplus/WebpayPlusTest.java
index 03e135ad..158c000c 100644
--- a/src/test/java/webpayplus/WebpayPlusTest.java
+++ b/src/test/java/webpayplus/WebpayPlusTest.java
@@ -66,7 +66,7 @@ public void create() throws IOException, TransactionCreateException {
String urlResponse = "https://webpay3gint.transbank.cl/webpayserver/initTransaction";
Map mapResponse = new HashMap();
- mapResponse.put("token", testToken);
+ mapResponse.put(ApiConstants.TOKEN_TEXT, testToken);
mapResponse.put("url", urlResponse);
Gson gson = new GsonBuilder().create();