inter_api 0.1.7 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/inter_api/client.rb +21 -2
- data/lib/inter_api/version.rb +1 -1
- data/lib/inter_api.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: db16129e231c0aa017089bb5a701e95dcf06a407402efa0ca12bc2d3ec0110f0
|
4
|
+
data.tar.gz: aca55c9bd8fd7e37a1e13e85c81c5d81929eaeb3412bce2a663aceba1a3b269a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 913351127cd258e3fa8d6708af0e5e24e8fa11b49a22277dd8abe76d48581b3f2518cefb148cb1cc3858527174a7c96a44392453fb28aa644868c1c66ed404b1
|
7
|
+
data.tar.gz: c8bf3ef2db3a681db0502608bcf8535e3a88d093a74d13af76a680a7f76c83fd0a273428db1b7618939500b9a652c59358be42687bbe651964629a4c3fae4c83
|
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
|
|
@@ -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
data/lib/inter_api.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.9
|
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
|