Class: OffsitePayments::Integrations::Migs::SecureHash
- Inherits:
-
Object
- Object
- OffsitePayments::Integrations::Migs::SecureHash
- Defined in:
- lib/offsite_payments/integrations/migs.rb
Constant Summary collapse
- DIGEST =
OpenSSL::Digest.new('sha256')
Class Method Summary collapse
Class Method Details
.calculate(secure_hash, post) ⇒ Object
149 150 151 152 153 154 |
# File 'lib/offsite_payments/integrations/migs.rb', line 149 def self.calculate(secure_hash, post) post_without_secure_hash = post.reject { |k, _v| [:SecureHash, :SecureHashType].include? k } sorted_values = post_without_secure_hash.sort_by(&:to_s).map { |key, value| "vpc_#{key}=#{value}"} input = sorted_values.join('&') OpenSSL::HMAC.hexdigest(DIGEST, [secure_hash].pack('H*'), input).upcase end |