unitpay 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 257e71a55aae731c0562c38c7a23db75c6e67d38
4
- data.tar.gz: 9b7ba6ffaf048c0c0f4795ff0f1713d1b2a13b1d
3
+ metadata.gz: 5f80e17e37ec40c85f65d7db95d2081bfa69d3d1
4
+ data.tar.gz: 2df24e17305806bb4930decbe2ad3322cdc6dbe7
5
5
  SHA512:
6
- metadata.gz: da68e495ff7b77d5a7a4719bbebb283acf2c61af140e0d7b0789062b226c5eeb3175650d7e721db2268df10ecb46cd26fdf9c30bb2682a65f728bfef6785ff48
7
- data.tar.gz: 54b14a50c8cd1662060d3ce54ba93b528333ccb576ad2a4d5472181dea5bfa1ea20518c9e15a5d62413141d855bb0f1b2e2a1558f3a8c99b0400da63a2104fc3
6
+ metadata.gz: e05e226f14007a31c53ca259fd8f808639dc24efde617e718e4f844c5da1d6f3e09a9ab15608d3463c7206812832ea96ce25b824ecd82476b785f5fdbe083db3
7
+ data.tar.gz: 985a56a9a39e6358802242e29007d5ddcd590bedb0a84e6427debf9506f28d4afc10016b81e4caa8c411cb9ad91d35d82baf4ea3b4a0f386f7007d6ffe8dc188
@@ -3,8 +3,8 @@ module Unitpay
3
3
  EXTRA_OPTIONS = [:locale, :hideHint, :hideBackUrl, :hideOrderCost, :hideMenu, :hideDesc, :hideOtherMethods]
4
4
  URL = 'https://unitpay.ru/pay'
5
5
 
6
- def initialize(public_key, secret_key, currency = 'RUB')
7
- @public_key, @secret_key, @currency = public_key, secret_key, currency
6
+ def initialize(public_key, secret_key, use_sign = true, currency = 'RUB')
7
+ @public_key, @secret_key, @use_sign, @currency = public_key, secret_key, use_sign, currency
8
8
  end
9
9
 
10
10
  def payment_url(sum, account, desc, options = {})
@@ -12,7 +12,18 @@ module Unitpay
12
12
  end
13
13
 
14
14
  def payment_params(sum, account, desc, options = {})
15
- main_params(sum, account, desc, options[:use_sign]).merge(extra_params(options))
15
+ main_params(sum, account, desc).merge(extra_params(options))
16
+ end
17
+
18
+ def params_for_widget(sum, account, desc)
19
+ {
20
+ publicKey: public_key,
21
+ sum: sum,
22
+ account: account,
23
+ desc: desc,
24
+ currency: 'RUB',
25
+ sign: calculate_sign(sum, account, desc)
26
+ }
16
27
  end
17
28
 
18
29
  def valid_sign?(current_sign, sum, account, desc)
@@ -25,7 +36,7 @@ module Unitpay
25
36
 
26
37
  private
27
38
 
28
- attr_reader :public_key, :secret_key, :currency
39
+ attr_reader :public_key, :secret_key, :currency, :use_sign
29
40
 
30
41
  def calculate_sign(sum, account, desc)
31
42
  Digest::MD5.hexdigest( [account, currency, desc, sum, secret_key].join )
@@ -37,8 +48,7 @@ module Unitpay
37
48
  Digest::MD5.hexdigest(values.join)
38
49
  end
39
50
 
40
- def main_params(sum, account, desc, use_sign)
41
- use_sign = true if use_sign.nil?
51
+ def main_params(sum, account, desc)
42
52
  sign = use_sign ? { sign: calculate_sign(sum, account, desc) } : {}
43
53
 
44
54
  {
@@ -1,3 +1,3 @@
1
1
  module Unitpay
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unitpay
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - ssnikolay
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-11-29 00:00:00.000000000 Z
11
+ date: 2015-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler