transbank-sdk 3.0.2 → 5.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.
@@ -2,7 +2,7 @@ module Transbank
2
2
  module Webpay
3
3
  module TransaccionCompleta
4
4
  class MallTransaction < ::Transbank::Common::BaseTransaction
5
- DEFAULT_ENVIRONMENT = :integration
5
+ private_class_method :new
6
6
  RESOURCES_URL = ::Transbank::Common::ApiConstants::WEBPAY_ENDPOINT
7
7
  CREATE_ENDPOINT = (RESOURCES_URL + '/transactions/').freeze
8
8
  INSTALLMENTS_ENDPOINT = (RESOURCES_URL + '/transactions/%{token}/installments').freeze
@@ -10,18 +10,37 @@ 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
17
13
 
18
- def initialize(commerce_code = ::Transbank::Common::IntegrationCommerceCodes::TRANSACCION_COMPLETA_MALL, api_key = ::Transbank::Common::IntegrationApiKeys::WEBPAY, environment = DEFAULT_ENVIRONMENT)
19
- super(commerce_code, api_key, environment)
14
+ def initialize(options)
15
+ super
16
+ end
17
+
18
+ def self.new(options)
19
+ super(options)
20
+ end
21
+
22
+ def self.build_for_integration(commerce_code, api_key)
23
+ options = Options.new(
24
+ commerce_code,
25
+ api_key,
26
+ :integration
27
+ )
28
+
29
+ new(options)
30
+ end
31
+
32
+ def self.build_for_production(commerce_code, api_key)
33
+ options = Options.new(
34
+ commerce_code,
35
+ api_key,
36
+ :production
37
+ )
38
+ new(options)
20
39
  end
21
40
 
22
41
  def create(buy_order, session_id, card_number, card_expiration_date, details, cvv = nil)
23
42
  request_service = ::Transbank::Shared::RequestService.new(
24
- @environment, CREATE_ENDPOINT, @commerce_code, @api_key
43
+ @environment, CREATE_ENDPOINT, @commerce_code, @api_key, @timeout
25
44
  )
26
45
  request_service.post({
27
46
  buy_order: buy_order, session_id: session_id, card_number: card_number, card_expiration_date: card_expiration_date, details: details, cvv: cvv
@@ -30,7 +49,7 @@ module Transbank
30
49
 
31
50
  def installments(token, details)
32
51
  request_service = ::Transbank::Shared::RequestService.new(
33
- @environment, format(INSTALLMENTS_ENDPOINT, token: token), @commerce_code, @api_key
52
+ @environment, format(INSTALLMENTS_ENDPOINT, token: token), @commerce_code, @api_key, @timeout
34
53
  )
35
54
  details.map {
36
55
  |detail|
@@ -40,82 +59,31 @@ module Transbank
40
59
 
41
60
  def commit(token, details)
42
61
  request_service = ::Transbank::Shared::RequestService.new(
43
- @environment, format(COMMIT_ENDPOINT, token: token), @commerce_code, @api_key
62
+ @environment, format(COMMIT_ENDPOINT, token: token), @commerce_code, @api_key, @timeout
44
63
  )
45
64
  request_service.put({details: details})
46
65
  end
47
66
 
48
67
  def status(token)
49
68
  request_service = ::Transbank::Shared::RequestService.new(
50
- @environment, format(STATUS_ENDPOINT, token: token), @commerce_code, @api_key
69
+ @environment, format(STATUS_ENDPOINT, token: token), @commerce_code, @api_key, @timeout
51
70
  )
52
71
  request_service.get
53
72
  end
54
73
 
55
74
  def refund(token, buy_order, commerce_code_child, amount)
56
75
  request_service = ::Transbank::Shared::RequestService.new(
57
- @environment, format(REFUND_ENDPOINT, token: token), @commerce_code, @api_key
76
+ @environment, format(REFUND_ENDPOINT, token: token), @commerce_code, @api_key, @timeout
58
77
  )
59
78
  request_service.post(buy_order: buy_order, commerce_code: commerce_code_child, amount: amount)
60
79
  end
61
80
 
62
81
  def capture(token, commerce_code, buy_order, authorization_code, amount)
63
82
  request_service = ::Transbank::Shared::RequestService.new(
64
- @environment, format(CAPTURE_ENDPOINT, token: token), @commerce_code, @api_key
83
+ @environment, format(CAPTURE_ENDPOINT, token: token), @commerce_code, @api_key, @timeout
65
84
  )
66
85
  request_service.put(buy_order: buy_order, commerce_code: commerce_code, authorization_code: authorization_code, capture_amount: amount)
67
86
  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
119
87
  end
120
88
  end
121
89
  end
@@ -2,7 +2,7 @@ module Transbank
2
2
  module Webpay
3
3
  module TransaccionCompleta
4
4
  class Transaction < ::Transbank::Common::BaseTransaction
5
- DEFAULT_ENVIRONMENT = :integration
5
+ private_class_method :new
6
6
  RESOURCES_URL = ::Transbank::Common::ApiConstants::WEBPAY_ENDPOINT
7
7
  CREATE_ENDPOINT = (RESOURCES_URL + '/transactions/').freeze
8
8
  INSTALLMENTS_ENDPOINT = (RESOURCES_URL + '/transactions/%{token}/installments').freeze
@@ -10,14 +10,33 @@ 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
17
13
 
18
- def initialize(commerce_code = ::Transbank::Common::IntegrationCommerceCodes::TRANSACCION_COMPLETA, api_key = ::Transbank::Common::IntegrationApiKeys::WEBPAY, environment = DEFAULT_ENVIRONMENT)
14
+ def initialize(options)
19
15
  super
20
16
  end
17
+
18
+ def self.new(options)
19
+ super(options)
20
+ end
21
+
22
+ def self.build_for_integration(commerce_code, api_key)
23
+ options = Options.new(
24
+ commerce_code,
25
+ api_key,
26
+ :integration
27
+ )
28
+
29
+ new(options)
30
+ end
31
+
32
+ def self.build_for_production(commerce_code, api_key)
33
+ options = Options.new(
34
+ commerce_code,
35
+ api_key,
36
+ :production
37
+ )
38
+ new(options)
39
+ end
21
40
 
22
41
  def create(buy_order, session_id, amount, cvv, card_number, card_expiration_date)
23
42
 
@@ -27,7 +46,7 @@ module Transbank
27
46
  Transbank::Common::Validation.has_text_with_max_length(card_expiration_date, Transbank::Common::ApiConstants::CARD_EXPIRATION_DATE_LENGTH, "card_expiration_date")
28
47
 
29
48
  request_service = ::Transbank::Shared::RequestService.new(
30
- @environment, CREATE_ENDPOINT, @commerce_code, @api_key
49
+ @environment, CREATE_ENDPOINT, @commerce_code, @api_key, @timeout
31
50
  )
32
51
  request_service.post({
33
52
  buy_order: buy_order, session_id: session_id, amount: amount, cvv: cvv, card_number: card_number, card_expiration_date: card_expiration_date
@@ -36,83 +55,37 @@ module Transbank
36
55
 
37
56
  def installments(token, installments_number)
38
57
  request_service = ::Transbank::Shared::RequestService.new(
39
- @environment, format(INSTALLMENTS_ENDPOINT, token: token), @commerce_code, @api_key
58
+ @environment, format(INSTALLMENTS_ENDPOINT, token: token), @commerce_code, @api_key, @timeout
40
59
  )
41
60
  request_service.post({installments_number: installments_number})
42
61
  end
43
62
 
44
63
  def commit(token, id_query_installments, deferred_period_index, grace_period)
45
64
  request_service = ::Transbank::Shared::RequestService.new(
46
- @environment, format(COMMIT_ENDPOINT, token: token), @commerce_code, @api_key
65
+ @environment, format(COMMIT_ENDPOINT, token: token), @commerce_code, @api_key, @timeout
47
66
  )
48
67
  request_service.put({id_query_installments: id_query_installments, deferred_period_index: deferred_period_index, grace_period: grace_period})
49
68
  end
50
69
 
51
70
  def status(token)
52
71
  request_service = ::Transbank::Shared::RequestService.new(
53
- @environment, format(STATUS_ENDPOINT, token: token), @commerce_code, @api_key
72
+ @environment, format(STATUS_ENDPOINT, token: token), @commerce_code, @api_key, @timeout
54
73
  )
55
74
  request_service.get
56
75
  end
57
76
 
58
77
  def refund(token, amount)
59
78
  request_service = ::Transbank::Shared::RequestService.new(
60
- @environment, format(REFUND_ENDPOINT, token: token), @commerce_code, @api_key
79
+ @environment, format(REFUND_ENDPOINT, token: token), @commerce_code, @api_key, @timeout
61
80
  )
62
81
  request_service.post(amount: amount)
63
82
  end
64
83
 
65
84
  def capture(token, buy_order, authorization_code, amount)
66
85
  request_service = ::Transbank::Shared::RequestService.new(
67
- @environment, format(CAPTURE_ENDPOINT, token: token), @commerce_code, @api_key
86
+ @environment, format(CAPTURE_ENDPOINT, token: token), @commerce_code, @api_key, @timeout
68
87
  )
69
88
  request_service.put(buy_order: buy_order, authorization_code: authorization_code, capture_amount: amount)
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
89
  end
117
90
  end
118
91
  end
@@ -2,22 +2,41 @@ module Transbank
2
2
  module Webpay
3
3
  module WebpayPlus
4
4
  class MallTransaction < ::Transbank::Common::BaseTransaction
5
- DEFAULT_ENVIRONMENT = :integration
5
+ private_class_method :new
6
6
  RESOURCES_URL = ::Transbank::Common::ApiConstants::WEBPAY_ENDPOINT
7
7
  CREATE_ENDPOINT = (RESOURCES_URL + '/transactions/').freeze
8
8
  COMMIT_ENDPOINT = (RESOURCES_URL + '/transactions/%{token}').freeze
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
- def initialize(commerce_code = ::Transbank::Common::IntegrationCommerceCodes::WEBPAY_PLUS_MALL, api_key = ::Transbank::Common::IntegrationApiKeys::WEBPAY, environment = DEFAULT_ENVIRONMENT)
13
+ def initialize(options)
18
14
  super
19
15
  end
20
16
 
17
+ def self.new(options)
18
+ super(options)
19
+ end
20
+
21
+ def self.build_for_integration(commerce_code, api_key)
22
+ options = Options.new(
23
+ commerce_code,
24
+ api_key,
25
+ :integration
26
+ )
27
+
28
+ new(options)
29
+ end
30
+
31
+ def self.build_for_production(commerce_code, api_key)
32
+ options = Options.new(
33
+ commerce_code,
34
+ api_key,
35
+ :production
36
+ )
37
+ new(options)
38
+ end
39
+
21
40
  def create(buy_order, session_id, return_url, details)
22
41
 
23
42
  Transbank::Common::Validation.has_text_with_max_length(buy_order, Transbank::Common::ApiConstants::BUY_ORDER_LENGTH, "buy_order")
@@ -25,7 +44,7 @@ module Transbank
25
44
  Transbank::Common::Validation.has_text_with_max_length(return_url, Transbank::Common::ApiConstants::RETURN_URL_LENGTH, "return_url")
26
45
 
27
46
  request_service = ::Transbank::Shared::RequestService.new(
28
- @environment, CREATE_ENDPOINT, @commerce_code, @api_key
47
+ @environment, CREATE_ENDPOINT, @commerce_code, @api_key, @timeout
29
48
  )
30
49
  request_service.post({
31
50
  buy_order: buy_order, session_id: session_id, return_url: return_url, details: details
@@ -37,7 +56,7 @@ module Transbank
37
56
  Transbank::Common::Validation.has_text_with_max_length(token, Transbank::Common::ApiConstants::TOKEN_LENGTH, "token")
38
57
 
39
58
  request_service = ::Transbank::Shared::RequestService.new(
40
- @environment, format(COMMIT_ENDPOINT, token: token), @commerce_code, @api_key
59
+ @environment, format(COMMIT_ENDPOINT, token: token), @commerce_code, @api_key, @timeout
41
60
  )
42
61
  request_service.put({})
43
62
  end
@@ -47,7 +66,7 @@ module Transbank
47
66
  Transbank::Common::Validation.has_text_with_max_length(token, Transbank::Common::ApiConstants::TOKEN_LENGTH, "token")
48
67
 
49
68
  request_service = ::Transbank::Shared::RequestService.new(
50
- @environment, format(STATUS_ENDPOINT, token: token), @commerce_code, @api_key
69
+ @environment, format(STATUS_ENDPOINT, token: token), @commerce_code, @api_key, @timeout
51
70
  )
52
71
  request_service.get
53
72
  end
@@ -59,7 +78,7 @@ module Transbank
59
78
  Transbank::Common::Validation.has_text_with_max_length(child_commerce_code, Transbank::Common::ApiConstants::COMMERCE_CODE_LENGTH, "child_commerce_code")
60
79
 
61
80
  request_service = ::Transbank::Shared::RequestService.new(
62
- @environment, format(REFUND_ENDPOINT, token: token), @commerce_code, @api_key
81
+ @environment, format(REFUND_ENDPOINT, token: token), @commerce_code, @api_key, @timeout
63
82
  )
64
83
  request_service.post(buy_order: buy_order, commerce_code: child_commerce_code, amount: amount)
65
84
  end
@@ -73,61 +92,10 @@ module Transbank
73
92
  Transbank::Common::Validation.has_text_with_max_length(authorization_code, Transbank::Common::ApiConstants::AUTHORIZATION_CODE_LENGTH, "authorization_code")
74
93
 
75
94
  request_service = ::Transbank::Shared::RequestService.new(
76
- @environment, format(CAPTURE_ENDPOINT, token: token), @commerce_code, @api_key
95
+ @environment, format(CAPTURE_ENDPOINT, token: token), @commerce_code, @api_key, @timeout
77
96
  )
78
97
  request_service.put(commerce_code: child_commerce_code, buy_order: buy_order, authorization_code: authorization_code, capture_amount: capture_amount)
79
98
  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
131
99
  end
132
100
  end
133
101
  end
@@ -2,21 +2,39 @@ module Transbank
2
2
  module Webpay
3
3
  module WebpayPlus
4
4
  class Transaction < ::Transbank::Common::BaseTransaction
5
- DEFAULT_ENVIRONMENT = :integration
5
+ private_class_method :new
6
6
  RESOURCES_URL = ::Transbank::Common::ApiConstants::WEBPAY_ENDPOINT
7
7
  CREATE_ENDPOINT = (RESOURCES_URL + '/transactions/').freeze
8
8
  COMMIT_ENDPOINT = (RESOURCES_URL + '/transactions/%{token}').freeze
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
+
13
+ def initialize(options)
14
+ super
15
+ end
16
+
17
+ def self.new(options)
18
+ super(options)
19
+ end
16
20
 
17
-
18
- def initialize(commerce_code = ::Transbank::Common::IntegrationCommerceCodes::WEBPAY_PLUS, api_key = ::Transbank::Common::IntegrationApiKeys::WEBPAY, environment = DEFAULT_ENVIRONMENT)
19
- super(commerce_code, api_key, environment)
21
+ def self.build_for_integration(commerce_code, api_key)
22
+ options = Options.new(
23
+ commerce_code,
24
+ api_key,
25
+ :integration
26
+ )
27
+
28
+ new(options)
29
+ end
30
+
31
+ def self.build_for_production(commerce_code, api_key)
32
+ options = Options.new(
33
+ commerce_code,
34
+ api_key,
35
+ :production
36
+ )
37
+ new(options)
20
38
  end
21
39
 
22
40
  def create(buy_order, session_id, amount, return_url)
@@ -26,7 +44,7 @@ module Transbank
26
44
  Transbank::Common::Validation.has_text_with_max_length(return_url, Transbank::Common::ApiConstants::RETURN_URL_LENGTH, "return_url")
27
45
 
28
46
  request_service = ::Transbank::Shared::RequestService.new(
29
- @environment, CREATE_ENDPOINT, @commerce_code, @api_key
47
+ @environment, CREATE_ENDPOINT, @commerce_code, @api_key, @timeout
30
48
  )
31
49
  request_service.post({
32
50
  buy_order: buy_order, session_id: session_id, amount: amount, return_url: return_url
@@ -38,7 +56,7 @@ module Transbank
38
56
  Transbank::Common::Validation.has_text_with_max_length(token, Transbank::Common::ApiConstants::TOKEN_LENGTH, "token")
39
57
 
40
58
  request_service = ::Transbank::Shared::RequestService.new(
41
- @environment, format(COMMIT_ENDPOINT, token: token), @commerce_code, @api_key
59
+ @environment, format(COMMIT_ENDPOINT, token: token), @commerce_code, @api_key, @timeout
42
60
  )
43
61
  request_service.put({})
44
62
  end
@@ -48,7 +66,7 @@ module Transbank
48
66
  Transbank::Common::Validation.has_text_with_max_length(token, Transbank::Common::ApiConstants::TOKEN_LENGTH, "token")
49
67
 
50
68
  request_service = ::Transbank::Shared::RequestService.new(
51
- @environment, format(STATUS_ENDPOINT, token: token), @commerce_code, @api_key
69
+ @environment, format(STATUS_ENDPOINT, token: token), @commerce_code, @api_key, @timeout
52
70
  )
53
71
  request_service.get
54
72
  end
@@ -58,7 +76,7 @@ module Transbank
58
76
  Transbank::Common::Validation.has_text_with_max_length(token, Transbank::Common::ApiConstants::TOKEN_LENGTH, "token")
59
77
 
60
78
  request_service = ::Transbank::Shared::RequestService.new(
61
- @environment, format(REFUND_ENDPOINT, token: token), @commerce_code, @api_key
79
+ @environment, format(REFUND_ENDPOINT, token: token), @commerce_code, @api_key, @timeout
62
80
  )
63
81
  request_service.post(amount: amount)
64
82
  end
@@ -70,55 +88,9 @@ module Transbank
70
88
  Transbank::Common::Validation.has_text_with_max_length(authorization_code, Transbank::Common::ApiConstants::AUTHORIZATION_CODE_LENGTH, "authorization_code")
71
89
 
72
90
  request_service = ::Transbank::Shared::RequestService.new(
73
- @environment, format(CAPTURE_ENDPOINT, token: token), @commerce_code, @api_key
91
+ @environment, format(CAPTURE_ENDPOINT, token: token), @commerce_code, @api_key, @timeout
74
92
  )
75
93
  request_service.put(buy_order: buy_order, authorization_code: authorization_code, capture_amount: amount)
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
94
  end
123
95
 
124
96
  end
data/lib/transbank/sdk.rb CHANGED
@@ -12,6 +12,9 @@ require 'transbank/sdk/common/validation'
12
12
  require 'transbank/sdk/shared/request_service'
13
13
  require 'transbank/sdk/shared/transbank_error'
14
14
 
15
+ require 'transbank/sdk/webpay/options'
16
+ require 'transbank/sdk/patpass/options'
17
+
15
18
  require 'transbank/sdk/webpay/webpay_plus/transaction'
16
19
  require 'transbank/sdk/webpay/webpay_plus/mall_transaction'
17
20
 
@@ -21,7 +24,5 @@ require 'transbank/sdk/webpay/oneclick/mall_inscription'
21
24
  require 'transbank/sdk/webpay/transaccion_completa/transaction'
22
25
  require 'transbank/sdk/webpay/transaccion_completa/mall_transaction'
23
26
 
24
- require 'transbank/sdk/patpass/patpass_by_webpay/transaction'
25
27
  require 'transbank/sdk/patpass/patpass_comercio/inscription'
26
28
 
27
- require 'transbank/sdk/webpay/webpay_plus_modal/transaction'
@@ -12,6 +12,8 @@ Gem::Specification.new do |spec|
12
12
  spec.summary = %q{Transbank SDK for Ruby}
13
13
  spec.homepage = "https://www.transbankdevelopers.cl/"
14
14
  spec.license = "BSD-3-Clause"
15
+ spec.required_ruby_version = ">= 2.7"
16
+ spec.required_rubygems_version = ">= 3.0"
15
17
 
16
18
  # Specify which files should be added to the gem when it is released.
17
19
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
@@ -22,14 +24,14 @@ Gem::Specification.new do |spec|
22
24
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
25
  spec.require_paths = ["lib"]
24
26
 
25
- spec.add_dependency "json", "~> 2.0"
26
- spec.add_development_dependency "bundler", "~> 2.1"
27
- spec.add_development_dependency "rake", "~> 12.3"
28
- spec.add_development_dependency "minitest", "~> 5.0"
29
- spec.add_development_dependency "rubocop", "~> 0.59"
30
- spec.add_development_dependency "pry", "~> 0.11"
31
- spec.add_development_dependency 'minitest-reporters', '~> 1.1'
27
+ spec.add_dependency "json", "~> 2.6"
28
+ spec.add_development_dependency "bundler", "~> 2.4"
29
+ spec.add_development_dependency "rake", "~> 13.2"
30
+ spec.add_development_dependency "minitest", "~> 5.2"
31
+ spec.add_development_dependency "rubocop", "~> 1.50"
32
+ spec.add_development_dependency "pry", "~> 0.14"
33
+ spec.add_development_dependency 'minitest-reporters', '~> 1.6'
32
34
  spec.add_development_dependency 'byebug', "~> 11.1"
33
35
  spec.add_development_dependency 'pry-byebug', "~> 3.9"
34
- spec.add_development_dependency 'webmock', "~> 3.12"
36
+ spec.add_development_dependency 'webmock', "~> 3.19"
35
37
  end