inter_api 1.2.0 → 1.2.1
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_production.rb +3 -2
- data/lib/inter_api/payment.rb +10 -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: d016f71b392598ab87338408e6a36f7d0ff7ab041da3098a711fda117750f47c
|
4
|
+
data.tar.gz: 348c6582451bfcd451b3034fcf5021b4560b1c1432d8f859bcfe200716fe0b14
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18d4435b099ef5b725e16a6e3640a64cde2c4a0c26530c759d5ff96b8465bf52fbc843f419ee9ed7b1e6190c0a766331859e9c73551ec006c01f2bd2afa1640b
|
7
|
+
data.tar.gz: 52d3d394e215ba90ccaaafbfc7785e4cc340b5e143d3952f5568b3dcc46066209a7d812366b27c10decbee01d0e3d993a2c6f6c8606af606b9c99f7160ce09f6
|
@@ -61,12 +61,11 @@ module InterApi
|
|
61
61
|
post_request("/pix/v2/cob", headers: build_headers, sslcert: @crt, sslkey: @key, body: JSON.dump(body))
|
62
62
|
end
|
63
63
|
|
64
|
-
def create_payment(amount:, payer_tax_id
|
64
|
+
def create_payment(amount:, payer_tax_id: nil, payer_name: nil, expiration: 3600, solicitacao_pagador: nil, info_adicionais: [])
|
65
65
|
body = {
|
66
66
|
calendario: {
|
67
67
|
expiracao: expiration
|
68
68
|
},
|
69
|
-
devedor: build_devedor(payer_tax_id, payer_name),
|
70
69
|
valor: {
|
71
70
|
original: format("%.2f", amount),
|
72
71
|
modalidadeAlteracao: 0
|
@@ -75,6 +74,8 @@ module InterApi
|
|
75
74
|
solicitacaoPagador: solicitacao_pagador,
|
76
75
|
infoAdicionais: info_adicionais
|
77
76
|
}
|
77
|
+
body[:devedor] = build_devedor(payer_tax_id, payer_name) if payer_tax_id && payer_name
|
78
|
+
|
78
79
|
response = post("/pix/v2/cob", headers: build_headers, sslcert: @crt, sslkey: @key, body: JSON.dump(body)) { |response| validate_response(response, "txid") }
|
79
80
|
InterApi::Payment.new(response.json, self)
|
80
81
|
end
|
data/lib/inter_api/payment.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module InterApi
|
2
2
|
class Payment
|
3
|
-
attr_reader :response, :txid, :end_to_end_id, :devolucoes, :copia_e_cola, :status, :solicitacao, :info_adicionais, :valor_original, :valor_pago, :criacao, :expiracao, :devedor_nome, :devedor_tax_id, :internal_error
|
3
|
+
attr_reader :response, :txid, :end_to_end_id, :devolucoes, :copia_e_cola, :status, :solicitacao, :info_adicionais, :valor_original, :valor_pago, :criacao, :expiracao, :pago_em, :devedor_nome, :devedor_tax_id, :internal_error
|
4
4
|
def initialize(response, client)
|
5
5
|
@client = client
|
6
6
|
@response = response
|
@@ -15,13 +15,15 @@ module InterApi
|
|
15
15
|
@valor_pago = response.dig("pix", 0, "valor")
|
16
16
|
@criacao = creation_date
|
17
17
|
@expiracao = expiration_date
|
18
|
+
@pago_em = paid_date
|
18
19
|
@devedor_nome = response.dig("devedor", "nome")
|
19
20
|
@devedor_tax_id = response.dig("devedor", "cpf") || response.dig("devedor", "cnpj")
|
20
21
|
@internal_error = PaymentError.new(response).internal_error
|
21
22
|
end
|
22
23
|
|
23
|
-
def paid?
|
24
|
-
|
24
|
+
def paid? external_value = nil
|
25
|
+
external_value = @valor_original if external_value.nil?
|
26
|
+
@status == "CONCLUIDA" && @valor_original.to_d == @valor_pago.to_d && external_value.to_d == @valor_pago.to_d
|
25
27
|
end
|
26
28
|
|
27
29
|
def valid?
|
@@ -68,5 +70,10 @@ module InterApi
|
|
68
70
|
return nil unless @response.dig("calendario", "criacao")
|
69
71
|
Time.new(@response.dig("calendario", "criacao")) + @response.dig("calendario", "expiracao")
|
70
72
|
end
|
73
|
+
|
74
|
+
def paid_date
|
75
|
+
return nil unless @response.dig("pix", 0, "horario")
|
76
|
+
Time.new(@response.dig("pix", 0, "horario"))
|
77
|
+
end
|
71
78
|
end
|
72
79
|
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: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Todas Essas Coisas
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-10-
|
11
|
+
date: 2024-10-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ac
|