getnet_api 0.1.1 → 1.0.3

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: 5aab4ff1ccb3f001c28e65c81e62dd72fa8baa7c
4
- data.tar.gz: b7bba3dd819473f70285ed51a13ba71bb2e23ed0
2
+ SHA256:
3
+ metadata.gz: b083288e0b0ceb66b96ec653754a6ef21f464987b09ec56d05713308a61ac5e8
4
+ data.tar.gz: 249bf80e84152c593846858e785c1762c3bcb75fd0ac6dc926dfcb588de2c641
5
5
  SHA512:
6
- metadata.gz: aaff9d29f48ccdfd366be7f611a24dff5d693a87eee4f3088309f7633f2ccba1f24e9be6ea7832324a4d86aa7c89027ac646cca5884e9088ef8d76474463bfa3
7
- data.tar.gz: 8d63931e1fa248e26883488300c54d62838ef7647d11cfa4c1012ca32bbef14dc4b52fcd2d1fb3046e23be4cce2fbddc88c6c9131d2f571e72db94de2cc445fc
6
+ metadata.gz: 152b4a70325e83ff21d558ebe801299f347b621735276226cbff7af16dc09d89c3ed6e0a1effe10fd720d0ea7454afcf3c3d536690a7800ea51b38c92676756a
7
+ data.tar.gz: 7f2f0f5338c61b5874a1f45973a0f8d64f304de1975d5d081ce5813ae7fba05af382966e5d3f2e47e1e0e8841e1f47b133edfc1414490a9b4d511cb8366c2ad8
@@ -0,0 +1,28 @@
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
+ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
+ # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
+
8
+ name: Ruby
9
+
10
+ on:
11
+ push:
12
+ branches: [ master ]
13
+ pull_request:
14
+ branches: [ master ]
15
+
16
+ jobs:
17
+ test:
18
+ runs-on: ubuntu-latest
19
+ steps:
20
+ - uses: actions/checkout@v2
21
+ - uses: actions/setup-ruby@v1
22
+ with:
23
+ ruby-version: '2.6'
24
+ - name: Install dependencies
25
+ run: bundle install
26
+ - name: Run tests
27
+ run: bundle exec rspec
28
+
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper
data/Gemfile CHANGED
@@ -1,2 +1,12 @@
1
- source "https://rubygems.org"
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
2
4
  gemspec
5
+ gem 'activemodel'
6
+
7
+ group :test do
8
+ gem 'pry', '~> 0.13.1'
9
+ gem 'rspec'
10
+ gem 'vcr'
11
+ gem 'webmock'
12
+ end
data/Gemfile.lock CHANGED
@@ -1,33 +1,86 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- getnet_api (0.1.0)
5
- rest-client
4
+ getnet_api (1.0.1)
5
+ rest-client (>= 1.7.3)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- domain_name (0.5.20180417)
10
+ activemodel (6.1.3.1)
11
+ activesupport (= 6.1.3.1)
12
+ activesupport (6.1.3.1)
13
+ concurrent-ruby (~> 1.0, >= 1.0.2)
14
+ i18n (>= 1.6, < 2)
15
+ minitest (>= 5.1)
16
+ tzinfo (~> 2.0)
17
+ zeitwerk (~> 2.3)
18
+ addressable (2.7.0)
19
+ public_suffix (>= 2.0.2, < 5.0)
20
+ coderay (1.1.3)
21
+ concurrent-ruby (1.1.8)
22
+ crack (0.4.3)
23
+ safe_yaml (~> 1.0.0)
24
+ diff-lcs (1.4.4)
25
+ domain_name (0.5.20190701)
11
26
  unf (>= 0.0.5, < 1.0.0)
27
+ hashdiff (1.0.0)
28
+ http-accept (1.7.0)
12
29
  http-cookie (1.0.3)
13
30
  domain_name (~> 0.5)
14
- mime-types (3.2.2)
31
+ i18n (1.8.10)
32
+ concurrent-ruby (~> 1.0)
33
+ method_source (1.0.0)
34
+ mime-types (3.3.1)
15
35
  mime-types-data (~> 3.2015)
16
- mime-types-data (3.2018.0812)
36
+ mime-types-data (3.2021.0225)
37
+ minitest (5.14.4)
17
38
  netrc (0.11.0)
18
- rest-client (2.0.2)
39
+ pry (0.13.1)
40
+ coderay (~> 1.1)
41
+ method_source (~> 1.0)
42
+ public_suffix (4.0.6)
43
+ rest-client (2.1.0)
44
+ http-accept (>= 1.7.0, < 2.0)
19
45
  http-cookie (>= 1.0.2, < 2.0)
20
46
  mime-types (>= 1.16, < 4.0)
21
47
  netrc (~> 0.8)
48
+ rspec (3.10.0)
49
+ rspec-core (~> 3.10.0)
50
+ rspec-expectations (~> 3.10.0)
51
+ rspec-mocks (~> 3.10.0)
52
+ rspec-core (3.10.1)
53
+ rspec-support (~> 3.10.0)
54
+ rspec-expectations (3.10.1)
55
+ diff-lcs (>= 1.2.0, < 2.0)
56
+ rspec-support (~> 3.10.0)
57
+ rspec-mocks (3.10.2)
58
+ diff-lcs (>= 1.2.0, < 2.0)
59
+ rspec-support (~> 3.10.0)
60
+ rspec-support (3.10.2)
61
+ safe_yaml (1.0.5)
62
+ tzinfo (2.0.4)
63
+ concurrent-ruby (~> 1.0)
22
64
  unf (0.1.4)
23
65
  unf_ext
24
- unf_ext (0.0.7.5)
66
+ unf_ext (0.0.7.7)
67
+ vcr (6.0.0)
68
+ webmock (3.7.1)
69
+ addressable (>= 2.3.6)
70
+ crack (>= 0.3.2)
71
+ hashdiff (>= 0.4.0, < 2.0.0)
72
+ zeitwerk (2.4.2)
25
73
 
26
74
  PLATFORMS
27
75
  ruby
28
76
 
29
77
  DEPENDENCIES
78
+ activemodel
30
79
  getnet_api!
80
+ pry (~> 0.13.1)
81
+ rspec
82
+ vcr
83
+ webmock
31
84
 
32
85
  BUNDLED WITH
33
- 1.16.4
86
+ 1.17.3
data/README.md CHANGED
@@ -59,7 +59,7 @@ end
59
59
  Nesse endpoint serão recebidos dados para os pagamentos.
60
60
 
61
61
 
62
- ### Montar [Endereço](http://www.rubydoc.info/github/qw3/superpay_api/GetnetApi/Address)
62
+ ### Montar [Endereço](https://www.rubydoc.info/gems/getnet_api/GetnetApi/Address)
63
63
 
64
64
  ```ruby
65
65
  obj_endereco = GetnetApi::Address.new ({
@@ -73,7 +73,7 @@ obj_endereco = GetnetApi::Address.new ({
73
73
  })
74
74
  ```
75
75
 
76
- ### Montar [Cliente](http://www.rubydoc.info/github/qw3/superpay_api/GetnetApi/Customer)
76
+ ### Montar [Cliente](https://www.rubydoc.info/gems/getnet_api/GetnetApi/Customer)
77
77
 
78
78
  ```ruby
79
79
  obj_cliente = GetnetApi::Customer.new ({
@@ -90,7 +90,7 @@ obj_cliente = GetnetApi::Customer.new ({
90
90
  })
91
91
  ```
92
92
 
93
- ### Montar [Pedido](http://www.rubydoc.info/github/qw3/superpay_api/GetnetApi/Order)
93
+ ### Montar [Pedido](https://www.rubydoc.info/gems/getnet_api/GetnetApi/Order)
94
94
 
95
95
  ```ruby
96
96
  obj_pedido = GetnetApi::Order.new ({
@@ -102,7 +102,7 @@ obj_pedido = GetnetApi::Order.new ({
102
102
 
103
103
  ---
104
104
 
105
- ### Montar [Pagamento](http://www.rubydoc.info/github/qw3/superpay_api/GetnetApi/Payment)
105
+ ### Montar [Pagamento](https://www.rubydoc.info/gems/getnet_api/GetnetApi/Payment)
106
106
 
107
107
  ```ruby
108
108
  obj_pagamento = GetnetApi::Payment.new ({
@@ -114,7 +114,7 @@ obj_pagamento = GetnetApi::Payment.new ({
114
114
  ```
115
115
  ## Criando um pagamento na GetNet do tipo Credit
116
116
 
117
- ### Montar [Cartão](http://www.rubydoc.info/github/qw3/superpay_api/GetnetApi/Credit)
117
+ ### Montar [Cartão](https://www.rubydoc.info/gems/getnet_api/GetnetApi/Credit)
118
118
 
119
119
  ```ruby
120
120
  obj_credit = GetnetApi::Credit.new ({
@@ -139,7 +139,7 @@ novo_pagamento = GetnetApi::Payment.create obj_pagamento, obj_credito, :credit
139
139
 
140
140
  ## Criando um pagamento na GetNet do tipo Boleto
141
141
 
142
- ### Montar [Boleto](http://www.rubydoc.info/github/qw3/superpay_api/GetnetApi/Boleto)
142
+ ### Montar [Boleto](https://www.rubydoc.info/gems/getnet_api/GetnetApi/Boleto)
143
143
 
144
144
  ```ruby
145
145
  obj_boleto = GetnetApi::Boleto.new ({
@@ -157,6 +157,19 @@ obj_boleto = GetnetApi::Boleto.new ({
157
157
  novo_pagamento = GetnetApi::Payment.create obj_pagamento, obj_boleto, :boleto
158
158
  ```
159
159
 
160
+ ## Criando um cancelamento de cartão de crédito
161
+
162
+ ### Montar [Cancelamento](https://www.rubydoc.info/gems/getnet_api/GetnetApi/PaymentCancel)
163
+ ```ruby
164
+ obj_cancelamento = GetnetApi::PaymentCancel.new ({
165
+ payment_id: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
166
+ cancel_amount: 1000
167
+ })
168
+
169
+ # GetnetApi::PaymentCancel.create(GetnetApi::PaymentCancel)
170
+ cancelamento = GetnetApi::PaymentCancel.create obj_cancelamento
171
+ ```
172
+
160
173
  ---
161
174
 
162
175
 
@@ -164,7 +177,12 @@ novo_pagamento = GetnetApi::Payment.create obj_pagamento, obj_boleto, :boleto
164
177
 
165
178
  - [QW3 Software & Marketing](http://qw3.com.br)
166
179
  - [Leandro dos Santos Falcão](https://www.linkedin.com/in/lsfalcao)
180
+
181
+ ## Contributors
182
+
167
183
  - [Victor Barreiros](www.linkedin.com/in/victor-barreiros)
184
+ - [Daniel B. Brumazzi](https://www.linkedin.com/in/daniel-brumazzi-2153707b/)
185
+ - [eduardosleite](https://github.com/eduardosleite)
168
186
 
169
187
  ## Copyright
170
188
 
data/getnet_api.gemspec CHANGED
@@ -22,6 +22,6 @@ Gem::Specification.new do |spec|
22
22
 
23
23
  spec.required_ruby_version = Gem::Requirement.new(">= 1.9")
24
24
 
25
- spec.add_dependency 'rest-client', '~> 0'
25
+ spec.add_dependency 'rest-client', '>= 1.7.3'
26
26
 
27
27
  end
data/lib/getnet_api.rb CHANGED
@@ -1,6 +1,8 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  require 'rubygems'
3
3
  require 'active_model'
4
+ require 'active_support/time'
5
+ require 'json'
4
6
 
5
7
  require "getnet_api/version"
6
8
  require "getnet_api/configure"
@@ -14,6 +16,7 @@ require "getnet_api/order"
14
16
  require "getnet_api/boleto"
15
17
  require "getnet_api/credit"
16
18
  require "getnet_api/payment"
19
+ require "getnet_api/payment_cancel"
17
20
 
18
21
 
19
22
  # -*- encoding : utf-8 -*-
@@ -27,6 +27,10 @@ module GetnetApi
27
27
  # Ano de expiração do cartão com dois dígitos.
28
28
  attr_accessor :expiration_year
29
29
 
30
+ def brand
31
+ @brand ||= ""
32
+ end
33
+
30
34
  # Validações do Rails 3
31
35
  include ActiveModel::Validations
32
36
 
@@ -5,14 +5,14 @@ module GetnetApi
5
5
  require 'net/http'
6
6
 
7
7
  # Metodo para verificar se o token gerado é valido.
8
- def self.verify card_token
8
+ def self.verify card
9
9
 
10
10
  hash = {
11
- "number_token" => card_token.to_s,
12
- "cardholder_name": "JOAO DA SILVA",
13
- "expiration_month": "12",
14
- "expiration_year": "20",
15
- "security_code": "123"
11
+ "number_token" => card.number_token.to_s,
12
+ "cardholder_name" => card.cardholder_name.to_s,
13
+ "expiration_month" => card.expiration_month.to_s,
14
+ "expiration_year" => card.expiration_year.to_s,
15
+ "security_code" => card.security_code.to_s
16
16
  }
17
17
 
18
18
  response = self.build_request self.endpoint, "post", hash
@@ -29,4 +29,4 @@ module GetnetApi
29
29
  end
30
30
  end
31
31
 
32
- # GetnetApi::CardVerification.verify a["number_token"]
32
+ # GetnetApi::CardVerification.verify card
@@ -98,7 +98,7 @@ module GetnetApi
98
98
  end
99
99
 
100
100
  def base_uri
101
- return "#{self.endpoint}/#{self.api_version}/"
101
+ return "#{self.endpoint}/#{self.api_version}"
102
102
  end
103
103
 
104
104
  end
@@ -106,10 +106,10 @@ module GetnetApi
106
106
  }
107
107
 
108
108
  if tipo == :customer
109
- customer.merge!({"address": address.to_request,})
109
+ customer.merge!({"address" => address.to_request,})
110
110
  elsif tipo == :payment
111
- customer.merge!({"name": self.name.to_s,})
112
- customer.merge!({"billing_address": address.to_request,})
111
+ customer.merge!({"name" => self.name.to_s,})
112
+ customer.merge!({"billing_address" => address.to_request,})
113
113
  end
114
114
 
115
115
  return customer
@@ -82,9 +82,9 @@ module GetnetApi
82
82
  }
83
83
 
84
84
  if type == :boleto
85
- payment.merge!({"boleto": obj.to_request,})
85
+ payment.merge!({"boleto" => obj.to_request,})
86
86
  elsif :credit
87
- payment.merge!({"credit": obj.to_request,})
87
+ payment.merge!({"credit" => obj.to_request,})
88
88
  end
89
89
 
90
90
  return payment
@@ -0,0 +1,48 @@
1
+ module GetnetApi
2
+ class PaymentCancel < Base
3
+ # payment_id
4
+ # string <= 36 characters Required
5
+ # ID do pagamento via cartão de crédito
6
+ attr_accessor :payment_id
7
+
8
+ # cancel_amount
9
+ # interger Required
10
+ # Valor do pagamento em centavos
11
+ attr_accessor :cancel_amount
12
+
13
+ # Validações do Rails 3
14
+ include ActiveModel::Validations
15
+
16
+ validates :cancel_amount, length: { maximum: 10 }
17
+
18
+ def initialize campos={}
19
+ campos.each do |campo, valor|
20
+ if GetnetApi::PaymentCancel.public_instance_methods.include? "#{campo}=".to_sym
21
+ send "#{campo}=", valor
22
+ end
23
+ end
24
+ end
25
+
26
+ # Montar o Hash de dados do usuario no padrão utilizado pela Getnet
27
+ def to_request
28
+ pay_cancel = {
29
+ payment_id: self.payment_id,
30
+ cancel_amount: self.cancel_amount,
31
+ }
32
+ end
33
+
34
+ # a = GetnetApi::PaymentCancel.create cancelamento_pagamento
35
+ def self.create payment_cancel
36
+ hash = payment_cancel.to_request
37
+
38
+ response = self.build_request self.endpoint(hash[:payment_id]), "post", hash
39
+
40
+ return JSON.parse(response.read_body)
41
+ end
42
+
43
+ private
44
+ def self.endpoint payment_id
45
+ "payments/credit/#{payment_id}/cancel"
46
+ end
47
+ end
48
+ end
@@ -1,9 +1,9 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module GetnetApi
3
3
  module Version
4
- MAJOR = 0
5
- MINOR = 1
6
- PATCH = 1
4
+ MAJOR = 1
5
+ MINOR = 0
6
+ PATCH = 3
7
7
  STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
8
8
  end
9
9
  end
@@ -0,0 +1,65 @@
1
+ # frozen_string_literal: true
2
+
3
+ describe GetnetApi::Base do
4
+ describe '.build_request' do
5
+ it 'builds and executes request based on' do
6
+ VCR.use_cassette 'getnet_api/base/build_request' do
7
+ GetnetApi.ambiente = :sandbox
8
+ response = GetnetApi::Base.build_request 'some_endpoint', 'get'
9
+ expect(response).to be_a Net::HTTPNotFound
10
+ expected_uri = 'https://api-sandbox.getnet.com.br/v1/some_endpoint'
11
+ expect(WebMock).to have_requested(:get, expected_uri)
12
+ end
13
+ end
14
+ end
15
+
16
+ describe '.default_headers' do
17
+ let(:dummy_url) { 'someurl.com' }
18
+ let(:dummy_request) { Net::HTTP::Get.new(dummy_url) }
19
+ it 'creates headers for request' do
20
+ VCR.use_cassette 'getnet_api/base/valid_bearer' do
21
+ request = GetnetApi::Base.default_headers dummy_request
22
+ expected_auth = "Bearer #{GetnetApi::Base.valid_bearer}"
23
+ expect(request['authorization']).to eq expected_auth
24
+ expect(request['Content-Type']).to eq 'application/json'
25
+ expect(request['seller_id']).to eq GetnetApi.seller_id
26
+ end
27
+ end
28
+ end
29
+
30
+ describe '.valid_bearer' do
31
+ context 'when token is expired' do
32
+ it 'requests for new access token' do
33
+ VCR.use_cassette 'getnet_api/base/valid_bearer' do
34
+ GetnetApi.expires_in = nil
35
+ expect(GetnetApi::Base.valid_bearer).to be_present
36
+ expect(GetnetApi.expires_in).to be_present
37
+ expect(GetnetApi.expires_in > DateTime.current).to be true
38
+ end
39
+ end
40
+ end
41
+
42
+ context 'when token is not expired' do
43
+ it 'returnes current token' do
44
+ GetnetApi.access_token = 'some_token'
45
+ GetnetApi.expires_in = DateTime.current + 1.day
46
+ expect(GetnetApi::Base.valid_bearer).to be_present
47
+ expect(GetnetApi::Base.valid_bearer).to eq 'some_token'
48
+ end
49
+ end
50
+ end
51
+
52
+ describe '.get_token_de_bearer' do
53
+ context 'when token is expired' do
54
+ it 'creates requests for new access token' do
55
+ VCR.use_cassette 'getnet_api/base/valid_bearer' do
56
+ GetnetApi.expires_in = nil
57
+ GetnetApi::Base.get_token_de_bearer
58
+ expect(GetnetApi::Base.valid_bearer).to be_present
59
+ expect(GetnetApi.expires_in).to be_present
60
+ expect(GetnetApi.expires_in).to be > DateTime.current
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ describe GetnetApi::CardToken do
4
+ describe '.get' do
5
+ it 'performs the request and returns the number_token' do
6
+ VCR.use_cassette 'getnet_api/cardtoken/get' do
7
+ card_number = '5155901222280001' # see https://developers.getnet.com.br/api#section/Cartoes-para-Teste
8
+ response = GetnetApi::CardToken.get card_number
9
+ expected_uri = 'https://api-sandbox.getnet.com.br/v1/tokens/card'
10
+ expect(WebMock).to have_requested(:post, expected_uri)
11
+ expect(response).to have_key("number_token")
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ describe GetnetApi::Configure do
4
+ describe '#configure' do
5
+ before do
6
+ GetnetApi.configure do |config|
7
+ config.ambiente = :sandbox
8
+ config.seller_id = 'seller_id'
9
+ config.client_id = 'client_id'
10
+ config.client_secret = 'client_secret'
11
+ end
12
+ end
13
+
14
+ it 'sets attributes to GetnetApi' do
15
+ expect(GetnetApi.seller_id).to eq 'seller_id'
16
+ expect(GetnetApi.client_id).to eq 'client_id'
17
+ expect(GetnetApi.client_secret).to eq 'client_secret'
18
+ end
19
+ end
20
+
21
+ describe '#endpoint' do
22
+ it 'sets and returns endpoint based on ambiente' do
23
+ ambiente = GetnetApi.ambiente
24
+ expected_endpoint = GetnetApi::Configure::URL[ambiente]
25
+ expect(GetnetApi.endpoint).to eq expected_endpoint
26
+ end
27
+ end
28
+
29
+ describe '#set_endpoint' do
30
+ context 'when ambiente is producao' do
31
+ it 'returns endpoint for producao' do
32
+ GetnetApi.ambiente = :producao
33
+ expected_endpoint = GetnetApi::Configure::URL[:producao]
34
+ expect(GetnetApi.set_endpoint).to eq expected_endpoint
35
+ end
36
+ end
37
+
38
+ context 'when ambiente is homologacao' do
39
+ it 'returns endpoint for homologacao' do
40
+ GetnetApi.ambiente = :homologacao
41
+ expected_endpoint = GetnetApi::Configure::URL[:homologacao]
42
+ expect(GetnetApi.set_endpoint).to eq expected_endpoint
43
+ end
44
+ end
45
+
46
+ context 'when ambiente is sandbox' do
47
+ it 'returns endpoint for sandbox' do
48
+ GetnetApi.ambiente = :sandbox
49
+ expected_endpoint = GetnetApi::Configure::URL[:sandbox]
50
+ expect(GetnetApi.set_endpoint).to eq expected_endpoint
51
+ end
52
+ end
53
+ end
54
+
55
+ describe '#base_uri' do
56
+ it 'returnes uri based on endpoint and api version' do
57
+ expected_endpoint = "#{GetnetApi.endpoint}/#{GetnetApi.api_version}"
58
+ expect(GetnetApi.base_uri).to eq expected_endpoint
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,120 @@
1
+ require 'rubygems'
2
+ require 'getnet_api'
3
+ require 'pry'
4
+ require 'vcr'
5
+ require 'webmock/rspec'
6
+
7
+ # This file was generated by the `rspec --init` command. Conventionally, all
8
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
9
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
10
+ # this file to always be loaded, without a need to explicitly require it in any
11
+ # files.
12
+ #
13
+ # Given that it is always loaded, you are encouraged to keep this file as
14
+ # light-weight as possible. Requiring heavyweight dependencies from this file
15
+ # will add to the boot time of your test suite on EVERY test run, even for an
16
+ # individual file that may not need all of that loaded. Instead, consider making
17
+ # a separate helper file that requires the additional dependencies and performs
18
+ # the additional setup, and require it from the spec files that actually need
19
+ # it.
20
+ #
21
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
22
+
23
+ GetnetApi.configure do |config|
24
+ config.ambiente = :sandbox
25
+ config.seller_id = '67be6e90-00c1-410d-83f5-6d75621effc8'
26
+ config.client_id = '74438877-f00b-4502-8454-de3d7166dc2a'
27
+ config.client_secret = '4eac6920-1b57-4cd1-8799-d877173bfa37'
28
+ end
29
+
30
+ VCR.configure do |c|
31
+ c.cassette_library_dir = 'spec/vcr_cassettes'
32
+ c.hook_into :webmock
33
+ c.allow_http_connections_when_no_cassette = false
34
+ end
35
+
36
+ RSpec.configure do |config|
37
+ # rspec-expectations config goes here. You can use an alternate
38
+ # assertion/expectation library such as wrong or the stdlib/minitest
39
+ # assertions if you prefer.
40
+ config.expect_with :rspec do |expectations|
41
+ # This option will default to `true` in RSpec 4. It makes the `description`
42
+ # and `failure_message` of custom matchers include text for helper methods
43
+ # defined using `chain`, e.g.:
44
+ # be_bigger_than(2).and_smaller_than(4).description
45
+ # # => "be bigger than 2 and smaller than 4"
46
+ # ...rather than:
47
+ # # => "be bigger than 2"
48
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
49
+ end
50
+
51
+ # rspec-mocks config goes here. You can use an alternate test double
52
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
53
+ config.mock_with :rspec do |mocks|
54
+ # Prevents you from mocking or stubbing a method that does not exist on
55
+ # a real object. This is generally recommended, and will default to
56
+ # `true` in RSpec 4.
57
+ mocks.verify_partial_doubles = true
58
+ end
59
+
60
+ # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
61
+ # have no way to turn it off -- the option exists only for backwards
62
+ # compatibility in RSpec 3). It causes shared context metadata to be
63
+ # inherited by the metadata hash of host groups and examples, rather than
64
+ # triggering implicit auto-inclusion in groups with matching metadata.
65
+ config.shared_context_metadata_behavior = :apply_to_host_groups
66
+
67
+ # The settings below are suggested to provide a good initial experience
68
+ # with RSpec, but feel free to customize to your heart's content.
69
+ =begin
70
+ # This allows you to limit a spec run to individual examples or groups
71
+ # you care about by tagging them with `:focus` metadata. When nothing
72
+ # is tagged with `:focus`, all examples get run. RSpec also provides
73
+ # aliases for `it`, `describe`, and `context` that include `:focus`
74
+ # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
75
+ config.filter_run_when_matching :focus
76
+
77
+ # Allows RSpec to persist some state between runs in order to support
78
+ # the `--only-failures` and `--next-failure` CLI options. We recommend
79
+ # you configure your source control system to ignore this file.
80
+ config.example_status_persistence_file_path = "spec/examples.txt"
81
+
82
+ # Limits the available syntax to the non-monkey patched syntax that is
83
+ # recommended. For more details, see:
84
+ # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
85
+ # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
86
+ # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
87
+ config.disable_monkey_patching!
88
+
89
+ # This setting enables warnings. It's recommended, but in some cases may
90
+ # be too noisy due to issues in dependencies.
91
+ config.warnings = true
92
+
93
+ # Many RSpec users commonly either run the entire suite or an individual
94
+ # file, and it's useful to allow more verbose output when running an
95
+ # individual spec file.
96
+ if config.files_to_run.one?
97
+ # Use the documentation formatter for detailed output,
98
+ # unless a formatter has already been configured
99
+ # (e.g. via a command-line flag).
100
+ config.default_formatter = "doc"
101
+ end
102
+
103
+ # Print the 10 slowest examples and example groups at the
104
+ # end of the spec run, to help surface which specs are running
105
+ # particularly slow.
106
+ config.profile_examples = 10
107
+
108
+ # Run specs in random order to surface order dependencies. If you find an
109
+ # order dependency and want to debug it, you can fix the order by providing
110
+ # the seed, which is printed after each run.
111
+ # --seed 1234
112
+ config.order = :random
113
+
114
+ # Seed global randomization in this process using the `--seed` CLI option.
115
+ # Setting this allows you to use `--seed` to deterministically reproduce
116
+ # test failures related to randomization by passing the same `--seed` value
117
+ # as the one that triggered the failure.
118
+ Kernel.srand config.seed
119
+ =end
120
+ end
@@ -0,0 +1,113 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api-sandbox.getnet.com.br/auth/oauth/v2/token
6
+ body:
7
+ encoding: UTF-8
8
+ string: grant_type=client_credentials&scope=oob
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ Host:
17
+ - api-sandbox.getnet.com.br
18
+ Authorization:
19
+ - Basic NzQ0Mzg4NzctZjAwYi00NTAyLTg0NTQtZGUzZDcxNjZkYzJhOjRlYWM2OTIwLTFiNTctNGNkMS04Nzk5LWQ4NzcxNzNiZmEzNw==
20
+ Content-Type:
21
+ - application/x-www-form-urlencoded
22
+ response:
23
+ status:
24
+ code: 200
25
+ message: OK
26
+ headers:
27
+ Server:
28
+ - Apache-Coyote/1.1
29
+ Pragma:
30
+ - no-cache
31
+ Cache-Control:
32
+ - no-store
33
+ Strict-Transport-Security:
34
+ - max-age=15552000; includeSubDomains
35
+ Preload:
36
+ - ''
37
+ Content-Type:
38
+ - application/json;charset=UTF-8
39
+ X-Edgeconnect-Midmile-Rtt:
40
+ - '9'
41
+ X-Edgeconnect-Origin-Mex-Latency:
42
+ - '28'
43
+ X-Powered-By:
44
+ - '49660'
45
+ Vary:
46
+ - Accept-Encoding
47
+ Date:
48
+ - Tue, 06 Apr 2021 17:04:11 GMT
49
+ Content-Length:
50
+ - '127'
51
+ Connection:
52
+ - keep-alive
53
+ body:
54
+ encoding: UTF-8
55
+ string: "{\r\n \"access_token\":\"38e87c4a-4047-4791-9745-91313acf4a1a\",\r\n
56
+ \ \"token_type\":\"Bearer\",\r\n \"expires_in\":3600,\r\n \"scope\":\"oob\"\r\n}"
57
+ recorded_at: Tue, 06 Apr 2021 17:04:11 GMT
58
+ - request:
59
+ method: get
60
+ uri: https://api-sandbox.getnet.com.br/v1/some_endpoint
61
+ body:
62
+ encoding: UTF-8
63
+ string: 'null'
64
+ headers:
65
+ Accept-Encoding:
66
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
67
+ Accept:
68
+ - "*/*"
69
+ User-Agent:
70
+ - Ruby
71
+ Host:
72
+ - api-sandbox.getnet.com.br
73
+ Authorization:
74
+ - Bearer 38e87c4a-4047-4791-9745-91313acf4a1a
75
+ Content-Type:
76
+ - application/json
77
+ Seller-Id:
78
+ - 67be6e90-00c1-410d-83f5-6d75621effc8
79
+ response:
80
+ status:
81
+ code: 404
82
+ message: Not Found
83
+ headers:
84
+ Server:
85
+ - Apache-Coyote/1.1
86
+ Cache-Control:
87
+ - no-cache
88
+ Strict-Transport-Security:
89
+ - max-age=15552000; includeSubDomains
90
+ Preload:
91
+ - ''
92
+ Content-Type:
93
+ - application/json;charset=utf-8
94
+ X-Edgeconnect-Midmile-Rtt:
95
+ - '8'
96
+ X-Edgeconnect-Origin-Mex-Latency:
97
+ - '76'
98
+ X-Powered-By:
99
+ - '49661'
100
+ Vary:
101
+ - Accept-Encoding
102
+ Date:
103
+ - Tue, 06 Apr 2021 17:04:11 GMT
104
+ Content-Length:
105
+ - '196'
106
+ Connection:
107
+ - keep-alive
108
+ body:
109
+ encoding: UTF-8
110
+ string: '{"message":"Not Found","name":"GatewayClientError","status_code":404,"details":[{"status":"DENIED","error_code":"GENERIC-404","description":"Not
111
+ Found","description_detail":"Resource not found"}]}'
112
+ recorded_at: Tue, 06 Apr 2021 17:04:11 GMT
113
+ recorded_with: VCR 6.0.0
@@ -0,0 +1,58 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api-sandbox.getnet.com.br/auth/oauth/v2/token
6
+ body:
7
+ encoding: UTF-8
8
+ string: grant_type=client_credentials&scope=oob
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ Host:
17
+ - api-sandbox.getnet.com.br
18
+ Authorization:
19
+ - Basic NzQ0Mzg4NzctZjAwYi00NTAyLTg0NTQtZGUzZDcxNjZkYzJhOjRlYWM2OTIwLTFiNTctNGNkMS04Nzk5LWQ4NzcxNzNiZmEzNw==
20
+ Content-Type:
21
+ - application/x-www-form-urlencoded
22
+ response:
23
+ status:
24
+ code: 200
25
+ message: OK
26
+ headers:
27
+ Server:
28
+ - Apache-Coyote/1.1
29
+ Pragma:
30
+ - no-cache
31
+ Cache-Control:
32
+ - no-store
33
+ Strict-Transport-Security:
34
+ - max-age=15552000; includeSubDomains
35
+ Preload:
36
+ - ''
37
+ Content-Type:
38
+ - application/json;charset=UTF-8
39
+ X-Edgeconnect-Midmile-Rtt:
40
+ - '8'
41
+ X-Edgeconnect-Origin-Mex-Latency:
42
+ - '29'
43
+ X-Powered-By:
44
+ - '63123'
45
+ Vary:
46
+ - Accept-Encoding
47
+ Date:
48
+ - Tue, 06 Apr 2021 16:45:43 GMT
49
+ Content-Length:
50
+ - '127'
51
+ Connection:
52
+ - keep-alive
53
+ body:
54
+ encoding: UTF-8
55
+ string: "{\r\n \"access_token\":\"3e28e48b-478f-4b98-b2ca-c2e82e4d5d14\",\r\n
56
+ \ \"token_type\":\"Bearer\",\r\n \"expires_in\":3600,\r\n \"scope\":\"oob\"\r\n}"
57
+ recorded_at: Tue, 06 Apr 2021 16:45:43 GMT
58
+ recorded_with: VCR 6.0.0
@@ -0,0 +1,110 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api-sandbox.getnet.com.br/auth/oauth/v2/token
6
+ body:
7
+ encoding: UTF-8
8
+ string: grant_type=client_credentials&scope=oob
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ Host:
17
+ - api-sandbox.getnet.com.br
18
+ Authorization:
19
+ - Basic NzQ0Mzg4NzctZjAwYi00NTAyLTg0NTQtZGUzZDcxNjZkYzJhOjRlYWM2OTIwLTFiNTctNGNkMS04Nzk5LWQ4NzcxNzNiZmEzNw==
20
+ Content-Type:
21
+ - application/x-www-form-urlencoded
22
+ response:
23
+ status:
24
+ code: 200
25
+ message: OK
26
+ headers:
27
+ Server:
28
+ - Apache-Coyote/1.1
29
+ Pragma:
30
+ - no-cache
31
+ Cache-Control:
32
+ - no-store
33
+ Strict-Transport-Security:
34
+ - max-age=15552000; includeSubDomains
35
+ Preload:
36
+ - ''
37
+ Content-Type:
38
+ - application/json;charset=UTF-8
39
+ X-Edgeconnect-Midmile-Rtt:
40
+ - '1'
41
+ X-Edgeconnect-Origin-Mex-Latency:
42
+ - '36'
43
+ X-Powered-By:
44
+ - '11711'
45
+ Vary:
46
+ - Accept-Encoding
47
+ Date:
48
+ - Fri, 09 Apr 2021 06:39:57 GMT
49
+ Content-Length:
50
+ - '127'
51
+ Connection:
52
+ - keep-alive
53
+ body:
54
+ encoding: UTF-8
55
+ string: "{\r\n \"access_token\":\"3f322bbc-b2b6-45aa-9faa-5f8e3b9a73a5\",\r\n
56
+ \ \"token_type\":\"Bearer\",\r\n \"expires_in\":3600,\r\n \"scope\":\"oob\"\r\n}"
57
+ recorded_at: Fri, 09 Apr 2021 06:39:57 GMT
58
+ - request:
59
+ method: post
60
+ uri: https://api-sandbox.getnet.com.br/v1/tokens/card
61
+ body:
62
+ encoding: UTF-8
63
+ string: '{"card_number":"5155901222280001"}'
64
+ headers:
65
+ Accept-Encoding:
66
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
67
+ Accept:
68
+ - "*/*"
69
+ User-Agent:
70
+ - Ruby
71
+ Host:
72
+ - api-sandbox.getnet.com.br
73
+ Authorization:
74
+ - Bearer 3f322bbc-b2b6-45aa-9faa-5f8e3b9a73a5
75
+ Content-Type:
76
+ - application/json
77
+ Seller-Id:
78
+ - 67be6e90-00c1-410d-83f5-6d75621effc8
79
+ response:
80
+ status:
81
+ code: 201
82
+ message: Created
83
+ headers:
84
+ Server:
85
+ - Apache-Coyote/1.1
86
+ Cache-Control:
87
+ - no-cache
88
+ Strict-Transport-Security:
89
+ - max-age=15552000; includeSubDomains
90
+ Preload:
91
+ - ''
92
+ Content-Type:
93
+ - application/json;charset=utf-8
94
+ Content-Length:
95
+ - '132'
96
+ X-Edgeconnect-Midmile-Rtt:
97
+ - '1'
98
+ X-Edgeconnect-Origin-Mex-Latency:
99
+ - '43'
100
+ X-Powered-By:
101
+ - '11712'
102
+ Date:
103
+ - Fri, 09 Apr 2021 06:39:57 GMT
104
+ Connection:
105
+ - keep-alive
106
+ body:
107
+ encoding: ASCII-8BIT
108
+ string: '{"number_token":"bad203f8101ee124f0fadde3c5200ab130a3ae577d3ecd687e3a8743767bf3ca36fe9b4a1f0698520de1172acda4d5aa8407f4f22035e6dc197a083a88459f9e"}'
109
+ recorded_at: Fri, 09 Apr 2021 06:39:57 GMT
110
+ recorded_with: VCR 6.0.0
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: getnet_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - QW3 Software & Marketing
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-28 00:00:00.000000000 Z
11
+ date: 2021-04-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 1.7.3
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: 1.7.3
27
27
  description: Gem para utilização dos meios de pagamento Getnet - Uma empresa Santander
28
28
  para integrar sua plataforma de forma segura e eficaz com as principais formas de
29
29
  pagamento disponíveis no mercado.
@@ -33,7 +33,9 @@ executables: []
33
33
  extensions: []
34
34
  extra_rdoc_files: []
35
35
  files:
36
+ - ".github/workflows/ruby.yml"
36
37
  - ".gitignore"
38
+ - ".rspec"
37
39
  - Gemfile
38
40
  - Gemfile.lock
39
41
  - LICENSE
@@ -52,7 +54,15 @@ files:
52
54
  - lib/getnet_api/customer.rb
53
55
  - lib/getnet_api/order.rb
54
56
  - lib/getnet_api/payment.rb
57
+ - lib/getnet_api/payment_cancel.rb
55
58
  - lib/getnet_api/version.rb
59
+ - spec/lib/getnet_api/base_spec.rb
60
+ - spec/lib/getnet_api/card_token_spec.rb
61
+ - spec/lib/getnet_api/configure_spec.rb
62
+ - spec/spec_helper.rb
63
+ - spec/vcr_cassettes/getnet_api/base/build_request.yml
64
+ - spec/vcr_cassettes/getnet_api/base/valid_bearer.yml
65
+ - spec/vcr_cassettes/getnet_api/cardtoken/get.yml
56
66
  homepage: https://github.com/qw3/getnet_api
57
67
  licenses:
58
68
  - MIT
@@ -72,9 +82,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
72
82
  - !ruby/object:Gem::Version
73
83
  version: '0'
74
84
  requirements: []
75
- rubyforge_project:
76
- rubygems_version: 2.4.8
85
+ rubygems_version: 3.0.8
77
86
  signing_key:
78
87
  specification_version: 4
79
88
  summary: Getnet API - Meios de Pagamento
80
- test_files: []
89
+ test_files:
90
+ - spec/lib/getnet_api/base_spec.rb
91
+ - spec/lib/getnet_api/card_token_spec.rb
92
+ - spec/lib/getnet_api/configure_spec.rb
93
+ - spec/spec_helper.rb
94
+ - spec/vcr_cassettes/getnet_api/base/build_request.yml
95
+ - spec/vcr_cassettes/getnet_api/base/valid_bearer.yml
96
+ - spec/vcr_cassettes/getnet_api/cardtoken/get.yml