Class: MpApi::PaymentError
- Inherits:
-
Object
- Object
- MpApi::PaymentError
- Defined in:
- lib/mp_api/payment_error.rb
Instance Attribute Summary collapse
-
#json_response ⇒ Object
readonly
Returns the value of attribute json_response.
Instance Method Summary collapse
- #error ⇒ Object
-
#initialize(json_response:) ⇒ PaymentError
constructor
A new instance of PaymentError.
- #internal_error ⇒ Object
Constructor Details
#initialize(json_response:) ⇒ PaymentError
Returns a new instance of PaymentError.
4 5 6 |
# File 'lib/mp_api/payment_error.rb', line 4 def initialize(json_response:) @json_response = json_response end |
Instance Attribute Details
#json_response ⇒ Object (readonly)
Returns the value of attribute json_response.
3 4 5 |
# File 'lib/mp_api/payment_error.rb', line 3 def json_response @json_response end |
Instance Method Details
#error ⇒ Object
8 9 10 11 |
# File 'lib/mp_api/payment_error.rb', line 8 def error return nil unless json_response["error"] || ["rejected"].include?(json_response["status"]) rejected_payment_error || failed_payment_error || "Pagamento recusado." end |
#internal_error ⇒ Object
13 14 15 16 |
# File 'lib/mp_api/payment_error.rb', line 13 def internal_error return nil unless json_response["error"] json_response["cause"]&.first["description"] end |