Skip to content

Commit

Permalink
Merge pull request #177 from TransbankDevelopers/feat/downgrade-tbk-a…
Browse files Browse the repository at this point in the history
…pi-version

feat: downgrade tbk api version
  • Loading branch information
mvarlic authored Nov 20, 2023
2 parents bfe261a + 95c2434 commit 55ccc7c
Show file tree
Hide file tree
Showing 18 changed files with 2 additions and 455 deletions.
4 changes: 2 additions & 2 deletions src/main/java/cl/transbank/common/ApiConstants.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package cl.transbank.common;

public class ApiConstants {
public static String WEBPAY_ENDPOINT = "rswebpaytransaction/api/webpay/v1.3";
public static String ONECLICK_ENDPOINT = "rswebpaytransaction/api/oneclick/v1.3";
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;
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,7 @@
import cl.transbank.webpay.oneclick.model.MallTransactionCreateDetails;
import cl.transbank.webpay.oneclick.requests.*;
import cl.transbank.webpay.oneclick.responses.*;
import cl.transbank.webpay.requests.*;
import cl.transbank.webpay.responses.*;


import java.io.IOException;
import java.util.List;


abstract class OneclickMallTransaction extends BaseTransaction {

Expand Down Expand Up @@ -85,55 +79,4 @@ public OneclickMallTransactionCaptureResponse capture(String childCommerceCode,
}
}

public IncreaseAmountResponse increaseAmount(String childCommerceCode, String childBuyOrder, String authorizationCode, double amount) throws IOException, IncreaseAmountException {
ValidationUtil.hasTextWithMaxLength(childCommerceCode, ApiConstants.COMMERCE_CODE_LENGTH, "childCommerceCode");
ValidationUtil.hasTextWithMaxLength(childBuyOrder, ApiConstants.BUY_ORDER_LENGTH, "childBuyOrder");
ValidationUtil.hasTextWithMaxLength(authorizationCode, ApiConstants.AUTHORIZATION_CODE_LENGTH, "authorizationCode");
WebpayApiRequest request = new IncreaseAmountRequest(childCommerceCode, childBuyOrder, authorizationCode, amount);
String endpoint = String.format("%s/transactions/amount", ApiConstants.ONECLICK_ENDPOINT);
try {
return WebpayApiResource.execute(endpoint, HttpUtil.RequestMethod.PUT, request, options, IncreaseAmountResponse.class);
} catch (TransbankException e) {
throw new IncreaseAmountException(e);
}
}

public IncreaseAuthorizationDateResponse increaseAuthorizationDate(String childCommerceCode, String childBuyOrder, String authorizationCode) throws IOException, IncreaseAuthorizationDateException {
ValidationUtil.hasTextWithMaxLength(childCommerceCode, ApiConstants.COMMERCE_CODE_LENGTH, "childCommerceCode");
ValidationUtil.hasTextWithMaxLength(childBuyOrder, ApiConstants.BUY_ORDER_LENGTH, "childBuyOrder");
ValidationUtil.hasTextWithMaxLength(authorizationCode, ApiConstants.AUTHORIZATION_CODE_LENGTH, "authorizationCode");
WebpayApiRequest request = new IncreaseAuthorizationDateRequest(childCommerceCode, childBuyOrder, authorizationCode);
String endpoint = String.format("%s/transactions/authorization_date", ApiConstants.ONECLICK_ENDPOINT);
try {
return WebpayApiResource.execute(endpoint, HttpUtil.RequestMethod.PUT, request, options, IncreaseAuthorizationDateResponse.class);
} catch (TransbankException e) {
throw new IncreaseAuthorizationDateException(e);
}
}

public ReversePreAuthorizedAmountResponse reversePreAuthorizedAmount(String childCommerceCode, String childBuyOrder, String authorizationCode, double amount) throws IOException, ReversePreAuthorizedAmountException {
ValidationUtil.hasTextWithMaxLength(childCommerceCode, ApiConstants.COMMERCE_CODE_LENGTH, "childCommerceCode");
ValidationUtil.hasTextWithMaxLength(childBuyOrder, ApiConstants.BUY_ORDER_LENGTH, "childBuyOrder");
ValidationUtil.hasTextWithMaxLength(authorizationCode, ApiConstants.AUTHORIZATION_CODE_LENGTH, "authorizationCode");
WebpayApiRequest request = new ReversePreAuthorizedAmountRequest(childCommerceCode, childBuyOrder, authorizationCode, amount);
String endpoint = String.format("%s/transactions/reverse/amount", ApiConstants.ONECLICK_ENDPOINT);
try {
return WebpayApiResource.execute(endpoint, HttpUtil.RequestMethod.PUT, request, options, ReversePreAuthorizedAmountResponse.class);
} catch (TransbankException e) {
throw new ReversePreAuthorizedAmountException(e);
}
}

public List<DeferredCaptureHistoryResponse> deferredCaptureHistory(String childCommerceCode, String childBuyOrder, String authorizationCode) throws IOException, DeferredCaptureHistoryException {
ValidationUtil.hasTextWithMaxLength(childCommerceCode, ApiConstants.COMMERCE_CODE_LENGTH, "childCommerceCode");
ValidationUtil.hasTextWithMaxLength(childBuyOrder, ApiConstants.BUY_ORDER_LENGTH, "childBuyOrder");
ValidationUtil.hasTextWithMaxLength(authorizationCode, ApiConstants.AUTHORIZATION_CODE_LENGTH, "authorizationCode");
WebpayApiRequest request = new DeferredCaptureHistoryRequest(childCommerceCode, childBuyOrder, authorizationCode);
String endpoint = String.format("%s/transactions/details", ApiConstants.ONECLICK_ENDPOINT);
try {
return WebpayApiResource.executeToList(endpoint, HttpUtil.RequestMethod.POST, request, options, DeferredCaptureHistoryResponse[].class);
} catch (TransbankException e) {
throw new DeferredCaptureHistoryException(e);
}
}
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
import cl.transbank.util.ValidationUtil;
import cl.transbank.webpay.common.TransactionCaptureRequest;
import cl.transbank.webpay.common.TransactionRefundRequest;
import cl.transbank.webpay.requests.*;
import cl.transbank.webpay.responses.*;
import cl.transbank.webpay.transaccioncompleta.requests.*;
import cl.transbank.webpay.transaccioncompleta.responses.*;
import cl.transbank.util.HttpUtil;
Expand All @@ -17,7 +15,6 @@
import cl.transbank.webpay.exception.*;

import java.io.IOException;
import java.util.List;

public class FullTransaction extends BaseTransaction {

Expand Down Expand Up @@ -103,55 +100,6 @@ public FullTransactionCaptureResponse capture(String token, String buyOrder, Str
}
}

public IncreaseAmountResponse increaseAmount(String token, String buyOrder, String authorizationCode, double amount) throws IOException, IncreaseAmountException {
ValidationUtil.hasTextWithMaxLength(token, ApiConstants.TOKEN_LENGTH, "token");
ValidationUtil.hasTextWithMaxLength(buyOrder, ApiConstants.BUY_ORDER_LENGTH, "buyOrder");
ValidationUtil.hasTextWithMaxLength(authorizationCode, ApiConstants.AUTHORIZATION_CODE_LENGTH, "authorizationCode");
WebpayApiRequest request = new IncreaseAmountRequest(options.getCommerceCode(), buyOrder, authorizationCode, amount);
String endpoint = String.format("%s/transactions/%s/amount", ApiConstants.WEBPAY_ENDPOINT, token);
try {
return WebpayApiResource.execute(endpoint, HttpUtil.RequestMethod.PUT, request, options, IncreaseAmountResponse.class);
} catch (TransbankException e) {
throw new IncreaseAmountException(e);
}
}

public IncreaseAuthorizationDateResponse increaseAuthorizationDate(String token, String buyOrder, String authorizationCode) throws IOException, IncreaseAuthorizationDateException {
ValidationUtil.hasTextWithMaxLength(token, ApiConstants.TOKEN_LENGTH, "token");
ValidationUtil.hasTextWithMaxLength(buyOrder, ApiConstants.BUY_ORDER_LENGTH, "buyOrder");
ValidationUtil.hasTextWithMaxLength(authorizationCode, ApiConstants.AUTHORIZATION_CODE_LENGTH, "authorizationCode");
WebpayApiRequest request = new IncreaseAuthorizationDateRequest(options.getCommerceCode(), buyOrder, authorizationCode);
String endpoint = String.format("%s/transactions/%s/authorization_date", ApiConstants.WEBPAY_ENDPOINT, token);
try {
return WebpayApiResource.execute(endpoint, HttpUtil.RequestMethod.PUT, request, options, IncreaseAuthorizationDateResponse.class);
} catch (TransbankException e) {
throw new IncreaseAuthorizationDateException(e);
}
}

public ReversePreAuthorizedAmountResponse reversePreAuthorizedAmount(String token, String buyOrder, String authorizationCode, double amount) throws IOException, ReversePreAuthorizedAmountException {
ValidationUtil.hasTextWithMaxLength(token, ApiConstants.TOKEN_LENGTH, "token");
ValidationUtil.hasTextWithMaxLength(buyOrder, ApiConstants.BUY_ORDER_LENGTH, "buyOrder");
ValidationUtil.hasTextWithMaxLength(authorizationCode, ApiConstants.AUTHORIZATION_CODE_LENGTH, "authorizationCode");
WebpayApiRequest request = new ReversePreAuthorizedAmountRequest(options.getCommerceCode(), buyOrder, authorizationCode, amount);
String endpoint = String.format("%s/transactions/%s/reverse/amount", ApiConstants.WEBPAY_ENDPOINT, token);
try {
return WebpayApiResource.execute(endpoint, HttpUtil.RequestMethod.PUT, request, options, ReversePreAuthorizedAmountResponse.class);
} catch (TransbankException e) {
throw new ReversePreAuthorizedAmountException(e);
}
}

public List<DeferredCaptureHistoryResponse> deferredCaptureHistory(String token) throws IOException, DeferredCaptureHistoryException {
ValidationUtil.hasTextWithMaxLength(token, ApiConstants.TOKEN_LENGTH, "token");
String endpoint = String.format("%s/transactions/%s/details", ApiConstants.WEBPAY_ENDPOINT,token);
try {
return WebpayApiResource.executeToList(endpoint, HttpUtil.RequestMethod.GET, options, DeferredCaptureHistoryResponse[].class);
} catch (TransbankException e) {
throw new DeferredCaptureHistoryException(e);
}
}


/*
|--------------------------------------------------------------------------
Expand Down
Loading

0 comments on commit 55ccc7c

Please sign in to comment.