Module: DPay::IpnVerifier
- Defined in:
- lib/dpay/ipn/ipn_verifier.rb,
sig/dpay/ipn/ipn_verifier.rbs
Constant Summary collapse
- REQUIRED_FIELDS =
%w[id amount type attempt version signature].freeze
- INVALID_PAYLOAD =
"Invalid IPN payload"
Class Method Summary collapse
Instance Method Summary collapse
- #self?.construct_event ⇒ IpnEvent
- #self?.expected_signature ⇒ String
- #self?.parse ⇒ Hash[String, untyped]
- #self?.secure_compare ⇒ Boolean
Class Method Details
.construct_event(raw_body, secret_hash) ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/dpay/ipn/ipn_verifier.rb', line 14 def construct_event(raw_body, secret_hash) payload = parse(raw_body) signature = payload["signature"] raise SignatureVerificationError, INVALID_PAYLOAD unless signature.is_a?(String) expected = expected_signature(payload, secret_hash) raise SignatureVerificationError, "Invalid IPN signature" unless secure_compare(expected, signature) IpnEvent.from_verified_payload(payload) end |
Instance Method Details
#self?.construct_event ⇒ IpnEvent
6 |
# File 'sig/dpay/ipn/ipn_verifier.rbs', line 6
def self?.construct_event: (untyped raw_body, String secret_hash) -> IpnEvent
|
#self?.expected_signature ⇒ String
8 |
# File 'sig/dpay/ipn/ipn_verifier.rbs', line 8
def self?.expected_signature: (Hash[String, untyped] payload, String secret_hash) -> String
|
#self?.parse ⇒ Hash[String, untyped]
7 |
# File 'sig/dpay/ipn/ipn_verifier.rbs', line 7
def self?.parse: (untyped raw_body) -> Hash[String, untyped]
|
#self?.secure_compare ⇒ Boolean
9 |
# File 'sig/dpay/ipn/ipn_verifier.rbs', line 9
def self?.secure_compare: (String expected, String actual) -> bool
|