razorpay 2.0.1 → 2.1.0.pre
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 +6 -1
- data/Rakefile +1 -1
- data/lib/razorpay.rb +1 -0
- data/lib/razorpay/constants.rb +1 -1
- data/lib/razorpay/payment.rb +4 -0
- data/lib/razorpay/request.rb +7 -4
- data/lib/razorpay/virtual_account.rb +33 -0
- data/test/fixtures/fake_payment_bank_transfer.json +12 -0
- data/test/fixtures/fake_virtual_account.json +21 -0
- data/test/fixtures/fake_virtual_account_closed.json +21 -0
- data/test/fixtures/fake_virtual_account_collection.json +48 -0
- data/test/razorpay/test_virtual_account.rb +72 -0
- data/test/test_helper.rb +11 -7
- metadata +16 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b464a4ac1b55d618bb1af484eba8f9cb07fb8ae7
|
4
|
+
data.tar.gz: 8e2d8c5f6c9abd7f08bf7beee1c643fa86b10e64
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 10acefb42404585616e9f17092c1f85da4f5cea75b9e83d3f453b9c35dfbca7c77307da27e04edc7b9020da51d72465c0ff7702b0018b174e0beb6ad9e8bd640
|
7
|
+
data.tar.gz: 765e74db5ff99dd15b4f1c078497f1e6532bbe3e96b723c6bb967b3b8d554cefb4c30f9ecdf3e627a652b293ca0d5c137c95b45da4a22a1164efaa91fda58e68
|
data/CHANGELOG
CHANGED
@@ -4,6 +4,10 @@ Changelog for Razorpay-Ruby SDK.
|
|
4
4
|
|
5
5
|
## Unreleased
|
6
6
|
|
7
|
+
## [2.1.0.pre] - 2017-08-17
|
8
|
+
### Added
|
9
|
+
- Support for Virtual Accounts
|
10
|
+
|
7
11
|
## [2.0.1] - 2017-07-31
|
8
12
|
### Fixed
|
9
13
|
- Webhook signature verification
|
@@ -50,7 +54,8 @@ Changelog for Razorpay-Ruby SDK.
|
|
50
54
|
### Added
|
51
55
|
- Initial Release
|
52
56
|
|
53
|
-
[Unreleased]: https://github.com/razorpay/razorpay-ruby/compare/2.0.
|
57
|
+
[Unreleased]: https://github.com/razorpay/razorpay-ruby/compare/2.1.0.pre...HEAD
|
58
|
+
[2.1.0.pre]: https://github.com/razorpay/razorpay-ruby/compare/2.0.1...2.1.0.pre
|
54
59
|
[2.0.1]: https://github.com/razorpay/razorpay-ruby/compare/2.0.0...2.0.1
|
55
60
|
[2.0.0]: https://github.com/razorpay/razorpay-ruby/compare/1.2.1...2.0.0
|
56
61
|
[1.2.1]: https://github.com/razorpay/razorpay-ruby/compare/1.2.0...1.2.1
|
data/Rakefile
CHANGED
@@ -16,7 +16,7 @@ task :rubocop do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
FileList['test/razorpay/test_*.rb'].each do |file|
|
19
|
-
group = File.basename(file, '.rb').split('_').
|
19
|
+
group = File.basename(file, '.rb').split('_').drop(1).join('_').to_sym
|
20
20
|
Rake::TestTask.new(group) do |t|
|
21
21
|
t.libs << 'test'
|
22
22
|
t.test_files = [file]
|
data/lib/razorpay.rb
CHANGED
data/lib/razorpay/constants.rb
CHANGED
data/lib/razorpay/payment.rb
CHANGED
data/lib/razorpay/request.rb
CHANGED
@@ -46,6 +46,10 @@ module Razorpay
|
|
46
46
|
request :put, "/#{@entity_name}/#{id}", data
|
47
47
|
end
|
48
48
|
|
49
|
+
def patch(id, data = {})
|
50
|
+
request :patch, "/#{@entity_name}/#{id}", data
|
51
|
+
end
|
52
|
+
|
49
53
|
def create(data)
|
50
54
|
request :post, "/#{@entity_name}", data
|
51
55
|
end
|
@@ -54,9 +58,7 @@ module Razorpay
|
|
54
58
|
case method
|
55
59
|
when :get
|
56
60
|
@options[:query] = data
|
57
|
-
when :post
|
58
|
-
@options[:body] = data
|
59
|
-
when :put
|
61
|
+
when :post, :put, :patch
|
60
62
|
@options[:body] = data
|
61
63
|
end
|
62
64
|
create_instance self.class.send(method, url, @options)
|
@@ -77,8 +79,9 @@ module Razorpay
|
|
77
79
|
|
78
80
|
# There must be a top level entity
|
79
81
|
# This is either one of payment, refund, or collection at present
|
80
|
-
class_name = response['entity'].capitalize
|
81
82
|
begin
|
83
|
+
class_name = response['entity'].split('_').collect(&:capitalize).join
|
84
|
+
|
82
85
|
klass = Razorpay.const_get class_name
|
83
86
|
rescue NameError
|
84
87
|
# Use Entity class if we don't find any
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'razorpay/request'
|
2
|
+
require 'razorpay/entity'
|
3
|
+
|
4
|
+
module Razorpay
|
5
|
+
# Virtual Account API allows you to create and
|
6
|
+
# manage virtual accounts with Razorpay
|
7
|
+
class VirtualAccount < Entity
|
8
|
+
def self.request
|
9
|
+
Razorpay::Request.new('virtual_accounts')
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.create(options)
|
13
|
+
request.create options
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.fetch(id)
|
17
|
+
request.fetch id
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.all(options = {})
|
21
|
+
request.all options
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.close(id)
|
25
|
+
request.patch id, status: 'closed'
|
26
|
+
end
|
27
|
+
|
28
|
+
def payments(options = {})
|
29
|
+
r = self.class.request
|
30
|
+
r.request :get, "/virtual_accounts/#{id}/payments", options
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
{
|
2
|
+
"payment_id" : "fake_payment_id",
|
3
|
+
"virtual_account_id" : "va_4xbQrmEoA5WJ0G",
|
4
|
+
"amount" : 900,
|
5
|
+
"payer_bank_account" : {
|
6
|
+
"id" : "ba_8JpVEbAkzgjtuB",
|
7
|
+
"entity" : "bank_account",
|
8
|
+
"account_number" : "765432123456789",
|
9
|
+
"ifsc" : "RAZR0000001",
|
10
|
+
"name" : "Merchant Billing Label"
|
11
|
+
}
|
12
|
+
}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
{
|
2
|
+
"id": "va_4xbQrmEoA5WJ0G",
|
3
|
+
"entity": "virtual_account",
|
4
|
+
"description": "First Virtual Account",
|
5
|
+
"customer_id": "cust_805c8oBQdBGPwS",
|
6
|
+
"status": "active",
|
7
|
+
"amount_paid": 0,
|
8
|
+
"notes": {
|
9
|
+
"reference_key": "reference_value"
|
10
|
+
},
|
11
|
+
"receivers": [
|
12
|
+
{
|
13
|
+
"id": "ba_4lsdkfldlteskf",
|
14
|
+
"entity": "bank_account",
|
15
|
+
"name": "Merchant Billing Label",
|
16
|
+
"account_number": "RAZORPAY9876543210",
|
17
|
+
"ifsc": "RZPB0000001"
|
18
|
+
}
|
19
|
+
],
|
20
|
+
"created_at": 1455696638
|
21
|
+
}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
{
|
2
|
+
"id": "va_4xbQrmEoA5WJ0G",
|
3
|
+
"entity": "virtual_account",
|
4
|
+
"description": "First Virtual Account",
|
5
|
+
"customer_id": "cust_805c8oBQdBGPwS",
|
6
|
+
"status": "closed",
|
7
|
+
"amount_paid": 900,
|
8
|
+
"notes": {
|
9
|
+
"reference_key": "reference_value"
|
10
|
+
},
|
11
|
+
"receivers": [
|
12
|
+
{
|
13
|
+
"id": "ba_4lsdkfldlteskf",
|
14
|
+
"entity": "bank_account",
|
15
|
+
"name": "Merchant Billing Label",
|
16
|
+
"account_number": "RAZORPAY9876543210",
|
17
|
+
"ifsc": "RZPB0000001"
|
18
|
+
}
|
19
|
+
],
|
20
|
+
"created_at": 1455696638
|
21
|
+
}
|
@@ -0,0 +1,48 @@
|
|
1
|
+
{
|
2
|
+
"entity": "collection",
|
3
|
+
"count": 2,
|
4
|
+
"items": [
|
5
|
+
{
|
6
|
+
"id": "va_84lyVss1CRZ6eM",
|
7
|
+
"entity": "virtual_account",
|
8
|
+
"name": "Merchant Billing Label",
|
9
|
+
"description": "Second Virtual Account",
|
10
|
+
"status": "active",
|
11
|
+
"amount_paid": 1200,
|
12
|
+
"notes": [],
|
13
|
+
"customer_id": null,
|
14
|
+
"receivers": [
|
15
|
+
{
|
16
|
+
"id": "ba_87txVas2oSzzvx",
|
17
|
+
"entity": "bank_account",
|
18
|
+
"name": "Merchant Billing Label",
|
19
|
+
"account_number": "RAZORPAY9KWHB7BL92",
|
20
|
+
"ifsc": "RZPB0000001"
|
21
|
+
}
|
22
|
+
],
|
23
|
+
"created_at": 1497873405
|
24
|
+
},
|
25
|
+
{
|
26
|
+
"id": "va_4xbQrmEoA5WJ0G",
|
27
|
+
"entity": "virtual_account",
|
28
|
+
"name": "Merchant Billing Label",
|
29
|
+
"description": "First Virtual Account",
|
30
|
+
"status": "active",
|
31
|
+
"amount_paid": 900,
|
32
|
+
"notes": {
|
33
|
+
"reference_key": "reference_value"
|
34
|
+
},
|
35
|
+
"receivers": [
|
36
|
+
{
|
37
|
+
"id": "ba_4lsdkfldlteskf",
|
38
|
+
"entity": "bank_account",
|
39
|
+
"name": "Merchant Billing Label",
|
40
|
+
"account_number": "RAZORPAY9876543210",
|
41
|
+
"ifsc": "RZPB0000001"
|
42
|
+
}
|
43
|
+
],
|
44
|
+
"customer_id": "cust_805c8oBQdBGPwS",
|
45
|
+
"created_at": 1497922042
|
46
|
+
}
|
47
|
+
]
|
48
|
+
}
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Razorpay
|
4
|
+
# Tests for Razorpay::VirtualAccount
|
5
|
+
class RazorpayVirtualAccountTest < Minitest::Test
|
6
|
+
def setup
|
7
|
+
@virtual_account_id = 'va_4xbQrmEoA5WJ0G'
|
8
|
+
|
9
|
+
@virtual_account_create_array = {
|
10
|
+
receiver_types: ['bank_account'],
|
11
|
+
description: 'First Virtual Account'
|
12
|
+
}
|
13
|
+
|
14
|
+
# Any request that ends with virtual_accounts/id
|
15
|
+
stub_get(%r{virtual_accounts/#{@virtual_account_id}$}, 'fake_virtual_account')
|
16
|
+
stub_get(/virtual_accounts$/, 'fake_virtual_account_collection')
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_virtual_account_should_be_defined
|
20
|
+
refute_nil Razorpay::VirtualAccount
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_virtual_account_should_be_created
|
24
|
+
stub_post(
|
25
|
+
/virtual_accounts$/,
|
26
|
+
'fake_virtual_account',
|
27
|
+
'receiver_types[]=bank_account&description=First%20Virtual%20Account'
|
28
|
+
)
|
29
|
+
|
30
|
+
virtual_account = Razorpay::VirtualAccount.create @virtual_account_create_array
|
31
|
+
assert_equal 'First Virtual Account', virtual_account.description
|
32
|
+
assert_equal 'active', virtual_account.status
|
33
|
+
refute_empty virtual_account.receivers
|
34
|
+
|
35
|
+
receiver = virtual_account.receivers.first
|
36
|
+
assert_includes receiver.keys, 'account_number'
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_close_virtual_account
|
40
|
+
stub_patch(%r{virtual_accounts/#{@virtual_account_id}$}, 'fake_virtual_account_closed', 'status=closed')
|
41
|
+
virtual_account = Razorpay::VirtualAccount.close(@virtual_account_id)
|
42
|
+
assert_instance_of Razorpay::VirtualAccount, virtual_account
|
43
|
+
assert_equal 'closed', virtual_account.status
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_fetch_all_virtual_accounts
|
47
|
+
virtual_accounts = Razorpay::VirtualAccount.all
|
48
|
+
assert_instance_of Razorpay::Collection, virtual_accounts
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_fetch_specific_virtual_account
|
52
|
+
virtual_account = Razorpay::VirtualAccount.fetch(@virtual_account_id)
|
53
|
+
assert_instance_of Razorpay::VirtualAccount, virtual_account
|
54
|
+
assert_equal @virtual_account_id, virtual_account.id
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_fetch_payment_bank_transfer
|
58
|
+
stub_get(%r{payments/fake_payment_id$$}, 'fake_payment')
|
59
|
+
stub_get(%r{payments/fake_payment_id/bank_transfer$}, 'fake_payment_bank_transfer')
|
60
|
+
bank_transfer = Razorpay::Payment.fetch('fake_payment_id').bank_transfer
|
61
|
+
assert_equal @virtual_account_id, bank_transfer.virtual_account_id
|
62
|
+
assert_equal 'fake_payment_id', bank_transfer.payment_id
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_fetch_virtual_account_payments
|
66
|
+
stub_get(/payments$/, 'payment_collection')
|
67
|
+
payments = Razorpay::VirtualAccount.fetch(@virtual_account_id).payments
|
68
|
+
assert_instance_of Razorpay::Collection, payments, 'Payments should be an array'
|
69
|
+
assert !payments.items.empty?, 'Payments should be more than one'
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -25,17 +25,21 @@ def stub_get(*args)
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def stub_post(*args)
|
28
|
-
|
29
|
-
data = args.pop
|
30
|
-
response = stub_response(*args)
|
31
|
-
url = args[0]
|
32
|
-
stub_request(:post, url).with(body: data).to_return(response)
|
28
|
+
stub_request_with_body(:post, *args)
|
33
29
|
end
|
34
30
|
|
35
31
|
def stub_put(*args)
|
36
|
-
|
32
|
+
stub_request_with_body(:put, *args)
|
33
|
+
end
|
34
|
+
|
35
|
+
def stub_patch(*args)
|
36
|
+
stub_request_with_body(:patch, *args)
|
37
|
+
end
|
38
|
+
|
39
|
+
def stub_request_with_body(verb, *args)
|
40
|
+
# The last argument is the data
|
37
41
|
data = args.pop
|
38
42
|
response = stub_response(*args)
|
39
43
|
url = args[0]
|
40
|
-
stub_request(
|
44
|
+
stub_request(verb, url).with(body: data).to_return(response)
|
41
45
|
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.0.
|
4
|
+
version: 2.1.0.pre
|
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: 2017-
|
12
|
+
date: 2017-08-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -131,6 +131,7 @@ files:
|
|
131
131
|
- lib/razorpay/refund.rb
|
132
132
|
- lib/razorpay/request.rb
|
133
133
|
- lib/razorpay/utility.rb
|
134
|
+
- lib/razorpay/virtual_account.rb
|
134
135
|
- razorpay-ruby.gemspec
|
135
136
|
- test/fixtures/bad_request_error.json
|
136
137
|
- test/fixtures/customer_collection.json
|
@@ -142,7 +143,11 @@ files:
|
|
142
143
|
- test/fixtures/fake_order.json
|
143
144
|
- test/fixtures/fake_payment.json
|
144
145
|
- test/fixtures/fake_payment_authorized_webhook.json
|
146
|
+
- test/fixtures/fake_payment_bank_transfer.json
|
145
147
|
- test/fixtures/fake_refund.json
|
148
|
+
- test/fixtures/fake_virtual_account.json
|
149
|
+
- test/fixtures/fake_virtual_account_closed.json
|
150
|
+
- test/fixtures/fake_virtual_account_collection.json
|
146
151
|
- test/fixtures/hello_response.json
|
147
152
|
- test/fixtures/invoice_collection.json
|
148
153
|
- test/fixtures/order_collection.json
|
@@ -161,6 +166,7 @@ files:
|
|
161
166
|
- test/razorpay/test_razorpay.rb
|
162
167
|
- test/razorpay/test_refund.rb
|
163
168
|
- test/razorpay/test_utility.rb
|
169
|
+
- test/razorpay/test_virtual_account.rb
|
164
170
|
- test/test_helper.rb
|
165
171
|
homepage: https://razorpay.com/
|
166
172
|
licenses:
|
@@ -177,12 +183,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
177
183
|
version: '0'
|
178
184
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
179
185
|
requirements:
|
180
|
-
- - "
|
186
|
+
- - ">"
|
181
187
|
- !ruby/object:Gem::Version
|
182
|
-
version:
|
188
|
+
version: 1.3.1
|
183
189
|
requirements: []
|
184
190
|
rubyforge_project:
|
185
|
-
rubygems_version: 2.
|
191
|
+
rubygems_version: 2.6.12
|
186
192
|
signing_key:
|
187
193
|
specification_version: 4
|
188
194
|
summary: Razorpay's Ruby API
|
@@ -197,7 +203,11 @@ test_files:
|
|
197
203
|
- test/fixtures/fake_order.json
|
198
204
|
- test/fixtures/fake_payment.json
|
199
205
|
- test/fixtures/fake_payment_authorized_webhook.json
|
206
|
+
- test/fixtures/fake_payment_bank_transfer.json
|
200
207
|
- test/fixtures/fake_refund.json
|
208
|
+
- test/fixtures/fake_virtual_account.json
|
209
|
+
- test/fixtures/fake_virtual_account_closed.json
|
210
|
+
- test/fixtures/fake_virtual_account_collection.json
|
201
211
|
- test/fixtures/hello_response.json
|
202
212
|
- test/fixtures/invoice_collection.json
|
203
213
|
- test/fixtures/order_collection.json
|
@@ -216,4 +226,5 @@ test_files:
|
|
216
226
|
- test/razorpay/test_razorpay.rb
|
217
227
|
- test/razorpay/test_refund.rb
|
218
228
|
- test/razorpay/test_utility.rb
|
229
|
+
- test/razorpay/test_virtual_account.rb
|
219
230
|
- test/test_helper.rb
|