Skip to content

Commit 5d26dad

Browse files
authored
Merge pull request #77 from TransbankDevelopers/feat/api1.3
update to api 1.3
2 parents e73c7b1 + 6caa5ae commit 5d26dad

File tree

9 files changed

+290
-12
lines changed

9 files changed

+290
-12
lines changed

lib/transbank/sdk/common/api_constants.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
module Transbank
22
module Common
33
module ApiConstants
4-
WEBPAY_ENDPOINT = 'rswebpaytransaction/api/webpay/v1.2'.freeze
5-
ONECLICK_ENDPOINT = 'rswebpaytransaction/api/oneclick/v1.2'.freeze
4+
WEBPAY_ENDPOINT = 'rswebpaytransaction/api/webpay/v1.3'.freeze
5+
ONECLICK_ENDPOINT = 'rswebpaytransaction/api/oneclick/v1.3'.freeze
66
PATPASS_ENDPOINT = 'restpatpass/v1/services'.freeze
77

88
BUY_ORDER_LENGTH = 26;

lib/transbank/sdk/common/integration_commerce_codes.rb

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,29 @@ module IntegrationCommerceCodes
1010
WEBPAY_PLUS_MALL_CHILD1 = '597055555536'.freeze
1111
WEBPAY_PLUS_MALL_CHILD2 = '597055555537'.freeze
1212
WEBPAY_PLUS_MALL_CHILD_COMMERCE_CODES = [
13-
'597055555582'.freeze,
14-
'597055555583'.freeze
13+
'597055555536'.freeze,
14+
'597055555537'.freeze
1515
].freeze
1616

1717
WEBPAY_PLUS_MALL_DEFERRED = '597055555581'.freeze
1818
WEBPAY_PLUS_MALL_DEFERRED_CHILD1 = '597055555582'.freeze
1919
WEBPAY_PLUS_MALL_DEFERRED_CHILD2 = '597055555583'.freeze
20-
ONECLICK_MALL = '597055555541'.freeze
20+
WEBPAY_PLUS_MALL_DEFERRED_CHILD_COMMERCE_CODES = [
21+
'597055555582'.freeze,
22+
'597055555583'.freeze
23+
].freeze
2124

25+
ONECLICK_MALL = '597055555541'.freeze
26+
ONECLICK_MALL_CHILD1 = '597055555542'.freeze
27+
ONECLICK_MALL_CHILD2 = '597055555543'.freeze
2228
ONECLICK_MALL_CHILD_COMMERCE_CODES = [
2329
'597055555542'.freeze,
2430
'597055555543'.freeze
2531
].freeze
2632

2733
ONECLICK_MALL_DEFERRED = '597055555547'.freeze
28-
34+
ONECLICK_MALL_DEFERRED_CHILD1 = '597055555548'.freeze
35+
ONECLICK_MALL_DEFERRED_CHILD2 = '597055555549'.freeze
2936
ONECLICK_MALL_DEFERRED_CHILD_COMMERCE_CODES = [
3037
'597055555548'.freeze,
3138
'597055555549'.freeze
@@ -45,6 +52,8 @@ module IntegrationCommerceCodes
4552
].freeze
4653

4754
TRANSACCION_COMPLETA_MALL_SIN_CVV = '597055555551'.freeze
55+
TRANSACCION_COMPLETA_MALL_SIN_CVV_CHILD1 = '597055555552'.freeze
56+
TRANSACCION_COMPLETA_MALL_SIN_CVV_CHILD2 = '597055555553'.freeze
4857
TRANSACCION_COMPLETA_MALL_SIN_CVV_CHILD = [
4958
'597055555552'.freeze,
5059
'597055555553'.freeze
@@ -61,6 +70,11 @@ module IntegrationCommerceCodes
6170
TRANSACCION_COMPLETA_MALL_DEFERRED_SIN_CVV = '597055555561'.freeze
6271
TRANSACCION_COMPLETA_MALL_DEFERRED_SIN_CVV_CHILD1 = '597055555562'.freeze
6372
TRANSACCION_COMPLETA_MALL_DEFERRED_SIN_CVV_CHILD2 = '597055555563'.freeze
73+
TRANSACCION_COMPLETA_MALL_DEFERRED_SIN_CVV_CHILD = [
74+
'597055555562'.freeze,
75+
'597055555563'.freeze
76+
].freeze
77+
6478
PATPASS_COMERCIO = '28299257'.freeze
6579
PATPASS_BY_WEBPAY = "597055555550".freeze
6680
end

lib/transbank/sdk/common/validation.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module Common
44
class Validation
55

66
def self.has_text_with_max_length(value, value_max_length, value_name)
7-
if value.empty?
7+
if value.nil? || value.empty?
88
raise Transbank::Shared::TransbankError, "Transbank Error: %s is empty" % [value_name]
99
end
1010
if value.length() > value_max_length

lib/transbank/sdk/webpay/oneclick/mall_transaction.rb

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ class MallTransaction < ::Transbank::Common::BaseTransaction
88
STATUS_ENDPOINT = (RESOURCES_URL + '/transactions/%{token}').freeze
99
REFUND_ENDPOINT = (RESOURCES_URL + '/transactions/%{token}/refunds').freeze
1010
CAPTURE_ENDPOINT = (RESOURCES_URL + '/transactions/capture').freeze
11+
INCREASE_AMOUNT_ENDPOINT = (RESOURCES_URL + '/transactions/amount').freeze
12+
INCREASE_AUTHORIZATION_DATE_ENDPOINT = (RESOURCES_URL + '/transactions/authorization_date').freeze
13+
REVERSE_PRE_AUTHORIZED_AMOUNT_ENDPOINT = (RESOURCES_URL + '/transactions/reverse/amount').freeze
14+
DEFERRED_CAPTURE_HISTORY_ENDPOINT = (RESOURCES_URL + '/transactions/details').freeze
1115

1216
def initialize(commerce_code = ::Transbank::Common::IntegrationCommerceCodes::ONECLICK_MALL, api_key = ::Transbank::Common::IntegrationApiKeys::WEBPAY, environment = DEFAULT_ENVIRONMENT)
1317
super(commerce_code, api_key, environment)
@@ -59,7 +63,55 @@ def refund(buy_order, child_commerce_code, child_buy_order, amount)
5963
@environment, format(REFUND_ENDPOINT, token: buy_order), @commerce_code, @api_key
6064
)
6165
request_service.post(detail_buy_order: child_buy_order, commerce_code: child_commerce_code, amount: amount)
62-
end
66+
end
67+
68+
def increase_amount(child_commerce_code, child_buy_order, authorization_code, amount)
69+
70+
Transbank::Common::Validation.has_text_with_max_length(child_commerce_code, Transbank::Common::ApiConstants::COMMERCE_CODE_LENGTH, "child_commerce_code")
71+
Transbank::Common::Validation.has_text_with_max_length(child_buy_order, Transbank::Common::ApiConstants::BUY_ORDER_LENGTH, "child_buy_order")
72+
Transbank::Common::Validation.has_text_with_max_length(authorization_code, Transbank::Common::ApiConstants::AUTHORIZATION_CODE_LENGTH, "authorization_code")
73+
74+
request_service = ::Transbank::Shared::RequestService.new(
75+
@environment, INCREASE_AMOUNT_ENDPOINT, @commerce_code, @api_key
76+
)
77+
request_service.put(commerce_code: child_commerce_code, buy_order: child_buy_order, authorization_code: authorization_code, amount: amount)
78+
end
79+
80+
def increase_authorization_date(child_commerce_code, child_buy_order, authorization_code)
81+
82+
Transbank::Common::Validation.has_text_with_max_length(child_commerce_code, Transbank::Common::ApiConstants::COMMERCE_CODE_LENGTH, "child_commerce_code")
83+
Transbank::Common::Validation.has_text_with_max_length(child_buy_order, Transbank::Common::ApiConstants::BUY_ORDER_LENGTH, "child_buy_order")
84+
Transbank::Common::Validation.has_text_with_max_length(authorization_code, Transbank::Common::ApiConstants::AUTHORIZATION_CODE_LENGTH, "authorization_code")
85+
86+
request_service = ::Transbank::Shared::RequestService.new(
87+
@environment, INCREASE_AUTHORIZATION_DATE_ENDPOINT, @commerce_code, @api_key
88+
)
89+
request_service.put(commerce_code: child_commerce_code, buy_order: child_buy_order, authorization_code: authorization_code)
90+
end
91+
92+
def reverse_pre_authorized_amount(child_commerce_code, child_buy_order, authorization_code, amount)
93+
94+
Transbank::Common::Validation.has_text_with_max_length(child_commerce_code, Transbank::Common::ApiConstants::COMMERCE_CODE_LENGTH, "child_commerce_code")
95+
Transbank::Common::Validation.has_text_with_max_length(child_buy_order, Transbank::Common::ApiConstants::BUY_ORDER_LENGTH, "child_buy_order")
96+
Transbank::Common::Validation.has_text_with_max_length(authorization_code, Transbank::Common::ApiConstants::AUTHORIZATION_CODE_LENGTH, "authorization_code")
97+
98+
request_service = ::Transbank::Shared::RequestService.new(
99+
@environment, REVERSE_PRE_AUTHORIZED_AMOUNT_ENDPOINT, @commerce_code, @api_key
100+
)
101+
request_service.put(commerce_code: child_commerce_code, buy_order: child_buy_order, authorization_code: authorization_code, amount: amount)
102+
end
103+
104+
def deferred_capture_history(child_commerce_code, child_buy_order, authorization_code)
105+
106+
Transbank::Common::Validation.has_text_with_max_length(child_commerce_code, Transbank::Common::ApiConstants::COMMERCE_CODE_LENGTH, "child_commerce_code")
107+
Transbank::Common::Validation.has_text_with_max_length(child_buy_order, Transbank::Common::ApiConstants::BUY_ORDER_LENGTH, "child_buy_order")
108+
Transbank::Common::Validation.has_text_with_max_length(authorization_code, Transbank::Common::ApiConstants::AUTHORIZATION_CODE_LENGTH, "authorization_code")
109+
110+
request_service = ::Transbank::Shared::RequestService.new(
111+
@environment, DEFERRED_CAPTURE_HISTORY_ENDPOINT, @commerce_code, @api_key
112+
)
113+
request_service.post(commerce_code: child_commerce_code, buy_order: child_buy_order, authorization_code: authorization_code)
114+
end
63115
end
64116
end
65117
end

lib/transbank/sdk/webpay/transaccion_completa/mall_transaction.rb

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ class MallTransaction < ::Transbank::Common::BaseTransaction
1010
STATUS_ENDPOINT = (RESOURCES_URL + '/transactions/%{token}').freeze
1111
REFUND_ENDPOINT = (RESOURCES_URL + '/transactions/%{token}/refunds').freeze
1212
CAPTURE_ENDPOINT = (RESOURCES_URL + '/transactions/%{token}/capture').freeze
13+
INCREASE_AMOUNT_ENDPOINT = (RESOURCES_URL + '/transactions/%{token}/amount').freeze
14+
INCREASE_AUTHORIZATION_DATE_ENDPOINT = (RESOURCES_URL + '/transactions/%{token}/authorization_date').freeze
15+
REVERSE_PRE_AUTHORIZED_AMOUNT_ENDPOINT = (RESOURCES_URL + '/transactions/%{token}/reverse/amount').freeze
16+
DEFERRED_CAPTURE_HISTORY_ENDPOINT = (RESOURCES_URL + '/transactions/%{token}/details').freeze
1317

1418
def initialize(commerce_code = ::Transbank::Common::IntegrationCommerceCodes::TRANSACCION_COMPLETA_MALL, api_key = ::Transbank::Common::IntegrationApiKeys::WEBPAY, environment = DEFAULT_ENVIRONMENT)
1519
super(commerce_code, api_key, environment)
@@ -60,7 +64,58 @@ def capture(token, commerce_code, buy_order, authorization_code, amount)
6064
@environment, format(CAPTURE_ENDPOINT, token: token), @commerce_code, @api_key
6165
)
6266
request_service.put(buy_order: buy_order, commerce_code: commerce_code, authorization_code: authorization_code, capture_amount: amount)
63-
end
67+
end
68+
69+
def increase_amount(token, child_commerce_code, child_buy_order, authorization_code, amount)
70+
71+
Transbank::Common::Validation.has_text_with_max_length(child_commerce_code, Transbank::Common::ApiConstants::COMMERCE_CODE_LENGTH, "child_commerce_code")
72+
Transbank::Common::Validation.has_text_with_max_length(token, Transbank::Common::ApiConstants::TOKEN_LENGTH, "token")
73+
Transbank::Common::Validation.has_text_with_max_length(child_buy_order, Transbank::Common::ApiConstants::BUY_ORDER_LENGTH, "child_buy_order")
74+
Transbank::Common::Validation.has_text_with_max_length(authorization_code, Transbank::Common::ApiConstants::AUTHORIZATION_CODE_LENGTH, "authorization_code")
75+
76+
request_service = ::Transbank::Shared::RequestService.new(
77+
@environment, format(INCREASE_AMOUNT_ENDPOINT, token: token), @commerce_code, @api_key
78+
)
79+
request_service.put(commerce_code: child_commerce_code, buy_order: child_buy_order, authorization_code: authorization_code, amount: amount)
80+
end
81+
82+
def increase_authorization_date(token, child_commerce_code, child_buy_order, authorization_code)
83+
84+
Transbank::Common::Validation.has_text_with_max_length(child_commerce_code, Transbank::Common::ApiConstants::COMMERCE_CODE_LENGTH, "child_commerce_code")
85+
Transbank::Common::Validation.has_text_with_max_length(token, Transbank::Common::ApiConstants::TOKEN_LENGTH, "token")
86+
Transbank::Common::Validation.has_text_with_max_length(child_buy_order, Transbank::Common::ApiConstants::BUY_ORDER_LENGTH, "child_buy_order")
87+
Transbank::Common::Validation.has_text_with_max_length(authorization_code, Transbank::Common::ApiConstants::AUTHORIZATION_CODE_LENGTH, "authorization_code")
88+
89+
request_service = ::Transbank::Shared::RequestService.new(
90+
@environment, format(INCREASE_AUTHORIZATION_DATE_ENDPOINT, token: token), @commerce_code, @api_key
91+
)
92+
request_service.put(commerce_code: child_commerce_code, buy_order: child_buy_order, authorization_code: authorization_code)
93+
end
94+
95+
def reverse_pre_authorized_amount(token, child_commerce_code, child_buy_order, authorization_code, amount)
96+
97+
Transbank::Common::Validation.has_text_with_max_length(child_commerce_code, Transbank::Common::ApiConstants::COMMERCE_CODE_LENGTH, "child_commerce_code")
98+
Transbank::Common::Validation.has_text_with_max_length(token, Transbank::Common::ApiConstants::TOKEN_LENGTH, "token")
99+
Transbank::Common::Validation.has_text_with_max_length(child_buy_order, Transbank::Common::ApiConstants::BUY_ORDER_LENGTH, "child_buy_order")
100+
Transbank::Common::Validation.has_text_with_max_length(authorization_code, Transbank::Common::ApiConstants::AUTHORIZATION_CODE_LENGTH, "authorization_code")
101+
102+
request_service = ::Transbank::Shared::RequestService.new(
103+
@environment, format(REVERSE_PRE_AUTHORIZED_AMOUNT_ENDPOINT, token: token), @commerce_code, @api_key
104+
)
105+
request_service.put(commerce_code: child_commerce_code, buy_order: child_buy_order, authorization_code: authorization_code, amount: amount)
106+
end
107+
108+
def deferred_capture_history(token, child_commerce_code, child_buy_order)
109+
110+
Transbank::Common::Validation.has_text_with_max_length(child_commerce_code, Transbank::Common::ApiConstants::COMMERCE_CODE_LENGTH, "child_commerce_code")
111+
Transbank::Common::Validation.has_text_with_max_length(token, Transbank::Common::ApiConstants::TOKEN_LENGTH, "token")
112+
Transbank::Common::Validation.has_text_with_max_length(child_buy_order, Transbank::Common::ApiConstants::BUY_ORDER_LENGTH, "child_buy_order")
113+
114+
request_service = ::Transbank::Shared::RequestService.new(
115+
@environment, format(DEFERRED_CAPTURE_HISTORY_ENDPOINT, token: token), @commerce_code, @api_key
116+
)
117+
request_service.post(commerce_code: child_commerce_code, buy_order: child_buy_order)
118+
end
64119
end
65120
end
66121
end

lib/transbank/sdk/webpay/transaccion_completa/transaction.rb

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ class Transaction < ::Transbank::Common::BaseTransaction
1010
STATUS_ENDPOINT = (RESOURCES_URL + '/transactions/%{token}').freeze
1111
REFUND_ENDPOINT = (RESOURCES_URL + '/transactions/%{token}/refunds').freeze
1212
CAPTURE_ENDPOINT = (RESOURCES_URL + '/transactions/%{token}/capture').freeze
13+
INCREASE_AMOUNT_ENDPOINT = (RESOURCES_URL + '/transactions/%{token}/amount').freeze
14+
INCREASE_AUTHORIZATION_DATE_ENDPOINT = (RESOURCES_URL + '/transactions/%{token}/authorization_date').freeze
15+
REVERSE_PRE_AUTHORIZED_AMOUNT_ENDPOINT = (RESOURCES_URL + '/transactions/%{token}/reverse/amount').freeze
16+
DEFERRED_CAPTURE_HISTORY_ENDPOINT = (RESOURCES_URL + '/transactions/%{token}/details').freeze
1317

1418
def initialize(commerce_code = ::Transbank::Common::IntegrationCommerceCodes::TRANSACCION_COMPLETA, api_key = ::Transbank::Common::IntegrationApiKeys::WEBPAY, environment = DEFAULT_ENVIRONMENT)
1519
super
@@ -64,6 +68,52 @@ def capture(token, buy_order, authorization_code, amount)
6468
)
6569
request_service.put(buy_order: buy_order, authorization_code: authorization_code, capture_amount: amount)
6670
end
71+
72+
def increase_amount(token, buy_order, authorization_code, amount)
73+
74+
Transbank::Common::Validation.has_text_with_max_length(token, Transbank::Common::ApiConstants::TOKEN_LENGTH, "token")
75+
Transbank::Common::Validation.has_text_with_max_length(buy_order, Transbank::Common::ApiConstants::BUY_ORDER_LENGTH, "buy_order")
76+
Transbank::Common::Validation.has_text_with_max_length(authorization_code, Transbank::Common::ApiConstants::AUTHORIZATION_CODE_LENGTH, "authorization_code")
77+
78+
request_service = ::Transbank::Shared::RequestService.new(
79+
@environment, format(INCREASE_AMOUNT_ENDPOINT, token: token), @commerce_code, @api_key
80+
)
81+
request_service.put(commerce_code: @commerce_code, buy_order: buy_order, authorization_code: authorization_code, amount: amount)
82+
end
83+
84+
def increase_authorization_date(token, buy_order, authorization_code)
85+
86+
Transbank::Common::Validation.has_text_with_max_length(token, Transbank::Common::ApiConstants::TOKEN_LENGTH, "token")
87+
Transbank::Common::Validation.has_text_with_max_length(buy_order, Transbank::Common::ApiConstants::BUY_ORDER_LENGTH, "buy_order")
88+
Transbank::Common::Validation.has_text_with_max_length(authorization_code, Transbank::Common::ApiConstants::AUTHORIZATION_CODE_LENGTH, "authorization_code")
89+
90+
request_service = ::Transbank::Shared::RequestService.new(
91+
@environment, format(INCREASE_AUTHORIZATION_DATE_ENDPOINT, token: token), @commerce_code, @api_key
92+
)
93+
request_service.put(commerce_code: @commerce_code, buy_order: buy_order, authorization_code: authorization_code)
94+
end
95+
96+
def reverse_pre_authorized_amount(token, buy_order, authorization_code, amount)
97+
98+
Transbank::Common::Validation.has_text_with_max_length(token, Transbank::Common::ApiConstants::TOKEN_LENGTH, "token")
99+
Transbank::Common::Validation.has_text_with_max_length(buy_order, Transbank::Common::ApiConstants::BUY_ORDER_LENGTH, "buy_order")
100+
Transbank::Common::Validation.has_text_with_max_length(authorization_code, Transbank::Common::ApiConstants::AUTHORIZATION_CODE_LENGTH, "authorization_code")
101+
102+
request_service = ::Transbank::Shared::RequestService.new(
103+
@environment, format(REVERSE_PRE_AUTHORIZED_AMOUNT_ENDPOINT, token: token), @commerce_code, @api_key
104+
)
105+
request_service.put(commerce_code: @commerce_code, buy_order: buy_order, authorization_code: authorization_code, amount: amount)
106+
end
107+
108+
def deferred_capture_history(token)
109+
110+
Transbank::Common::Validation.has_text_with_max_length(token, Transbank::Common::ApiConstants::TOKEN_LENGTH, "token")
111+
112+
request_service = ::Transbank::Shared::RequestService.new(
113+
@environment, format(DEFERRED_CAPTURE_HISTORY_ENDPOINT, token: token), @commerce_code, @api_key
114+
)
115+
request_service.get
116+
end
67117
end
68118
end
69119
end

0 commit comments

Comments
 (0)