razorpay 2.4.0 → 2.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -1
- data/lib/razorpay/constants.rb +1 -1
- data/lib/razorpay/request.rb +1 -1
- data/lib/razorpay/utility.rb +5 -4
- data/test/razorpay/test_razorpay.rb +2 -2
- data/test/razorpay/test_utility.rb +6 -4
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2bfaf6eed8197ba96d0e861fc499da1b7bf502602330f005d32edda91971fcb6
|
|
4
|
+
data.tar.gz: 59e845994a4d2865e3832709d5aa6afc7bbc038f4655033e5e445843f1bad13d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 35657de03884f8dd1fd50e038f318586ac8520653c9f75bb66dae4363c1a558122362a21f0f843cb1d7d685612c4a47c9c465bb5485e43b4a2fe4b6dd5dd84ea
|
|
7
|
+
data.tar.gz: d753fdf647555ac0084b4341e6e27a9bf998b9b9d32e2e6ffab9976fa1ab51b79c11653ad6ef36d8ea7f4afa53ccfaa64f47878e15fb95966d9d2a3e56309ba4
|
data/CHANGELOG.md
CHANGED
|
@@ -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.
|
|
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
|
data/lib/razorpay/constants.rb
CHANGED
data/lib/razorpay/request.rb
CHANGED
|
@@ -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)
|
data/lib/razorpay/utility.rb
CHANGED
|
@@ -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
|
|
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
|
-
|
|
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: '
|
|
12
|
+
razorpay_order_id: 'fake_other_id',
|
|
13
13
|
razorpay_payment_id: 'fake_payment_id',
|
|
14
|
-
razorpay_signature: '
|
|
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
|
-
|
|
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.
|
|
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-
|
|
12
|
+
date: 2019-04-09 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: httparty
|