mp_api 1.2.1 → 1.2.2

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: 6572a103bae8bedda82d3d2ef36d7341f382b175dec29210090b8ddbce872319
4
- data.tar.gz: 00e11cca8e2b32d735ea81ac513710d176c1ab3e798a8d26502073c81ed23dd4
3
+ metadata.gz: 59d843843d099fc02a62263d86caacb6d71655c160680034923a443155c2b1c8
4
+ data.tar.gz: 42bf488a1003f5e38d2418125e5d5b29f0de78c7c0aca65bb6a9329f2831f092
5
5
  SHA512:
6
- metadata.gz: 6974da8f6fd6e647524f0fe31e5f654264a5f9aed8d85b68ec7981de448ee7c56e5be099d21c5dc429eec5553e4ab8b2e6b700c1ffb39936b200fb0b97f201de
7
- data.tar.gz: 97f55e5e9062c772de7321febc26a9eccbc4f4ecd87673df64b8e617b7a00f1a0bf832e7e0416e1abf56a4264d189211307f98cc9953a48c7d479630c262a94e
6
+ metadata.gz: 0b769d68eb164df97a1ff8d2e7745b6205472acb3619aa22ee41fd1f869c17099cc1479bee8743dfcc30ada82c6b553169dfc43c55e6121e8ee6e4026f0b7d5b
7
+ data.tar.gz: 8d5503eb188b0bdc9bf1be1b9ecc8e2532a33b5474048bda8c46ef897cc8b9d597e63a6b7843f1af48ab8c328d0f1bcf61f8d12021dec506afc254c0eb226613
@@ -1,7 +1,7 @@
1
1
  module MpApi
2
2
  class Payment
3
3
  attr_reader :status_detail, :three_ds_info_creq, :three_ds_info_external_resource_url, :three_d_secure_mode, :id, :description, :date_approved, :date_created, :money_release_date, :payer_email, :payer_identification_type, :payer_identification_number, :payment_method, :last_four_digits, :payment_type, :qr_code, :qr_code_base_64, :transaction_id, :ticket_url, :status, :amount, :token, :issuer_id, :installments, :statement_descriptor, :items, :error, :internal_error, :capture, :date_of_expiration, :saved_card, :customer_id
4
- def initialize(payer_email:, payer_identification_type:, payer_identification_number:, payment_method:, last_four_digits: nil, amount:, status_detail: nil, three_ds_info_creq: nil, three_ds_info_external_resource_url: nil, three_d_secure_mode: nil, id: nil, description: nil, date_approved: nil, date_created: nil, money_release_date: nil, payment_type: nil, qr_code: nil, qr_code_base_64: nil, transaction_id: nil, ticket_url: nil, status: nil, token: nil, issuer_id: nil, installments: nil, items: nil, statement_descriptor: nil, error: nil, internal_error: nil, capture: nil, date_of_expiration: nil, saved_card: false, customer_id: nil)
4
+ def initialize(payer_email:, payer_identification_type:, payer_identification_number:, payment_method:, amount:, last_four_digits: nil, status_detail: nil, three_ds_info_creq: nil, three_ds_info_external_resource_url: nil, three_d_secure_mode: nil, id: nil, description: nil, date_approved: nil, date_created: nil, money_release_date: nil, payment_type: nil, qr_code: nil, qr_code_base_64: nil, transaction_id: nil, ticket_url: nil, status: nil, token: nil, issuer_id: nil, installments: nil, items: nil, statement_descriptor: nil, error: nil, internal_error: nil, capture: nil, date_of_expiration: nil, saved_card: false, customer_id: nil)
5
5
  @id = id
6
6
  @description = description
7
7
  @date_approved = date_approved
@@ -96,14 +96,23 @@ module MpApi
96
96
  self.class.new(**self.class.build_hash(response.json))
97
97
  end
98
98
 
99
+ def pix_paid? external_value = nil
100
+ external_value = @amount if external_value.nil?
101
+ @status == "approved" && external_value.to_d == @amount.to_d
102
+ end
103
+
99
104
  def update attributes
100
105
  attributes.each do |key, value|
101
- instance_variable_set("@#{key}", value)
106
+ instance_variable_set(:"@#{key}", value)
102
107
  end
103
108
  Client.new.update_payment(id, JSON.dump(build_update_json))
104
109
  self.class.find_by_id(id)
105
110
  end
106
111
 
112
+ def invalidate_pix!
113
+ update(status: "cancelled")
114
+ end
115
+
107
116
  def self.find_by_id(payment_id)
108
117
  response = Client.new.get_payment(payment_id)
109
118
  new(**build_hash(response.json))
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MpApi
4
- VERSION = "1.2.1"
4
+ VERSION = "1.2.2"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mp_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.2
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-25 00:00:00.000000000 Z
11
+ date: 2024-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ac
@@ -67,7 +67,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  requirements: []
70
- rubygems_version: 3.5.16
70
+ rubygems_version: 3.5.22
71
71
  signing_key:
72
72
  specification_version: 4
73
73
  summary: ''