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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 8a59bcc8731edabd8b65c29379086457abeda4a5
4
- data.tar.gz: 81f4a5421ea4633ada33442ab969a05db18bd5f8
2
+ SHA256:
3
+ metadata.gz: 5869521de720f438d8d86cf0865ea02d79ce5972c80ebebe9e62e93932b81015
4
+ data.tar.gz: 580054a4099e31676413cf05138f67cefbc6113d75e7d139af2fe485b674891c
5
5
  SHA512:
6
- metadata.gz: e1053b5266297a8b7641823aeee4bbac4867e7ffcf0f5ec5bb1471d64c1be343d23492b3a3ed1cefce1fcfcadccbf5920f215e0014c7d5ae5daa617bbba92f33
7
- data.tar.gz: 846f79b2912f876228f70e3e360603cd31ff040e863b2fcc4b90f5cd6b7dfde9bb7508e88f588001fe134ea2a667a5cd441375616328cae161c3c954bdf20424
6
+ metadata.gz: 7d09cb3642c8b2d37bced404a7940c5d6fb8e63e347e57239ed54d5d9ae33f35c97e42da9ac1ed15dc40ccb3101b9959b0edf4f81c4be5da05d2230557297f85
7
+ data.tar.gz: f6fe4d977746b50baf17ea3181d59ceec260734e3b2529b041e9d699223859fb55e4aa91f6f363b2f7818807f303f47d0f65ff363efe7b3eb587f824f72f4223
@@ -24,10 +24,10 @@ jobs:
24
24
 
25
25
  steps:
26
26
  - uses: actions/checkout@v3
27
- - name: Set up Ruby 2.4
27
+ - name: Set up Ruby 2.7
28
28
  uses: ruby/setup-ruby@v1
29
29
  with:
30
- ruby-version: 2.4
30
+ ruby-version: 2.7
31
31
  - run: |
32
32
  bundle install
33
33
 
data/CHANGELOG.md CHANGED
@@ -5,6 +5,42 @@ Todos los cambios notables a este proyecto serán documentados en este archivo.
5
5
  El formato está basado en [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
6
6
  y este proyecto adhiere a [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [5.0.0] - 2025-05-05
9
+
10
+ Esta versión no tiene cambios en el comportamiento de las funcionalidades de la API.
11
+
12
+ ¡Importante!
13
+
14
+ El SDK ya no apunta por defecto al ambiente de integración. Ahora es necesario configurar de forma explícita las credenciales. Para esto se debe inicializar explícitamente los objetos de los distintos productos, ya sea utilizando la clase Options o a través de los nuevos métodos build_for_integration y build_for_production. Además, notar que ahora la versión mínima de Ruby a la 2.7.
15
+
16
+ ### Agrega
17
+ - Se agrega el parámetro timeout para que pueda modificarse en todos los productos.
18
+ - Se agregan los métodos build_for_integration y build_for_production a todos los productos
19
+
20
+ ### Actualiza
21
+ - Se actualiza la versión mínima soportada de Ruby a la 2.7
22
+ - Se configura por defecto el timeout a 600 segundos para todas las peticiones.
23
+ - Se actualizan las versiones de las dependencias.
24
+ - Se actualizan los test.
25
+
26
+ ### Borra
27
+ - Se elimina el constructor por defecto en Webpayplus
28
+ - Se elimina el constructor por defecto en Oneclick
29
+ - Se elimina el constructor por defecto en Patpass Comercio
30
+ - Se elimina el constructor por defecto en Full Transaction y Mall Full Transaction
31
+ - Se elimina el código que hace referencia al producto ‘Webpay Modal’
32
+ - Se elimina el código que hace referencia al producto ‘Patpass by webpay’
33
+
34
+ ## [4.0.0] - 2024-03-20
35
+
36
+ ### Changed
37
+
38
+ - Downgrade del API de la versión 1.3 a la versión 1.2
39
+
40
+ ### Fixed
41
+
42
+ - Corregido un error en RequestService que causaba problemas debido a la dependencia de `.blank?`, que no es parte de la biblioteca estándar de Ruby
43
+
8
44
  ## [3.0.2] - 2023-03-7
9
45
 
10
46
  ### Fixed
data/README.md CHANGED
@@ -9,23 +9,26 @@ SDK Oficial de Transbank
9
9
  # Instalación
10
10
 
11
11
  Puedes instalar el SDK directamente
12
+
12
13
  ```bash
13
14
  gem install transbank-sdk
14
15
  ```
15
16
 
16
17
  o añadirlo a tu `Gemfile`
18
+
17
19
  ```ruby
18
20
  gem 'transbank-sdk'
19
21
  ```
22
+
20
23
  y luego ejecutar
24
+
21
25
  ```bash
22
26
  bundle install
23
27
  ```
24
- ## Documentación
25
28
 
26
- Puedes encontrar toda la documentación de cómo usar este SDK en el sitio https://www.transbankdevelopers.cl.
29
+ ## Documentación
27
30
 
28
- Actualmente este SDK contiene sólo Onepay.
31
+ Puedes encontrar toda la documentación de cómo usar este SDK en el sitio https://www.transbankdevelopers.cl.
29
32
 
30
33
  La documentación relevante para usar este SDK es:
31
34
 
@@ -34,45 +37,62 @@ La documentación relevante para usar este SDK es:
34
37
 
35
38
  ## Información para contribuir y desarrollar este SDK
36
39
 
37
- ### Requerimientos
38
- - Docker
39
- - Make
40
- - Plugin de editorconfig para tu editor favorito.
40
+ #### Short lead tokens
41
+
42
+ `WIP` = En progreso.
43
+
44
+ `feat` = Nuevos features.
45
+
46
+ `fix` = Corrección de un bug.
47
+
48
+ `docs` = Cambios solo de documentación.
49
+
50
+ `style` = Cambios que no afectan el significado del código. (espaciado, formateo de código, comillas faltantes, etc)
51
+
52
+ `refactor` = Un cambio en el código que no arregla un bug ni agrega una funcionalidad.
53
+
54
+ `perf` = Cambio que mejora el rendimiento.
55
+
56
+ `test` = Agregar test faltantes o los corrige.
57
+
58
+ `chore` = Cambios en el build o herramientas auxiliares y librerías.
59
+
60
+ `revert` = Revierte un commit.
61
+
62
+ `release` = Para liberar una nueva versión.
41
63
 
42
64
  ### Standares
43
65
 
44
66
  - Para los commits respetamos las siguientes normas: https://chris.beams.io/posts/git-commit/
45
67
  - Usamos ingles, para los mensajes de commit.
46
68
  - Se pueden usar tokens como WIP, en el subject de un commit, separando el token con `:`, por ejemplo:
47
- `WIP: This is a useful commit message`
69
+ `WIP: This is a useful commit message`
48
70
  - Para los nombres de ramas también usamos ingles.
49
71
  - Se asume, que una rama de feature no mezclada, es un feature no terminado.
50
72
  - El nombre de las ramas va en minúsculas.
51
73
  - Las palabras se separan con `-`.
52
74
  - Las ramas comienzan con alguno de los short lead tokens definidos, por ejemplo: `feat/tokens-configuration`
53
75
 
54
- #### Short lead tokens
55
- ##### Commits
56
- - WIP = Trabajo en progreso.
57
- ##### Ramas
58
- - feat = Nuevos features
59
- - chore = Tareas, que no son visibles al usuario.
60
- - bug = Resolución de bugs.
76
+ ### **Reglas** 📖
61
77
 
62
- ### Todas las mezclas a master se hacen mediante Pull Request.
78
+ 1. Todo PR debe incluir test o evidencia de que funcione correctamente(gif, foto).
79
+ 2. El PR debe tener 2 o más aprobaciones para poder mezclarse.
80
+ 3. Si un commit revierte un commit anterior deberá comenzar con "revert:" seguido del mensaje del commit anterior.
63
81
 
64
- ### Test
65
- Primero y solamente una vez para instalar gemas debes usar el siguiente comando en una terminal.
66
- ```bash
67
- make build
68
- ```
82
+ ### **Pull Request**
69
83
 
70
- Para ejecutar los test localmente debes usar el siguiente comando en una terminal.
71
- ```bash
72
- make
73
- ```
84
+ - Usar un lenguaje imperativo y en tiempo presente: "change" no "changed" ni "changes".
85
+ - El título del los PR y mensajes de commit no pueden comenzar con una letra mayúscula.
86
+ - No se debe usar punto final en los títulos o descripción de los commits.
87
+ - El título del PR debe comenzar con el short lead token definido para la rama, seguido de : y una breve descripción del cambio.
88
+ - La descripción del PR debe detallar los cambios.
89
+ - La descripción del PR debe incluir evidencias de que los test se ejecutan de forma correcta.
90
+ - Se pueden usar gif o videos para complementar la descripción o evidenciar el funcionamiento del PR.
91
+
92
+ ### Todas las mezclas a master se hacen mediante Pull Request.
74
93
 
75
94
  ### Deploy de una nueva versión.
95
+
76
96
  Para generar una nueva versión, se debe crear un PR (con un título "Prepare release X.Y.Z" con los valores que correspondan para `X`, `Y` y `Z`). Se debe seguir el estándar semver para determinar si se incrementa el valor de `X` (si hay cambios no retrocompatibles), `Y` (para mejoras retrocompatibles) o `Z` (si sólo hubo correcciones a bugs).
77
97
 
78
98
  En ese PR deben incluirse los siguientes cambios:
@@ -82,4 +102,4 @@ En ese PR deben incluirse los siguientes cambios:
82
102
 
83
103
  Luego de obtener aprobación del pull request, debe mezclarse a master e inmediatamente generar un release en GitHub con el tag `vX.Y.Z`. En la descripción del release debes poner lo mismo que agregaste al changelog.
84
104
 
85
- Con eso Github Actions generará automáticamente una nueva versión de la librería y la publicará en RubyGems.
105
+ Con eso Github Actions generará automáticamente una nueva versión de la librería y la publicará en RubyGems.
@@ -1,8 +1,8 @@
1
1
  module Transbank
2
2
  module Common
3
3
  module ApiConstants
4
- WEBPAY_ENDPOINT = 'rswebpaytransaction/api/webpay/v1.3'.freeze
5
- ONECLICK_ENDPOINT = 'rswebpaytransaction/api/oneclick/v1.3'.freeze
4
+ WEBPAY_ENDPOINT = 'rswebpaytransaction/api/webpay/v1.2'.freeze
5
+ ONECLICK_ENDPOINT = 'rswebpaytransaction/api/oneclick/v1.2'.freeze
6
6
  PATPASS_ENDPOINT = 'restpatpass/v1/services'.freeze
7
7
 
8
8
  BUY_ORDER_LENGTH = 26;
@@ -16,6 +16,7 @@ module Transbank
16
16
  COMMERCE_CODE_LENGTH = 12;
17
17
  TOKEN_LENGTH = 64;
18
18
  EMAIL_LENGTH = 100;
19
+ REQUEST_TIMEOUT = 600;
19
20
  end
20
21
  end
21
22
  end
@@ -2,14 +2,22 @@ module Transbank
2
2
  module Common
3
3
  class BaseTransaction
4
4
 
5
- def initialize(commerce_code = ::Transbank::Common::IntegrationCommerceCodes::WEBPAY_PLUS, api_key = ::Transbank::Common::IntegrationApiKeys::WEBPAY, environment = DEFAULT_ENVIRONMENT)
6
- @commerce_code = commerce_code
7
- @api_key = api_key
8
- unless %i[production integration].include?(environment)
5
+ def initialize(options)
6
+ required_methods = [:commerce_code, :api_key, :environment, :timeout]
7
+ missing_methods = required_methods.reject { |method| options.respond_to?(method) }
8
+
9
+ unless missing_methods.empty?
10
+ raise ArgumentError, "Options object must respond to: #{missing_methods.join(', ')}"
11
+ end
12
+ unless %i[production integration].include?(options.environment)
9
13
  raise ArgumentError, "Environment must be either 'integration' or 'production'"
10
14
  end
15
+
16
+ @commerce_code = options.commerce_code
17
+ @api_key = options.api_key
11
18
 
12
- @environment = environment
19
+ @environment = options.environment
20
+ @timeout = options.timeout
13
21
  end
14
22
  end
15
23
  end
@@ -0,0 +1,14 @@
1
+ module Transbank
2
+ module Patpass
3
+ class Options
4
+ attr_accessor :commerce_code, :api_key, :environment, :timeout
5
+
6
+ def initialize(commerce_code, api_key, environment, timeout = ::Transbank::Common::ApiConstants::REQUEST_TIMEOUT)
7
+ @commerce_code = commerce_code
8
+ @api_key = api_key
9
+ @environment = environment
10
+ @timeout = timeout
11
+ end
12
+ end
13
+ end
14
+ end
@@ -2,23 +2,46 @@ module Transbank
2
2
  module Patpass
3
3
  module PatpassComercio
4
4
  class Inscription < ::Transbank::Common::BaseTransaction
5
- DEFAULT_ENVIRONMENT = :integration
5
+ private_class_method :new
6
6
  RESOURCES_URL = ::Transbank::Common::ApiConstants::PATPASS_ENDPOINT
7
7
  START_ENDPOINT = (RESOURCES_URL + '/patInscription').freeze
8
8
  STATUS_ENDPOINT = (RESOURCES_URL + '/status').freeze
9
9
 
10
10
  ENVIRONMENTS = {
11
- production: 'https://www.pagoautomaticocontarjetas.cl',
11
+ production: 'https://www.pagoautomaticocontarjetas.cl/',
12
12
  integration: 'https://pagoautomaticocontarjetasint.transbank.cl/'
13
13
  }
14
14
 
15
- def initialize(commerce_code = ::Transbank::Common::IntegrationCommerceCodes::PATPASS_COMERCIO, api_key = ::Transbank::Common::IntegrationApiKeys::PATPASS_COMERCIO, environment = DEFAULT_ENVIRONMENT)
16
- super(commerce_code, api_key, environment)
15
+ def initialize(options)
16
+ super
17
+ end
18
+
19
+ def self.new(options)
20
+ super(options)
21
+ end
22
+
23
+ def self.build_for_integration(commerce_code, api_key)
24
+ options = Options.new(
25
+ commerce_code,
26
+ api_key,
27
+ :integration
28
+ )
29
+
30
+ new(options)
31
+ end
32
+
33
+ def self.build_for_production(commerce_code, api_key)
34
+ options = Options.new(
35
+ commerce_code,
36
+ api_key,
37
+ :production
38
+ )
39
+ new(options)
17
40
  end
18
41
 
19
42
  def start(url, name, last_name, second_last_name, rut, service_id, final_url, max_amount, phone, cell_phone, patpass_name, person_email, commerce_email, address, city)
20
43
  request_service = ::Transbank::Shared::RequestService.new(
21
- ENVIRONMENTS[@environment] + START_ENDPOINT, @commerce_code, @api_key
44
+ @environment, ENVIRONMENTS[@environment] + START_ENDPOINT, @commerce_code, @api_key, @timeout, true
22
45
  )
23
46
  request_service.set_patpass();
24
47
  request_service.post({
@@ -44,7 +67,7 @@ module Transbank
44
67
 
45
68
  def status(token)
46
69
  request_service = ::Transbank::Shared::RequestService.new(
47
- ENVIRONMENTS[@environment] + format(STATUS_ENDPOINT, token: token), @commerce_code, @api_key
70
+ @environment, ENVIRONMENTS[@environment] + format(STATUS_ENDPOINT, token: token), @commerce_code, @api_key, @timeout, true
48
71
  )
49
72
  request_service.set_patpass();
50
73
  request_service.post({token: token})
@@ -6,13 +6,14 @@ module Transbank
6
6
  integration: 'https://webpay3gint.transbank.cl/'
7
7
  }
8
8
 
9
- def initialize(environment=nil, endpoint, commerce_code, api_key)
9
+ def initialize(environment, endpoint, commerce_code, api_key, timeout, is_patpass= false)
10
+ @timeout = timeout
10
11
  @commerce_code = commerce_code
11
12
  @api_key = api_key
12
- if environment.nil?
13
- @url = endpoint
13
+ if is_patpass
14
+ @url = endpoint
14
15
  else
15
- @url = ENVIRONMENTS[environment] + endpoint
16
+ @url = ENVIRONMENTS[environment] + endpoint
16
17
  end
17
18
  @headers = headers(@commerce_code, @api_key)
18
19
  end
@@ -52,7 +53,7 @@ module Transbank
52
53
  return JSON.parse(response.body)
53
54
  end
54
55
 
55
- if !response.body.blank?
56
+ if !response.body.to_s.empty?
56
57
  body = JSON.parse(response.body)
57
58
  if body.key?("description")
58
59
  raise TransbankError, "Transbank Error: #{body['code']} - #{body['description']}"
@@ -68,6 +69,8 @@ module Transbank
68
69
  uri = URI.parse(@url)
69
70
  http = Net::HTTP.new(uri.host, uri.port)
70
71
  http.use_ssl = uri.scheme == 'https'
72
+ http.open_timeout = @timeout
73
+ http.read_timeout = @timeout
71
74
  [uri, http]
72
75
  end
73
76
 
@@ -1,5 +1,5 @@
1
1
  module Transbank
2
2
  module Sdk
3
- VERSION = '3.0.2'
3
+ VERSION = '5.0.0'
4
4
  end
5
5
  end
@@ -2,24 +2,46 @@ module Transbank
2
2
  module Webpay
3
3
  module Oneclick
4
4
  class MallInscription < ::Transbank::Common::BaseTransaction
5
- DEFAULT_ENVIRONMENT = :integration
5
+ private_class_method :new
6
6
  RESOURCES_URL = ::Transbank::Common::ApiConstants::ONECLICK_ENDPOINT
7
7
  START_ENDPOINT = (RESOURCES_URL + '/inscriptions').freeze
8
8
  FINISH_ENDPOINT = (RESOURCES_URL + '/inscriptions/%{token}').freeze
9
9
  DELETE_ENDPOINT = (RESOURCES_URL + '/inscriptions').freeze
10
10
 
11
- def initialize(commerce_code = ::Transbank::Common::IntegrationCommerceCodes::ONECLICK_MALL, api_key = ::Transbank::Common::IntegrationApiKeys::WEBPAY, environment = DEFAULT_ENVIRONMENT)
11
+ def initialize(options)
12
12
  super
13
13
  end
14
+
15
+ def self.new(options)
16
+ super(options)
17
+ end
18
+
19
+ def self.build_for_integration(commerce_code, api_key)
20
+ options = Options.new(
21
+ commerce_code,
22
+ api_key,
23
+ :integration
24
+ )
25
+
26
+ new(options)
27
+ end
28
+
29
+ def self.build_for_production(commerce_code, api_key)
30
+ options = Options.new(
31
+ commerce_code,
32
+ api_key,
33
+ :production
34
+ )
35
+ new(options)
36
+ end
14
37
 
15
38
  def start(username, email, response_url)
16
-
17
39
  Transbank::Common::Validation.has_text_with_max_length(username, Transbank::Common::ApiConstants::USER_NAME_LENGTH, "username")
18
40
  Transbank::Common::Validation.has_text_with_max_length(email, Transbank::Common::ApiConstants::EMAIL_LENGTH, "email")
19
41
  Transbank::Common::Validation.has_text_with_max_length(response_url, Transbank::Common::ApiConstants::RETURN_URL_LENGTH, "response_url")
20
42
 
21
43
  request_service = ::Transbank::Shared::RequestService.new(
22
- @environment, START_ENDPOINT, @commerce_code, @api_key
44
+ @environment, START_ENDPOINT, @commerce_code, @api_key, @timeout
23
45
  )
24
46
  request_service.post({
25
47
  username: username, email: email, response_url: response_url
@@ -31,7 +53,7 @@ module Transbank
31
53
  Transbank::Common::Validation.has_text_with_max_length(token, Transbank::Common::ApiConstants::TOKEN_LENGTH, "token")
32
54
 
33
55
  request_service = ::Transbank::Shared::RequestService.new(
34
- @environment, format(FINISH_ENDPOINT, token: token), @commerce_code, @api_key
56
+ @environment, format(FINISH_ENDPOINT, token: token), @commerce_code, @api_key, @timeout
35
57
  )
36
58
  request_service.put({})
37
59
  end
@@ -42,7 +64,7 @@ module Transbank
42
64
  Transbank::Common::Validation.has_text_with_max_length(username, Transbank::Common::ApiConstants::USER_NAME_LENGTH, "username")
43
65
 
44
66
  request_service = ::Transbank::Shared::RequestService.new(
45
- @environment, DELETE_ENDPOINT, @commerce_code, @api_key
67
+ @environment, DELETE_ENDPOINT, @commerce_code, @api_key, @timeout
46
68
  )
47
69
  request_service.delete({tbk_user: tbk_user, username: username})
48
70
  end
@@ -2,19 +2,38 @@ module Transbank
2
2
  module Webpay
3
3
  module Oneclick
4
4
  class MallTransaction < ::Transbank::Common::BaseTransaction
5
- DEFAULT_ENVIRONMENT = :integration
5
+ private_class_method :new
6
6
  RESOURCES_URL = ::Transbank::Common::ApiConstants::ONECLICK_ENDPOINT
7
7
  AUTHORIZE_ENDPOINT = (RESOURCES_URL + '/transactions').freeze
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
15
11
 
16
- def initialize(commerce_code = ::Transbank::Common::IntegrationCommerceCodes::ONECLICK_MALL, api_key = ::Transbank::Common::IntegrationApiKeys::WEBPAY, environment = DEFAULT_ENVIRONMENT)
17
- super(commerce_code, api_key, environment)
12
+ def initialize(options)
13
+ super
14
+ end
15
+
16
+ def self.new(options)
17
+ super(options)
18
+ end
19
+
20
+ def self.build_for_integration(commerce_code, api_key)
21
+ options = Options.new(
22
+ commerce_code,
23
+ api_key,
24
+ :integration
25
+ )
26
+
27
+ new(options)
28
+ end
29
+
30
+ def self.build_for_production(commerce_code, api_key)
31
+ options = Options.new(
32
+ commerce_code,
33
+ api_key,
34
+ :production
35
+ )
36
+ new(options)
18
37
  end
19
38
 
20
39
  def authorize(username, tbk_user, parent_buy_order, details)
@@ -24,7 +43,7 @@ module Transbank
24
43
  Transbank::Common::Validation.has_text_with_max_length(parent_buy_order, Transbank::Common::ApiConstants::BUY_ORDER_LENGTH, "parent_buy_order")
25
44
 
26
45
  request_service = ::Transbank::Shared::RequestService.new(
27
- @environment, AUTHORIZE_ENDPOINT, @commerce_code, @api_key
46
+ @environment, AUTHORIZE_ENDPOINT, @commerce_code, @api_key, @timeout
28
47
  )
29
48
  request_service.post({
30
49
  username: username, tbk_user: tbk_user, buy_order: parent_buy_order, details: details
@@ -38,7 +57,7 @@ module Transbank
38
57
  Transbank::Common::Validation.has_text_with_max_length(authorization_code, Transbank::Common::ApiConstants::AUTHORIZATION_CODE_LENGTH, "authorization_code")
39
58
 
40
59
  request_service = ::Transbank::Shared::RequestService.new(
41
- @environment, CAPTURE_ENDPOINT, @commerce_code, @api_key
60
+ @environment, CAPTURE_ENDPOINT, @commerce_code, @api_key, @timeout
42
61
  )
43
62
  request_service.put(commerce_code: child_commerce_code, buy_order: child_buy_order, authorization_code: authorization_code, capture_amount: amount)
44
63
  end
@@ -48,7 +67,7 @@ module Transbank
48
67
  Transbank::Common::Validation.has_text_with_max_length(buy_order, Transbank::Common::ApiConstants::BUY_ORDER_LENGTH, "buy_order")
49
68
 
50
69
  request_service = ::Transbank::Shared::RequestService.new(
51
- @environment, format(STATUS_ENDPOINT, token: buy_order), @commerce_code, @api_key
70
+ @environment, format(STATUS_ENDPOINT, token: buy_order), @commerce_code, @api_key, @timeout
52
71
  )
53
72
  request_service.get
54
73
  end
@@ -60,58 +79,10 @@ module Transbank
60
79
  Transbank::Common::Validation.has_text_with_max_length(child_buy_order, Transbank::Common::ApiConstants::BUY_ORDER_LENGTH, "child_buy_order")
61
80
 
62
81
  request_service = ::Transbank::Shared::RequestService.new(
63
- @environment, format(REFUND_ENDPOINT, token: buy_order), @commerce_code, @api_key
82
+ @environment, format(REFUND_ENDPOINT, token: buy_order), @commerce_code, @api_key, @timeout
64
83
  )
65
84
  request_service.post(detail_buy_order: child_buy_order, commerce_code: child_commerce_code, amount: amount)
66
85
  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
115
86
  end
116
87
  end
117
88
  end
@@ -0,0 +1,14 @@
1
+ module Transbank
2
+ module Webpay
3
+ class Options
4
+ attr_accessor :commerce_code, :api_key, :environment, :timeout
5
+
6
+ def initialize(commerce_code, api_key, environment, timeout = ::Transbank::Common::ApiConstants::REQUEST_TIMEOUT)
7
+ @commerce_code = commerce_code
8
+ @api_key = api_key
9
+ @environment = environment
10
+ @timeout = timeout
11
+ end
12
+ end
13
+ end
14
+ end