mp_api 0.3.6 → 0.3.8

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: af6c473fbc12cab2fcc872a734480743f6da9e938f0289f58bcdf4b07275a9dd
4
- data.tar.gz: 8c37b5e63d81b7187358db698480c57fcd5e8089c5ae06ec8407e9074420aaae
3
+ metadata.gz: 70b974d39a2f32b20eaf5ab1d1e71a808aee9727de3b440cbcaca6155b70b8be
4
+ data.tar.gz: 652c07eda8d6f6a2d246b86a0a95ccf5b564d28c7f4a02f253d849690f9cbaf3
5
5
  SHA512:
6
- metadata.gz: 2f2a9a0bdabd4326ddf2167258bf8584d5efa6c7ddc03bd5c6cf85fd9fe7a6353fc29935ce4268033acae052fcb3e03852e1b12289a86b9b31f7022d352605b1
7
- data.tar.gz: 85ae787be3b4461d11bfc97f88def20b582e3d04d934e2fc785b862a7f26c28ea269aac143177a216c1ae8809b4e1a87ce4005a089d57450444115d79fb6caae
6
+ metadata.gz: 21a90e4578f235b1c22fe19a83b2058b54c8d5d08376be73f67cb82ae7817a7c3fcb8b70cf61135eb8a440932ddc2aea916acb5802fe8d72ec21a10d9120813c
7
+ data.tar.gz: 2711a21679e9a2f34c25b88acf1dbf3e446267906ba9bf079d408e8d039c8a0d977674e1f8f4fe39c971cc1770883749c80492aea58feaee9f483204bf4ce5af
@@ -6,11 +6,12 @@ module MpApi
6
6
  end
7
7
 
8
8
  def error
9
- rejected_payment_error
9
+ rejected_payment_error || failed_payment_error || "Pagamento recusado."
10
10
  end
11
11
 
12
12
  def internal_error
13
- failed_payment_error
13
+ return nil unless json_response["error"]
14
+ json_response["cause"]&.first["description"]
14
15
  end
15
16
 
16
17
  private
@@ -22,7 +23,7 @@ module MpApi
22
23
 
23
24
  def failed_payment_error
24
25
  return nil unless json_response["error"]
25
- json_response["cause"].first["description"]
26
+ message_by_error_message(json_response["cause"]&.first["description"])
26
27
  end
27
28
 
28
29
  def message_by_status_detail(status_detail)
@@ -33,7 +34,15 @@ module MpApi
33
34
  "cc_rejected_insufficient_amount" => "Pagamento recusado. Limite insuficiente.",
34
35
  "cc_rejected_call_for_authorize" => "Pagamento recusado.",
35
36
  "cc_rejected_other_reason" => "Pagamento recusado."
36
- }[status_detail] || "Pagamento recusado."
37
+ }[status_detail]
37
38
  end
39
+
40
+ def message_by_error_message(error_message)
41
+ {
42
+ "Invalid user identification number" => "CPF inválido."
43
+ # "Payer email forbidden" => "E-mail inválido.", Caso do erro no email test_user_2147198029@testuser.com (Nao sei se da pra causar com email valido)
44
+ }[error_message]
45
+ end
46
+
38
47
  end
39
48
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MpApi
4
- VERSION = "0.3.6"
4
+ VERSION = "0.3.8"
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: 0.3.6
4
+ version: 0.3.8
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-10 00:00:00.000000000 Z
11
+ date: 2024-01-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ac