bs2_api 1.0.3 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/Gemfile.lock +3 -3
- data/README.md +23 -3
- data/lib/bs2_api/entities/bank.rb +1 -0
- data/lib/bs2_api/entities/payment.rb +9 -9
- data/lib/bs2_api/payment/detail.rb +27 -0
- data/lib/bs2_api/util/bank_service.rb +1 -1
- data/lib/bs2_api/version.rb +1 -1
- data/lib/bs2_api.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 68ed1e77534b0eaefc776507d8251749815a45e958ab03860bb3680f587d966b
|
4
|
+
data.tar.gz: 462fc6a165a14fd8d8c1065d7bae3dab8795b5bf0bb67e368766b1c694960766
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a73e88ab91779a2e9f771001eb17b08e6c4e5056cbe50d4308251e27f6368ed713b571651f32fc0844d9e225fd9e8247c41a0edd6b2a88a113bcb36affcaaa1
|
7
|
+
data.tar.gz: '04098a0800c1bf9324ef44494a2c2800def7fd71b14fda526c89996cd5b9016166725112d18428fd204ea18adb386bc491fac8bfb0b6573c7df95a589ac8c2dc'
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
bs2_api (1.0.
|
4
|
+
bs2_api (1.0.3)
|
5
5
|
activesupport
|
6
6
|
builder
|
7
7
|
bundler
|
@@ -11,7 +11,7 @@ PATH
|
|
11
11
|
GEM
|
12
12
|
remote: https://rubygems.org/
|
13
13
|
specs:
|
14
|
-
activesupport (6.1.4)
|
14
|
+
activesupport (6.1.4.1)
|
15
15
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
16
16
|
i18n (>= 1.6, < 2)
|
17
17
|
minitest (>= 5.1)
|
@@ -48,7 +48,7 @@ GEM
|
|
48
48
|
byebug (~> 11.0)
|
49
49
|
pry (~> 0.13.0)
|
50
50
|
public_suffix (4.0.6)
|
51
|
-
rake (13.0.
|
51
|
+
rake (13.0.6)
|
52
52
|
rexml (3.2.5)
|
53
53
|
rspec (3.10.0)
|
54
54
|
rspec-core (~> 3.10.0)
|
data/README.md
CHANGED
@@ -12,7 +12,7 @@ TO-DO:
|
|
12
12
|
- [x] Criar pagamento por Chave
|
13
13
|
- [x] Criar pagamento Manual
|
14
14
|
- [x] Confirmar pagamento
|
15
|
-
- [
|
15
|
+
- [x] Consultar pagamento
|
16
16
|
- Recebimentos (**Recebe** dinheiro de alguém)
|
17
17
|
- [ ] Cobrança estático
|
18
18
|
- [ ] Cobrança dinâmico
|
@@ -66,12 +66,14 @@ pix_key = Bs2Api::Entities::PixKey.new(
|
|
66
66
|
# Veja abaixo (Classes de errors) quais erros que podem ser lançados
|
67
67
|
pay_key = Bs2Api::Payment::Key.new(pix_key).call
|
68
68
|
|
69
|
-
pay_key.payment.
|
69
|
+
pay_key.payment.payment_id
|
70
70
|
=> "96f0b3c4-4c76-4a7a-9933-9c9f86df7490" # pagamentoId gerado no BS2
|
71
71
|
|
72
72
|
pay_key.payment.end_to_end_id
|
73
73
|
=> "E710278662021061618144401750781P" # endToEndId gerado no BS2
|
74
74
|
|
75
|
+
pay_key.payment.class
|
76
|
+
=> Bs2Api::Entities::Payment
|
75
77
|
```
|
76
78
|
|
77
79
|
### Inicia ordem de Transferência PIX via: Manual
|
@@ -99,10 +101,13 @@ receiver_bank = Bs2Api::Entities::Bank.new(
|
|
99
101
|
pay_manual = Bs2Api::Payment::Manual.new(receiver_bank).call
|
100
102
|
|
101
103
|
pay_manual.payment.payment_id
|
102
|
-
=> "96f0b3c4-4c76-4a7a-9933-9c9f86df7490" #
|
104
|
+
=> "96f0b3c4-4c76-4a7a-9933-9c9f86df7490" # Payment id no BS2
|
103
105
|
|
104
106
|
pay_manual.payment.end_to_end_id
|
105
107
|
=> "E710278662021061618144401750781P" # endToEndId gerado no BS2
|
108
|
+
|
109
|
+
pay_manual.payment.class
|
110
|
+
=> Bs2Api::Entities::Payment
|
106
111
|
```
|
107
112
|
|
108
113
|
### Confirmar ordem de transferência
|
@@ -127,6 +132,21 @@ raise Bs2Api::Errors::ConfirmationError
|
|
127
132
|
confirmation.success?
|
128
133
|
```
|
129
134
|
|
135
|
+
### Busca informações do pagamento
|
136
|
+
```ruby
|
137
|
+
payment_id = "96f0b3c4-4c76-4a7a-9933-9c9f86df7490"
|
138
|
+
|
139
|
+
payment = Bs2Api::Payment::Detail.new(payment_id).call # Payment id no BS2
|
140
|
+
payment.id
|
141
|
+
=> "96f0b3c4-4c76-4a7a-9933-9c9f86df7490"
|
142
|
+
|
143
|
+
payment.end_to_end_id
|
144
|
+
=> "E710278662021061618144401750781P" # endToEndId gerado no BS2
|
145
|
+
|
146
|
+
payment.class
|
147
|
+
=> Bs2Api::Entities::Payment
|
148
|
+
```
|
149
|
+
|
130
150
|
### Classes de erros:
|
131
151
|
```ruby
|
132
152
|
# Todos erros herdam de:
|
@@ -13,21 +13,21 @@ module Bs2Api
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def to_hash
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
)
|
16
|
+
hash_data = {
|
17
|
+
"pagamentoId": @payment_id,
|
18
|
+
"endToEndId": @end_to_end_id
|
19
|
+
}
|
20
|
+
|
21
|
+
hash_data.merge!({ "recebedor": @receiver.to_hash } ) if @receiver.present?
|
22
|
+
hash_data.merge!({ "pagador": @payer.to_hash } ) if @payer.present?
|
23
|
+
ActiveSupport::HashWithIndifferentAccess.new(hash_data)
|
24
24
|
end
|
25
25
|
|
26
26
|
def self.from_response(hash_payload)
|
27
27
|
hash = ActiveSupport::HashWithIndifferentAccess.new(hash_payload)
|
28
28
|
|
29
29
|
Bs2Api::Entities::Payment.new(
|
30
|
-
payment_id: hash["pagamentoId"],
|
30
|
+
payment_id: hash["pagamentoId"] || hash["cobranca"]["id"],
|
31
31
|
end_to_end_id: hash["endToEndId"],
|
32
32
|
receiver: Bs2Api::Entities::Bank.from_response(hash["recebedor"]),
|
33
33
|
payer: Bs2Api::Entities::Bank.from_response(hash["pagador"])
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Bs2Api
|
2
|
+
module Payment
|
3
|
+
class Detail < Base
|
4
|
+
attr_reader :success
|
5
|
+
|
6
|
+
def initialize payment_id
|
7
|
+
@payment_id = payment_id
|
8
|
+
end
|
9
|
+
|
10
|
+
def call
|
11
|
+
response = detail_request
|
12
|
+
raise Bs2Api::Errors::BadRequest, ::Util::Response.parse_error(response) unless response.ok?
|
13
|
+
|
14
|
+
Bs2Api::Entities::Payment.from_response(response)
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
def url
|
19
|
+
"#{Bs2Api.endpoint}/pix/direto/forintegration/v1/pagamentos/#{@payment_id}"
|
20
|
+
end
|
21
|
+
|
22
|
+
def detail_request
|
23
|
+
HTTParty.get(url, headers: headers)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -8,7 +8,7 @@ module Bs2Api
|
|
8
8
|
class << self
|
9
9
|
def find_by_code code
|
10
10
|
bank = bank_list.find {|b| b["code"] == code }
|
11
|
-
raise Bs2Api::Errors::MissingBank,
|
11
|
+
raise Bs2Api::Errors::MissingBank, "Bank with code #{code} not registered into util/banks.yml file" if bank.blank?
|
12
12
|
bank
|
13
13
|
end
|
14
14
|
|
data/lib/bs2_api/version.rb
CHANGED
data/lib/bs2_api.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bs2_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kim Pastro
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-09-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: builder
|
@@ -217,6 +217,7 @@ files:
|
|
217
217
|
- lib/bs2_api/errors/unauthorized.rb
|
218
218
|
- lib/bs2_api/payment/base.rb
|
219
219
|
- lib/bs2_api/payment/confirmation.rb
|
220
|
+
- lib/bs2_api/payment/detail.rb
|
220
221
|
- lib/bs2_api/payment/key.rb
|
221
222
|
- lib/bs2_api/payment/manual.rb
|
222
223
|
- lib/bs2_api/request/auth.rb
|