Class: Platidoma::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/platidoma/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Client

Returns a new instance of Client.



6
7
8
9
10
# File 'lib/platidoma/client.rb', line 6

def initialize(args)
  self.shop_id = args[:shop_id]
  self. = args[:login]
  self.gate_password = args[:gate_password]
end

Instance Attribute Details

#gate_passwordObject

Returns the value of attribute gate_password.



4
5
6
# File 'lib/platidoma/client.rb', line 4

def gate_password
  @gate_password
end

#loginObject

Returns the value of attribute login.



4
5
6
# File 'lib/platidoma/client.rb', line 4

def 
  @login
end

#shop_idObject

Returns the value of attribute shop_id.



4
5
6
# File 'lib/platidoma/client.rb', line 4

def shop_id
  @shop_id
end

Instance Method Details

#build_payment_sign(args) ⇒ Object



12
13
14
15
16
17
# File 'lib/platidoma/client.rb', line 12

def build_payment_sign(args)
  amount = args[:amount]
  rnd = args[:rnd]
  #FIXME преоброзование суммы к формату .xx
  Digest::MD5.hexdigest("#{shop_id}:#{}:#{gate_password}:#{rnd}:#{amount}.00")
end

#build_payment_url(args) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/platidoma/client.rb', line 27

def build_payment_url(args)
  params = { 
    pd_shop_id: shop_id, 
    pd_login: , 
    pd_amount: "#{args[:amount]}.00", 
    pd_order_id: args[:order_id], 
    pd_email: args[:email],
    pd_rnd: args[:rnd],
    pd_sign: args[:sign]
  }

  uri = ::Addressable::URI.new
  uri.query_values = params

  "https://#{Platidoma.configuration.host}/payment.php?#{uri.query}"

end

#build_status_sign(args) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/platidoma/client.rb', line 19

def build_status_sign(args)
  amount = args[:amount]
  rnd = args[:rnd]
  trans_id = args[:trans_id]
  order_id = args[:order_id]
  Digest::MD5.hexdigest("#{shop_id}:#{}:#{gate_password}:#{rnd}:#{trans_id}:#{order_id}:#{amount}.00")
end

#get_status(args) ⇒ Object



46
47
48
49
# File 'lib/platidoma/client.rb', line 46

def get_status(args)
  response = client_proxy.get_status(args).perform
  Response::GetStatus.parse(response.body).pd_status if response.success?
end