Class: Integral::Yandex::Money::NotificationValidator
- Inherits:
-
Object
- Object
- Integral::Yandex::Money::NotificationValidator
- Includes:
- Helpers
- Defined in:
- lib/integral/yandex/money/notification_validator.rb,
lib/integral/yandex/money/notification_validator/identity.rb
Overview
Validation is documented here: tech.yandex.ru/money/doc/dg/reference/notification-p2p-incoming-docpage/#notification-p2p-incoming__verify-notification
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
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
Instance Method Summary collapse
-
#initialize(params:, secret:) ⇒ NotificationValidator
constructor
A new instance of NotificationValidator.
- #valid? ⇒ Boolean
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
#errors ⇒ Object (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
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 |