inter_api 0.1.5 → 0.1.8
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 +4 -4
- data/lib/inter_api/client.rb +22 -3
- data/lib/inter_api/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 50e5c72c21a5a02a2c320b1abd0455a7406f9d713203f30286ecb009c32cdfbc
|
4
|
+
data.tar.gz: 5f1fa2b57a8f354da8071275abf502aa817cad3d868058a0a771f5c469be80e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1bc26a87ed361e9c4643d6897907a3e9f4e5aef1946060f8a8fd6ba0dffb0445a42ba7cba5c58a9ab90294a45b827444ca348d74775b5f8fc3e6aaa73988b715
|
7
|
+
data.tar.gz: e2d6dbb63754bad7ad47cf719b95ef75c5c4af1fb99f5221303eb5b19ec207612383525e8f46025d9372180679ec077daa4027503b9fbaacbd2f8c1f5c95a98b
|
data/lib/inter_api/client.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
module InterApi
|
2
2
|
class Client < Ac::Base
|
3
3
|
BASE_URL = "https://cdpj.partners.bancointer.com.br/"
|
4
|
+
MAX_RETIES = 2
|
4
5
|
|
5
6
|
attr_reader :crt, :key, :client_id, :client_secret, :chave_pix, :conta_corrente, :scopes
|
6
7
|
attr_accessor :token, :token_expires_at
|
@@ -39,7 +40,7 @@ module InterApi
|
|
39
40
|
end
|
40
41
|
|
41
42
|
def get_payment(payment_id)
|
42
|
-
response =
|
43
|
+
response = get("/pix/v2/cob/#{payment_id}", headers: build_headers, sslcert: @crt, sslkey: @key) { |response| validate_response(response, "txid") }
|
43
44
|
InterApi::Payment.new(response.json, self)
|
44
45
|
end
|
45
46
|
|
@@ -61,7 +62,20 @@ module InterApi
|
|
61
62
|
end
|
62
63
|
|
63
64
|
def create_payment(amount:, payer_tax_id:, payer_name:, expiration: 3600, solicitacao_pagador: nil, info_adicionais: [])
|
64
|
-
|
65
|
+
body = {
|
66
|
+
calendario: {
|
67
|
+
expiracao: expiration
|
68
|
+
},
|
69
|
+
devedor: build_devedor(payer_tax_id, payer_name),
|
70
|
+
valor: {
|
71
|
+
original: format("%.2f", amount),
|
72
|
+
modalidadeAlteracao: 0
|
73
|
+
},
|
74
|
+
chave: @chave_pix,
|
75
|
+
solicitacaoPagador: solicitacao_pagador,
|
76
|
+
infoAdicionais: info_adicionais
|
77
|
+
}
|
78
|
+
response = post("/pix/v2/cob", headers: build_headers, sslcert: @crt, sslkey: @key, body: JSON.dump(body)) { |response| validate_response(response, "txid") }
|
65
79
|
InterApi::Payment.new(response.json, self)
|
66
80
|
end
|
67
81
|
|
@@ -70,7 +84,7 @@ module InterApi
|
|
70
84
|
end
|
71
85
|
|
72
86
|
def update_payment(payment_id, body)
|
73
|
-
response = update_payment_request(payment_id,
|
87
|
+
response = update_payment_request(payment_id, body).run
|
74
88
|
InterApi::Payment.new(response.json, self)
|
75
89
|
end
|
76
90
|
|
@@ -108,5 +122,10 @@ module InterApi
|
|
108
122
|
"Content-Type" => "application/json"
|
109
123
|
}
|
110
124
|
end
|
125
|
+
|
126
|
+
def validate_response(response, required_response_key)
|
127
|
+
puts response.json unless response.success?
|
128
|
+
![500, 429].include?(response.code) || response.json.dig(*required_response_key)
|
129
|
+
end
|
111
130
|
end
|
112
131
|
end
|
data/lib/inter_api/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inter_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ulysses
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-05-
|
11
|
+
date: 2024-05-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ac
|