Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add javadocs #180

Merged
merged 2 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 19 additions & 14 deletions src/main/java/cl/transbank/common/ApiConstants.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
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 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;
}
8 changes: 7 additions & 1 deletion src/main/java/cl/transbank/common/BaseTransaction.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@

import cl.transbank.model.Options;

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

/**
* The options for the transaction.
*/
protected Options options = null;
}
16 changes: 14 additions & 2 deletions src/main/java/cl/transbank/common/IntegrationApiKeys.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
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 String WEBPAY =
"579B532A7440BB0C9079DED94D31EA1615BACEB56610332264630D42D0A36B1C";

/**
* The API key for Patpass Comercio in the integration environment.
*/
public static String PATPASS_COMERCIO = "cxxXQgGD9vrVe4M41FIt";
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package cl.transbank.common;

/**
* This class contains the commerce codes for integration.
*/
public class IntegrationCommerceCodes {
public static String WEBPAY_PLUS = "597055555532";
public static String WEBPAY_PLUS_MODAL = "597055555584";
Expand Down
61 changes: 39 additions & 22 deletions src/main/java/cl/transbank/common/IntegrationTypeHelper.java
Original file line number Diff line number Diff line change
@@ -1,30 +1,47 @@
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.
*/
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.
*/
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";
}
}
}
100 changes: 66 additions & 34 deletions src/main/java/cl/transbank/exception/TransbankException.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,71 @@

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 int code;

/**
* Constructs a new TransbankException with no detail message.
*/
public TransbankException() {
super();
}

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

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

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

/**
* Constructs a new TransbankException with the specified cause.
*/
public TransbankException(Throwable cause) {
super(cause);
}

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

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

import lombok.*;

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

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

import lombok.*;

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

private String cardNumber;
}
Loading
Loading