razorpay 1.2.0 → 1.2.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: 17c4aad5f24c1236ebd6451887926d9bf5b45b34
4
- data.tar.gz: ae0ef8f24f6de62bdf014e9a22b0a70de095a924
3
+ metadata.gz: f1342dbfd634ead754a60f675870429894fdab71
4
+ data.tar.gz: f3b91327653aa94ac1e19e684223ffc9e7e890c7
5
5
  SHA512:
6
- metadata.gz: 127d16bbbc8b8a19a8cc4a0be9cab4d167781af3dd4fa847a4f9d7293044f732c5608f3eed52a82ec786280305fd80d5b35ddc3c448eeceaa5cd9f7f5652b012
7
- data.tar.gz: eefee7a5c5011b3f88e0efec3763fc16ecda6f7469bf3e65a732adc3db1c228cef45ac8dea52f43c5fa0f39a23df67c967e5c1de4427fbb6610988dc66f115f5
6
+ metadata.gz: 977fee36b31a1d7e44d0679eddf5593702387974a46438613383ea9f9588f84c3e9dbda7d6a05f719f22086a206ab5e07918eb474be04822b144cfb329d45bbd
7
+ data.tar.gz: 3e32025de35f357144a6da06a492e42c9efe20e93ef546cfc55bafb607dc4df6a3d9d13fcbb01f656a6ac6cbeb018d108c8e674b5e5f78956247d334dd871305
data/CHANGELOG CHANGED
@@ -2,7 +2,12 @@
2
2
 
3
3
  Changelog for Razorpay-Ruby SDK.
4
4
 
5
- ## Unreleased
5
+ ## [1.2.1] - 2016-12-22
6
+ ### Changed
7
+ - Drops ArgumentError checks for local validation. Rely on server side checks instead.
8
+ ### Added
9
+ - Support for customers and invoices API
10
+ - Loads Order class by default.
6
11
 
7
12
  ## [1.2.0] - 2016-11-23
8
13
  ### Added
@@ -25,7 +30,8 @@ Changelog for Razorpay-Ruby SDK.
25
30
  ### Added
26
31
  - Initial Release
27
32
 
28
- [Unreleased]: https://github.com/razorpay/razorpay-ruby/compare/1.2.0...HEAD
33
+ [Unreleased]: https://github.com/razorpay/razorpay-ruby/compare/1.2.1...HEAD
34
+ [1.2.1]: https://github.com/razorpay/razorpay-ruby/compare/1.2.0...1.2.1
29
35
  [1.2.0]: https://github.com/razorpay/razorpay-ruby/compare/1.1.0...1.2.0
30
36
  [1.1.0]: https://github.com/razorpay/razorpay-ruby/compare/1.0.3...1.1.0
31
37
  [1.0.3]: https://github.com/razorpay/razorpay-ruby/compare/1.0.1...1.0.3
data/README.md CHANGED
@@ -53,9 +53,9 @@ see our online documentation on <https://docs.razorpay.com>
53
53
 
54
54
  ### Orders API
55
55
 
56
- Send us a mail at <support@razorpay.com> to enable the Orders API
57
- for your account. You can use the orders API using the following
58
- constructs:
56
+ You can use the orders API using the following constructs:
57
+
58
+ You can find docs at <https://docs.razorpay.com/v1/page/orders>
59
59
 
60
60
  ```rb
61
61
  order = Razorpay::Order.create amount: 5000, currency: 'INR', receipt: 'TEST'
@@ -70,8 +70,17 @@ puts order.amount
70
70
 
71
71
  # Fetching payments corresponding to an order
72
72
  payments = order.payments
73
+
74
+ # Create a customer
75
+ customer = Razorpay::Customer.create email: 'test@razorpay.com', contact: '9876543210'
76
+ puts customer.id #cust_6vRXClWqnLhV14
77
+
78
+ # Creating an invoice
79
+ invoice = Razorpay::Invoice.create customer_id: customer.id, amount: 100, currency: 'INR', description: 'Test description', type: 'link'
73
80
  ```
74
81
 
82
+ You can find invoices API documentation at <https://docs.razorpay.com/v1/page/invoices>.
83
+
75
84
  ## Development
76
85
 
77
86
  - Everything is namespaced under the Razorpay module
@@ -90,3 +99,19 @@ payments = order.payments
90
99
  4. Commit your changes (`git commit -am 'Add some feature'`)
91
100
  5. Push to the branch (`git push origin my-new-feature`)
92
101
  6. Create a new Pull Request
102
+
103
+ ## Release
104
+
105
+ Steps to follow for a release:
106
+
107
+ 0. Merge the branch with the new code to master.
108
+ 1. Bump the Version in `lib/razorpay/constants.rb`
109
+ 2. Rename Unreleased to the new tag in `CHANGELOG`
110
+ 3. Fix links at bottom in `CHANGELOG`
111
+ 4. Commit (message should include version number)
112
+ 5. Tag the release and push to GitHub. Get the tag signed using Razorpay GPG key.
113
+ 6. Create a release on GitHub using the website with more details about the release
114
+ 7. Run `gem build razorpay-ruby.gemspec`
115
+ 8. Run `gem push razorpay-{version}.gem`
116
+
117
+ `gem push` will ask you for credentials, if you are not logged in already.
@@ -1,5 +1,6 @@
1
1
  require 'razorpay/constants'
2
2
  require 'razorpay/payment'
3
+ require 'razorpay/order'
3
4
 
4
5
  # Base Razorpay module
5
6
  module Razorpay
@@ -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 = '1.2.0'.freeze
5
+ VERSION = '1.2.1'.freeze
6
6
  end
@@ -0,0 +1,15 @@
1
+ require 'razorpay/request'
2
+ require 'razorpay/entity'
3
+
4
+ module Razorpay
5
+ # Customer API allows you to create customer IDs on Razorpay
6
+ class Customer < Entity
7
+ def self.request
8
+ Razorpay::Request.new('customers')
9
+ end
10
+
11
+ def self.create(options)
12
+ request.create options
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,24 @@
1
+ require 'razorpay/request'
2
+ require 'razorpay/entity'
3
+
4
+ module Razorpay
5
+ # Invoice API allows you to create and
6
+ # manage invoices with Razorpay
7
+ class Invoice < Entity
8
+ def self.request
9
+ Razorpay::Request.new('invoices')
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
+ end
24
+ end
@@ -2,17 +2,14 @@ require 'razorpay/request'
2
2
  require 'razorpay/entity'
3
3
 
4
4
  module Razorpay
5
- # Order API is currently in beta and allows you to
6
- # associate Payments with an order entity
5
+ # Order API allows you to associate
6
+ # Payments with an order entity
7
7
  class Order < Entity
8
8
  def self.request
9
9
  Razorpay::Request.new('orders')
10
10
  end
11
11
 
12
12
  def self.create(options)
13
- raise ArgumentError, 'Please provide order amount' unless options.key?(:amount)
14
- raise ArgumentError, 'Please provide order currency' unless options.key?(:currency)
15
- raise ArgumentError, 'Please provide order receipt' unless options.key?(:receipt)
16
13
  request.create options
17
14
  end
18
15
 
@@ -29,13 +29,11 @@ module Razorpay
29
29
  end
30
30
 
31
31
  def capture(options)
32
- raise ArgumentError, 'Please provide capture amount' unless options.key?(:amount)
33
32
  self.class.request.post "#{id}/capture", options
34
33
  end
35
34
 
36
35
  def method
37
36
  method_missing(:method)
38
37
  end
39
-
40
38
  end
41
39
  end
@@ -0,0 +1,8 @@
1
+ {
2
+ "id": "cust_6vRXClWqnLhV14",
3
+ "email": "test@razorpay.com",
4
+ "contact": "9876543210",
5
+ "notes": [],
6
+ "created_at": 1482299274,
7
+ "entity": "customer"
8
+ }
@@ -0,0 +1,29 @@
1
+ {
2
+ "id": "inv_6vRZmJYFAG1mNq",
3
+ "entity": "invoice",
4
+ "receipt": null,
5
+ "customer_id": "cust_6vRXClWqnLhV14",
6
+ "customer_details": {
7
+ "customer_name": null,
8
+ "customer_email": "test@razorpay.com",
9
+ "customer_contact": "9876543210",
10
+ "customer_address": null
11
+ },
12
+ "order_id": "order_6vRZmJu7EPEMY0",
13
+ "line_items": [],
14
+ "payment_id": null,
15
+ "status": "issued",
16
+ "issued_at": 1482299421,
17
+ "paid_at": null,
18
+ "sms_status": "sent",
19
+ "email_status": "sent",
20
+ "date": 1482299421,
21
+ "amount": 100,
22
+ "description": "Test description",
23
+ "notes": [],
24
+ "currency": "INR",
25
+ "short_url": "http://bit.ly/2i8kSqu",
26
+ "view_less": true,
27
+ "type": "link",
28
+ "created_at": 1482299422
29
+ }
@@ -0,0 +1,93 @@
1
+ {
2
+ "entity": "collection",
3
+ "count": 3,
4
+ "items": [
5
+ {
6
+ "id": "inv_6vRZmJYFAG1mNq",
7
+ "entity": "invoice",
8
+ "receipt": null,
9
+ "customer_id": "cust_6vRXClWqnLhV14",
10
+ "customer_details": {
11
+ "customer_name": null,
12
+ "customer_email": "test@razorpay.com",
13
+ "customer_contact": "9876543210",
14
+ "customer_address": null
15
+ },
16
+ "order_id": "order_6vRZmJu7EPEMY0",
17
+ "line_items": [],
18
+ "payment_id": null,
19
+ "status": "issued",
20
+ "issued_at": 1482299421,
21
+ "paid_at": null,
22
+ "sms_status": "sent",
23
+ "email_status": "sent",
24
+ "date": 1482299421,
25
+ "amount": 100,
26
+ "description": "Test description",
27
+ "notes": [],
28
+ "currency": "INR",
29
+ "short_url": "http://bit.ly/2i8kSqu",
30
+ "view_less": true,
31
+ "type": "link",
32
+ "created_at": 1482299422
33
+ },
34
+ {
35
+ "id": "inv_6vRaHV8UDx58xy",
36
+ "entity": "invoice",
37
+ "receipt": null,
38
+ "customer_id": "cust_6vRXClWqnLhV14",
39
+ "customer_details": {
40
+ "customer_name": null,
41
+ "customer_email": "test@razorpay.com",
42
+ "customer_contact": "9876543210",
43
+ "customer_address": null
44
+ },
45
+ "order_id": "order_6vRaHVgZ1D3ESr",
46
+ "line_items": [],
47
+ "payment_id": null,
48
+ "status": "issued",
49
+ "issued_at": 1482299449,
50
+ "paid_at": null,
51
+ "sms_status": "sent",
52
+ "email_status": "sent",
53
+ "date": 1482299449,
54
+ "amount": 100,
55
+ "description": "Test description",
56
+ "notes": [],
57
+ "currency": "INR",
58
+ "short_url": "http://bit.ly/2h0nLV7",
59
+ "view_less": true,
60
+ "type": "link",
61
+ "created_at": 1482299450
62
+ },
63
+ {
64
+ "id": "inv_6vRaaIQ6I3vO53",
65
+ "entity": "invoice",
66
+ "receipt": null,
67
+ "customer_id": "cust_6vRXClWqnLhV14",
68
+ "customer_details": {
69
+ "customer_name": null,
70
+ "customer_email": "test@razorpay.com",
71
+ "customer_contact": "9876543210",
72
+ "customer_address": null
73
+ },
74
+ "order_id": "order_6vRaaInhKbWFUB",
75
+ "line_items": [],
76
+ "payment_id": null,
77
+ "status": "issued",
78
+ "issued_at": 1482299466,
79
+ "paid_at": null,
80
+ "sms_status": "sent",
81
+ "email_status": "sent",
82
+ "date": 1482299466,
83
+ "amount": 100,
84
+ "description": "Test description",
85
+ "notes": [],
86
+ "currency": "INR",
87
+ "short_url": "http://bit.ly/2h0jYHp",
88
+ "view_less": true,
89
+ "type": "link",
90
+ "created_at": 1482299468
91
+ }
92
+ ]
93
+ }
@@ -0,0 +1,27 @@
1
+ require 'test_helper'
2
+ require 'razorpay/customer'
3
+ require 'razorpay/collection'
4
+
5
+ module Razorpay
6
+ # Tests for Razorpay::Customer
7
+ class RazorpayCustomerTest < Minitest::Test
8
+ def setup
9
+ @customer_id = 'cust_6vRXClWqnLhV14'
10
+
11
+ # Any request that ends with customers/customer_id
12
+ stub_get(%r{customers/#{@customer_id}$}, 'fake_customer')
13
+ end
14
+
15
+ def test_customer_should_be_defined
16
+ refute_nil Razorpay::Customer
17
+ end
18
+
19
+ def test_customer_should_be_created
20
+ stub_post(/customers$/, 'fake_customer', 'email=test%40razorpay.com&contact=9876543210')
21
+ customer = Razorpay::Customer.create email: 'test@razorpay.com', contact: '9876543210'
22
+
23
+ assert_equal 'test@razorpay.com', customer.email
24
+ assert_equal '9876543210', customer.contact
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,43 @@
1
+ require 'test_helper'
2
+ require 'razorpay/invoice'
3
+ require 'razorpay/collection'
4
+
5
+ module Razorpay
6
+ # Tests for Razorpay::Invoice
7
+ class RazorpayInvoiceTest < Minitest::Test
8
+ def setup
9
+ @invoice_id = 'inv_6vRZmJYFAG1mNq'
10
+
11
+ # Any request that ends with invoices/invoice_id
12
+ stub_get(%r{invoices/#{@invoice_id}$}, 'fake_invoice')
13
+ end
14
+
15
+ def test_invoice_should_be_defined
16
+ refute_nil Razorpay::Invoice
17
+ end
18
+
19
+ def test_invoice_should_be_created
20
+ stub_post(/invoices$/, 'fake_invoice', 'customer_id=cust_6vRXClWqnLhV14&amount=100&currency=INR&description=Test%20description&type=link')
21
+ invoice = Razorpay::Invoice.create customer_id: 'cust_6vRXClWqnLhV14', amount: 100, currency: 'INR', description: 'Test description', type: 'link'
22
+
23
+ assert_equal 'cust_6vRXClWqnLhV14', invoice.customer_id
24
+ assert_equal 100, invoice.amount
25
+ assert_equal 'INR', invoice.currency
26
+ assert_equal 'Test description', invoice.description
27
+ assert_equal 'link', invoice.type
28
+ end
29
+
30
+ def test_invoices_should_be_fetched
31
+ invoice = Razorpay::Invoice.fetch(@invoice_id)
32
+ assert_instance_of Razorpay::Invoice, invoice, 'invoice not an instance of Razorpay::Invoice class'
33
+ assert_equal @invoice_id, invoice.id, 'invoice IDs do not match'
34
+ end
35
+
36
+ def test_fetching_all_invoices
37
+ stub_get(/invoices$/, 'invoice_collection')
38
+ invoices = Razorpay::Invoice.all
39
+ assert_instance_of Razorpay::Collection, invoices, 'Invoices should be an array'
40
+ assert !invoices.items.empty?, 'invoices should be more than one'
41
+ end
42
+ end
43
+ end
@@ -57,9 +57,6 @@ module Razorpay
57
57
  def test_payment_capture
58
58
  stub_post(%r{payments/#{@payment_id}/capture$}, 'fake_captured_payment', 'amount=5100')
59
59
  payment = Razorpay::Payment.fetch(@payment_id)
60
- assert_raises(ArgumentError, 'ArgumentError should be raised if amount is not provided') do
61
- payment.capture
62
- end
63
60
  payment = payment.capture(amount: 5100)
64
61
  assert_equal 'captured', payment.status
65
62
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: razorpay
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Abhay Rana
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-23 00:00:00.000000000 Z
11
+ date: 2016-12-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -101,12 +101,14 @@ files:
101
101
  - lib/razorpay.rb
102
102
  - lib/razorpay/collection.rb
103
103
  - lib/razorpay/constants.rb
104
+ - lib/razorpay/customer.rb
104
105
  - lib/razorpay/entity.rb
105
106
  - lib/razorpay/errors.rb
106
107
  - lib/razorpay/errors/bad_request_error.rb
107
108
  - lib/razorpay/errors/gateway_error.rb
108
109
  - lib/razorpay/errors/razorpay_error.rb
109
110
  - lib/razorpay/errors/server_error.rb
111
+ - lib/razorpay/invoice.rb
110
112
  - lib/razorpay/order.rb
111
113
  - lib/razorpay/payment.rb
112
114
  - lib/razorpay/refund.rb
@@ -114,17 +116,22 @@ files:
114
116
  - razorpay-ruby.gemspec
115
117
  - test/fixtures/bad_request_error.json
116
118
  - test/fixtures/fake_captured_payment.json
119
+ - test/fixtures/fake_customer.json
120
+ - test/fixtures/fake_invoice.json
117
121
  - test/fixtures/fake_order.json
118
122
  - test/fixtures/fake_payment.json
119
123
  - test/fixtures/fake_refund.json
120
124
  - test/fixtures/hello_response.json
125
+ - test/fixtures/invoice_collection.json
121
126
  - test/fixtures/order_collection.json
122
127
  - test/fixtures/order_payments.json
123
128
  - test/fixtures/payment_collection.json
124
129
  - test/fixtures/payment_collection_with_one_payment.json
125
130
  - test/fixtures/refund_collection.json
131
+ - test/razorpay/test_customer.rb
126
132
  - test/razorpay/test_entity.rb
127
133
  - test/razorpay/test_errors.rb
134
+ - test/razorpay/test_invoice.rb
128
135
  - test/razorpay/test_order.rb
129
136
  - test/razorpay/test_payment.rb
130
137
  - test/razorpay/test_razorpay.rb
@@ -157,17 +164,22 @@ summary: Razorpay's Ruby API
157
164
  test_files:
158
165
  - test/fixtures/bad_request_error.json
159
166
  - test/fixtures/fake_captured_payment.json
167
+ - test/fixtures/fake_customer.json
168
+ - test/fixtures/fake_invoice.json
160
169
  - test/fixtures/fake_order.json
161
170
  - test/fixtures/fake_payment.json
162
171
  - test/fixtures/fake_refund.json
163
172
  - test/fixtures/hello_response.json
173
+ - test/fixtures/invoice_collection.json
164
174
  - test/fixtures/order_collection.json
165
175
  - test/fixtures/order_payments.json
166
176
  - test/fixtures/payment_collection.json
167
177
  - test/fixtures/payment_collection_with_one_payment.json
168
178
  - test/fixtures/refund_collection.json
179
+ - test/razorpay/test_customer.rb
169
180
  - test/razorpay/test_entity.rb
170
181
  - test/razorpay/test_errors.rb
182
+ - test/razorpay/test_invoice.rb
171
183
  - test/razorpay/test_order.rb
172
184
  - test/razorpay/test_payment.rb
173
185
  - test/razorpay/test_razorpay.rb