mvarlic-ruby-sdk 3.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +7 -0
  2. data/.github/ISSUE_TEMPLATE/reporte-de-error.md +40 -0
  3. data/.github/workflows/publish-sdk.yml +58 -0
  4. data/.gitignore +16 -0
  5. data/CHANGELOG.md +104 -0
  6. data/Dockerfile +5 -0
  7. data/Gemfile +6 -0
  8. data/LICENSE.md +11 -0
  9. data/Makefile +24 -0
  10. data/README.md +85 -0
  11. data/Rakefile +10 -0
  12. data/bin/console +14 -0
  13. data/bin/setup +8 -0
  14. data/docker-compose.yml +20 -0
  15. data/lib/transbank/sdk/common/api_constants.rb +23 -0
  16. data/lib/transbank/sdk/common/base_transaction.rb +18 -0
  17. data/lib/transbank/sdk/common/integration_api_keys.rb +9 -0
  18. data/lib/transbank/sdk/common/integration_commerce_codes.rb +82 -0
  19. data/lib/transbank/sdk/common/validation.rb +19 -0
  20. data/lib/transbank/sdk/patpass/patpass_by_webpay/transaction.rb +41 -0
  21. data/lib/transbank/sdk/patpass/patpass_comercio/inscription.rb +56 -0
  22. data/lib/transbank/sdk/shared/request_service.rb +93 -0
  23. data/lib/transbank/sdk/shared/transbank_error.rb +5 -0
  24. data/lib/transbank/sdk/version.rb +5 -0
  25. data/lib/transbank/sdk/webpay/oneclick/mall_inscription.rb +52 -0
  26. data/lib/transbank/sdk/webpay/oneclick/mall_transaction.rb +118 -0
  27. data/lib/transbank/sdk/webpay/transaccion_completa/mall_transaction.rb +122 -0
  28. data/lib/transbank/sdk/webpay/transaccion_completa/transaction.rb +120 -0
  29. data/lib/transbank/sdk/webpay/webpay_plus/mall_transaction.rb +134 -0
  30. data/lib/transbank/sdk/webpay/webpay_plus/transaction.rb +127 -0
  31. data/lib/transbank/sdk/webpay/webpay_plus_modal/transaction.rb +62 -0
  32. data/lib/transbank/sdk.rb +27 -0
  33. data/mvarlic-ruby-sdk.gemspec +35 -0
  34. data/sdk_test.sh +2 -0
  35. metadata +216 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: aa1a8a71a66b0089c85f8a8770260b6d770306e59b0a44b5cbc446804e337926
4
+ data.tar.gz: 8d419cbe0e917a38a98097db49474416dd138bdbf7ccefddb92c4fdac3b09890
5
+ SHA512:
6
+ metadata.gz: 9b2e41dffae8d9da7daf0f953b1747d540a857caa2baf40e03d8cd966503ab2b3ca8432f900ccf0579ef6f42b8ec6fae26a17aa6f44292dbc19e5530a8495f15
7
+ data.tar.gz: ff6b2288271e53dfc66ddc68c5ca4ffdcacb051844b80e6dd9e200af91a324f7fa64a8d5cbfde2dbfd7898c40c9c7c1f15d1dd7c3eee15f351f57f388cb84844
@@ -0,0 +1,40 @@
1
+ ---
2
+ name: Reporte de Error
3
+ about: Crea un reporte para ayudarnos a mejorar
4
+ title: ''
5
+ labels: bug
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **Describe el bug**
11
+
12
+ Una descripción concisa sobre el bug.
13
+
14
+ **Para reproducir**
15
+
16
+ 1. Configura '...'
17
+ 2. Crea un objeto '...'
18
+ 3. Ejecuta el método '...'
19
+ 4. Se ve el error en '...'
20
+
21
+ **Comportamiento observado**
22
+
23
+ Describe de forma concisa lo que observaste siguiendo los pasos para reproducir el error.
24
+
25
+ **Comportamiento esperado**
26
+
27
+ Una explicación concisa y clara de qué es lo que esperas que ocurra.
28
+
29
+ **Capturas de pantalla**
30
+
31
+ Si aplica, agrega aquí capturas de pantalla que ayuden a explicar tu problema.
32
+
33
+ **Versiones (por favor agrega aquí la siguiente información):**
34
+ - SDK: [e.g. 1.1.0]
35
+ - Ruby: [e.g. 2.5.2]
36
+ - Bundler: [e.g. 2.0.1]
37
+
38
+ **Contexto adicional**
39
+
40
+ Agrega cualquier otro información sobre el problema aquí.
@@ -0,0 +1,58 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+
6
+ # GitHub recommends pinning actions to a commit SHA.
7
+ # To get a newer version, you will need to update the SHA.
8
+ # You can also reference a tag or branch, but the action may change without warning.
9
+
10
+ name: Ruby Gem
11
+
12
+ on:
13
+ # Manually publish
14
+ workflow_dispatch:
15
+ # Alternatively, publish whenever changes are merged to the `main` branch.
16
+ push:
17
+ branches: [ main ]
18
+ pull_request:
19
+ branches: [ main ]
20
+
21
+ jobs:
22
+ build:
23
+ name: Build + Publish
24
+ runs-on: ubuntu-latest
25
+ permissions:
26
+ packages: write
27
+ contents: read
28
+
29
+ steps:
30
+ - uses: actions/checkout@v3
31
+ - name: Set up Ruby 2.6
32
+ uses: ruby/setup-ruby@477b21f02be01bcb8030d50f37cfec92bfa615b6
33
+ with:
34
+ ruby-version: 2.6
35
+ - run: bundle install
36
+
37
+ - name: Publish to GPR
38
+ run: |
39
+ mkdir -p $HOME/.gem
40
+ touch $HOME/.gem/credentials
41
+ chmod 0600 $HOME/.gem/credentials
42
+ printf -- "---\n:github: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
43
+ gem build *.gemspec
44
+ gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} *.gem
45
+ env:
46
+ GEM_HOST_API_KEY: "Bearer ${{secrets.GITHUB_TOKEN}}"
47
+ OWNER: ${{ github.repository_owner }}
48
+
49
+ - name: Publish to RubyGems
50
+ run: |
51
+ mkdir -p $HOME/.gem
52
+ touch $HOME/.gem/credentials
53
+ chmod 0600 $HOME/.gem/credentials
54
+ printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
55
+ gem build *.gemspec
56
+ gem push *.gem
57
+ env:
58
+ GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_API_KEY}}"
data/.gitignore ADDED
@@ -0,0 +1,16 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ /.DS_Store/
10
+ .idea
11
+ *.gem
12
+ Gemfile.lock
13
+ .built
14
+ .bundled
15
+ .rakeTasks
16
+ .DS_Store
data/CHANGELOG.md ADDED
@@ -0,0 +1,104 @@
1
+ # Changelog
2
+ Todos los cambios notables a este proyecto serán documentados en este archivo.
3
+
4
+ El formato está basado en [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
5
+ y este proyecto adhiere a [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
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
+
25
+ ## [2.0.0] - 2022-01-03
26
+
27
+ ### Removed
28
+
29
+ - Se elimina Onepay
30
+
31
+ ### Changed
32
+
33
+ - Se agrega soporte a Webpay Modal
34
+ - Se migra el api desde la versión 1.0 a la versión 1.2
35
+ - Ahora el método de retorno al crear la transacción en WebPayPlus debe tener soporte GET (cuando es exitosa) y POST (cuando se retorna sin concluir el ingreso de la tarjeta)
36
+ - Ahora el método de retorno al inscribirse en Oneclick debe tener soporte GET (cuando es exitosa) y POST (cuando se retorna sin concluir la inscripción)
37
+ - Se refactoriza y migra todos los productos desde clases estáticas a clases instanciables
38
+ - Se unifica 'Transaction' y 'DeferredTransaction' en WebpayPlus
39
+ - Se unifica 'MallTransaction' y 'MallDeferredTransaction' en WebpayPlus y Oneclick
40
+
41
+ ### Added
42
+
43
+ - Se agrega soporte a Webpay Modal
44
+ - Se agregan validaciones de obligatoriedad y tamaño de los parámetros a los métodos de WebpayPlus, Oneclick, Webpay Modal, Transacción Completa
45
+ - Se agrega un módulo de constantes con los códigos de comercio de integración: 'IntegrationCommerceCodes'
46
+ - Se agrega un módulo de constantes con las claves de comercio de integración: 'IntegrationApiKeys'
47
+
48
+ ## [1.5.1] - 2021-04-12
49
+ ### Added
50
+ - Se agrega captura diferida en Transacción Completa y Transacción Completa Mall
51
+
52
+ ## [1.4.1] - 2021-03-30
53
+ ### Fixed
54
+ - Se agrega parámetro de estado faltante en respuesta de Commit y Status en Webpay Plus
55
+ - Se agrega dependencia JSON (~> 2.0) para evitar problemas al recibir respuesta de Commit
56
+ - Se arregla endpoint de captura en Webpay Plus
57
+
58
+ ## [1.4.0] - 2020-12-03
59
+ ### Added
60
+ - Se agregan métodos de configuración para integración a Webpay Plus en sus modalidades diferidas y mall diferida.
61
+ - Se agregan métodos de configuración para integración a Webpay Oneclick en su modalidad mall diferida.
62
+
63
+ ### Fixed
64
+ - Se arregla forma en que se lee configuración del SDK, estaba tomando valores de una constante en vez de la variable de clase correspondiente. Este arreglo es para todos los productos con la excepción de Onepay
65
+
66
+ ## [1.3.1] - 2020-10-29
67
+ ### Fixed
68
+ - Se revierte commit que elimina requires necesarios para productos REST
69
+
70
+ ## [1.3.0] - 2020-10-26
71
+
72
+ ### Added
73
+
74
+ - Se agrega soporte para:
75
+ - Webpay Plus Rest
76
+ - modalidad normal
77
+ - modalidad captura diferida
78
+ - modalidad mall
79
+ - modalidad mall captura diferida
80
+ - Patpass by Webpay Rest
81
+ - Patpass Comercio Rest
82
+ - Transacción completa Rest
83
+ - modalidad mall
84
+ - Oneclick Mall Captura diferida
85
+
86
+ ## [1.2.0] - 2019-12-26
87
+ ### Added
88
+ - Se agrega soporte para Oneclick Mall y Transacción Completa en sus versiones REST.
89
+
90
+ ## [1.1.0] - 2018-04-08
91
+ ### Added
92
+ - Se agregaron los parámetros `qr_width_height` y `commerce_logo_url` a Options, para definir el tamaño del QR generado para la transacción, y especificar la ubicación del logo de comercio para ser mostrado en la aplicación móvil de Onepay. Puedes configurar estos parámetros globalmente o por transacción.
93
+
94
+ ## [1.0.2] - 2018-11-29
95
+ ### Fixed
96
+ - Corrige problema que evitaba poder utilizar un `CHANNEL` distinto a `WEB`
97
+
98
+ ## [1.0.1] - 2018-10-24
99
+ ### Fixed
100
+ - Cambios para subir automáticamente la gema a RubyGems cuando se hace un nuevo release
101
+
102
+ ## [1.0.0] - 2018-10-23
103
+ ### Added
104
+ - Primer lanzamiento del SDK
data/Dockerfile ADDED
@@ -0,0 +1,5 @@
1
+ FROM ruby:2.4-jessie
2
+ RUN apt-get update && apt-get install
3
+ RUN mkdir -p /sdk
4
+ WORKDIR /sdk
5
+ COPY . /sdk
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in mvarlic-ruby-sdk.gemspec
6
+ gemspec
data/LICENSE.md ADDED
@@ -0,0 +1,11 @@
1
+ Copyright 2018 Transbank
2
+
3
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
4
+
5
+ Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
6
+
7
+ Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8
+
9
+ Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
10
+
11
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/Makefile ADDED
@@ -0,0 +1,24 @@
1
+ SHELL := /bin/bash
2
+
3
+ all: build run
4
+
5
+ run: build
6
+ docker-compose run --rm web
7
+
8
+ build: .built .bundled
9
+
10
+ .built: Dockerfile
11
+ docker-compose build
12
+ touch .built
13
+
14
+ .bundled: Gemfile
15
+ docker-compose run web bundle install
16
+ touch .bundled
17
+
18
+ logs:
19
+ docker-compose logs
20
+
21
+ clean:
22
+ docker-compose rm
23
+ rm .built
24
+ rm .bundled
data/README.md ADDED
@@ -0,0 +1,85 @@
1
+ # Transbank SDK Ruby
2
+
3
+ SDK Oficial de Transbank
4
+
5
+ ## Requisitos:
6
+
7
+ - Ruby 2.4+
8
+
9
+ # Instalación
10
+
11
+ Puedes instalar el SDK directamente
12
+ ```bash
13
+ gem install transbank-sdk
14
+ ```
15
+
16
+ o añadirlo a tu `Gemfile`
17
+ ```ruby
18
+ gem 'transbank-sdk'
19
+ ```
20
+ y luego ejecutar
21
+ ```bash
22
+ bundle install
23
+ ```
24
+ ## Documentación
25
+
26
+ Puedes encontrar toda la documentación de cómo usar este SDK en el sitio https://www.transbankdevelopers.cl.
27
+
28
+ Actualmente este SDK contiene sólo Onepay.
29
+
30
+ La documentación relevante para usar este SDK es:
31
+
32
+ - Documentación sobre [ambientes, deberes del comercio, puesta en producción,
33
+ etc](https://www.transbankdevelopers.cl/documentacion/como_empezar#ambientes).
34
+
35
+ ## Información para contribuir y desarrollar este SDK
36
+
37
+ ### Requerimientos
38
+ - Docker
39
+ - Make
40
+ - Plugin de editorconfig para tu editor favorito.
41
+
42
+ ### Standares
43
+
44
+ - Para los commits respetamos las siguientes normas: https://chris.beams.io/posts/git-commit/
45
+ - Usamos ingles, para los mensajes de commit.
46
+ - 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`
48
+ - Para los nombres de ramas también usamos ingles.
49
+ - Se asume, que una rama de feature no mezclada, es un feature no terminado.
50
+ - El nombre de las ramas va en minúsculas.
51
+ - Las palabras se separan con `-`.
52
+ - Las ramas comienzan con alguno de los short lead tokens definidos, por ejemplo: `feat/tokens-configuration`
53
+
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.
61
+
62
+ ### Todas las mezclas a master se hacen mediante Pull Request.
63
+
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
+ ```
69
+
70
+ Para ejecutar los test localmente debes usar el siguiente comando en una terminal.
71
+ ```bash
72
+ make
73
+ ```
74
+
75
+ ### Deploy de una nueva versión.
76
+ 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
+
78
+ En ese PR deben incluirse los siguientes cambios:
79
+
80
+ 1. Modificar el archivo `CHANGELOG.md` para incluir una nueva entrada (al comienzo) para `X.Y.Z` que explique en español los cambios **de cara al usuario del SDK**.
81
+ 2. Modificar [version.rb](./lib/transbank/sdk/version.rb) para poner la nueva versión que corresponde.
82
+
83
+ 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
+
85
+ Con eso Travis CI generará automáticamente una nueva versión de la librería y la publicará en RubyGems.
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task :default => :test
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "transbank/sdk"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,20 @@
1
+ version: '2'
2
+ services:
3
+ web: &web
4
+ tty: true
5
+ stdin_open: true
6
+ build:
7
+ context: .
8
+ dockerfile: Dockerfile
9
+ command: rake test
10
+ volumes:
11
+ - .:/sdk
12
+ volumes_from:
13
+ - bundle_cache
14
+ ports:
15
+ - "8000:8000"
16
+
17
+ bundle_cache:
18
+ image: ruby:2.4-jessie # Should be the same as the app Dockerfile.dev base image
19
+ volumes:
20
+ - /usr/local/bundle
@@ -0,0 +1,23 @@
1
+ module Transbank
2
+ module Common
3
+ module ApiConstants
4
+ WEBPAY_ENDPOINT = 'rswebpaytransaction/api/webpay/v1.3'.freeze
5
+ ONECLICK_ENDPOINT = 'rswebpaytransaction/api/oneclick/v1.3'.freeze
6
+ PATPASS_ENDPOINT = 'restpatpass/v1/services'.freeze
7
+
8
+ BUY_ORDER_LENGTH = 26;
9
+ SESSION_ID_LENGTH = 61;
10
+ RETURN_URL_LENGTH = 255;
11
+ AUTHORIZATION_CODE_LENGTH = 6;
12
+ CARD_EXPIRATION_DATE_LENGTH = 5;
13
+ CARD_NUMBER_LENGTH = 19;
14
+ TBK_USER_LENGTH = 40;
15
+ USER_NAME_LENGTH = 40;
16
+ COMMERCE_CODE_LENGTH = 12;
17
+ TOKEN_LENGTH = 64;
18
+ EMAIL_LENGTH = 100;
19
+ end
20
+ end
21
+ end
22
+
23
+
@@ -0,0 +1,18 @@
1
+ module Transbank
2
+ module Common
3
+ class BaseTransaction
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)
9
+ raise ArgumentError, "Environment must be either 'integration' or 'production'"
10
+ end
11
+
12
+ @environment = environment
13
+ end
14
+ end
15
+ end
16
+ end
17
+
18
+
@@ -0,0 +1,9 @@
1
+ # Contains the Webpay, Oneclick and Patpass Comercio constants for testing.
2
+ module Transbank
3
+ module Common
4
+ module IntegrationApiKeys
5
+ WEBPAY = '579B532A7440BB0C9079DED94D31EA1615BACEB56610332264630D42D0A36B1C'.freeze
6
+ PATPASS_COMERCIO = 'cxxXQgGD9vrVe4M41FIt'.freeze
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,82 @@
1
+ # Contains the Webpay, Oneclick and Patpass Comercio constants for testing.
2
+ module Transbank
3
+ module Common
4
+ module IntegrationCommerceCodes
5
+ WEBPAY_PLUS = '597055555532'.freeze
6
+ WEBPAY_PLUS_MODAL = '597055555584'.freeze
7
+ WEBPAY_PLUS_DEFERRED = '597055555540'.freeze
8
+
9
+ WEBPAY_PLUS_MALL = '597055555535'.freeze
10
+ WEBPAY_PLUS_MALL_CHILD1 = '597055555536'.freeze
11
+ WEBPAY_PLUS_MALL_CHILD2 = '597055555537'.freeze
12
+ WEBPAY_PLUS_MALL_CHILD_COMMERCE_CODES = [
13
+ '597055555536'.freeze,
14
+ '597055555537'.freeze
15
+ ].freeze
16
+
17
+ WEBPAY_PLUS_MALL_DEFERRED = '597055555581'.freeze
18
+ WEBPAY_PLUS_MALL_DEFERRED_CHILD1 = '597055555582'.freeze
19
+ WEBPAY_PLUS_MALL_DEFERRED_CHILD2 = '597055555583'.freeze
20
+ WEBPAY_PLUS_MALL_DEFERRED_CHILD_COMMERCE_CODES = [
21
+ '597055555582'.freeze,
22
+ '597055555583'.freeze
23
+ ].freeze
24
+
25
+ ONECLICK_MALL = '597055555541'.freeze
26
+ ONECLICK_MALL_CHILD1 = '597055555542'.freeze
27
+ ONECLICK_MALL_CHILD2 = '597055555543'.freeze
28
+ ONECLICK_MALL_CHILD_COMMERCE_CODES = [
29
+ '597055555542'.freeze,
30
+ '597055555543'.freeze
31
+ ].freeze
32
+
33
+ ONECLICK_MALL_DEFERRED = '597055555547'.freeze
34
+ ONECLICK_MALL_DEFERRED_CHILD1 = '597055555548'.freeze
35
+ ONECLICK_MALL_DEFERRED_CHILD2 = '597055555549'.freeze
36
+ ONECLICK_MALL_DEFERRED_CHILD_COMMERCE_CODES = [
37
+ '597055555548'.freeze,
38
+ '597055555549'.freeze
39
+ ].freeze
40
+
41
+ TRANSACCION_COMPLETA = '597055555530'.freeze
42
+ TRANSACCION_COMPLETA_SIN_CVV = '597055555557'.freeze
43
+ TRANSACCION_COMPLETA_DEFERRED = '597055555531'.freeze
44
+ TRANSACCION_COMPLETA_DEFERRED_SIN_CVV = '597055555556'.freeze
45
+
46
+ TRANSACCION_COMPLETA_MALL = '597055555573'.freeze
47
+ TRANSACCION_COMPLETA_MALL_CHILD1 = '597055555574'.freeze
48
+ TRANSACCION_COMPLETA_MALL_CHILD2 = '597055555575'.freeze
49
+ TRANSACCION_COMPLETA_MALL_CHILD = [
50
+ '597055555574'.freeze,
51
+ '597055555575'.freeze
52
+ ].freeze
53
+
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
57
+ TRANSACCION_COMPLETA_MALL_SIN_CVV_CHILD = [
58
+ '597055555552'.freeze,
59
+ '597055555553'.freeze
60
+ ].freeze
61
+
62
+ TRANSACCION_COMPLETA_MALL_DEFERRED = '597055555576'.freeze
63
+ TRANSACCION_COMPLETA_MALL_DEFERRED_CHILD1 = '597055555577'.freeze
64
+ TRANSACCION_COMPLETA_MALL_DEFERRED_CHILD2 = '597055555578'.freeze
65
+ TRANSACCION_COMPLETA_MALL_DEFERRED_CHILD = [
66
+ '597055555577'.freeze,
67
+ '597055555578'.freeze
68
+ ].freeze
69
+
70
+ TRANSACCION_COMPLETA_MALL_DEFERRED_SIN_CVV = '597055555561'.freeze
71
+ TRANSACCION_COMPLETA_MALL_DEFERRED_SIN_CVV_CHILD1 = '597055555562'.freeze
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
+
78
+ PATPASS_COMERCIO = '28299257'.freeze
79
+ PATPASS_BY_WEBPAY = "597055555550".freeze
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,19 @@
1
+
2
+ module Transbank
3
+ module Common
4
+ class Validation
5
+
6
+ def self.has_text_with_max_length(value, value_max_length, value_name)
7
+ if value.nil? || value.empty?
8
+ raise Transbank::Shared::TransbankError, "Transbank Error: %s is empty" % [value_name]
9
+ end
10
+ if value.length() > value_max_length
11
+ raise Transbank::Shared::TransbankError, "%s is too long, the maximum length is %s"% [value_name, value_max_length]
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+
18
+
19
+
@@ -0,0 +1,41 @@
1
+ module Transbank
2
+ module Patpass
3
+ module PatpassByWebpay
4
+ class Transaction < ::Transbank::Common::BaseTransaction
5
+ DEFAULT_ENVIRONMENT = :integration
6
+ RESOURCES_URL = ::Transbank::Common::ApiConstants::WEBPAY_ENDPOINT
7
+ CREATE_ENDPOINT = (RESOURCES_URL + '/transactions/').freeze
8
+ COMMIT_ENDPOINT = (RESOURCES_URL + '/transactions/%{token}').freeze
9
+ STATUS_ENDPOINT = (RESOURCES_URL + '/transactions/%{token}').freeze
10
+
11
+ def initialize(commerce_code = ::Transbank::Common::IntegrationCommerceCodes::PATPASS_BY_WEBPAY, api_key = ::Transbank::Common::IntegrationApiKeys::WEBPAY, environment = DEFAULT_ENVIRONMENT)
12
+ super
13
+ end
14
+
15
+ def create(buy_order, session_id, amount, return_url, details)
16
+ request_service = ::Transbank::Shared::RequestService.new(
17
+ @environment, CREATE_ENDPOINT, @commerce_code, @api_key
18
+ )
19
+ request_service.post({
20
+ buy_order: buy_order, session_id: session_id, amount: amount, return_url: return_url, wpm_detail: details
21
+ })
22
+ end
23
+
24
+ def commit(token)
25
+ request_service = ::Transbank::Shared::RequestService.new(
26
+ @environment, format(COMMIT_ENDPOINT, token: token), @commerce_code, @api_key
27
+ )
28
+ request_service.put({})
29
+ end
30
+
31
+ def status(token)
32
+ request_service = ::Transbank::Shared::RequestService.new(
33
+ @environment, format(STATUS_ENDPOINT, token: token), @commerce_code, @api_key
34
+ )
35
+ request_service.get
36
+ end
37
+
38
+ end
39
+ end
40
+ end
41
+ end