Class: Rubykassa::PaymentInterface
- Inherits:
-
Object
- Object
- Rubykassa::PaymentInterface
- Includes:
- SignatureGenerator
- Defined in:
- lib/rubykassa/payment_interface.rb
Constant Summary collapse
- PARAMS_CONFORMITY =
{ login: "MrchLogin", total: "OutSum", invoice_id: "InvId", signature: "SignatureValue", email: "Email", currency: "IncCurrLabel", description: "Desc", culture: "Culture" }
Instance Attribute Summary collapse
-
#invoice_id ⇒ Object
Returns the value of attribute invoice_id.
-
#params ⇒ Object
Returns the value of attribute params.
-
#total ⇒ Object
Returns the value of attribute total.
Instance Method Summary collapse
- #base_url ⇒ Object
- #initial_options ⇒ Object
-
#initialize(&block) ⇒ PaymentInterface
constructor
A new instance of PaymentInterface.
- #pay_url(extra_params = {}) ⇒ Object
- #test_mode? ⇒ Boolean
Methods included from SignatureGenerator
#custom_params, #generate_signature_for, #params_string
Constructor Details
#initialize(&block) ⇒ PaymentInterface
Returns a new instance of PaymentInterface.
21 22 23 24 |
# File 'lib/rubykassa/payment_interface.rb', line 21 def initialize &block instance_eval &block if block_given? shpfy_params end |
Instance Attribute Details
#invoice_id ⇒ Object
Returns the value of attribute invoice_id.
19 20 21 |
# File 'lib/rubykassa/payment_interface.rb', line 19 def invoice_id @invoice_id end |
#params ⇒ Object
Returns the value of attribute params.
19 20 21 |
# File 'lib/rubykassa/payment_interface.rb', line 19 def params @params end |
#total ⇒ Object
Returns the value of attribute total.
19 20 21 |
# File 'lib/rubykassa/payment_interface.rb', line 19 def total @total end |
Instance Method Details
#base_url ⇒ Object
30 31 32 |
# File 'lib/rubykassa/payment_interface.rb', line 30 def base_url test_mode? ? "http://test.robokassa.ru/Index.aspx" : "https://merchant.roboxchange.com/Index.aspx" end |
#initial_options ⇒ Object
46 47 48 49 50 51 52 53 |
# File 'lib/rubykassa/payment_interface.rb', line 46 def { login: Rubykassa.login, total: @total, invoice_id: @invoice_id, signature: generate_signature_for(:payment) }.merge(Hash[@params.sort.map {|param_name| [param_name[0], param_name[1]]}]) end |
#pay_url(extra_params = {}) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/rubykassa/payment_interface.rb', line 34 def pay_url(extra_params = {}) extra_params = extra_params.slice(:currency, :description, :email, :culture) "#{base_url}?" + .merge(extra_params).map do |key, value| if key =~ /^shp/ "#{key}=#{value}" else "#{PARAMS_CONFORMITY[key]}=#{value}" end end.compact.join("&") end |
#test_mode? ⇒ Boolean
26 27 28 |
# File 'lib/rubykassa/payment_interface.rb', line 26 def test_mode? Rubykassa.mode == :test end |