Class: Payzilla::Gateways::Mailru

Inherits:
Gateway
  • Object
show all
Defined in:
lib/payzilla/gateways/mailru.rb

Instance Attribute Summary

Attributes inherited from Gateway

#config, #logger, #revision_page_size

Instance Method Summary collapse

Methods inherited from Gateway

available_attachments, available_settings, available_switches, can_list_providers, #can_list_providers?, can_list_providers?, #initialize, register_attachments, register_settings, register_switches, require_payment_fields, required_payment_fields, requires_revision, requires_revision?, #requires_revision?, #revise

Constructor Details

This class inherits a constructor from Payzilla::Gateways::Gateway

Instance Method Details

#check(payment) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/payzilla/gateways/mailru.rb', line 8

def check(payment)
  begin 
    result = send 'user/check', 
        :rcpt => payment.

    if result == 'OK'
      return {:success => true, :error => "0"}
    else
      result = result.split(':')[0].gsub('E', '').to_i
      return {:success => false, :error => result}
    end
  rescue Errno::ECONNRESET
    return retval(-1000)
  end
end

#pay(payment) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/payzilla/gateways/mailru.rb', line 24

def pay(payment)
  begin
    result = send 'payment/make',
      :rcpt        => payment.,
      :currency    => 'RUR',
      :sum         => payment.enrolled_amount,
      :description => Base64.encode64("Пополнение кошелька")

    if result[0] == 'E'
      result = result.split(':')[0].gsub('E', '').to_i
      return {:success => false, :error => result}
    else
      return {:success => true, :gateway_payment_id => result}
    end
  rescue Errno::ECONNRESET
    return retval(-1000)
  end
end