solidus_inter 1.0.0 → 1.1.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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9f8527b4fe113c48cde458b6dd290795d126c040c52f1f4f591010017b2e1f10
|
4
|
+
data.tar.gz: 95d4f66b4f3df7d7bda6198c300c31d2afd928cc6ccb1f71e06c8aed5fc611cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 83b9e1a62a7b57e7b4dd1e81bda915d0dfd816c18e7aea34a7a777830bf009f7f7609b948635aef92c4534309f010669b8554b9c1b6137e00149ac2e4f85beca
|
7
|
+
data.tar.gz: 9f51b1ad2e8014ec45168b7700655c8177849688183a590ef3351bf00c27f40b66a14f3afe52b1c9cac03f63554e0c3bbff8bef00602c6ff47481ab85b178628
|
@@ -54,10 +54,12 @@ module SolidusInter
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def invalidate_payment(payment)
|
57
|
-
return unless payment && payment.source.txid
|
57
|
+
return false unless payment && payment.source.txid
|
58
58
|
inter_payment = find_payment(payment.source.txid)
|
59
|
+
return false if inter_payment.paid?
|
59
60
|
inter_payment.invalidate!
|
60
61
|
payment.log_entries.create!(parsed_payment_response_details_with_fallback: failure_response("Pagamento cancelado"))
|
62
|
+
true
|
61
63
|
end
|
62
64
|
|
63
65
|
def purchase(money, source, options = {})
|
@@ -82,14 +84,19 @@ module SolidusInter
|
|
82
84
|
private
|
83
85
|
|
84
86
|
def set_api_client
|
85
|
-
::
|
87
|
+
account = SolidusInter::Account.find_by(chave_pix: preferences[:chave_pix])
|
88
|
+
client = ::InterApi::Client.new(
|
86
89
|
client_id: preferences[:client_id],
|
87
90
|
client_secret: preferences[:client_secret],
|
88
91
|
chave_pix: preferences[:chave_pix],
|
89
92
|
conta_corrente: preferences[:conta_corrente],
|
90
93
|
crt: temp_file(preferences[:crt]).path,
|
91
|
-
key: temp_file(preferences[:key]).path
|
94
|
+
key: temp_file(preferences[:key]).path,
|
95
|
+
token: account&.token,
|
96
|
+
token_expires_at: account&.expires_at
|
92
97
|
)
|
98
|
+
SolidusInter::Account.upsert({token: client.token, expires_at: client.token_expires_at, chave_pix: client.chave_pix, spree_payment_method_id: id}, unique_by: :chave_pix)
|
99
|
+
client
|
93
100
|
end
|
94
101
|
|
95
102
|
def temp_file content
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class CreateSolidusInterAccounts < ActiveRecord::Migration[7.0]
|
2
|
+
def change
|
3
|
+
create_table :solidus_inter_accounts do |t|
|
4
|
+
t.string :chave_pix, index: { unique: true }
|
5
|
+
t.string :token
|
6
|
+
t.datetime :expires_at
|
7
|
+
t.integer :spree_payment_method_id
|
8
|
+
|
9
|
+
t.timestamps
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solidus_inter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ulysses
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-06-
|
11
|
+
date: 2024-06-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: solidus_core
|
@@ -104,6 +104,7 @@ files:
|
|
104
104
|
- LICENSE
|
105
105
|
- README.md
|
106
106
|
- Rakefile
|
107
|
+
- app/models/solidus_inter/account.rb
|
107
108
|
- app/models/solidus_inter/inter_pix.rb
|
108
109
|
- app/models/solidus_inter/pix_payment_source.rb
|
109
110
|
- app/views/spree/admin/payments/source_forms/_inter_pix.html.erb
|
@@ -119,6 +120,7 @@ files:
|
|
119
120
|
- config/locales/en.yml
|
120
121
|
- config/routes.rb
|
121
122
|
- db/migrate/20240527193953_create_solidus_inter_pix_payment_sources.rb
|
123
|
+
- db/migrate/20240603132203_create_solidus_inter_accounts.rb
|
122
124
|
- lib/generators/solidus_inter/install/install_generator.rb
|
123
125
|
- lib/generators/solidus_inter/install/templates/initializer.rb
|
124
126
|
- lib/solidus_inter.rb
|