mp_api 1.2.0 → 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: acb1327c5e7bdeb10e34f09b348fff419d38451506f7f4e18f75bdeeceec5294
4
- data.tar.gz: 170333900c1568e4937e0dbd5b333ea764f1f548871acaab5dd1825e238c6605
3
+ metadata.gz: 59d843843d099fc02a62263d86caacb6d71655c160680034923a443155c2b1c8
4
+ data.tar.gz: 42bf488a1003f5e38d2418125e5d5b29f0de78c7c0aca65bb6a9329f2831f092
5
5
  SHA512:
6
- metadata.gz: 77a6f9bc3cdce5dfddf47c90dc2de04af4b3f0da903cbd502c41325cdf910f9573a25757f22ef5dd99bcd822841cfd9cd23aa88950fac49315539f45ae4569cc
7
- data.tar.gz: de19a66ddb638012c114f1df58b679affe37be5345ab418253c37bb8376f99b0634181353a26ce3ca61c5dca093c5fa0eec926a39fc8fc32beccb6208b63234c
6
+ metadata.gz: 0b769d68eb164df97a1ff8d2e7745b6205472acb3619aa22ee41fd1f869c17099cc1479bee8743dfcc30ada82c6b553169dfc43c55e6121e8ee6e4026f0b7d5b
7
+ data.tar.gz: 8d5503eb188b0bdc9bf1be1b9ecc8e2532a33b5474048bda8c46ef897cc8b9d597e63a6b7843f1af48ab8c328d0f1bcf61f8d12021dec506afc254c0eb226613
data/lib/mp_api/client.rb CHANGED
@@ -2,6 +2,8 @@ module MpApi
2
2
  class Client < Ac::Base
3
3
  BASE_URL = "https://api.mercadopago.com/v1/"
4
4
  MAX_RETRIES = 1
5
+ SAVE_RESPONSES = true
6
+
5
7
  attr_reader :access_token
6
8
  def initialize(access_token = MpApi.configuration.access_token)
7
9
  @headers = {
@@ -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.0"
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.0
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-07-12 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.11
70
+ rubygems_version: 3.5.22
71
71
  signing_key:
72
72
  specification_version: 4
73
73
  summary: ''