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 +4 -4
- data/lib/mp_api/payment_error.rb +23 -2
- data/lib/mp_api/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1ad0d87569bda2d5fd1c4894b172e603641d775370e8954f64ffde4e5306e008
|
4
|
+
data.tar.gz: 39e0da14355f414c9f9d70dc2c7a47fe58f9a1fd5c48c9846bc27b98fb23298f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ad37f1e152106dac28d157dd35d20fd60265929358bba3ab1ee322df84e4190003257e73ac77e91de78240ee637443ff851c02c2c4f9bffd039af8116ef07a3
|
7
|
+
data.tar.gz: ec72395c7c24c650c69fa4a2ae594645efc9d863ffc4f893c5a791c8efb47b815144a49977fb87c136e84aea2b43dfa43f541ffb9f61ce185c6adf1e140d40d2
|
data/lib/mp_api/payment_error.rb
CHANGED
@@ -7,11 +7,32 @@ module MpApi
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def errors
|
10
|
-
|
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.",
|
data/lib/mp_api/version.rb
CHANGED