transbank-sdk 2.0.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 256bc0c3ced136ec4077152e1a70b5bd8ea2c62dea6acffad29cb9dff3ea8921
4
- data.tar.gz: eac1beeaef40af4e68141d0ac6bfa4b67d6f24bc16d78a8c27a53039c2aed2dc
3
+ metadata.gz: 0da69d29f9e4d6a1ec20aa068d1b5f96489d3ef09677d32c8489b19196c01e94
4
+ data.tar.gz: 84c5739eb799a97ef0e4f69e0ca2765aa911351f16e34d075599062c3e24a1e3
5
5
  SHA512:
6
- metadata.gz: ae2e6b60df22a2baff554a9ab2c5be814d6d3c94e3b303871dbb23f5298c0d805b8aa1c955678f2d18c4ea6768e78fde8b981cd9bf94bbf37c6093ac8acdf899
7
- data.tar.gz: 34bdd0c1c17ff3444121c60b2387417a2b7616b1e3dd950d94104f7c2a3978b7115353d600a7ff7c279486c6860be21bf72aa01b7a5ce9dfe550b2d28cfee428
6
+ metadata.gz: 4773adc503cd8410601d9ba32d04011339d21b638088077998d11bafab5d5ffed7ff6ce65efaeb9fe1fa7de2c86e9e6bc8e4554ff68e2f5ae352e0abcb36f224
7
+ data.tar.gz: f744b9aee837b30e2d228dbc96db66570ed53c10788af624d8b26897fbd9574d3bd0515c3eacc882c5e1e63b63c7d3f318989a173365f09a0bfb183174ad1c9b
data/CHANGELOG.md CHANGED
@@ -4,6 +4,24 @@ Todos los cambios notables a este proyecto serán documentados en este archivo.
4
4
  El formato está basado en [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
5
5
  y este proyecto adhiere a [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [4.0.0] - 2022-09-19
8
+
9
+ ### Fixed
10
+
11
+ - Se soluciona el método 'has_text_with_max_length' para que valide los atributos nulos
12
+
13
+ ### Changed
14
+
15
+ - Se migra el API desde la versión 1.2 a la versión 1.3
16
+
17
+ ### Added
18
+
19
+ - Se agrega los métodos 'increaseAmount', 'increaseAuthorizationDate', 'reversePreAuthorizedAmount', 'deferredCaptureHistory' a las versiones diferidas de WebpayPlus, WebpayPlus Mall, Oneclick Mall, Transaccion Completa y Transaccion Completa Mall
20
+
21
+ ## [2.0.1] - 2022-06-14
22
+ ### Fixed
23
+ - Se soluciona error en método refund para transacciones Webpay Plus Mall. Muchas gracias por tu aporte @danirod
24
+
7
25
  ## [2.0.0] - 2022-01-03
8
26
 
9
27
  ### Removed
@@ -1,8 +1,8 @@
1
1
  module Transbank
2
2
  module Common
3
3
  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
6
6
  PATPASS_ENDPOINT = 'restpatpass/v1/services'.freeze
7
7
 
8
8
  BUY_ORDER_LENGTH = 26;
@@ -10,22 +10,29 @@ module Transbank
10
10
  WEBPAY_PLUS_MALL_CHILD1 = '597055555536'.freeze
11
11
  WEBPAY_PLUS_MALL_CHILD2 = '597055555537'.freeze
12
12
  WEBPAY_PLUS_MALL_CHILD_COMMERCE_CODES = [
13
- '597055555582'.freeze,
14
- '597055555583'.freeze
13
+ '597055555536'.freeze,
14
+ '597055555537'.freeze
15
15
  ].freeze
16
16
 
17
17
  WEBPAY_PLUS_MALL_DEFERRED = '597055555581'.freeze
18
18
  WEBPAY_PLUS_MALL_DEFERRED_CHILD1 = '597055555582'.freeze
19
19
  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
21
24
 
25
+ ONECLICK_MALL = '597055555541'.freeze
26
+ ONECLICK_MALL_CHILD1 = '597055555542'.freeze
27
+ ONECLICK_MALL_CHILD2 = '597055555543'.freeze
22
28
  ONECLICK_MALL_CHILD_COMMERCE_CODES = [
23
29
  '597055555542'.freeze,
24
30
  '597055555543'.freeze
25
31
  ].freeze
26
32
 
27
33
  ONECLICK_MALL_DEFERRED = '597055555547'.freeze
28
-
34
+ ONECLICK_MALL_DEFERRED_CHILD1 = '597055555548'.freeze
35
+ ONECLICK_MALL_DEFERRED_CHILD2 = '597055555549'.freeze
29
36
  ONECLICK_MALL_DEFERRED_CHILD_COMMERCE_CODES = [
30
37
  '597055555548'.freeze,
31
38
  '597055555549'.freeze
@@ -45,6 +52,8 @@ module Transbank
45
52
  ].freeze
46
53
 
47
54
  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
48
57
  TRANSACCION_COMPLETA_MALL_SIN_CVV_CHILD = [
49
58
  '597055555552'.freeze,
50
59
  '597055555553'.freeze
@@ -61,6 +70,11 @@ module Transbank
61
70
  TRANSACCION_COMPLETA_MALL_DEFERRED_SIN_CVV = '597055555561'.freeze
62
71
  TRANSACCION_COMPLETA_MALL_DEFERRED_SIN_CVV_CHILD1 = '597055555562'.freeze
63
72
  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
+
64
78
  PATPASS_COMERCIO = '28299257'.freeze
65
79
  PATPASS_BY_WEBPAY = "597055555550".freeze
66
80
  end
@@ -4,7 +4,7 @@ module Transbank
4
4
  class Validation
5
5
 
6
6
  def self.has_text_with_max_length(value, value_max_length, value_name)
7
- if value.empty?
7
+ if value.nil? || value.empty?
8
8
  raise Transbank::Shared::TransbankError, "Transbank Error: %s is empty" % [value_name]
9
9
  end
10
10
  if value.length() > value_max_length
@@ -1,5 +1,5 @@
1
1
  module Transbank
2
2
  module Sdk
3
- VERSION = '2.0.0'
3
+ VERSION = '3.0.0'
4
4
  end
5
5
  end
@@ -8,6 +8,10 @@ module Transbank
8
8
  STATUS_ENDPOINT = (RESOURCES_URL + '/transactions/%{token}').freeze
9
9
  REFUND_ENDPOINT = (RESOURCES_URL + '/transactions/%{token}/refunds').freeze
10
10
  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
11
15
 
12
16
  def initialize(commerce_code = ::Transbank::Common::IntegrationCommerceCodes::ONECLICK_MALL, api_key = ::Transbank::Common::IntegrationApiKeys::WEBPAY, environment = DEFAULT_ENVIRONMENT)
13
17
  super(commerce_code, api_key, environment)
@@ -59,7 +63,55 @@ module Transbank
59
63
  @environment, format(REFUND_ENDPOINT, token: buy_order), @commerce_code, @api_key
60
64
  )
61
65
  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
63
115
  end
64
116
  end
65
117
  end
@@ -10,6 +10,10 @@ module Transbank
10
10
  STATUS_ENDPOINT = (RESOURCES_URL + '/transactions/%{token}').freeze
11
11
  REFUND_ENDPOINT = (RESOURCES_URL + '/transactions/%{token}/refunds').freeze
12
12
  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
13
17
 
14
18
  def initialize(commerce_code = ::Transbank::Common::IntegrationCommerceCodes::TRANSACCION_COMPLETA_MALL, api_key = ::Transbank::Common::IntegrationApiKeys::WEBPAY, environment = DEFAULT_ENVIRONMENT)
15
19
  super(commerce_code, api_key, environment)
@@ -60,7 +64,58 @@ module Transbank
60
64
  @environment, format(CAPTURE_ENDPOINT, token: token), @commerce_code, @api_key
61
65
  )
62
66
  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
64
119
  end
65
120
  end
66
121
  end
@@ -10,6 +10,10 @@ module Transbank
10
10
  STATUS_ENDPOINT = (RESOURCES_URL + '/transactions/%{token}').freeze
11
11
  REFUND_ENDPOINT = (RESOURCES_URL + '/transactions/%{token}/refunds').freeze
12
12
  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
13
17
 
14
18
  def initialize(commerce_code = ::Transbank::Common::IntegrationCommerceCodes::TRANSACCION_COMPLETA, api_key = ::Transbank::Common::IntegrationApiKeys::WEBPAY, environment = DEFAULT_ENVIRONMENT)
15
19
  super
@@ -64,6 +68,52 @@ module Transbank
64
68
  )
65
69
  request_service.put(buy_order: buy_order, authorization_code: authorization_code, capture_amount: amount)
66
70
  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
67
117
  end
68
118
  end
69
119
  end
@@ -9,6 +9,10 @@ module Transbank
9
9
  STATUS_ENDPOINT = (RESOURCES_URL + '/transactions/%{token}').freeze
10
10
  REFUND_ENDPOINT = (RESOURCES_URL + '/transactions/%{token}/refunds').freeze
11
11
  CAPTURE_ENDPOINT = (RESOURCES_URL + '/transactions/%{token}/capture').freeze
12
+ INCREASE_AMOUNT_ENDPOINT = (RESOURCES_URL + '/transactions/%{token}/amount').freeze
13
+ INCREASE_AUTHORIZATION_DATE_ENDPOINT = (RESOURCES_URL + '/transactions/%{token}/authorization_date').freeze
14
+ REVERSE_PRE_AUTHORIZED_AMOUNT_ENDPOINT = (RESOURCES_URL + '/transactions/%{token}/reverse/amount').freeze
15
+ DEFERRED_CAPTURE_HISTORY_ENDPOINT = (RESOURCES_URL + '/transactions/%{token}/details').freeze
12
16
 
13
17
  def initialize(commerce_code = ::Transbank::Common::IntegrationCommerceCodes::WEBPAY_PLUS_MALL, api_key = ::Transbank::Common::IntegrationApiKeys::WEBPAY, environment = DEFAULT_ENVIRONMENT)
14
18
  super
@@ -50,9 +54,9 @@ module Transbank
50
54
 
51
55
  def refund(token, buy_order, child_commerce_code, amount)
52
56
 
57
+ Transbank::Common::Validation.has_text_with_max_length(token, Transbank::Common::ApiConstants::TOKEN_LENGTH, "token")
53
58
  Transbank::Common::Validation.has_text_with_max_length(buy_order, Transbank::Common::ApiConstants::BUY_ORDER_LENGTH, "buy_order")
54
59
  Transbank::Common::Validation.has_text_with_max_length(child_commerce_code, Transbank::Common::ApiConstants::COMMERCE_CODE_LENGTH, "child_commerce_code")
55
- Transbank::Common::Validation.has_text_with_max_length(child_buy_order, Transbank::Common::ApiConstants::BUY_ORDER_LENGTH, "child_buy_order")
56
60
 
57
61
  request_service = ::Transbank::Shared::RequestService.new(
58
62
  @environment, format(REFUND_ENDPOINT, token: token), @commerce_code, @api_key
@@ -72,7 +76,58 @@ module Transbank
72
76
  @environment, format(CAPTURE_ENDPOINT, token: token), @commerce_code, @api_key
73
77
  )
74
78
  request_service.put(commerce_code: child_commerce_code, buy_order: buy_order, authorization_code: authorization_code, capture_amount: capture_amount)
75
- end
79
+ end
80
+
81
+ def increase_amount(token, child_commerce_code, child_buy_order, authorization_code, amount)
82
+
83
+ Transbank::Common::Validation.has_text_with_max_length(child_commerce_code, Transbank::Common::ApiConstants::COMMERCE_CODE_LENGTH, "child_commerce_code")
84
+ Transbank::Common::Validation.has_text_with_max_length(token, Transbank::Common::ApiConstants::TOKEN_LENGTH, "token")
85
+ Transbank::Common::Validation.has_text_with_max_length(child_buy_order, Transbank::Common::ApiConstants::BUY_ORDER_LENGTH, "child_buy_order")
86
+ Transbank::Common::Validation.has_text_with_max_length(authorization_code, Transbank::Common::ApiConstants::AUTHORIZATION_CODE_LENGTH, "authorization_code")
87
+
88
+ request_service = ::Transbank::Shared::RequestService.new(
89
+ @environment, format(INCREASE_AMOUNT_ENDPOINT, token: token), @commerce_code, @api_key
90
+ )
91
+ request_service.put(commerce_code: child_commerce_code, buy_order: child_buy_order, authorization_code: authorization_code, amount: amount)
92
+ end
93
+
94
+ def increase_authorization_date(token, child_commerce_code, child_buy_order, authorization_code)
95
+
96
+ Transbank::Common::Validation.has_text_with_max_length(child_commerce_code, Transbank::Common::ApiConstants::COMMERCE_CODE_LENGTH, "child_commerce_code")
97
+ Transbank::Common::Validation.has_text_with_max_length(token, Transbank::Common::ApiConstants::TOKEN_LENGTH, "token")
98
+ Transbank::Common::Validation.has_text_with_max_length(child_buy_order, Transbank::Common::ApiConstants::BUY_ORDER_LENGTH, "child_buy_order")
99
+ Transbank::Common::Validation.has_text_with_max_length(authorization_code, Transbank::Common::ApiConstants::AUTHORIZATION_CODE_LENGTH, "authorization_code")
100
+
101
+ request_service = ::Transbank::Shared::RequestService.new(
102
+ @environment, format(INCREASE_AUTHORIZATION_DATE_ENDPOINT, token: token), @commerce_code, @api_key
103
+ )
104
+ request_service.put(commerce_code: child_commerce_code, buy_order: child_buy_order, authorization_code: authorization_code)
105
+ end
106
+
107
+ def reverse_pre_authorized_amount(token, child_commerce_code, child_buy_order, authorization_code, amount)
108
+
109
+ Transbank::Common::Validation.has_text_with_max_length(child_commerce_code, Transbank::Common::ApiConstants::COMMERCE_CODE_LENGTH, "child_commerce_code")
110
+ Transbank::Common::Validation.has_text_with_max_length(token, Transbank::Common::ApiConstants::TOKEN_LENGTH, "token")
111
+ Transbank::Common::Validation.has_text_with_max_length(child_buy_order, Transbank::Common::ApiConstants::BUY_ORDER_LENGTH, "child_buy_order")
112
+ Transbank::Common::Validation.has_text_with_max_length(authorization_code, Transbank::Common::ApiConstants::AUTHORIZATION_CODE_LENGTH, "authorization_code")
113
+
114
+ request_service = ::Transbank::Shared::RequestService.new(
115
+ @environment, format(REVERSE_PRE_AUTHORIZED_AMOUNT_ENDPOINT, token: token), @commerce_code, @api_key
116
+ )
117
+ request_service.put(commerce_code: child_commerce_code, buy_order: child_buy_order, authorization_code: authorization_code, amount: amount)
118
+ end
119
+
120
+ def deferred_capture_history(token, child_commerce_code, child_buy_order)
121
+
122
+ Transbank::Common::Validation.has_text_with_max_length(child_commerce_code, Transbank::Common::ApiConstants::COMMERCE_CODE_LENGTH, "child_commerce_code")
123
+ Transbank::Common::Validation.has_text_with_max_length(token, Transbank::Common::ApiConstants::TOKEN_LENGTH, "token")
124
+ Transbank::Common::Validation.has_text_with_max_length(child_buy_order, Transbank::Common::ApiConstants::BUY_ORDER_LENGTH, "child_buy_order")
125
+
126
+ request_service = ::Transbank::Shared::RequestService.new(
127
+ @environment, format(DEFERRED_CAPTURE_HISTORY_ENDPOINT, token: token), @commerce_code, @api_key
128
+ )
129
+ request_service.post(commerce_code: child_commerce_code, buy_order: child_buy_order)
130
+ end
76
131
  end
77
132
  end
78
133
  end
@@ -9,6 +9,11 @@ module Transbank
9
9
  STATUS_ENDPOINT = (RESOURCES_URL + '/transactions/%{token}').freeze
10
10
  REFUND_ENDPOINT = (RESOURCES_URL + '/transactions/%{token}/refunds').freeze
11
11
  CAPTURE_ENDPOINT = (RESOURCES_URL + '/transactions/%{token}/capture').freeze
12
+ INCREASE_AMOUNT_ENDPOINT = (RESOURCES_URL + '/transactions/%{token}/amount').freeze
13
+ INCREASE_AUTHORIZATION_DATE_ENDPOINT = (RESOURCES_URL + '/transactions/%{token}/authorization_date').freeze
14
+ REVERSE_PRE_AUTHORIZED_AMOUNT_ENDPOINT = (RESOURCES_URL + '/transactions/%{token}/reverse/amount').freeze
15
+ DEFERRED_CAPTURE_HISTORY_ENDPOINT = (RESOURCES_URL + '/transactions/%{token}/details').freeze
16
+
12
17
 
13
18
  def initialize(commerce_code = ::Transbank::Common::IntegrationCommerceCodes::WEBPAY_PLUS, api_key = ::Transbank::Common::IntegrationApiKeys::WEBPAY, environment = DEFAULT_ENVIRONMENT)
14
19
  super(commerce_code, api_key, environment)
@@ -69,6 +74,53 @@ module Transbank
69
74
  )
70
75
  request_service.put(buy_order: buy_order, authorization_code: authorization_code, capture_amount: amount)
71
76
  end
77
+
78
+ def increase_amount(token, buy_order, authorization_code, amount)
79
+
80
+ Transbank::Common::Validation.has_text_with_max_length(token, Transbank::Common::ApiConstants::TOKEN_LENGTH, "token")
81
+ Transbank::Common::Validation.has_text_with_max_length(buy_order, Transbank::Common::ApiConstants::BUY_ORDER_LENGTH, "buy_order")
82
+ Transbank::Common::Validation.has_text_with_max_length(authorization_code, Transbank::Common::ApiConstants::AUTHORIZATION_CODE_LENGTH, "authorization_code")
83
+
84
+ request_service = ::Transbank::Shared::RequestService.new(
85
+ @environment, format(INCREASE_AMOUNT_ENDPOINT, token: token), @commerce_code, @api_key
86
+ )
87
+ request_service.put(commerce_code: @commerce_code, buy_order: buy_order, authorization_code: authorization_code, amount: amount)
88
+ end
89
+
90
+ def increase_authorization_date(token, buy_order, authorization_code)
91
+
92
+ Transbank::Common::Validation.has_text_with_max_length(token, Transbank::Common::ApiConstants::TOKEN_LENGTH, "token")
93
+ Transbank::Common::Validation.has_text_with_max_length(buy_order, Transbank::Common::ApiConstants::BUY_ORDER_LENGTH, "buy_order")
94
+ Transbank::Common::Validation.has_text_with_max_length(authorization_code, Transbank::Common::ApiConstants::AUTHORIZATION_CODE_LENGTH, "authorization_code")
95
+
96
+ request_service = ::Transbank::Shared::RequestService.new(
97
+ @environment, format(INCREASE_AUTHORIZATION_DATE_ENDPOINT, token: token), @commerce_code, @api_key
98
+ )
99
+ request_service.put(commerce_code: @commerce_code, buy_order: buy_order, authorization_code: authorization_code)
100
+ end
101
+
102
+ def reverse_pre_authorized_amount(token, buy_order, authorization_code, amount)
103
+
104
+ Transbank::Common::Validation.has_text_with_max_length(token, Transbank::Common::ApiConstants::TOKEN_LENGTH, "token")
105
+ Transbank::Common::Validation.has_text_with_max_length(buy_order, Transbank::Common::ApiConstants::BUY_ORDER_LENGTH, "buy_order")
106
+ Transbank::Common::Validation.has_text_with_max_length(authorization_code, Transbank::Common::ApiConstants::AUTHORIZATION_CODE_LENGTH, "authorization_code")
107
+
108
+ request_service = ::Transbank::Shared::RequestService.new(
109
+ @environment, format(REVERSE_PRE_AUTHORIZED_AMOUNT_ENDPOINT, token: token), @commerce_code, @api_key
110
+ )
111
+ request_service.put(commerce_code: @commerce_code, buy_order: buy_order, authorization_code: authorization_code, amount: amount)
112
+ end
113
+
114
+ def deferred_capture_history(token)
115
+
116
+ Transbank::Common::Validation.has_text_with_max_length(token, Transbank::Common::ApiConstants::TOKEN_LENGTH, "token")
117
+
118
+ request_service = ::Transbank::Shared::RequestService.new(
119
+ @environment, format(DEFERRED_CAPTURE_HISTORY_ENDPOINT, token: token), @commerce_code, @api_key
120
+ )
121
+ request_service.get
122
+ end
123
+
72
124
  end
73
125
  end
74
126
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: transbank-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Transbank Developers
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-01-04 00:00:00.000000000 Z
11
+ date: 2022-09-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json