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

.hintObject (readonly)

Returns the value of attribute hint.



49
50
51
# File 'lib/mpp/errors.rb', line 49

def hint
  @hint
end

.statusObject (readonly)

Returns the value of attribute status.



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

def status
  @status
end

.titleObject (readonly)

Returns the value of attribute title.



46
47
48
# File 'lib/mpp/errors.rb', line 46

def title
  @title
end

.typeObject (readonly)

Returns the value of attribute type.



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

def type
  @type
end

Class Method Details

.inherited(subclass) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/mpp/errors.rb', line 21

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)
  subclass.instance_variable_set(:@hint, nil) unless subclass.instance_variable_defined?(:@hint)
end

Instance Method Details

#hintObject



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

def hint = self.class.hint

#statusObject



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

def status = self.class.status

#titleObject



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

def title = self.class.title

#to_problem_details(challenge_id: nil) ⇒ Object



80
81
82
83
84
85
86
87
88
89
90
# File 'lib/mpp/errors.rb', line 80

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

#typeObject



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

def type = self.class.type