Module: Przelewy24Payment

Defined in:
lib/przelewy24_payment.rb,
lib/przelewy24_payment/engine.rb,
lib/przelewy24_payment/version.rb

Defined Under Namespace

Modules: PaymentHelper Classes: Engine, InstallGenerator

Constant Summary collapse

VERSION =
"0.1.3"
@@seller_id =
''
@@language =
'pl'
@@mode =
:development
@@error_url =
''
@@comeback_url =
''
@@crc_key =
''
@@hostname =
{ :development => "http://localhost:3000" }

Class Method Summary collapse

Class Method Details

.calculate_crc(value, session_id, crc_key = nil) ⇒ Object



60
61
62
63
# File 'lib/przelewy24_payment.rb', line 60

def self.calculate_crc(value,session_id, crc_key=nil)
  calc_md5 = Digest::MD5.hexdigest(session_id.to_s + "|" + (seller_id).to_s + "|" + (p24_price(value)).to_s + "|" + (crc_key.nil? ? "" : crc_key.to_s))
  return calc_md5
end

.complete_url(params) ⇒ Object



32
33
34
# File 'lib/przelewy24_payment.rb', line 32

def self.complete_url(params)
  params
end

.friendly_tokenObject



56
57
58
# File 'lib/przelewy24_payment.rb', line 56

def self.friendly_token
  SecureRandom.base64(15).tr('+/=lIO0', 'aqrsxyz')
end

.get_comeback_urlObject



69
70
71
# File 'lib/przelewy24_payment.rb', line 69

def self.get_comeback_url
  get_hostname + @@comeback_url
end

.get_error_urlObject



73
74
75
# File 'lib/przelewy24_payment.rb', line 73

def self.get_error_url
  get_hostname + @@error_url
end

.get_hostnameObject



65
66
67
# File 'lib/przelewy24_payment.rb', line 65

def self.get_hostname
  @@hostname[@@mode]
end

.p24_price(price) ⇒ Object



52
53
54
# File 'lib/przelewy24_payment.rb', line 52

def self.p24_price(price)
  price.present? ? (price.to_f.round(2) * 100) : 0
end

.post_urlObject



36
37
38
39
40
41
42
# File 'lib/przelewy24_payment.rb', line 36

def self.post_url
  if @@mode == :development
    'https://sandbox.przelewy24.pl/index.php'
  elsif @@mode == :production
    'https://secure.przelewy24.pl/index.php'
  end
end

.setup {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



28
29
30
# File 'lib/przelewy24_payment.rb', line 28

def self.setup
  yield self
end

.transaction_urlObject



44
45
46
47
48
49
50
# File 'lib/przelewy24_payment.rb', line 44

def self.transaction_url
  if @@mode == :development
    'https://sandbox.przelewy24.pl/transakcja.php'
  elsif @mode == :production
    'https://secure.przelewy24.pl/index.php'
  end
end