Class: Platidoma::Client
- Inherits:
-
Object
- Object
- Platidoma::Client
- Defined in:
- lib/platidoma/client.rb
Instance Attribute Summary collapse
-
#gate_password ⇒ Object
Returns the value of attribute gate_password.
-
#login ⇒ Object
Returns the value of attribute login.
-
#shop_id ⇒ Object
Returns the value of attribute shop_id.
Instance Method Summary collapse
- #build_payment_sign(args) ⇒ Object
- #build_payment_url(args) ⇒ Object
- #build_status_sign(args) ⇒ Object
- #get_status(args) ⇒ Object
-
#initialize(args) ⇒ Client
constructor
A new instance of Client.
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.login = args[:login] self.gate_password = args[:gate_password] end |
Instance Attribute Details
#gate_password ⇒ Object
Returns the value of attribute gate_password.
4 5 6 |
# File 'lib/platidoma/client.rb', line 4 def gate_password @gate_password end |
#login ⇒ Object
Returns the value of attribute login.
4 5 6 |
# File 'lib/platidoma/client.rb', line 4 def login @login end |
#shop_id ⇒ Object
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}:#{login}:#{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: 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}:#{login}:#{gate_password}:#{rnd}:#{trans_id}:#{order_id}:#{amount}.00") end |