Exception: Mpp::PaymentError

Inherits:
StandardError
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/mpp/errors.rb

Overview

Base class for all payment-related errors with RFC 9457 support.

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.statusObject (readonly)

Returns the value of attribute status.



36
37
38
# File 'lib/mpp/errors.rb', line 36

def status
  @status
end

.titleObject (readonly)

Returns the value of attribute title.



42
43
44
# File 'lib/mpp/errors.rb', line 42

def title
  @title
end

.typeObject (readonly)

Returns the value of attribute type.



39
40
41
# File 'lib/mpp/errors.rb', line 39

def type
  @type
end

Class Method Details

.inherited(subclass) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/mpp/errors.rb', line 18

def self.inherited(subclass)
  super
  return if subclass.instance_variable_defined?(:@_mpp_configured)

  subclass.instance_variable_set(:@_mpp_configured, true)
  name = subclass.name&.split("::")&.last || "PaymentError"
  unless subclass.instance_variable_defined?(:@type)
    subclass.instance_variable_set(:@type,
      "#{BASE_URI}/#{to_slug(name)}")
  end
  subclass.instance_variable_set(:@title, to_title(name)) unless subclass.instance_variable_defined?(:@title)
  subclass.instance_variable_set(:@status, 402) unless subclass.instance_variable_defined?(:@status)
end

Instance Method Details

#statusObject



62
# File 'lib/mpp/errors.rb', line 62

def status = self.class.status

#titleObject



66
# File 'lib/mpp/errors.rb', line 66

def title = self.class.title

#to_problem_details(challenge_id: nil) ⇒ Object



70
71
72
73
74
75
76
77
78
79
# File 'lib/mpp/errors.rb', line 70

def to_problem_details(challenge_id: nil)
  details = {
    "type" => type,
    "title" => title,
    "status" => status,
    "detail" => message
  }
  details["challengeId"] = challenge_id if challenge_id
  details
end

#typeObject



64
# File 'lib/mpp/errors.rb', line 64

def type = self.class.type