solidus_inter 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7e4f2ec4ad7b0a257eaeb36a071d1536ea55230179d9ed90fbaf91909f1c3fd0
4
- data.tar.gz: b7f4db3f4c160512bf5666a5b303aa67217ebe1d1a821748954d6602c9338bc5
3
+ metadata.gz: 65574da9c18ba2b6a8614c875587a9b088c033b0aabfb5ff66781db662dfd5d5
4
+ data.tar.gz: f6781e3a2b08c876cca2b213f9d3911ec64573222356e2b9ba9ab59c36fa6f27
5
5
  SHA512:
6
- metadata.gz: 429e23c494782d30cd07def008f905c628e80ec646d1d5ac0ffbebcc6a5c49dd1813974020f83607c3286e5870073cd5a97f9f6f0d4435bde03552843f0ff35f
7
- data.tar.gz: 1775c4ccd206338334dbb9b6403406c4954f7781d1410ca91e479ab9ab12f58e8220ac4257c99d24c37c607fa28582da9d9f00d2b08da36f02a05b27d6493bde
6
+ metadata.gz: d8335b7d7dee01e2616b261f919c1fdb621ff9c025adc39fb6e7f22d1b71e7272060a44689fc9a0b3bacc7ba6797c65c41da562a703655c89edd0753f46b1a17
7
+ data.tar.gz: 896f661ccde79b9153572302a552328ef32fdceee38a6b902bedb822fc3b8da58534fb1ea3c1388460a37ac98c7d606a69481af3bb15d64c5e4d8d799795550d
@@ -0,0 +1,5 @@
1
+ module SolidusInter
2
+ class Account < ApplicationRecord
3
+ belongs_to :spree_payment_method, class_name: "Spree::PaymentMethod"
4
+ end
5
+ end
@@ -82,14 +82,19 @@ module SolidusInter
82
82
  private
83
83
 
84
84
  def set_api_client
85
- ::InterApi::Client.new(
85
+ account = SolidusInter::Account.find_by(chave_pix: preferences[:chave_pix])
86
+ client = ::InterApi::Client.new(
86
87
  client_id: preferences[:client_id],
87
88
  client_secret: preferences[:client_secret],
88
89
  chave_pix: preferences[:chave_pix],
89
90
  conta_corrente: preferences[:conta_corrente],
90
91
  crt: temp_file(preferences[:crt]).path,
91
- key: temp_file(preferences[:key]).path
92
+ key: temp_file(preferences[:key]).path,
93
+ token: account&.token,
94
+ token_expires_at: account&.expires_at
92
95
  )
96
+ 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)
97
+ client
93
98
  end
94
99
 
95
100
  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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SolidusInter
4
- VERSION = "1.0.0"
4
+ VERSION = "1.1.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solidus_inter
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ulysses
@@ -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