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.



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

def status
  @status
end

.titleObject (readonly)

Returns the value of attribute title.



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

def title
  @title
end

.typeObject (readonly)

Returns the value of attribute type.



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

def type
  @type
end

Class Method Details

.inherited(subclass) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
# 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)
end

Instance Method Details

#statusObject



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

def status = self.class.status

#titleObject



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

def title = self.class.title

#to_problem_details(challenge_id: nil) ⇒ Object



73
74
75
76
77
78
79
80
81
82
# File 'lib/mpp/errors.rb', line 73

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



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

def type = self.class.type