Exception: Mpp::Extensions::MCP::PaymentVerificationError

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(challenges:, reason: nil, detail: nil, message: "Payment Verification Failed") ⇒ PaymentVerificationError

Returns a new instance of PaymentVerificationError.



52
53
54
55
56
57
58
# File 'lib/mpp/extensions/mcp/errors.rb', line 52

def initialize(challenges:, reason: nil, detail: nil, message: "Payment Verification Failed")
  @challenges = T.let(challenges, T.untyped)
  @reason = T.let(reason, T.untyped)
  @detail = T.let(detail, T.untyped)
  @code = T.let(CODE_PAYMENT_VERIFICATION_FAILED, Integer)
  super(message)
end

Instance Attribute Details

#challengesObject (readonly)

Returns the value of attribute challenges.



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

def challenges
  @challenges
end

#codeObject (readonly)

Returns the value of attribute code.



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

def code
  @code
end

#detailObject (readonly)

Returns the value of attribute detail.



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

def detail
  @detail
end

#reasonObject (readonly)

Returns the value of attribute reason.



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

def reason
  @reason
end

Instance Method Details

#to_jsonrpc_errorObject



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/mpp/extensions/mcp/errors.rb', line 61

def to_jsonrpc_error
  data = {
    "httpStatus" => HTTP_STATUS_PAYMENT_REQUIRED,
    "challenges" => @challenges.map(&:to_dict)
  }
  if @reason || @detail
    failure = {}
    failure["reason"] = @reason if @reason
    failure["detail"] = @detail if @detail
    data["failure"] = failure
  end
  {
    "code" => CODE_PAYMENT_VERIFICATION_FAILED,
    "message" => message,
    "data" => data
  }
end