razorpay 2.0.0 → 2.0.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
  SHA1:
3
- metadata.gz: dc80169863413c4b51ebcd5dbc7a163a48c35a06
4
- data.tar.gz: 73f38b5fafff2e2933c112a54e7d3e418f9440a1
3
+ metadata.gz: 0c5e4a481b2e5c76f95a1b57784911d2c597a692
4
+ data.tar.gz: 11d9f4211bc2a291a43ddac976d562e16410907d
5
5
  SHA512:
6
- metadata.gz: 1740e3ece8cbdd0b3af137d861c8fecbeb880688df7f971d6780cd81bfac40a3341625e8f5d62dca1842f6a1a9015598c25737778fc0bd241accb0de8b4e7d52
7
- data.tar.gz: 56c6cbba384b3035cc9cb08a5d1ecdf5ca09401e0af7d1335d90e1a37962f455efaa9d5fb318af7f4acab7df690e1a00f29d11ee9b8733cc5f13f7d92733c4e5
6
+ metadata.gz: 75d442e5f84558f8dd223410450efe0c0e59ab9581c5418c24506332cf13e3df22c1ea4fc0a0322aa39ff87129564b2ef941fca1b00ed23316a7f3d3999b02e4
7
+ data.tar.gz: 7dbb7b5703a9fb06f7f0b4ddc4525a0223f337aba26e2d6318de28cdb024c831ca795af4090cd4f6f0ee14b7ccd5b2f9f8ef596d345afc2ffa5681c448e98b1d
@@ -6,6 +6,9 @@ Metrics/LineLength:
6
6
  Max: 110
7
7
  AllowURI: true
8
8
 
9
+ Style/SymbolArray:
10
+ MinSize: 3
11
+
9
12
  Style/ClassVars:
10
13
  Enabled: false
11
14
 
data/CHANGELOG CHANGED
@@ -4,7 +4,11 @@ Changelog for Razorpay-Ruby SDK.
4
4
 
5
5
  ## Unreleased
6
6
 
7
- ## [2.0.0] - 2016-03-02
7
+ ## [2.0.1] - 2017-07-31
8
+ ### Fixed
9
+ - Webhook signature verification
10
+
11
+ ## [2.0.0] - 2017-03-02
8
12
  ### Added
9
13
  - Adds `require` for all Razorpay supported entities
10
14
  - All entity objects now throw `NoMethodError` instead of `NameError` if the attribute doesn't exist
@@ -46,7 +50,8 @@ Changelog for Razorpay-Ruby SDK.
46
50
  ### Added
47
51
  - Initial Release
48
52
 
49
- [Unreleased]: https://github.com/razorpay/razorpay-ruby/compare/2.0.0...HEAD
53
+ [Unreleased]: https://github.com/razorpay/razorpay-ruby/compare/2.0.1...HEAD
54
+ [2.0.1]: https://github.com/razorpay/razorpay-ruby/compare/2.0.0...2.0.1
50
55
  [2.0.0]: https://github.com/razorpay/razorpay-ruby/compare/1.2.1...2.0.0
51
56
  [1.2.1]: https://github.com/razorpay/razorpay-ruby/compare/1.2.0...1.2.1
52
57
  [1.2.0]: https://github.com/razorpay/razorpay-ruby/compare/1.1.0...1.2.0
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![Build Status](https://travis-ci.org/razorpay/razorpay-ruby.svg?branch=master)](https://travis-ci.org/razorpay/razorpay-ruby) [![Gem Version](https://badge.fury.io/rb/razorpay.svg)](http://badge.fury.io/rb/razorpay) [![Coverage Status](https://coveralls.io/repos/github/Razorpay/razorpay-ruby/badge.svg?branch=master)](https://coveralls.io/github/Razorpay/razorpay-ruby?branch=master) [![License](http://img.shields.io/:license-mit-blue.svg)](http://doge.mit-license.org)
4
4
 
5
- This is the base ruby gem for interacting with the Razorpay API. This is primarily meant for merchants who wish to perform interactions with the Razorpay API programatically.
5
+ This is the base ruby gem for interacting with the Razorpay API. This is primarily meant for users who wish to perform interactions with the Razorpay API programatically.
6
6
 
7
7
  ## Installation
8
8
 
@@ -27,7 +27,7 @@ Remember to `require razorpay` before anything else.
27
27
  Next, you need to setup your key and secret using the following:
28
28
 
29
29
  ```rb
30
- Razorpay.setup("merchant_key_id", "merchant_key_secret")
30
+ Razorpay.setup('key_id', 'key_secret')
31
31
  ```
32
32
 
33
33
  You can set customer headers for your requests using the following:
@@ -47,14 +47,14 @@ Razorpay::Payment.fetch("payment_id").capture({amount:500})
47
47
  # that the purchase was correctly done and not tampered
48
48
  ```
49
49
 
50
- You can handle refunds using the following constructs:
50
+ You can refund a payment via the following:
51
51
 
52
52
  ```rb
53
53
  Razorpay::Payment.fetch("payment_id").refund({amount:500})
54
54
  refunds = Razorpay::Payment.fetch("payment_id").refunds
55
55
  ```
56
56
 
57
- Refunds can also be handled without fetching payments:
57
+ A payment can also be refunded without fetching it:
58
58
  ```rb
59
59
  refund = Razorpay::Refund.create(payment_id:"payment_id")
60
60
  Razorpay::Refund.fetch(refund.id)
@@ -95,6 +95,10 @@ puts payment_response
95
95
  # }
96
96
  Razorpay::Utility.verify_payment_signature(payment_response)
97
97
  ```
98
+ You can also [verify the signature](https://github.com/razorpay/razorpay-ruby/wiki/Webhooks) received in a webhook:
99
+ ```rb
100
+ Razorpay::Utility.verify_webhook_signature(webhook_body, webhook_signature, webhook_secret)
101
+ ```
98
102
 
99
103
  ### Customers
100
104
  ```rb
@@ -110,7 +114,7 @@ card = Razorpay::Card.fetch('card_7EZLhWkDt05n7V')
110
114
  puts card.network #VISA
111
115
  ```
112
116
 
113
- You can find invoices API documentation at <https://docs.razorpay.com/v1/page/cards>.
117
+ You can find cards API documentation at <https://docs.razorpay.com/v1/page/cards>.
114
118
 
115
119
  ### Invoices
116
120
  ```rb
@@ -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.0.0'.freeze
5
+ VERSION = '2.0.1'.freeze
6
6
  end
@@ -10,19 +10,19 @@ module Razorpay
10
10
 
11
11
  data = [order_id, payment_id].join '|'
12
12
 
13
- verify_signature(signature, data)
13
+ secret = Razorpay.auth[:password]
14
+
15
+ verify_signature(data, signature, secret)
14
16
  end
15
17
 
16
- def self.verify_webhook_signature(signature, body)
17
- verify_signature(signature, body)
18
+ def self.verify_webhook_signature(body, signature, secret)
19
+ verify_signature(body, signature, secret)
18
20
  end
19
21
 
20
22
  class << self
21
23
  private
22
24
 
23
- def verify_signature(signature, data)
24
- secret = Razorpay.auth[:password]
25
-
25
+ def verify_signature(data, signature, secret)
26
26
  expected_signature = OpenSSL::HMAC.hexdigest('SHA256', secret, data)
27
27
 
28
28
  verified = secure_compare(expected_signature, signature)
@@ -1,4 +1,5 @@
1
1
  # coding: utf-8
2
+
2
3
  lib = File.expand_path('../lib', __FILE__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
5
  require 'razorpay/constants'
@@ -6,8 +7,8 @@ require 'razorpay/constants'
6
7
  Gem::Specification.new do |spec|
7
8
  spec.name = 'razorpay'
8
9
  spec.version = Razorpay::VERSION
9
- spec.authors = ['Abhay Rana']
10
- spec.email = ['nemo@razorpay.com']
10
+ spec.authors = ['Abhay Rana', 'Harman Singh']
11
+ spec.email = ['nemo@razorpay.com', 'harman@razorpay.com']
11
12
  spec.summary = "Razorpay's Ruby API"
12
13
  spec.description = 'Official ruby bindings for the Razorpay API'
13
14
  spec.homepage = 'https://razorpay.com/'
@@ -22,6 +23,6 @@ Gem::Specification.new do |spec|
22
23
  spec.add_development_dependency 'minitest', '~> 5.10'
23
24
  spec.add_development_dependency 'webmock', '~> 2.3'
24
25
  spec.add_development_dependency 'coveralls', '~> 0.8'
25
- spec.add_development_dependency 'rubocop', '~> 0.47'
26
+ spec.add_development_dependency 'rubocop', '~> 0.49'
26
27
  spec.add_dependency 'httparty', '~> 0.14'
27
28
  end
@@ -23,12 +23,13 @@ module Razorpay
23
23
 
24
24
  def test_webhook_signature_verification
25
25
  webhook_body = fixture_file('fake_payment_authorized_webhook')
26
- signature = 'd60e67fd884556c045e9be7dad57903e33efc7172c17c6e3ef77db42d2b366e9'
27
- Razorpay::Utility.verify_webhook_signature(signature, webhook_body)
26
+ secret = 'chosen_webhook_secret'
27
+ signature = 'dda9ca344c56ccbd90167b1be0fd99dfa92fe2b827020f27e2a46024e31c7c99'
28
+ Razorpay::Utility.verify_webhook_signature(webhook_body, signature, secret)
28
29
 
29
30
  signature = '_dummy_signature' * 4
30
31
  assert_raises(SecurityError) do
31
- Razorpay::Utility.verify_webhook_signature(signature, webhook_body)
32
+ Razorpay::Utility.verify_webhook_signature(webhook_body, signature, secret)
32
33
  end
33
34
  end
34
35
  end
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: razorpay
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Abhay Rana
8
+ - Harman Singh
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2017-03-02 00:00:00.000000000 Z
12
+ date: 2017-07-31 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: rake
@@ -72,14 +73,14 @@ dependencies:
72
73
  requirements:
73
74
  - - "~>"
74
75
  - !ruby/object:Gem::Version
75
- version: '0.47'
76
+ version: '0.49'
76
77
  type: :development
77
78
  prerelease: false
78
79
  version_requirements: !ruby/object:Gem::Requirement
79
80
  requirements:
80
81
  - - "~>"
81
82
  - !ruby/object:Gem::Version
82
- version: '0.47'
83
+ version: '0.49'
83
84
  - !ruby/object:Gem::Dependency
84
85
  name: httparty
85
86
  requirement: !ruby/object:Gem::Requirement
@@ -97,6 +98,7 @@ dependencies:
97
98
  description: Official ruby bindings for the Razorpay API
98
99
  email:
99
100
  - nemo@razorpay.com
101
+ - harman@razorpay.com
100
102
  executables: []
101
103
  extensions: []
102
104
  extra_rdoc_files: []