razorpay 2.3.0 → 2.4.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: cd8a703b64189d31348ac44fccf9edef384ff5af
4
- data.tar.gz: f007b3cd479849931bda5fc5f59d584f4a15e18b
2
+ SHA256:
3
+ metadata.gz: 39cc293b9e35da57fbe365e94ee9d46d9c21d7843d8e08f40382d9683d5dac8a
4
+ data.tar.gz: '086f7b483c58b0841a5b4a7cc677f4d4cc083536b0999f5abff1986287be0fe3'
5
5
  SHA512:
6
- metadata.gz: 6d0c677d255482d7378c2eecf523d3ee8ae9d106af592885613d6c08a4a2b5be24c39c9c1c8dba270029336e1a1a56dc385358b48e90ff3e80adf638dedcf266
7
- data.tar.gz: 942c7c1247d66d697b4f597125d5c2c145112e0ea62f1fa14c4fe5835c03607a13fdcce26c36185a4ccd0fd08cd08fbaeb260a4751e2983c105c7a9d0229a22c
6
+ metadata.gz: af4c5ba0f617c776ac5b4ad191062e9530eb1c70443bc1e030873f90edb8b6072a90e66d50e7b55da8d1cbf30f6f590cb94f51c67b6cb9383584cd1f44182aaa
7
+ data.tar.gz: 1ddbe5914250c4dd745da91780ad0ac9e35f13fee040490a4b49cd43f5a72a5882aeaec3af6b311220c3537af41b36e5348428dc746f0f8fe3a1f24cbcc45fe2
@@ -9,9 +9,6 @@ Metrics/LineLength:
9
9
  Style/SymbolArray:
10
10
  MinSize: 3
11
11
 
12
- Style/ClassVars:
13
- Enabled: false
14
-
15
12
  Metrics/MethodLength:
16
13
  Max: 15
17
14
 
@@ -19,3 +16,7 @@ Naming/UncommunicativeMethodParamName:
19
16
  MinNameLength: 1
20
17
  AllowNamesEndingInNumbers: false
21
18
 
19
+ # Near-duplicate of a file from an external package, want to keep changes minimal
20
+ AllCops:
21
+ Exclude:
22
+ - 'lib/extensions/httparty/hash_conversions.rb'
@@ -3,20 +3,16 @@ language: ruby
3
3
  # Merged with whatever is the top of each branch at https://www.ruby-lang.org/en/downloads/releases/
4
4
  matrix:
5
5
  include:
6
- - rvm: "1.9.3"
7
- - rvm: "2.0.0"
8
- - rvm: "2.1.10"
9
- - rvm: "2.2.9"
10
- - rvm: "2.3.6"
11
- - rvm: "2.4.2"
12
- - rvm: "2.5.0"
13
- - rvm: "2.5.0"
6
+ - rvm: "2.6.2"
7
+ - rvm: "2.5.5"
8
+ - rvm: "2.4.6"
14
9
  env: LINT=rubocop
15
10
  allow_failures:
16
11
  # These are EOL versions of ruby
17
- - rvm: "1.9.3"
18
- - rvm: "2.0.0"
12
+ - rvm: "2.3.8"
19
13
  - rvm: "2.1.10"
14
+ - rvm: "2.0.0"
15
+ - rvm: "1.9.3"
20
16
  before_install: gem update --system
21
17
  script:
22
18
  - bundle exec rake test
@@ -4,32 +4,56 @@ Changelog for Razorpay-Ruby SDK.
4
4
 
5
5
  ## Unreleased
6
6
 
7
+ ## [2.4.0] - 2019-04-08
8
+
9
+ ### Changed
10
+
11
+ - Indexed keys used in x-www-form-urlencoded request bodies [[#68][68]]
12
+ - Updated Utility verify\_\* methods to return verification bool [[#72][72]]
13
+
14
+ ### Added
15
+
16
+ - Support for custom JSON options to Entity to_json [[#75][75]]
17
+
7
18
  ## [2.3.0] - 2018-04-20
19
+
8
20
  ### Added
21
+
9
22
  - Support for subscription signature verification
10
23
  - Bang! methods (`capture!`, `refund!`) that update the calling entity
11
24
 
12
25
  ## [2.2.0] - 2018-01-29
26
+
13
27
  ### Added
28
+
14
29
  - Support for Subscriptions
15
30
 
16
31
  ## [2.1.0] - 2017-11-17
32
+
17
33
  ### Changed
34
+
18
35
  - Generic `Razorpay::Error` is thrown when server is unreachable
19
36
 
20
37
  ### Added
38
+
21
39
  - Support for making raw requests to the API via `raw_request`.
22
40
 
23
41
  ## [2.1.0.pre] - 2017-08-17
42
+
24
43
  ### Added
44
+
25
45
  - Support for Virtual Accounts
26
46
 
27
47
  ## [2.0.1] - 2017-07-31
48
+
28
49
  ### Fixed
50
+
29
51
  - Webhook signature verification
30
52
 
31
53
  ## [2.0.0] - 2017-03-02
54
+
32
55
  ### Added
56
+
33
57
  - Adds `require` for all Razorpay supported entities
34
58
  - All entity objects now throw `NoMethodError` instead of `NameError` if the attribute doesn't exist
35
59
  - Adds customer edit API
@@ -42,43 +66,63 @@ Changelog for Razorpay-Ruby SDK.
42
66
  - Adds rake test groups
43
67
 
44
68
  ## [1.2.1] - 2016-12-22
69
+
45
70
  ### Changed
71
+
46
72
  - Drops ArgumentError checks for local validation. Rely on server side checks instead.
47
73
 
48
74
  ### Added
75
+
49
76
  - Support for customers and invoices API
50
77
  - Loads Order class by default.
51
78
 
52
79
  ## [1.2.0] - 2016-11-23
80
+
53
81
  ### Added
82
+
54
83
  - Fixed payment.method as an attribute accessor
55
84
 
56
85
  ## [1.1.0] - 2016-02-25
86
+
57
87
  ### Added
88
+
58
89
  - Add support for Orders API
59
90
  - Bundles the CA Certificate with the gem. See #6
60
91
 
61
92
  ## [1.0.3] - 2015-03-31
93
+
62
94
  ### Changed
95
+
63
96
  - Handles error requests properly
64
97
 
65
98
  ## [1.0.1] - 2015-02-23
99
+
66
100
  ### Added
101
+
67
102
  - Added support for ruby versions below 2.0
68
103
 
69
104
  ## [1.0.0] - 2015-01-17
105
+
70
106
  ### Added
107
+
71
108
  - Initial Release
72
109
 
73
- [Unreleased]: https://github.com/razorpay/razorpay-ruby/compare/2.3.0...HEAD
74
- [2.3.0]: https://github.com/razorpay/razorpay-ruby/compare/2.2.0...2.3.0
75
- [2.2.0]: https://github.com/razorpay/razorpay-ruby/compare/2.1.0...2.2.0
76
- [2.1.0]: https://github.com/razorpay/razorpay-ruby/compare/2.0.1...2.1.0
77
- [2.1.0.pre]: https://github.com/razorpay/razorpay-ruby/compare/2.0.1...2.1.0.pre
78
- [2.0.1]: https://github.com/razorpay/razorpay-ruby/compare/2.0.0...2.0.1
79
- [2.0.0]: https://github.com/razorpay/razorpay-ruby/compare/1.2.1...2.0.0
80
- [1.2.1]: https://github.com/razorpay/razorpay-ruby/compare/1.2.0...1.2.1
81
- [1.2.0]: https://github.com/razorpay/razorpay-ruby/compare/1.1.0...1.2.0
82
- [1.1.0]: https://github.com/razorpay/razorpay-ruby/compare/1.0.3...1.1.0
83
- [1.0.3]: https://github.com/razorpay/razorpay-ruby/compare/1.0.1...1.0.3
84
- [1.0.1]: https://github.com/razorpay/razorpay-ruby/compare/1.0.0...1.0.1
110
+ # Diff
111
+
112
+ - [Unreleased](https://github.com/razorpay/razorpay-ruby/compare/2.4.0...HEAD)
113
+ - [2.4.0](https://github.com/razorpay/razorpay-ruby/compare/2.3.0...2.4.0)
114
+ - [2.3.0](https://github.com/razorpay/razorpay-ruby/compare/2.2.0...2.3.0)
115
+ - [2.2.0](https://github.com/razorpay/razorpay-ruby/compare/2.1.0...2.2.0)
116
+ - [2.1.0](https://github.com/razorpay/razorpay-ruby/compare/2.0.1...2.1.0)
117
+ - [2.1.0.pre](https://github.com/razorpay/razorpay-ruby/compare/2.0.1...2.1.0.pre)
118
+ - [2.0.1](https://github.com/razorpay/razorpay-ruby/compare/2.0.0...2.0.1)
119
+ - [2.0.0](https://github.com/razorpay/razorpay-ruby/compare/1.2.1...2.0.0)
120
+ - [1.2.1](https://github.com/razorpay/razorpay-ruby/compare/1.2.0...1.2.1)
121
+ - [1.2.0](https://github.com/razorpay/razorpay-ruby/compare/1.1.0...1.2.0)
122
+ - [1.1.0](https://github.com/razorpay/razorpay-ruby/compare/1.0.3...1.1.0)
123
+ - [1.0.3](https://github.com/razorpay/razorpay-ruby/compare/1.0.1...1.0.3)
124
+ - [1.0.1](https://github.com/razorpay/razorpay-ruby/compare/1.0.0...1.0.1)
125
+
126
+ [68]: https://github.com/razorpay/razorpay-ruby/pull/68
127
+ [72]: https://github.com/razorpay/razorpay-ruby/pull/72
128
+ [75]: https://github.com/razorpay/razorpay-ruby/pull/75
@@ -1,4 +1,4 @@
1
- Copyright (c) 2014 Razorpay
1
+ Copyright (c) 2019 Razorpay
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -191,10 +191,10 @@ only, the code is tested against the following versions:
191
191
  * 1.9.3
192
192
  * 2.0.0
193
193
  * 2.1.10
194
- * 2.2.9
195
- * 2.3.6
196
- * 2.4.2
197
- * 2.5.0
194
+ * 2.3.8
195
+ * 2.4.6
196
+ * 2.5.5
197
+ * 2.6.2
198
198
 
199
199
  ## Release
200
200
 
@@ -0,0 +1,44 @@
1
+ require 'httparty'
2
+
3
+ # :nocov:
4
+ module HTTParty
5
+ # Extension of HTTParty:HashConversions. Changes made to add index to arrays
6
+ # https://github.com/jnunemaker/httparty/blob/master/lib/httparty/hash_conversions.rb#L42,L55
7
+ module HashConversions
8
+ def self.normalize_keys(key, value)
9
+ stack = []
10
+ normalized_keys = []
11
+
12
+ if value.respond_to?(:to_ary)
13
+ if value.empty?
14
+ normalized_keys << ["#{key}[]", '']
15
+ else
16
+ normalized_keys = value.to_ary.flat_map.with_index do
17
+ |element, index| normalize_keys("#{key}[#{index}]", element)
18
+ end
19
+ end
20
+ elsif value.respond_to?(:to_hash)
21
+ stack << [key, value.to_hash]
22
+ else
23
+ normalized_keys << [key.to_s, value]
24
+ end
25
+
26
+ stack.each do |parent, hash|
27
+ hash.each do |child_key, child_value|
28
+ if child_value.respond_to?(:to_hash)
29
+ stack << ["#{parent}[#{child_key}]", child_value.to_hash]
30
+ elsif child_value.respond_to?(:to_ary)
31
+ child_value.to_ary.each_with_index do |v, index|
32
+ normalized_keys << normalize_keys("#{parent}[#{child_key}][#{index}]", v).flatten
33
+ end
34
+ else
35
+ normalized_keys << normalize_keys("#{parent}[#{child_key}]", child_value).flatten
36
+ end
37
+ end
38
+ end
39
+
40
+ normalized_keys
41
+ end
42
+ end
43
+ end
44
+ # :nocov:
@@ -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.3.0'.freeze
5
+ VERSION = '2.4.0'.freeze
6
6
  end
@@ -28,8 +28,8 @@ module Razorpay
28
28
 
29
29
  # Public: Convert the Entity object to JSON
30
30
  # Returns the JSON representation of the Entity (as a string)
31
- def to_json
32
- @attributes.to_json
31
+ def to_json(*args)
32
+ @attributes.to_json(*args)
33
33
  end
34
34
 
35
35
  # Mutates the entity in accordance with
@@ -1,5 +1,6 @@
1
- require 'razorpay/constants'
2
1
  require 'httparty'
2
+ require 'extensions/httparty/hash_conversions'
3
+ require 'razorpay/constants'
3
4
 
4
5
  module Razorpay
5
6
  # Request objects are used to create fetch
@@ -28,6 +28,8 @@ module Razorpay
28
28
  verified = secure_compare(expected_signature, signature)
29
29
 
30
30
  raise SecurityError, 'Signature verification failed' unless verified
31
+
32
+ verified
31
33
  end
32
34
 
33
35
  def secure_compare(a, b)
@@ -44,6 +44,10 @@ module Razorpay
44
44
  assert_equal '{"a":1}', @entity.to_json
45
45
  end
46
46
 
47
+ def test_json_conversion_with_args
48
+ assert_equal '{"a": 1}', @entity.to_json(space: ' ')
49
+ end
50
+
47
51
  def test_invalid_attribute_get
48
52
  assert_raises(NoMethodError, 'It must raise a NoMethodError on invalid attribute') { @entity.b }
49
53
  end
@@ -51,6 +51,31 @@ module Razorpay
51
51
  assert_subscription_details(subscription)
52
52
  end
53
53
 
54
+ def test_subscription_should_be_created_with_upfront_amount
55
+ subscription_attrs = {
56
+ plan_id: 'fake_plan_id',
57
+ total_count: 12,
58
+ addons: [
59
+ { item: { amount: 100, currency: 'INR' } },
60
+ { item: { amount: 200, currency: 'INR' } }
61
+ ]
62
+ }
63
+
64
+ #
65
+ # Note that the stubbed request has the addons array
66
+ # indexed, ensuring that the right request is being built
67
+ #
68
+ # This test will fail if the request sends
69
+ # "addons[][item][amount]=100&addons[][item][currency]=INR" instead
70
+ #
71
+ stub_params = 'plan_id=fake_plan_id&total_count=12&' \
72
+ 'addons[0][item][amount]=100&addons[0][item][currency]=INR&' \
73
+ 'addons[1][item][amount]=200&addons[1][item][currency]=INR'
74
+ stub_post(/subscriptions$/, 'fake_subscription', stub_params)
75
+
76
+ Razorpay::Subscription.create subscription_attrs
77
+ end
78
+
54
79
  def test_subscription_can_be_cancelled_by_subscription_id
55
80
  stub_post(%r{subscriptions\/#{@subscription_id}\/cancel$}, 'cancel_subscription', {})
56
81
  subscription = Razorpay::Subscription.cancel(@subscription_id)
@@ -24,7 +24,7 @@ module Razorpay
24
24
  stub_post(
25
25
  /virtual_accounts$/,
26
26
  'fake_virtual_account',
27
- 'receiver_types[]=bank_account&description=First%20Virtual%20Account'
27
+ 'receiver_types[0]=bank_account&description=First%20Virtual%20Account'
28
28
  )
29
29
 
30
30
  virtual_account = Razorpay::VirtualAccount.create @virtual_account_create_array
@@ -8,6 +8,7 @@ Coveralls.wear! if ENV['CI']
8
8
 
9
9
  def fixture_file(filename)
10
10
  return '' if filename == ''
11
+
11
12
  file_path = File.expand_path(File.dirname(__FILE__) + '/fixtures/' + filename + '.json')
12
13
  File.read(file_path)
13
14
  end
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.3.0
4
+ version: 2.4.0
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: 2018-04-20 00:00:00.000000000 Z
12
+ date: 2019-04-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty
@@ -114,6 +114,7 @@ files:
114
114
  - README.md
115
115
  - Rakefile
116
116
  - lib/ca-bundle.crt
117
+ - lib/extensions/httparty/hash_conversions.rb
117
118
  - lib/razorpay.rb
118
119
  - lib/razorpay/addon.rb
119
120
  - lib/razorpay/card.rb
@@ -205,8 +206,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
205
206
  - !ruby/object:Gem::Version
206
207
  version: '0'
207
208
  requirements: []
208
- rubyforge_project:
209
- rubygems_version: 2.5.1
209
+ rubygems_version: 3.0.1
210
210
  signing_key:
211
211
  specification_version: 4
212
212
  summary: Razorpay's Ruby API