solidus_mp 0.1.3 → 0.2.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: c9cbe0419d92bfc532167ac7b8ace121e29371b1519f47b751e7273992de13bc
4
- data.tar.gz: b93c4a4124fb859dad4fa1e157ad75a2141b916ff8ef247774f71b12fb454c65
3
+ metadata.gz: 168201dbab03e9a372dfb2a51a5fefc305db0d3d669d0c86208af3f37468e5e8
4
+ data.tar.gz: f302be1de34ea914727302b4ccc27848ca2e7ce1f0b2dfe74e3b013b9ab8545b
5
5
  SHA512:
6
- metadata.gz: 0643ef776ae30d0e5db1f7dbee36bc5a2a49461f03be67ad8c5fc60233ebb0b81d02299cd0256ffb2ce6a9104b0b0a3247a674b837f2f1f05931f0b25fd670ae
7
- data.tar.gz: c6e903af6d4e1a1f4cb7129b424007ef7b8829d305b832793c7f78d6a301afa9848ce885a38af2c17a07816aeb2250713ac1af2fa4c7357e58eae93f6ea2c9cf
6
+ metadata.gz: 9ef4c615e9107b1aef599b78539d642c43b804df6f1325f06b9ea68202dd74735a76e070d6123eb7ed545b379bf93e91e35daef3d1b84a4f974088077405323a
7
+ data.tar.gz: 6ef19052988bc88d401d5a0b6602aa69a4972d74931f017f6f99d5c745fbb406bd390162ff11fda247ce5ccf1ddb3f2abb05d1c8d4382a4ab2be5fd2d507df17
data/README.md CHANGED
@@ -10,13 +10,13 @@
10
10
  Add solidus_bling to your Gemfile:
11
11
 
12
12
  ```ruby
13
- gem 'solidus_bling'
13
+ gem 'solidus_mp'
14
14
  ```
15
15
 
16
16
  Bundle your dependencies and run the installation generator:
17
17
 
18
18
  ```shell
19
- bin/rails generate solidus_bling:install
19
+ bin/rails generate solidus_mp:install
20
20
  ```
21
21
 
22
22
  ```shell
@@ -20,8 +20,13 @@ module SolidusMp
20
20
  def create_api_payment payment
21
21
  begin
22
22
  MpApi.configuration.access_token = preferences[:access_token]
23
- mp_payment = MpApi::Payment.new(amount: payment.amount.to_f, payment_method: payment.source.credit_card_brand, payer_email: payment.source.email, payer_identification_type: payment.source.payer_identification_type, payer_identification_number: payment.source.tax_id, token: payment.source.token, issuer_id: payment.source.issuer_id, installments: payment.source.installments, three_d_secure_mode: true).create
23
+ mp_payment = MpApi::Payment.new(amount: payment.amount.to_f, payment_method: payment.source.credit_card_brand, payer_email: payment.source.email, payer_identification_type: payment.source.payer_identification_type, payer_identification_number: payment.source.tax_id, token: payment.source.token, issuer_id: payment.source.issuer_id, installments: payment.source.installments, three_d_secure_mode: true, statement_descriptor: payment.source.statement_descriptor, description: payment.source.description, items: payment.source.items).create
24
24
  payment.source.update(external_id: mp_payment.id, three_ds_url: mp_payment.three_ds_info_external_resource_url, three_ds_creq: mp_payment.three_ds_info_creq)
25
+ if mp_payment.status == "approved"
26
+ payment.complete
27
+ elsif mp_payment.status == "rejected"
28
+ payment.invalidate
29
+ end
25
30
  rescue MpApi::TooManyRequestsError
26
31
  payment.invalidate
27
32
  rescue MpApi::RequestError
@@ -20,7 +20,7 @@ module SolidusMp
20
20
  def create_api_payment payment
21
21
  begin
22
22
  MpApi.configuration.access_token = preferences[:access_token]
23
- mp_payment = MpApi::Payment.new(payer_email: payment.source.email, payer_identification_type: "CPF", payment_method: "pix", payer_identification_number: payment.source.tax_id, amount: payment.amount.to_f).create
23
+ mp_payment = MpApi::Payment.new(payer_email: payment.source.email, payer_identification_type: "CPF", payment_method: "pix", payer_identification_number: payment.source.tax_id, amount: payment.amount.to_f, statement_descriptor: payment.source.statement_descriptor, description: payment.source.description, items: payment.source.items).create
24
24
  payment.source.update(external_id: mp_payment.id, qr_code: mp_payment.qr_code, qr_code_base64: mp_payment.qr_code_base_64, ticket_url: mp_payment.ticket_url)
25
25
  rescue MpApi::TooManyRequestsError
26
26
  payment.invalidate
@@ -8,7 +8,6 @@ class CreateSolidusMpPixPaymentSources < ActiveRecord::Migration[7.0]
8
8
  t.string :qr_code
9
9
  t.text :qr_code_base64
10
10
  t.string :ticket_url
11
-
12
11
  t.timestamps
13
12
  end
14
13
  end
@@ -0,0 +1,7 @@
1
+ class AddItemsToMpPix < ActiveRecord::Migration[7.0]
2
+ def change
3
+ add_column :solidus_mp_pix_payment_sources, :items, :jsonb, default: []
4
+ add_column :solidus_mp_pix_payment_sources, :statement_descriptor, :string
5
+ add_column :solidus_mp_pix_payment_sources, :description, :string
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ class AddItemsToMpCard < ActiveRecord::Migration[7.0]
2
+ def change
3
+ add_column :solidus_mp_card_payment_sources, :items, :jsonb, default: []
4
+ add_column :solidus_mp_card_payment_sources, :statement_descriptor, :string
5
+ add_column :solidus_mp_card_payment_sources, :description, :string
6
+ end
7
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SolidusMp
4
- VERSION = '0.1.3'
4
+ VERSION = '0.2.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solidus_mp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - caio
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-12-08 00:00:00.000000000 Z
11
+ date: 2023-12-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: solidus_core
@@ -111,6 +111,8 @@ files:
111
111
  - config/routes.rb
112
112
  - db/migrate/20231205142655_create_solidus_mp_pix_payment_sources.rb
113
113
  - db/migrate/20231205142931_create_solidus_mp_card_payment_sources.rb
114
+ - db/migrate/20231221130457_add_items_to_mp_pix.rb
115
+ - db/migrate/20231221141935_add_items_to_mp_card.rb
114
116
  - lib/generators/solidus_mp/install/install_generator.rb
115
117
  - lib/generators/solidus_mp/install/templates/app/javascript/controllers/credit_card_controller.js
116
118
  - lib/generators/solidus_mp/install/templates/app/javascript/controllers/three_ds_controller.js
@@ -153,7 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
153
155
  - !ruby/object:Gem::Version
154
156
  version: '0'
155
157
  requirements: []
156
- rubygems_version: 3.4.19
158
+ rubygems_version: 3.4.6
157
159
  signing_key:
158
160
  specification_version: 4
159
161
  summary: ''