Sha256: 2f29a841ac583d6c904024c019eff2ba62adff5a9f924adddfeeaf5721c85a58
Contents?: true
Size: 1.33 KB
Versions: 1
Compression:
Stored size: 1.33 KB
Contents
# -*- encoding : utf-8 -*- require 'rubykassa/signature_generator' module Rubykassa class PaymentInterface include SignatureGenerator PARAMS_CONFORMITY = { login: "MrchLogin", total: "OutSum", invoice_id: "InvId", signature: "SignatureValue", email: "Email", currency: "IncCurrLabel", description: "Desc", culture: "Culture" } attr_accessor :invoice_id, :total, :params def initialize &block instance_eval &block if block_given? end def test_mode? Rubykassa.mode == :test end def base_url test_mode? ? "http://test.robokassa.ru/Index.aspx" : "https://merchant.roboxchange.com/Index.aspx" end def pay_url(options = {}) options = options.slice(:currency, :description, :email, :culture) "#{base_url}?" + initial_options.merge(options).map do |key, value| if key =~ /^shp/ "#{key}=#{value}" else "#{PARAMS_CONFORMITY[key]}=#{value}" end end.compact.join("&") end def initial_options { login: Rubykassa.login, total: @total, invoice_id: @invoice_id, signature: generate_signature_for(:payment) }.merge(Hash[@params.sort.map {|param_name| ["shp#{param_name[0]}".to_sym, param_name[1]]}]) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rubykassa-0.2.5 | lib/rubykassa/payment_interface.rb |