Sha256: 0c633ed3f2a74ea12c95527d218a4b5e74c53a746e40f1db192f0de30502c85b
Contents?: true
Size: 1.4 KB
Versions: 1
Compression:
Stored size: 1.4 KB
Contents
class WebToPay::Payment ATTRIBUTES = [:projectid, :orderid, :lang, :amount, :currency, :accepturl, :cancelurl, :callbackurl, :country, :paytext, :p_email, :p_name, :p_surname, :payment, :test, :version] UNDERSCORE_MAPPINGS = {pname: :p_name, pemail: :p_email, psurname: :p_surname} attr_accessor *ATTRIBUTES extend ActiveModel::Naming include ActiveModel::AttributeMethods def initialize(params = {}, user_params = {}) self.version = WebToPay::API_VERSION self.projectid = user_params[:projectid] || WebToPay.config.project_id @sign_password = user_params[:sign_password] || WebToPay.config.sign_password params.each_pair do |field, value| field_name = field.to_s.downcase.gsub('_', '').to_sym field_name = UNDERSCORE_MAPPINGS[field_name] || field_name self.public_send("#{field_name}=", value) end end def query @query ||= begin query = [] ATTRIBUTES.each do |field| value = self.public_send(field) next if value.blank? query << "#{field}=#{ CGI::escape value.to_s}" end query.join('&') end end def data # encoded query @data ||= Base64.encode64(query).gsub("\n", '').gsub('/', '+').gsub('_', '-') end def url "https://www.mokejimai.lt/pay?data=#{CGI::escape data}&sign=#{CGI::escape sign}" end def sign Digest::MD5.hexdigest(data + @sign_password) end def to_key end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
webtopay-1.6.1 | lib/webtopay/payment.rb |