Skip to content

Commit

Permalink
downgrade api 1.3 to 1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
tribiec committed Jan 3, 2024
1 parent a584d7d commit 31790be
Show file tree
Hide file tree
Showing 12 changed files with 5 additions and 619 deletions.
10 changes: 5 additions & 5 deletions lib/transbank/common/api_constants.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/**
* Contains the Webpay and Oneclick URLs base.
*/
enum ApiConstants {
WEBPAY_ENDPOINT = "/rswebpaytransaction/api/webpay/v1.3",
ONECLICK_ENDPOINT = "/rswebpaytransaction/api/oneclick/v1.3",
PATPASS_COMERCIO_ENDPOINT = "/restpatpass/v1/services",
enum ApiConstants {
WEBPAY_ENDPOINT = '/rswebpaytransaction/api/webpay/v1.2',
ONECLICK_ENDPOINT = '/rswebpaytransaction/api/oneclick/v1.2',
PATPASS_COMERCIO_ENDPOINT = '/restpatpass/v1/services',

BUY_ORDER_LENGTH = 26,
SESSION_ID_LENGTH = 61,
Expand All @@ -16,7 +16,7 @@
USER_NAME_LENGTH = 40,
COMMERCE_CODE_LENGTH = 12,
TOKEN_LENGTH = 64,
EMAIL_LENGTH = 100
EMAIL_LENGTH = 100,
}

export default ApiConstants;
94 changes: 0 additions & 94 deletions lib/transbank/webpay/oneclick/mall_transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import ApiConstants from '../../common/api_constants';
import IntegrationCommerceCodes from '../../common/integration_commerce_codes';
import IntegrationApiKeys from '../../common/integration_api_keys';
import Environment from '../common/environment';
import { DeferredCaptureHistoryRequest, IncreaseAmountRequest, IncreaseAuthorizationDateRequest, ReversePreAuthorizedAmountRequest } from '../requests';

class MallTransaction extends BaseTransaction {

Expand Down Expand Up @@ -104,99 +103,6 @@ class MallTransaction extends BaseTransaction {
let captureRequest = new CaptureRequest(childCommerceCode, childBuyOrder, captureAmount, authorizationCode);
return RequestService.perform(captureRequest, this.options);
}

/** Increase pre-authorizate amount.
*
* Your commerce code must be configured to support deferred capture.
*
* @param childCommerceCode Child commerce code, used to indetify the correct child transaction
* @param childBuyOrder Child buy order, used to identify the correct child transaction.
* @param authorizationCode Transaction's authorization code
* @param amount Amount to be increase
*/
async increaseAmount (
childCommerceCode: string,
childBuyOrder: string,
authorizationCode: string,
amount: number
){
ValidationUtil.hasTextWithMaxLength(childCommerceCode, ApiConstants.COMMERCE_CODE_LENGTH, "childCommerceCode");
ValidationUtil.hasTextWithMaxLength(childBuyOrder, ApiConstants.BUY_ORDER_LENGTH, "childBuyOrder");
ValidationUtil.hasTextWithMaxLength(authorizationCode, ApiConstants.AUTHORIZATION_CODE_LENGTH, "authorizationCode");
return RequestService.perform(
new IncreaseAmountRequest(`${ApiConstants.ONECLICK_ENDPOINT}/transactions/amount`, childCommerceCode, childBuyOrder, authorizationCode, amount),
this.options
);
}

/** Increase authorization date.
*
* Your commerce code must be configured to support deferred capture.
*
* @param childCommerceCode Child commerce code, used to indetify the correct child transaction
* @param childBuyOrder Child buy order, used to identify the correct child transaction.
* @param authorizationCode Transaction's authorization code
*/
async increaseAuthorizationDate(
childCommerceCode: string,
childBuyOrder: string,
authorizationCode: string
){
ValidationUtil.hasTextWithMaxLength(childCommerceCode, ApiConstants.COMMERCE_CODE_LENGTH, "childCommerceCode");
ValidationUtil.hasTextWithMaxLength(childBuyOrder, ApiConstants.BUY_ORDER_LENGTH, "childBuyOrder");
ValidationUtil.hasTextWithMaxLength(authorizationCode, ApiConstants.AUTHORIZATION_CODE_LENGTH, "authorizationCode");
return RequestService.perform(
new IncreaseAuthorizationDateRequest(`${ApiConstants.ONECLICK_ENDPOINT}/transactions/authorization_date`, childCommerceCode, childBuyOrder, authorizationCode),
this.options
);
}

/** Reverse pre-authorizate amount.
*
* Your commerce code must be configured to support deferred capture.
*
* @param childCommerceCode Child commerce code, used to indetify the correct child transaction
* @param childBuyOrder Child buy order, used to identify the correct child transaction.
* @param authorizationCode Transaction's authorization code
* @param amount Amount to be increase
*/
async reversePreAuthorizedAmount(
childCommerceCode: string,
childBuyOrder: string,
authorizationCode: string,
amount: number
){
ValidationUtil.hasTextWithMaxLength(childCommerceCode, ApiConstants.COMMERCE_CODE_LENGTH, "childCommerceCode");
ValidationUtil.hasTextWithMaxLength(childBuyOrder, ApiConstants.BUY_ORDER_LENGTH, "childBuyOrder");
ValidationUtil.hasTextWithMaxLength(authorizationCode, ApiConstants.AUTHORIZATION_CODE_LENGTH, "authorizationCode");
return RequestService.perform(
new ReversePreAuthorizedAmountRequest(`${ApiConstants.ONECLICK_ENDPOINT}/transactions/reverse/amount`, childCommerceCode, childBuyOrder, authorizationCode, amount),
this.options
);
}

/** List deferred capture history.
*
* Your commerce code must be configured to support deferred capture.
*
* @param childCommerceCode Child commerce code, used to indetify the correct child transaction
* @param childBuyOrder Child buy order, used to identify the correct child transaction.
* @param authorizationCode Transaction's authorization code
*/
async deferredCaptureHistory(
childCommerceCode: string,
childBuyOrder: string,
authorizationCode: string
){
ValidationUtil.hasTextWithMaxLength(childCommerceCode, ApiConstants.COMMERCE_CODE_LENGTH, "childCommerceCode");
ValidationUtil.hasTextWithMaxLength(childBuyOrder, ApiConstants.BUY_ORDER_LENGTH, "childBuyOrder");
ValidationUtil.hasTextWithMaxLength(authorizationCode, ApiConstants.AUTHORIZATION_CODE_LENGTH, "authorizationCode");
return RequestService.perform(
new DeferredCaptureHistoryRequest(`${ApiConstants.ONECLICK_ENDPOINT}/transactions/details`, childCommerceCode, childBuyOrder, authorizationCode),
this.options
);
}

};

export default MallTransaction;
27 changes: 0 additions & 27 deletions lib/transbank/webpay/requests/deferred_capture_history_request.ts

This file was deleted.

This file was deleted.

28 changes: 0 additions & 28 deletions lib/transbank/webpay/requests/increase_amount_request.ts

This file was deleted.

This file was deleted.

13 changes: 0 additions & 13 deletions lib/transbank/webpay/requests/index.ts

This file was deleted.

This file was deleted.

105 changes: 0 additions & 105 deletions lib/transbank/webpay/transaccion_completa/mall_transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import IntegrationCommerceCodes from '../../common/integration_commerce_codes';
import IntegrationApiKeys from '../../common/integration_api_keys';
import ValidationUtil from '../../common/validation_util';
import ApiConstants from '../../common/api_constants';
import { DeferredCaptureHistoryRequest, IncreaseAmountRequest, IncreaseAuthorizationDateRequest, ReversePreAuthorizedAmountRequest } from '../requests';

class MallTransaction extends BaseTransaction {

Expand Down Expand Up @@ -161,110 +160,6 @@ class MallTransaction extends BaseTransaction {
);
return RequestService.perform(captureRequest, this.options);
}

/** Increase pre-authorizate amount.
*
* Your commerce code must be configured to support deferred capture.
*
* @param token Unique transaction identifier
* @param childCommerceCode Child commerce code, used to indetify the correct child transaction
* @param childBuyOrder Child buy order, used to identify the correct child transaction.
* @param authorizationCode Transaction's authorization code
* @param amount Amount to be increase
*/
async increaseAmount (
token: string,
childCommerceCode: string,
childBuyOrder: string,
authorizationCode: string,
amount: number
){
ValidationUtil.hasTextWithMaxLength(token, ApiConstants.TOKEN_LENGTH, "token");
ValidationUtil.hasTextWithMaxLength(childCommerceCode, ApiConstants.COMMERCE_CODE_LENGTH, "childCommerceCode");
ValidationUtil.hasTextWithMaxLength(childBuyOrder, ApiConstants.BUY_ORDER_LENGTH, "childBuyOrder");
ValidationUtil.hasTextWithMaxLength(authorizationCode, ApiConstants.AUTHORIZATION_CODE_LENGTH, "authorizationCode");
return RequestService.perform(
new IncreaseAmountRequest(`${ApiConstants.WEBPAY_ENDPOINT}/transactions/${token}/amount`, childCommerceCode, childBuyOrder, authorizationCode, amount),
this.options
);
}

/** Increase authorization date.
*
* Your commerce code must be configured to support deferred capture.
*
* @param token Unique transaction identifier
* @param childCommerceCode Child commerce code, used to indetify the correct child transaction
* @param childBuyOrder Child buy order, used to identify the correct child transaction.
* @param authorizationCode Transaction's authorization code
*/
async increaseAuthorizationDate(
token: string,
childCommerceCode: string,
childBuyOrder: string,
authorizationCode: string
){
ValidationUtil.hasTextWithMaxLength(token, ApiConstants.TOKEN_LENGTH, "token");
ValidationUtil.hasTextWithMaxLength(childCommerceCode, ApiConstants.COMMERCE_CODE_LENGTH, "childCommerceCode");
ValidationUtil.hasTextWithMaxLength(childBuyOrder, ApiConstants.BUY_ORDER_LENGTH, "childBuyOrder");
ValidationUtil.hasTextWithMaxLength(authorizationCode, ApiConstants.AUTHORIZATION_CODE_LENGTH, "authorizationCode");
return RequestService.perform(
new IncreaseAuthorizationDateRequest(`${ApiConstants.WEBPAY_ENDPOINT}/transactions/${token}/authorization_date`, childCommerceCode, childBuyOrder, authorizationCode),
this.options
);
}

/** Reverse pre-authorizate amount.
*
* Your commerce code must be configured to support deferred capture.
*
* @param token Unique transaction identifier
* @param childCommerceCode Child commerce code, used to indetify the correct child transaction
* @param childBuyOrder Child buy order, used to identify the correct child transaction.
* @param authorizationCode Transaction's authorization code
* @param amount Amount to be increase
*/
async reversePreAuthorizedAmount(
token: string,
childCommerceCode: string,
childBuyOrder: string,
authorizationCode: string,
amount: number
){
ValidationUtil.hasTextWithMaxLength(token, ApiConstants.TOKEN_LENGTH, "token");
ValidationUtil.hasTextWithMaxLength(childCommerceCode, ApiConstants.COMMERCE_CODE_LENGTH, "childCommerceCode");
ValidationUtil.hasTextWithMaxLength(childBuyOrder, ApiConstants.BUY_ORDER_LENGTH, "childBuyOrder");
ValidationUtil.hasTextWithMaxLength(authorizationCode, ApiConstants.AUTHORIZATION_CODE_LENGTH, "authorizationCode");
return RequestService.perform(
new ReversePreAuthorizedAmountRequest(`${ApiConstants.WEBPAY_ENDPOINT}/transactions/${token}/reverse/amount`, childCommerceCode, childBuyOrder, authorizationCode, amount),
this.options
);
}

/** List deferred capture history.
*
* Your commerce code must be configured to support deferred capture.
*
* @param token Unique transaction identifier
* @param childCommerceCode Child commerce code, used to indetify the correct child transaction
* @param childBuyOrder Child buy order, used to identify the correct child transaction.
* @param authorizationCode Transaction's authorization code
*/
async deferredCaptureHistory(
token: string,
childCommerceCode: string,
childBuyOrder: string,
authorizationCode: string
){
ValidationUtil.hasTextWithMaxLength(token, ApiConstants.TOKEN_LENGTH, "token");
ValidationUtil.hasTextWithMaxLength(childCommerceCode, ApiConstants.COMMERCE_CODE_LENGTH, "childCommerceCode");
ValidationUtil.hasTextWithMaxLength(childBuyOrder, ApiConstants.BUY_ORDER_LENGTH, "childBuyOrder");
ValidationUtil.hasTextWithMaxLength(authorizationCode, ApiConstants.AUTHORIZATION_CODE_LENGTH, "authorizationCode");
return RequestService.perform(
new DeferredCaptureHistoryRequest(`${ApiConstants.WEBPAY_ENDPOINT}/transactions/${token}/details`, childCommerceCode, childBuyOrder, ''),
this.options
);
}
};

export default MallTransaction;
Loading

0 comments on commit 31790be

Please sign in to comment.