solidus_mp 0.2.1 → 0.2.3

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: 98de92d2e207f5ff621a944cb8f4d361228293c85bf3ce399168b0a24f8128ef
4
- data.tar.gz: 9f6f5b90d2e06ece8de659e16cd750781dd0cfcbac76c1b87eafb3ea4d5c88b1
3
+ metadata.gz: 74ec75fa7d047fc008dd680e7471a4f547ddb9ba8ffc9a1aae76ce0feee57bae
4
+ data.tar.gz: 541d4d05bad0221c59a84c2ce02af4fa226d5c3c9783abe003873cf45494271d
5
5
  SHA512:
6
- metadata.gz: 5d0263a2f4408e083a27837083cda99f562843b2dcb564856e93c6d16019a19010d9b5ebf49e6c2a6d67395f2611c96c631178e81b011a1ca975277167539ce0
7
- data.tar.gz: 8d16891d5d19bb303429fc5a25f31a18f884d04b14c5528a864e51bb93cc0f047a66f17a41cc96a02197caf1bb3e3eea677a508a4596a928253aa1a1a0280ea7
6
+ metadata.gz: ab8837d46c3276df7089f3c898954e4dbaaedb9391c0e51223430dea4405a79d69505aa0e3acf761e54f5fcbe0dba3816be69f80bb28a7e59a23b757c1251d30
7
+ data.tar.gz: f8a947de786eae4233c255e3a6369dd5ac18d854c8e47be61dc4ae71ab35aeb14739615d4b0b8db51b2ad11ca30046acf583fcfb70b75e06d21221ce955b26ef
@@ -22,6 +22,11 @@ module SolidusMp
22
22
  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
23
23
  end
24
24
 
25
+ def cancel_payment payment
26
+ MpApi.configuration.access_token = preferences[:access_token]
27
+ MpApi::Payment.find_by_id(payment.source.external_id).update(status: "cancelled")
28
+ end
29
+
25
30
  def authorize(money, source, options = {})
26
31
  purchase(money, source, options)
27
32
  end
@@ -17,10 +17,30 @@ module SolidusMp
17
17
  source.is_a?(payment_source_class)
18
18
  end
19
19
 
20
- def create_api_payment payment
20
+ def create_pix_payment payment
21
+ mp_payment = create_mp_payment(payment)
22
+ if mp_payment.errors
23
+ payment.invalidate
24
+ error_message = mp_payment.errors&.first || mp_payment.status_detail
25
+ response = failure_response(error_message)
26
+ payment.log_entries.create!(parsed_payment_response_details_with_fallback: response)
27
+ payment.source.update(error_message: error_message, status: mp_payment.status)
28
+ "error"
29
+ elsif mp_payment.status == "pending"
30
+ 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, status: mp_payment.status)
31
+ "pending"
32
+ end
33
+ end
34
+
35
+ def create_mp_payment payment
21
36
  MpApi.configuration.access_token = preferences[:access_token]
22
37
  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
23
38
  end
39
+
40
+ def cancel_payment payment
41
+ MpApi.configuration.access_token = preferences[:access_token]
42
+ MpApi::Payment.find_by_id(payment.source.external_id).update(status: "cancelled")
43
+ end
24
44
 
25
45
  def authorize(money, source, options = {})
26
46
  purchase(money, source, options)
@@ -0,0 +1,6 @@
1
+ class AddStatusToPaymentSource < ActiveRecord::Migration[7.0]
2
+ def change
3
+ add_column :solidus_mp_pix_payment_sources, :status, :string
4
+ add_column :solidus_mp_card_payment_sources, :status, :string
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ class AddErrorMessageToPaymentSource < ActiveRecord::Migration[7.0]
2
+ def change
3
+ add_column :solidus_mp_pix_payment_sources, :error_message, :string
4
+ add_column :solidus_mp_card_payment_sources, :error_message, :string
5
+ end
6
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SolidusMp
4
- VERSION = '0.2.1'
4
+ VERSION = '0.2.3'
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.2.1
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - caio
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-01-05 00:00:00.000000000 Z
11
+ date: 2024-01-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: solidus_core
@@ -113,6 +113,8 @@ files:
113
113
  - db/migrate/20231205142931_create_solidus_mp_card_payment_sources.rb
114
114
  - db/migrate/20231221130457_add_items_to_mp_pix.rb
115
115
  - db/migrate/20231221141935_add_items_to_mp_card.rb
116
+ - db/migrate/20240105143500_add_status_to_payment_source.rb
117
+ - db/migrate/20240109171955_add_error_message_to_payment_source.rb
116
118
  - lib/generators/solidus_mp/install/install_generator.rb
117
119
  - lib/generators/solidus_mp/install/templates/app/javascript/controllers/credit_card_controller.js
118
120
  - lib/generators/solidus_mp/install/templates/app/javascript/controllers/three_ds_controller.js
@@ -155,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
155
157
  - !ruby/object:Gem::Version
156
158
  version: '0'
157
159
  requirements: []
158
- rubygems_version: 3.4.6
160
+ rubygems_version: 3.4.19
159
161
  signing_key:
160
162
  specification_version: 4
161
163
  summary: ''