Class: Integral::Yandex::Money::NotificationValidator

Inherits:
Object
  • Object
show all
Includes:
Helpers
Defined in:
lib/integral/yandex/money/notification_validator.rb,
lib/integral/yandex/money/notification_validator/identity.rb

Overview

Defined Under Namespace

Modules: Identity

Constant Summary collapse

KEYS_FOR_DIGEST =

Order is crucial for ‘KEYS_FOR_DIGEST`

%w[notification_type operation_id amount currency datetime sender codepro notification_secret label].freeze
REQUIRED_KEYS =
%w[amount codepro datetime notification_type operation_id sender].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers

encode_sha, find_missing_hash_values, stringify_params_with_order, validate_argument_type!

Constructor Details

#initialize(params:, secret:) ⇒ NotificationValidator

Returns a new instance of NotificationValidator.



19
20
21
22
23
24
25
# File 'lib/integral/yandex/money/notification_validator.rb', line 19

def initialize params:, secret:
  fail ArgumentError, "Yandex.Money notifications secret is required" if secret.to_s == ""
  validate_argument_type! argument: params, permitted_types: ["ActionController::Parameters", "Hash"]
  @secret = secret
  @params = params
  @errors = []
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



27
28
29
# File 'lib/integral/yandex/money/notification_validator.rb', line 27

def errors
  @errors
end

Instance Method Details

#valid?Boolean

Returns:

  • (Boolean)


29
30
31
32
33
# File 'lib/integral/yandex/money/notification_validator.rb', line 29

def valid?
  return false unless all_param_values_present?
  return false unless integrity_correct?
  true
end