razorpay 2.4.0 → 2.4.1

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
  SHA256:
3
- metadata.gz: 39cc293b9e35da57fbe365e94ee9d46d9c21d7843d8e08f40382d9683d5dac8a
4
- data.tar.gz: '086f7b483c58b0841a5b4a7cc677f4d4cc083536b0999f5abff1986287be0fe3'
3
+ metadata.gz: 2bfaf6eed8197ba96d0e861fc499da1b7bf502602330f005d32edda91971fcb6
4
+ data.tar.gz: 59e845994a4d2865e3832709d5aa6afc7bbc038f4655033e5e445843f1bad13d
5
5
  SHA512:
6
- metadata.gz: af4c5ba0f617c776ac5b4ad191062e9530eb1c70443bc1e030873f90edb8b6072a90e66d50e7b55da8d1cbf30f6f590cb94f51c67b6cb9383584cd1f44182aaa
7
- data.tar.gz: 1ddbe5914250c4dd745da91780ad0ac9e35f13fee040490a4b49cd43f5a72a5882aeaec3af6b311220c3537af41b36e5348428dc746f0f8fe3a1f24cbcc45fe2
6
+ metadata.gz: 35657de03884f8dd1fd50e038f318586ac8520653c9f75bb66dae4363c1a558122362a21f0f843cb1d7d685612c4a47c9c465bb5485e43b4a2fe4b6dd5dd84ea
7
+ data.tar.gz: d753fdf647555ac0084b4341e6e27a9bf998b9b9d32e2e6ffab9976fa1ab51b79c11653ad6ef36d8ea7f4afa53ccfaa64f47878e15fb95966d9d2a3e56309ba4
@@ -4,6 +4,16 @@ Changelog for Razorpay-Ruby SDK.
4
4
 
5
5
  ## Unreleased
6
6
 
7
+ ## [2.4.1] - 2019-04-09
8
+
9
+ ### Fixed
10
+
11
+ - Subscription signature verification [[#81][81]]
12
+
13
+ ### Added
14
+
15
+ - Ruby version to user agent header [[#79][79]]
16
+
7
17
  ## [2.4.0] - 2019-04-08
8
18
 
9
19
  ### Changed
@@ -109,7 +119,8 @@ Changelog for Razorpay-Ruby SDK.
109
119
 
110
120
  # Diff
111
121
 
112
- - [Unreleased](https://github.com/razorpay/razorpay-ruby/compare/2.4.0...HEAD)
122
+ - [Unreleased](https://github.com/razorpay/razorpay-ruby/compare/2.4.1...HEAD)
123
+ - [2.4.1](https://github.com/razorpay/razorpay-ruby/compare/2.4.0...2.4.1)
113
124
  - [2.4.0](https://github.com/razorpay/razorpay-ruby/compare/2.3.0...2.4.0)
114
125
  - [2.3.0](https://github.com/razorpay/razorpay-ruby/compare/2.2.0...2.3.0)
115
126
  - [2.2.0](https://github.com/razorpay/razorpay-ruby/compare/2.1.0...2.2.0)
@@ -126,3 +137,5 @@ Changelog for Razorpay-Ruby SDK.
126
137
  [68]: https://github.com/razorpay/razorpay-ruby/pull/68
127
138
  [72]: https://github.com/razorpay/razorpay-ruby/pull/72
128
139
  [75]: https://github.com/razorpay/razorpay-ruby/pull/75
140
+ [79]: https://github.com/razorpay/razorpay-ruby/pull/79
141
+ [81]: https://github.com/razorpay/razorpay-ruby/pull/81
@@ -2,5 +2,5 @@
2
2
  module Razorpay
3
3
  BASE_URI = 'https://api.razorpay.com/v1/'.freeze
4
4
  TEST_URL = 'https://api.razorpay.com/'.freeze
5
- VERSION = '2.4.0'.freeze
5
+ VERSION = '2.4.1'.freeze
6
6
  end
@@ -16,7 +16,7 @@ module Razorpay
16
16
  @entity_name = entity_name
17
17
  custom_headers = Razorpay.custom_headers || {}
18
18
  predefined_headers = {
19
- 'User-Agent' => "Razorpay-Ruby/#{Razorpay::VERSION}"
19
+ 'User-Agent' => "Razorpay-Ruby/#{Razorpay::VERSION}; Ruby/#{RUBY_VERSION}"
20
20
  }
21
21
  # Order is important to give precedence to predefined headers
22
22
  headers = custom_headers.merge(predefined_headers)
@@ -4,11 +4,12 @@ module Razorpay
4
4
  # Helper functions are defined here
5
5
  class Utility
6
6
  def self.verify_payment_signature(attributes)
7
- signature = attributes[:razorpay_signature]
8
- order_id = attributes[:razorpay_order_id] || attributes[:razorpay_subscription_id]
9
- payment_id = attributes[:razorpay_payment_id]
7
+ signature = attributes.delete(:razorpay_signature)
10
8
 
11
- data = [order_id, payment_id].join '|'
9
+ # Data requires the values to be in sorted order of their keys.
10
+ # attributes.sort returns a nested array, and the last
11
+ # element of each is the value. These are joined.
12
+ data = attributes.sort.map(&:last).join('|')
12
13
 
13
14
  secret = Razorpay.auth[:password]
14
15
 
@@ -22,7 +22,7 @@ module Razorpay
22
22
  stub_get(/$/, 'hello_response')
23
23
  Razorpay.headers = custom_headers
24
24
  Razorpay::Request.new('dummy').make_test_request
25
- user_agent = "Razorpay-Ruby/#{Razorpay::VERSION}"
25
+ user_agent = "Razorpay-Ruby/#{Razorpay::VERSION}; Ruby/#{RUBY_VERSION}"
26
26
  headers = { 'User-Agent' => user_agent, 'Authorization' => 'Basic a2V5X2lkOmtleV9zZWNyZXQ=' }
27
27
  headers = headers.merge(custom_headers)
28
28
  assert_requested :get, 'https://api.razorpay.com/',
@@ -43,7 +43,7 @@ module Razorpay
43
43
  def test_auth_header_and_user_agent
44
44
  stub_get(/$/, 'hello_response')
45
45
  Razorpay::Request.new('dummy').make_test_request
46
- user_agent = "Razorpay-Ruby/#{Razorpay::VERSION}"
46
+ user_agent = "Razorpay-Ruby/#{Razorpay::VERSION}; Ruby/#{RUBY_VERSION}"
47
47
  headers = { 'User-Agent' => user_agent, 'Authorization' => 'Basic a2V5X2lkOmtleV9zZWNyZXQ=' }
48
48
  assert_requested :get, 'https://api.razorpay.com/',
49
49
  headers: headers,
@@ -9,9 +9,9 @@ module Razorpay
9
9
 
10
10
  def test_payment_signature_verification
11
11
  payment_response = {
12
- razorpay_order_id: 'fake_order_id',
12
+ razorpay_order_id: 'fake_other_id',
13
13
  razorpay_payment_id: 'fake_payment_id',
14
- razorpay_signature: 'b2335e3b0801106b84a7faff035df56ecffde06918c9ddd1f0fafbb37a51cc89'
14
+ razorpay_signature: '965ee2de4c5c4e6f006fb0a5a1736d992e5d4d52f9fe10b98c9b97ee169ebe18'
15
15
  }
16
16
  Razorpay::Utility.verify_payment_signature(payment_response)
17
17
 
@@ -23,10 +23,12 @@ module Razorpay
23
23
 
24
24
  def test_subscription_signature_verification
25
25
  payment_response = {
26
- razorpay_subscription_id: 'fake_order_id',
27
26
  razorpay_payment_id: 'fake_payment_id',
28
- razorpay_signature: 'b2335e3b0801106b84a7faff035df56ecffde06918c9ddd1f0fafbb37a51cc89'
27
+ razorpay_subscription_id: 'fake_other_id',
28
+ razorpay_signature: '3dabcab8ca113e7994cf78c80f8d50974ddfb2d380029743f30a6d67934cd845'
29
29
  }
30
+ # A different signature is expected here compared to the previous test,
31
+ # since the sorted order of the keys is different in this case
30
32
  Razorpay::Utility.verify_payment_signature(payment_response)
31
33
 
32
34
  payment_response[:razorpay_signature] = '_dummy_signature' * 4
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: razorpay
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0
4
+ version: 2.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Abhay Rana
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-04-08 00:00:00.000000000 Z
12
+ date: 2019-04-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty