Module: OffsitePayments::Integrations::Paytm
- Defined in:
- lib/offsite_payments/integrations/paytm.rb
Defined Under Namespace
Classes: Helper, Notification, Return
Constant Summary
collapse
- CIPHER =
'AES-128-CBC'
- SALT_ALPHABET =
['a'..'z', 'A'..'Z', '0'..'9'].flat_map { |i| i.to_a }
- SALT_LENGTH =
4
- STATIC_IV =
'@@@@&&&&####$$$$'
Class Method Summary
collapse
Class Method Details
.checksum(hash, salt = nil) ⇒ Object
30
31
32
33
34
35
36
37
38
|
# 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) ⇒ Object
40
41
42
43
44
45
46
47
48
|
# 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 = {}) ⇒ Object
22
23
24
|
# File 'lib/offsite_payments/integrations/paytm.rb', line 22
def self.notification(post, options = {})
Notification.new(post, options)
end
|
.return(post, options = {}) ⇒ Object
26
27
28
|
# File 'lib/offsite_payments/integrations/paytm.rb', line 26
def self.return(post, options = {})
Return.new(post, options)
end
|
.service_url ⇒ Object
18
19
20
|
# File 'lib/offsite_payments/integrations/paytm.rb', line 18
def self.service_url
OffsitePayments.mode == :production ? production_url : test_url
end
|