mp_api 0.3.1 → 0.3.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: a77cbd351a3838728cbc5ef24aab99d7f27376856bd3175968e20c99262a35db
4
- data.tar.gz: cfdf6c3a0512aaba0f47a2c6de3365ac2acf6f4718eb433138e326f74dc84d73
3
+ metadata.gz: 1ad0d87569bda2d5fd1c4894b172e603641d775370e8954f64ffde4e5306e008
4
+ data.tar.gz: 39e0da14355f414c9f9d70dc2c7a47fe58f9a1fd5c48c9846bc27b98fb23298f
5
5
  SHA512:
6
- metadata.gz: a04392ee14dda763d30a07ab6fb4c16e02925f3510dbd4fedf566f9fd32e30b04b221cd1c35d74c5b92070268997381f1269ffb769f02e1ac970bcdd6b2c4de0
7
- data.tar.gz: 45dbb1dc44aeb78e60f1702d614149b73c3f51a2f05bd1a016371638a39023fd3cf1dbb31d20642492120abffcf38b85192b42f068b0d00819f8bcad5628240c
6
+ metadata.gz: 0ad37f1e152106dac28d157dd35d20fd60265929358bba3ab1ee322df84e4190003257e73ac77e91de78240ee637443ff851c02c2c4f9bffd039af8116ef07a3
7
+ data.tar.gz: ec72395c7c24c650c69fa4a2ae594645efc9d863ffc4f893c5a791c8efb47b815144a49977fb87c136e84aea2b43dfa43f541ffb9f61ce185c6adf1e140d40d2
@@ -7,11 +7,32 @@ module MpApi
7
7
  end
8
8
 
9
9
  def errors
10
- return nil unless json_response['error']
11
- json_response['cause'].map {|cause| message_by_error_code(cause['code']) || cause['description']}
10
+ rejected_payment_error || failed_payment_error
12
11
  end
13
12
 
14
13
  private
14
+
15
+ def rejected_payment_error
16
+ return nil unless ['rejected'].include?(json_response['status'])
17
+ [json_response['status_detail']]
18
+ end
19
+
20
+ def failed_payment_error
21
+ return nil unless json_response['error']
22
+ json_response['cause']&.map {|cause| message_by_error_code(cause['code']) || cause['description']}
23
+ end
24
+
25
+ def message_by_status_detail(status_detail)
26
+ {
27
+ 'cc_rejected_bad_filled_other' => 'Recusado por erro no formulário.',
28
+ 'cc_rejected_bad_filled_date' => 'Recusado por problema com a data de vencimento',
29
+ 'cc_rejected_bad_filled_security_code' => 'Recusado por código de segurança inválido.',
30
+ 'cc_rejected_insufficient_amount' => 'Recusado por quantia insuficiente.',
31
+ 'cc_rejected_call_for_authorize' => 'Recusado, ligue para a administradora do cartão para autorizar.',
32
+ 'cc_rejected_other_reason' => 'Recusado por erro geral'
33
+ }
34
+ end
35
+
15
36
  def message_by_error_code(code)
16
37
  {
17
38
  1 => "Erro nos parâmetros.",
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MpApi
4
- VERSION = "0.3.1"
4
+ VERSION = "0.3.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mp_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - caio