transbank-sdk 4.0.0 → 5.1.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 +5 -5
- data/.github/workflows/build.yml +54 -0
- data/.github/workflows/publish-lib.yml +2 -2
- data/CHANGELOG.md +34 -0
- data/README.md +46 -32
- data/lib/transbank/sdk/common/api_constants.rb +1 -0
- data/lib/transbank/sdk/common/base_transaction.rb +13 -5
- data/lib/transbank/sdk/patpass/options.rb +14 -0
- data/lib/transbank/sdk/patpass/patpass_comercio/inscription.rb +29 -6
- data/lib/transbank/sdk/shared/request_service.rb +7 -4
- data/lib/transbank/sdk/version.rb +1 -1
- data/lib/transbank/sdk/webpay/oneclick/mall_bin_info.rb +48 -0
- data/lib/transbank/sdk/webpay/oneclick/mall_inscription.rb +28 -6
- data/lib/transbank/sdk/webpay/oneclick/mall_transaction.rb +30 -7
- data/lib/transbank/sdk/webpay/options.rb +14 -0
- data/lib/transbank/sdk/webpay/transaccion_completa/mall_transaction.rb +32 -9
- data/lib/transbank/sdk/webpay/transaccion_completa/transaction.rb +31 -8
- data/lib/transbank/sdk/webpay/webpay_plus/mall_transaction.rb +30 -7
- data/lib/transbank/sdk/webpay/webpay_plus/transaction.rb +32 -9
- data/lib/transbank/sdk.rb +4 -3
- data/sonar-project.properties +7 -0
- data/transbank-sdk.gemspec +12 -8
- metadata +58 -28
- data/lib/transbank/sdk/patpass/patpass_by_webpay/transaction.rb +0 -41
- data/lib/transbank/sdk/webpay/webpay_plus_modal/transaction.rb +0 -62
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 17224cebe57ae3aefb293a9a5abd2b424eb8dc46c7f5ca7a153efce70b00db5d
|
4
|
+
data.tar.gz: 9cb85dec83cdf31ab6c0b7cb461fd386f6efb4c16c3a36a57c3eedb124c40d51
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de1b9c69dd772317fad521375cb47c9ea4188db9d029a57ca294f12fdd07c9c212ff69ed5f9b82255d3c99da148829b8efd1b121492ee6e082323e796ef4c436
|
7
|
+
data.tar.gz: dbb0d99de1dcc0aa8a14a4e6d17749c01927e6b7a8bcf867ffc1b5e7181fe8ea1dce40fd1a1c08b3a0f14b5935864b3cf800d096c5cf42675e3bfc2826b3ff39
|
@@ -0,0 +1,54 @@
|
|
1
|
+
name: Ruby CI
|
2
|
+
|
3
|
+
on:
|
4
|
+
pull_request:
|
5
|
+
types: [synchronize, opened, reopened]
|
6
|
+
|
7
|
+
jobs:
|
8
|
+
build:
|
9
|
+
runs-on: ubuntu-latest
|
10
|
+
|
11
|
+
steps:
|
12
|
+
- uses: actions/checkout@v4
|
13
|
+
with:
|
14
|
+
fetch-depth: 0
|
15
|
+
|
16
|
+
- name: Set up Ruby
|
17
|
+
uses: ruby/setup-ruby@v1
|
18
|
+
with:
|
19
|
+
ruby-version: '3.1'
|
20
|
+
|
21
|
+
- name: Install dependencies
|
22
|
+
run: |
|
23
|
+
gem install bundler
|
24
|
+
bundle install
|
25
|
+
|
26
|
+
- name: Run tests
|
27
|
+
run: bundle exec rake test
|
28
|
+
|
29
|
+
sonar-cloud-check:
|
30
|
+
runs-on: ubuntu-latest
|
31
|
+
|
32
|
+
steps:
|
33
|
+
- uses: actions/checkout@v4
|
34
|
+
with:
|
35
|
+
fetch-depth: 0
|
36
|
+
|
37
|
+
- name: Set up Ruby
|
38
|
+
uses: ruby/setup-ruby@v1
|
39
|
+
with:
|
40
|
+
ruby-version: '3.1'
|
41
|
+
|
42
|
+
- name: Install dependencies
|
43
|
+
run: |
|
44
|
+
gem install bundler
|
45
|
+
bundle install
|
46
|
+
|
47
|
+
- name: Run tests with coverage
|
48
|
+
run: bundle exec rake test
|
49
|
+
|
50
|
+
- name: SonarQube Scan
|
51
|
+
uses: sonarsource/sonarqube-scan-action@master
|
52
|
+
env:
|
53
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
54
|
+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,40 @@ 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.1.0] - 2025-06-23
|
9
|
+
|
10
|
+
Esta versión agrega una clase para la nueva funcionalidad de la API de OneClick. Los métodos existentes no tienen cambios.
|
11
|
+
|
12
|
+
### Agrega
|
13
|
+
|
14
|
+
- Se agrega la clase `MallBinInfo` , la cual contiene el método `query_bin` para la consulta de información de una tarjeta registrada en Oneclick.
|
15
|
+
|
16
|
+
## [5.0.0] - 2025-05-05
|
17
|
+
|
18
|
+
Esta versión no tiene cambios en el comportamiento de las funcionalidades de la API.
|
19
|
+
|
20
|
+
¡Importante!
|
21
|
+
|
22
|
+
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.
|
23
|
+
|
24
|
+
### Agrega
|
25
|
+
- Se agrega el parámetro timeout para que pueda modificarse en todos los productos.
|
26
|
+
- Se agregan los métodos build_for_integration y build_for_production a todos los productos
|
27
|
+
|
28
|
+
### Actualiza
|
29
|
+
- Se actualiza la versión mínima soportada de Ruby a la 2.7
|
30
|
+
- Se configura por defecto el timeout a 600 segundos para todas las peticiones.
|
31
|
+
- Se actualizan las versiones de las dependencias.
|
32
|
+
- Se actualizan los test.
|
33
|
+
|
34
|
+
### Borra
|
35
|
+
- Se elimina el constructor por defecto en Webpayplus
|
36
|
+
- Se elimina el constructor por defecto en Oneclick
|
37
|
+
- Se elimina el constructor por defecto en Patpass Comercio
|
38
|
+
- Se elimina el constructor por defecto en Full Transaction y Mall Full Transaction
|
39
|
+
- Se elimina el código que hace referencia al producto ‘Webpay Modal’
|
40
|
+
- Se elimina el código que hace referencia al producto ‘Patpass by webpay’
|
41
|
+
|
8
42
|
## [4.0.0] - 2024-03-20
|
9
43
|
|
10
44
|
### Changed
|
data/README.md
CHANGED
@@ -4,7 +4,7 @@ SDK Oficial de Transbank
|
|
4
4
|
|
5
5
|
## Requisitos:
|
6
6
|
|
7
|
-
- Ruby 2.
|
7
|
+
- Ruby 2.7+
|
8
8
|
|
9
9
|
# Instalación
|
10
10
|
|
@@ -26,6 +26,12 @@ y luego ejecutar
|
|
26
26
|
bundle install
|
27
27
|
```
|
28
28
|
|
29
|
+
## Ejecutar Test
|
30
|
+
|
31
|
+
```bash
|
32
|
+
bundle exec rake test
|
33
|
+
```
|
34
|
+
|
29
35
|
## Documentación
|
30
36
|
|
31
37
|
Puedes encontrar toda la documentación de cómo usar este SDK en el sitio https://www.transbankdevelopers.cl.
|
@@ -35,9 +41,22 @@ La documentación relevante para usar este SDK es:
|
|
35
41
|
- Documentación sobre [ambientes, deberes del comercio, puesta en producción,
|
36
42
|
etc](https://www.transbankdevelopers.cl/documentacion/como_empezar#ambientes).
|
37
43
|
|
38
|
-
## Información para contribuir y desarrollar este SDK
|
39
44
|
|
40
|
-
|
45
|
+
## Información para contribuir a este proyecto
|
46
|
+
|
47
|
+
### Forma de trabajo
|
48
|
+
|
49
|
+
- Para los mensajes de commits, nos basamos en las [Git Commit Guidelines de Angular](https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#commits).
|
50
|
+
- Usamos inglés para los nombres de ramas y mensajes de commit.
|
51
|
+
- Los mensajes de commit no deben llevar punto final.
|
52
|
+
- Los mensajes de commit deben usar un lenguaje imperativo y estar en tiempo presente, por ejemplo, usar "change" en lugar de "changed" o "changes".
|
53
|
+
- Los nombres de las ramas deben estar en minúsculas y las palabras deben separarse con guiones (-).
|
54
|
+
- Todas las fusiones a la rama principal se deben realizar mediante solicitudes de Pull Request(PR). ⬇️
|
55
|
+
- Se debe emplear tokens como "WIP" en el encabezado de un commit, separados por dos puntos (:), por ejemplo, "WIP: this is a useful commit message".
|
56
|
+
- Una rama con nuevas funcionalidades que no tenga un PR, se considera que está en desarrollo.
|
57
|
+
- Los nombres de las ramas deben comenzar con uno de los tokens definidos. Por ejemplo: "feat/tokens-configurations".
|
58
|
+
|
59
|
+
### Short lead tokens permitidos
|
41
60
|
|
42
61
|
`WIP` = En progreso.
|
43
62
|
|
@@ -61,45 +80,40 @@ La documentación relevante para usar este SDK es:
|
|
61
80
|
|
62
81
|
`release` = Para liberar una nueva versión.
|
63
82
|
|
64
|
-
###
|
65
|
-
|
66
|
-
- Para los commits respetamos las siguientes normas: https://chris.beams.io/posts/git-commit/
|
67
|
-
- Usamos ingles, para los mensajes de commit.
|
68
|
-
- Se pueden usar tokens como WIP, en el subject de un commit, separando el token con `:`, por ejemplo:
|
69
|
-
`WIP: This is a useful commit message`
|
70
|
-
- Para los nombres de ramas también usamos ingles.
|
71
|
-
- Se asume, que una rama de feature no mezclada, es un feature no terminado.
|
72
|
-
- El nombre de las ramas va en minúsculas.
|
73
|
-
- Las palabras se separan con `-`.
|
74
|
-
- Las ramas comienzan con alguno de los short lead tokens definidos, por ejemplo: `feat/tokens-configuration`
|
83
|
+
### Creación de un Pull Request
|
75
84
|
|
76
|
-
|
85
|
+
- El PR debe estar enfocado en un cambio en concreto, por ejemplo, agregar una nueva funcionalidad o solucionar un error, pero un solo PR no puede agregar una nueva funcionalidad y arreglar un error.
|
86
|
+
- El título del los PR y mensajes de commit no debe comenzar con una letra mayúscula.
|
87
|
+
- No se debe usar punto final en los títulos.
|
88
|
+
- 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.
|
89
|
+
- La descripción del PR debe detallar los cambios que se están incorporando.
|
90
|
+
- La descripción del PR debe incluir evidencias de que los test se ejecutan de forma correcta o incluir evidencias de que los cambios funcionan y no afectan la funcionalidad previa del proyecto.
|
91
|
+
- Se pueden agregar capturas, gif o videos para complementar la descripción o demostrar el funcionamiento del PR.
|
77
92
|
|
78
|
-
|
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.
|
93
|
+
#### Flujo de trabajo
|
81
94
|
|
82
|
-
|
95
|
+
1. Crea tu rama desde develop.
|
96
|
+
2. Haz un push de los commits y publica la nueva rama.
|
97
|
+
3. Abre un Pull Request apuntando tus cambios a develop.
|
98
|
+
4. Espera a la revisión de los demás integrantes del equipo.
|
99
|
+
5. Para poder mezclar los cambios se debe contar con 2 aprobaciones de los revisores y no tener alertas por parte de las herramientas de inspección.
|
83
100
|
|
84
|
-
|
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.
|
101
|
+
### Esquema de flujo con git
|
91
102
|
|
92
|
-
|
103
|
+

|
93
104
|
|
94
|
-
|
105
|
+
## Generar una nueva versión
|
95
106
|
|
96
|
-
Para generar una nueva versión, se debe crear un PR (con un título "
|
107
|
+
Para generar una nueva versión, se debe crear un PR (con un título "release: prepare release X.Y.Z" con los valores que correspondan para `X`, `Y` y `Z`). Se debe seguir el estándar [SemVer](https://semver.org/lang/es/) 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).
|
97
108
|
|
98
109
|
En ese PR deben incluirse los siguientes cambios:
|
99
110
|
|
100
|
-
1. Modificar el archivo `CHANGELOG.md` para incluir una nueva entrada (al comienzo) para `X.Y.Z` que explique en español los cambios
|
101
|
-
2. Modificar [version.rb](./lib/transbank/sdk/version.rb)
|
111
|
+
1. Modificar el archivo `CHANGELOG.md` para incluir una nueva entrada (al comienzo) para `X.Y.Z` que explique en español los cambios.
|
112
|
+
2. Modificar el archivo [version.rb](./lib/transbank/sdk/version.rb) y modificar la versión.
|
102
113
|
|
103
|
-
Luego de obtener aprobación del
|
114
|
+
Luego de obtener aprobación del PR, 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.
|
104
115
|
|
105
116
|
Con eso Github Actions generará automáticamente una nueva versión de la librería y la publicará en RubyGems.
|
117
|
+
|
118
|
+
|
119
|
+
Posterior a la liberación debes mezclar la rama release en develop, finalmente realizar un rebase de la rama develop utilizando como base la rama main.
|
@@ -2,14 +2,22 @@ module Transbank
|
|
2
2
|
module Common
|
3
3
|
class BaseTransaction
|
4
4
|
|
5
|
-
def initialize(
|
6
|
-
|
7
|
-
|
8
|
-
|
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
|
-
|
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(
|
16
|
-
super
|
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
|
-
|
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
|
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
|
13
|
-
|
13
|
+
if is_patpass
|
14
|
+
@url = endpoint
|
14
15
|
else
|
15
|
-
|
16
|
+
@url = ENVIRONMENTS[environment] + endpoint
|
16
17
|
end
|
17
18
|
@headers = headers(@commerce_code, @api_key)
|
18
19
|
end
|
@@ -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
|
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module Transbank
|
2
|
+
module Webpay
|
3
|
+
module Oneclick
|
4
|
+
class MallBinInfo < ::Transbank::Common::BaseTransaction
|
5
|
+
private_class_method :new
|
6
|
+
RESOURCES_URL = ::Transbank::Common::ApiConstants::ONECLICK_ENDPOINT
|
7
|
+
QUERY_BIN_ENDPOINT = (RESOURCES_URL + '/bin_info').freeze
|
8
|
+
|
9
|
+
def initialize(options)
|
10
|
+
super
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.new(options)
|
14
|
+
super(options)
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.build_for_integration(commerce_code, api_key)
|
18
|
+
options = Options.new(
|
19
|
+
commerce_code,
|
20
|
+
api_key,
|
21
|
+
:integration
|
22
|
+
)
|
23
|
+
|
24
|
+
new(options)
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.build_for_production(commerce_code, api_key)
|
28
|
+
options = Options.new(
|
29
|
+
commerce_code,
|
30
|
+
api_key,
|
31
|
+
:production
|
32
|
+
)
|
33
|
+
new(options)
|
34
|
+
end
|
35
|
+
|
36
|
+
def query_bin(tbk_user)
|
37
|
+
Transbank::Common::Validation.has_text_with_max_length(tbk_user, Transbank::Common::ApiConstants::TBK_USER_LENGTH, "tbk_user")
|
38
|
+
|
39
|
+
request_service = ::Transbank::Shared::RequestService.new(
|
40
|
+
@environment, QUERY_BIN_ENDPOINT, @commerce_code, @api_key, @timeout
|
41
|
+
)
|
42
|
+
request_service.post({ tbk_user: tbk_user })
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -2,24 +2,46 @@ module Transbank
|
|
2
2
|
module Webpay
|
3
3
|
module Oneclick
|
4
4
|
class MallInscription < ::Transbank::Common::BaseTransaction
|
5
|
-
|
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(
|
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,15 +2,38 @@ module Transbank
|
|
2
2
|
module Webpay
|
3
3
|
module Oneclick
|
4
4
|
class MallTransaction < ::Transbank::Common::BaseTransaction
|
5
|
-
|
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
11
|
|
12
|
-
def initialize(
|
13
|
-
super
|
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)
|
14
37
|
end
|
15
38
|
|
16
39
|
def authorize(username, tbk_user, parent_buy_order, details)
|
@@ -20,7 +43,7 @@ module Transbank
|
|
20
43
|
Transbank::Common::Validation.has_text_with_max_length(parent_buy_order, Transbank::Common::ApiConstants::BUY_ORDER_LENGTH, "parent_buy_order")
|
21
44
|
|
22
45
|
request_service = ::Transbank::Shared::RequestService.new(
|
23
|
-
@environment, AUTHORIZE_ENDPOINT, @commerce_code, @api_key
|
46
|
+
@environment, AUTHORIZE_ENDPOINT, @commerce_code, @api_key, @timeout
|
24
47
|
)
|
25
48
|
request_service.post({
|
26
49
|
username: username, tbk_user: tbk_user, buy_order: parent_buy_order, details: details
|
@@ -34,7 +57,7 @@ module Transbank
|
|
34
57
|
Transbank::Common::Validation.has_text_with_max_length(authorization_code, Transbank::Common::ApiConstants::AUTHORIZATION_CODE_LENGTH, "authorization_code")
|
35
58
|
|
36
59
|
request_service = ::Transbank::Shared::RequestService.new(
|
37
|
-
@environment, CAPTURE_ENDPOINT, @commerce_code, @api_key
|
60
|
+
@environment, CAPTURE_ENDPOINT, @commerce_code, @api_key, @timeout
|
38
61
|
)
|
39
62
|
request_service.put(commerce_code: child_commerce_code, buy_order: child_buy_order, authorization_code: authorization_code, capture_amount: amount)
|
40
63
|
end
|
@@ -44,7 +67,7 @@ module Transbank
|
|
44
67
|
Transbank::Common::Validation.has_text_with_max_length(buy_order, Transbank::Common::ApiConstants::BUY_ORDER_LENGTH, "buy_order")
|
45
68
|
|
46
69
|
request_service = ::Transbank::Shared::RequestService.new(
|
47
|
-
@environment, format(STATUS_ENDPOINT, token: buy_order), @commerce_code, @api_key
|
70
|
+
@environment, format(STATUS_ENDPOINT, token: buy_order), @commerce_code, @api_key, @timeout
|
48
71
|
)
|
49
72
|
request_service.get
|
50
73
|
end
|
@@ -56,7 +79,7 @@ module Transbank
|
|
56
79
|
Transbank::Common::Validation.has_text_with_max_length(child_buy_order, Transbank::Common::ApiConstants::BUY_ORDER_LENGTH, "child_buy_order")
|
57
80
|
|
58
81
|
request_service = ::Transbank::Shared::RequestService.new(
|
59
|
-
@environment, format(REFUND_ENDPOINT, token: buy_order), @commerce_code, @api_key
|
82
|
+
@environment, format(REFUND_ENDPOINT, token: buy_order), @commerce_code, @api_key, @timeout
|
60
83
|
)
|
61
84
|
request_service.post(detail_buy_order: child_buy_order, commerce_code: child_commerce_code, amount: amount)
|
62
85
|
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
|