Sha256: 28559da7c92111cffba3094f5b5e233fc4aa70aac3052e77ccb71224e79fa461

Contents?: true

Size: 1.36 KB

Versions: 3

Compression:

Stored size: 1.36 KB

Contents

require "przelewy24_payment/version"
require "przelewy24_payment/engine"

module Przelewy24Payment

  module Controllers
    autoload :Przelewy24Payment, 'controllers/przelewy24_payment'
  end

  mattr_accessor :seller_id
  @@seller_id = '17329'

  mattr_accessor :language
  @@language = 'pl'

  mattr_accessor :mode
  @@mode = :development

  mattr_accessor :error_url
  @@error_url = ''

  mattr_accessor :comeback_url
  @@comeback_url = ''

  mattr_accessor :crc_key
  @@crc_key = ''

  def self.setup
    yield self
  end

  def self.complete_url(params)
    params
  end

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

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

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

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

  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

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
przelewy24_payment-0.1.1 lib/przelewy24_payment.rb
przelewy24_payment-0.1.0 lib/przelewy24_payment.rb
przelewy24_payment-0.0.1 lib/przelewy24_payment.rb