module OffsitePayments::Integrations::Paytm

Constants

CIPHER
SALT_ALPHABET
SALT_LENGTH
STATIC_IV

Public Class Methods

checksum(hash, salt = nil) click to toggle source
# File lib/offsite_payments/integrations/paytm.rb, line 30
def self.checksum(hash, salt = nil)
  if salt.nil?
    salt = SALT_LENGTH.times.map { SALT_ALPHABET[SecureRandom.random_number(SALT_ALPHABET.length)] }.join
  end

  values = hash.sort.to_h.values
  values << salt
  Digest::SHA256.hexdigest(values.join('|')) + salt
end
encrypt(data, key) click to toggle source
# File lib/offsite_payments/integrations/paytm.rb, line 40
def self.encrypt(data, key)
  aes = OpenSSL::Cipher.new(CIPHER)
  aes.encrypt
  aes.key = key
  aes.iv = STATIC_IV

  encrypted_data = aes.update(data) + aes.final
  Base64.strict_encode64(encrypted_data)
end
notification(post, options = {}) click to toggle source
# File lib/offsite_payments/integrations/paytm.rb, line 22
def self.notification(post, options = {})
  Notification.new(post, options)
end
return(post, options = {}) click to toggle source
# File lib/offsite_payments/integrations/paytm.rb, line 26
def self.return(post, options = {})
  Return.new(post, options)
end
service_url() click to toggle source
# File lib/offsite_payments/integrations/paytm.rb, line 18
def self.service_url
  OffsitePayments.mode == :production ? production_url : test_url
end