Class: Espago::SecureWebPage

Inherits:
Object
  • Object
show all
Defined in:
lib/espago/secure_web_page.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#productionObject

Returns the value of attribute production.



4
5
6
# File 'lib/espago/secure_web_page.rb', line 4

def production
  @production
end

Class Method Details

.calculate_checksum(app_id, kind, session_id, amount, currency, ts, checksum_key) ⇒ Object



6
7
8
9
10
# File 'lib/espago/secure_web_page.rb', line 6

def self.calculate_checksum(app_id, kind, session_id,amount,currency,ts,checksum_key)
  Digest::MD5.hexdigest(
    [app_id.to_s, kind, session_id.to_s, amount.to_s, currency.to_s, ts.to_s, checksum_key.to_s].join('|')
  )
end

.form_post(api_v = nil) ⇒ Object



12
13
14
# File 'lib/espago/secure_web_page.rb', line 12

def self.form_post(api_v=nil)
  Espago.production ? "https://secure.espago.com/secure_web_page" : "https://sandbox.espago.com/secure_web_page"
end

.prepare_form(data) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/espago/secure_web_page.rb', line 16

def self.prepare_form(data)
  data[:kind] ||=  'sale'
  data[:ts] ||=  Time.now.to_i
  data[:app_id] ||=  Espago.app_id
  data[:api_version] ||= Espago.api_version
  data[:amount] = format('%.2f', data[:amount])
  data[:checksum] = calculate_checksum(data[:app_id],data[:kind],data[:session_id],data[:amount],data[:currency],data[:ts],data[:checksum_key]|| Espago.checksum_key)
  data
end