razorruby 3.0.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.
Files changed (171) hide show
  1. checksums.yaml +7 -0
  2. data/.DS_Store +0 -0
  3. data/.editorconfig +12 -0
  4. data/.github/dependabot.yml +8 -0
  5. data/.github/workflows/ruby.yml +38 -0
  6. data/.gitignore +23 -0
  7. data/.rubocop.yml +22 -0
  8. data/.simplecov +3 -0
  9. data/CHANGELOG.md +168 -0
  10. data/Gemfile +4 -0
  11. data/LICENSE.txt +22 -0
  12. data/README.md +102 -0
  13. data/Rakefile +26 -0
  14. data/documents/Invoice.md +539 -0
  15. data/documents/addon.md +191 -0
  16. data/documents/card.md +610 -0
  17. data/documents/customer.md +163 -0
  18. data/documents/emandate.md +492 -0
  19. data/documents/fund.md +89 -0
  20. data/documents/items.md +208 -0
  21. data/documents/order.md +281 -0
  22. data/documents/papernach.md +738 -0
  23. data/documents/payment.md +826 -0
  24. data/documents/paymentLink.md +1063 -0
  25. data/documents/paymentVerification.md +79 -0
  26. data/documents/plan.md +184 -0
  27. data/documents/qrcode.md +439 -0
  28. data/documents/refund.md +325 -0
  29. data/documents/registerEmandate.md +452 -0
  30. data/documents/registerNach.md +653 -0
  31. data/documents/settlement.md +478 -0
  32. data/documents/subscriptions.md +752 -0
  33. data/documents/tokens.md +262 -0
  34. data/documents/transfers.md +781 -0
  35. data/documents/upi.md +545 -0
  36. data/documents/virtualAccount.md +591 -0
  37. data/lib/ca-bundle.crt +3988 -0
  38. data/lib/extensions/httparty/hash_conversions.rb +44 -0
  39. data/lib/razorpay/addon.rb +32 -0
  40. data/lib/razorpay/card.rb +17 -0
  41. data/lib/razorpay/collection.rb +6 -0
  42. data/lib/razorpay/constants.rb +6 -0
  43. data/lib/razorpay/customer.rb +42 -0
  44. data/lib/razorpay/entity.rb +46 -0
  45. data/lib/razorpay/errors/bad_request_error.rb +14 -0
  46. data/lib/razorpay/errors/gateway_error.rb +7 -0
  47. data/lib/razorpay/errors/razorpay_error.rb +11 -0
  48. data/lib/razorpay/errors/server_error.rb +7 -0
  49. data/lib/razorpay/errors.rb +4 -0
  50. data/lib/razorpay/fund_account.rb +19 -0
  51. data/lib/razorpay/invoice.rb +68 -0
  52. data/lib/razorpay/item.rb +34 -0
  53. data/lib/razorpay/order.rb +39 -0
  54. data/lib/razorpay/payment.rb +116 -0
  55. data/lib/razorpay/payment_link.rb +36 -0
  56. data/lib/razorpay/payment_method.rb +17 -0
  57. data/lib/razorpay/plan.rb +24 -0
  58. data/lib/razorpay/qr_code.rb +34 -0
  59. data/lib/razorpay/refund.rb +27 -0
  60. data/lib/razorpay/request.rb +119 -0
  61. data/lib/razorpay/settlement.rb +39 -0
  62. data/lib/razorpay/subscription.rb +60 -0
  63. data/lib/razorpay/subscription_registration.rb +16 -0
  64. data/lib/razorpay/transfer.rb +35 -0
  65. data/lib/razorpay/utility.rb +57 -0
  66. data/lib/razorpay/virtual_account.rb +49 -0
  67. data/lib/razorpay.rb +37 -0
  68. data/razorpay-ruby.gemspec +36 -0
  69. data/test/fixtures/addon_collection.json +60 -0
  70. data/test/fixtures/bad_request_error.json +7 -0
  71. data/test/fixtures/cancel_invoice.json +44 -0
  72. data/test/fixtures/cancel_subscription.json +20 -0
  73. data/test/fixtures/create_json_payment.json +13 -0
  74. data/test/fixtures/customer_collection.json +22 -0
  75. data/test/fixtures/delete_token.json +3 -0
  76. data/test/fixtures/downtimes_collection.json +21 -0
  77. data/test/fixtures/empty.json +2 -0
  78. data/test/fixtures/fake_addon.json +24 -0
  79. data/test/fixtures/fake_captured_payment.json +13 -0
  80. data/test/fixtures/fake_card.json +9 -0
  81. data/test/fixtures/fake_create_upi_payment.json +3 -0
  82. data/test/fixtures/fake_customer.json +8 -0
  83. data/test/fixtures/fake_customer_edited.json +8 -0
  84. data/test/fixtures/fake_direct_transfer.json +32 -0
  85. data/test/fixtures/fake_downtime.json +14 -0
  86. data/test/fixtures/fake_fund_account.json +18 -0
  87. data/test/fixtures/fake_instant_settlement.json +19 -0
  88. data/test/fixtures/fake_invoice.json +30 -0
  89. data/test/fixtures/fake_item.json +9 -0
  90. data/test/fixtures/fake_order.json +10 -0
  91. data/test/fixtures/fake_order_transfers.json +88 -0
  92. data/test/fixtures/fake_otp_generate.json +19 -0
  93. data/test/fixtures/fake_otp_resend.json +7 -0
  94. data/test/fixtures/fake_otp_submit.json +5 -0
  95. data/test/fixtures/fake_payment.json +14 -0
  96. data/test/fixtures/fake_payment_authorized_webhook.json +40 -0
  97. data/test/fixtures/fake_payment_bank_transfer.json +12 -0
  98. data/test/fixtures/fake_payment_link.json +40 -0
  99. data/test/fixtures/fake_pending_update.json +30 -0
  100. data/test/fixtures/fake_plan.json +26 -0
  101. data/test/fixtures/fake_qrcode.json +20 -0
  102. data/test/fixtures/fake_qrcode_close.json +22 -0
  103. data/test/fixtures/fake_recurring.json +5 -0
  104. data/test/fixtures/fake_refund.json +8 -0
  105. data/test/fixtures/fake_refunded_payment.json +14 -0
  106. data/test/fixtures/fake_settlement.json +11 -0
  107. data/test/fixtures/fake_settlement_on_demand.json +39 -0
  108. data/test/fixtures/fake_subscription.json +20 -0
  109. data/test/fixtures/fake_subscription_pause.json +19 -0
  110. data/test/fixtures/fake_subscription_registration.json +91 -0
  111. data/test/fixtures/fake_subscription_resume.json +19 -0
  112. data/test/fixtures/fake_token.json +31 -0
  113. data/test/fixtures/fake_transfer.json +18 -0
  114. data/test/fixtures/fake_transfer_reverse.json +15 -0
  115. data/test/fixtures/fake_update_payment.json +39 -0
  116. data/test/fixtures/fake_validate_vpa.json +5 -0
  117. data/test/fixtures/fake_virtual_account.json +21 -0
  118. data/test/fixtures/fake_virtual_account_allowed.json +46 -0
  119. data/test/fixtures/fake_virtual_account_closed.json +21 -0
  120. data/test/fixtures/fake_virtual_account_collection.json +48 -0
  121. data/test/fixtures/fake_virtual_account_receiver.json +46 -0
  122. data/test/fixtures/fund_collection.json +20 -0
  123. data/test/fixtures/hello_response.json +3 -0
  124. data/test/fixtures/invoice_collection.json +93 -0
  125. data/test/fixtures/issue_invoice.json +44 -0
  126. data/test/fixtures/item_collection.json +24 -0
  127. data/test/fixtures/order_collection.json +36 -0
  128. data/test/fixtures/order_payments.json +29 -0
  129. data/test/fixtures/payment_collection.json +32 -0
  130. data/test/fixtures/payment_collection_with_one_payment.json +19 -0
  131. data/test/fixtures/payment_link_collection.json +43 -0
  132. data/test/fixtures/payment_link_response.json +3 -0
  133. data/test/fixtures/payment_methods_collection.json +149 -0
  134. data/test/fixtures/plan_collection.json +32 -0
  135. data/test/fixtures/qrcode_collection.json +50 -0
  136. data/test/fixtures/qrcode_payments_collection.json +74 -0
  137. data/test/fixtures/refund_collection.json +30 -0
  138. data/test/fixtures/refund_collection_for_payment.json +22 -0
  139. data/test/fixtures/settlement_collection.json +26 -0
  140. data/test/fixtures/settlement_instant_collection.json +84 -0
  141. data/test/fixtures/settlement_report_collection.json +117 -0
  142. data/test/fixtures/subscription_collection.json +26 -0
  143. data/test/fixtures/success.json +3 -0
  144. data/test/fixtures/tokens_collection.json +36 -0
  145. data/test/fixtures/transfer_settlements_collection.json +38 -0
  146. data/test/fixtures/transfers_collection.json +41 -0
  147. data/test/fixtures/update_invoice.json +44 -0
  148. data/test/fixtures/welcome.json +3 -0
  149. data/test/razorpay/test_addon.rb +76 -0
  150. data/test/razorpay/test_card.rb +23 -0
  151. data/test/razorpay/test_customer.rb +69 -0
  152. data/test/razorpay/test_entity.rb +55 -0
  153. data/test/razorpay/test_fund_account.rb +42 -0
  154. data/test/razorpay/test_invoice.rb +143 -0
  155. data/test/razorpay/test_item.rb +66 -0
  156. data/test/razorpay/test_order.rb +71 -0
  157. data/test/razorpay/test_payment.rb +303 -0
  158. data/test/razorpay/test_payment_link.rb +83 -0
  159. data/test/razorpay/test_plan.rb +65 -0
  160. data/test/razorpay/test_qr_code.rb +63 -0
  161. data/test/razorpay/test_razorpay.rb +53 -0
  162. data/test/razorpay/test_refund.rb +56 -0
  163. data/test/razorpay/test_request.rb +15 -0
  164. data/test/razorpay/test_settlement.rb +76 -0
  165. data/test/razorpay/test_subscription.rb +190 -0
  166. data/test/razorpay/test_subscription_registration.rb +58 -0
  167. data/test/razorpay/test_transfer.rb +77 -0
  168. data/test/razorpay/test_utility.rb +84 -0
  169. data/test/razorpay/test_virtual_account.rb +135 -0
  170. data/test/test_helper.rb +54 -0
  171. metadata +400 -0
@@ -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:
@@ -0,0 +1,32 @@
1
+ require 'razorpay/request'
2
+ require 'razorpay/entity'
3
+
4
+ module Razorpay
5
+ # Addon API allows you to fetch and delete
6
+ # subscription-addons with Razorpay
7
+ class Addon < Entity
8
+ def self.request
9
+ Razorpay::Request.new('addons')
10
+ end
11
+
12
+ def self.fetch(id)
13
+ request.fetch id
14
+ end
15
+
16
+ def self.all(options = {})
17
+ request.all options
18
+ end
19
+
20
+ def self.create(subscription_id, options)
21
+ r = request
22
+ # POST /addons is not supported
23
+ # Addon creation endpoint is:
24
+ # POST subscriptions/{sub_id}/addons
25
+ r.request :post, "/subscriptions/#{subscription_id}/addons", options
26
+ end
27
+
28
+ def self.delete(id)
29
+ request.delete id
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,17 @@
1
+ require 'razorpay/request'
2
+ require 'razorpay/entity'
3
+
4
+ module Razorpay
5
+ # Card API allows you to fetch cards
6
+ # saved with Razorpay
7
+ # Docs: https://docs.razorpay.com/v1/page/cards
8
+ class Card < Entity
9
+ def self.request
10
+ Razorpay::Request.new('cards')
11
+ end
12
+
13
+ def self.fetch(id)
14
+ request.fetch id
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,6 @@
1
+ module Razorpay
2
+ # Collection class handles groups of similar
3
+ # entities
4
+ class Collection < Entity
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ # Version and other constants are defined here
2
+ module Razorpay
3
+ BASE_URI = 'https://api.razorpay.com/v1/'.freeze
4
+ TEST_URL = 'https://api.razorpay.com/'.freeze
5
+ VERSION = '3.0.1'.freeze
6
+ end
@@ -0,0 +1,42 @@
1
+ require 'razorpay/request'
2
+ require 'razorpay/entity'
3
+
4
+ module Razorpay
5
+ # Customer API allows you to create and fetch customers 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
+
15
+ def self.fetch(id)
16
+ request.fetch id
17
+ end
18
+
19
+ def self.edit(id, options = {})
20
+ request.put id, options
21
+ end
22
+
23
+ def self.all(options = {})
24
+ request.all options
25
+ end
26
+
27
+ # Fetch token by customerId
28
+ # https://razorpay.com/docs/api/recurring-payments/upi/tokens/#22-fetch-tokens-by-customer-id
29
+ def fetchTokens
30
+ self.class.request.get "#{id}/tokens"
31
+ end
32
+
33
+ # Fetch specific token
34
+ def fetchToken(tokenId)
35
+ self.class.request.get "#{id}/tokens/#{tokenId}"
36
+ end
37
+
38
+ def deleteToken(tokenId)
39
+ self.class.request.delete "#{id}/tokens/#{tokenId}"
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,46 @@
1
+ require 'json'
2
+
3
+ module Razorpay
4
+ # Entity class is the base class for all Razorpay objects
5
+ # This saves data in a hash internally, and makes it available
6
+ # via direct methods
7
+ class Entity
8
+ attr_reader :attributes
9
+
10
+ def initialize(attributes)
11
+ @attributes = attributes
12
+ end
13
+
14
+ # This method fakes attr_reader, but uses
15
+ # the @attributes hash as the source, instead of
16
+ # instance variables
17
+ def method_missing(name)
18
+ if @attributes.key? name.to_s
19
+ @attributes[name.to_s]
20
+ else
21
+ super
22
+ end
23
+ end
24
+
25
+ def respond_to_missing?(method_name, include_private = false)
26
+ @attributes.key?(method_name.to_s) || super
27
+ end
28
+
29
+ # Public: Convert the Entity object to JSON
30
+ # Returns the JSON representation of the Entity (as a string)
31
+ def to_json(*args)
32
+ @attributes.to_json(*args)
33
+ end
34
+
35
+ # Mutates the entity in accordance with
36
+ # the block passed to this construct
37
+ #
38
+ # Used to implement bang methods, by calling
39
+ # the non-bang method in the passed block
40
+ def with_a_bang
41
+ mutated_entity = yield
42
+ @attributes = mutated_entity.attributes
43
+ mutated_entity
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,14 @@
1
+ require 'razorpay/errors/razorpay_error'
2
+
3
+ module Razorpay
4
+ # Bad request to API. Missing a field or an invalid field.
5
+ # Error in merchant request. Check the description and correct the request accordingly.
6
+ class BadRequestError < Razorpay::Error
7
+ attr_reader :field
8
+
9
+ def initialize(code, status, field = nil)
10
+ super(code, status)
11
+ @field = field
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,7 @@
1
+ require 'razorpay/errors/razorpay_error'
2
+
3
+ module Razorpay
4
+ # Error in Gateway Communication.
5
+ class GatewayError < Razorpay::Error
6
+ end
7
+ end
@@ -0,0 +1,11 @@
1
+ module Razorpay
2
+ # Default Error class for any unknown errors
3
+ class Error < StandardError
4
+ attr_reader :code, :status
5
+
6
+ def initialize(code = nil, status = nil)
7
+ @code = code
8
+ @status = status
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,7 @@
1
+ require 'razorpay/errors/razorpay_error'
2
+
3
+ module Razorpay
4
+ # There is some problem with the server
5
+ class ServerError < Razorpay::Error
6
+ end
7
+ end
@@ -0,0 +1,4 @@
1
+ require 'razorpay/errors/razorpay_error'
2
+ require 'razorpay/errors/bad_request_error'
3
+ require 'razorpay/errors/gateway_error'
4
+ require 'razorpay/errors/server_error'
@@ -0,0 +1,19 @@
1
+ require 'razorpay/request'
2
+ require 'razorpay/entity'
3
+
4
+ module Razorpay
5
+ # FundAccount API allows you to create and fetch a fund account for a customer.
6
+ class FundAccount < Entity
7
+ def self.request
8
+ Razorpay::Request.new('fund_accounts')
9
+ end
10
+
11
+ def self.create(options)
12
+ request.create options
13
+ end
14
+
15
+ def self.all(data = {})
16
+ request.all data
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,68 @@
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
+
24
+ def self.edit(id, options = {})
25
+ request.patch id, options
26
+ end
27
+
28
+ def self.issue(id)
29
+ request.post "#{id}/issue"
30
+ end
31
+
32
+ def self.cancel(id)
33
+ request.post "#{id}/cancel"
34
+ end
35
+
36
+ def edit(options = {})
37
+ self.class.edit id, options
38
+ end
39
+
40
+ def edit!(options = {})
41
+ with_a_bang { edit options }
42
+ end
43
+
44
+ def issue
45
+ self.class.issue id
46
+ end
47
+
48
+ def issue!
49
+ with_a_bang { issue }
50
+ end
51
+
52
+ def cancel
53
+ self.class.cancel id
54
+ end
55
+
56
+ def cancel!
57
+ with_a_bang { cancel }
58
+ end
59
+
60
+ def self.notify_by(id, medium)
61
+ request.post "#{id}/notify_by/#{medium}"
62
+ end
63
+
64
+ def self.delete(id)
65
+ request.delete "#{id}"
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,34 @@
1
+ require 'razorpay/request'
2
+ require 'razorpay/entity'
3
+
4
+ module Razorpay
5
+ # Item API allows you to create and fetch customers on Razorpay
6
+ class Item < Entity
7
+ def self.request
8
+ Razorpay::Request.new('items')
9
+ end
10
+
11
+ def self.create(options)
12
+ request.create options
13
+ end
14
+
15
+ def self.fetch(id)
16
+ request.fetch id
17
+ end
18
+
19
+ def self.edit(id, options = {})
20
+ if(!options.is_a?(String) && options.key?(:active))
21
+ options[:active] = (options[:active] ? 1 : 0)
22
+ end
23
+ request.patch id, options
24
+ end
25
+
26
+ def self.all(options = {})
27
+ request.all options
28
+ end
29
+
30
+ def self.delete(id)
31
+ request.delete id
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,39 @@
1
+ require 'razorpay/request'
2
+ require 'razorpay/entity'
3
+
4
+ module Razorpay
5
+ # Order API allows you to associate
6
+ # Payments with an order entity
7
+ class Order < Entity
8
+ def self.request
9
+ Razorpay::Request.new('orders')
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 payments(options = {})
25
+ r = self.class.request
26
+ r.request :get, "/orders/#{id}/payments", options
27
+ end
28
+
29
+ def self.edit(id, options = {})
30
+ request.patch id, options
31
+ end
32
+
33
+ def self.fetch_transfer_order(id)
34
+ # Fetch Transfer for an Order
35
+ # Docs: https://razorpay.com/docs/api/payments/route/#fetch-transfer-for-an-order
36
+ request.get "#{id}/?expand[]=transfers&status"
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,116 @@
1
+ require 'razorpay/request'
2
+ require 'razorpay/refund'
3
+ require 'razorpay/entity'
4
+
5
+ module Razorpay
6
+ # Payment class is the most commonly used class
7
+ # and is used to interact with Payments, the most
8
+ # common type of transactions
9
+ class Payment < Entity
10
+ def self.request
11
+ Razorpay::Request.new('payments')
12
+ end
13
+
14
+ def self.create_recurring_payment(data={})
15
+ request.post "create/recurring" , data
16
+ end
17
+
18
+ def self.create_json_payment(data={})
19
+ request.post "create/json" , data
20
+ end
21
+
22
+ def self.fetch_payment_downtime
23
+ request.get "downtimes"
24
+ end
25
+
26
+ def self.fetch_payment_downtime_by_id(id)
27
+ request.get "downtimes/#{id}"
28
+ end
29
+
30
+ def self.fetch_card_details(id)
31
+ request.get "#{id}/card"
32
+ end
33
+
34
+ def fetch_transfer
35
+ self.class.request.get "#{id}/transfers"
36
+ end
37
+
38
+ def fetch_refund(refundId)
39
+ self.class.request.get "#{id}/refunds/#{refundId}"
40
+ end
41
+
42
+ def self.fetch_multiple_refund(id, options = {})
43
+ request.get "#{id}/refunds",options
44
+ end
45
+
46
+ def transfer(options = {})
47
+ self.class.request.post "#{id}/transfers", options
48
+ end
49
+
50
+ def edit(options = {})
51
+ self.class.request.patch id, options
52
+ end
53
+
54
+ def self.fetch(id)
55
+ request.fetch id
56
+ end
57
+
58
+ def self.all(options = {})
59
+ request.all options
60
+ end
61
+
62
+ def self.capture(id, options)
63
+ request.post "#{id}/capture", options
64
+ end
65
+
66
+ def refund(options = {})
67
+ self.class.request.post "#{id}/refund", options
68
+ end
69
+
70
+ def refund!(options = {})
71
+ refund = refund options
72
+ with_a_bang { self.class.request.fetch id }
73
+ refund
74
+ end
75
+
76
+ def capture(options)
77
+ self.class.request.post "#{id}/capture", options
78
+ end
79
+
80
+ def capture!(options)
81
+ with_a_bang { capture options }
82
+ end
83
+
84
+ def refunds
85
+ self.class.request.get "#{id}/refunds"
86
+ end
87
+
88
+ def method
89
+ method_missing(:method)
90
+ end
91
+
92
+ def bank_transfer
93
+ self.class.request.get "#{id}/bank_transfer"
94
+ end
95
+
96
+ def self.otp_generate(id)
97
+ request.post "#{id}/otp_generate"
98
+ end
99
+
100
+ def otp_submit(options)
101
+ self.class.request.post "#{id}/otp/submit", options
102
+ end
103
+
104
+ def otp_resend
105
+ self.class.request.post "#{id}/otp/resend"
106
+ end
107
+
108
+ def self.create_upi(data={})
109
+ request.post "create/upi" , data
110
+ end
111
+
112
+ def self.validate_vpa(data={})
113
+ request.post "validate/vpa" , data
114
+ end
115
+ end
116
+ end
@@ -0,0 +1,36 @@
1
+ require 'razorpay/request'
2
+ require 'razorpay/entity'
3
+
4
+ module Razorpay
5
+ # Payment Links are URLs that you can send to your customers
6
+ # through SMS and email to collect payments from them.
7
+ class PaymentLink < Entity
8
+ def self.request
9
+ Razorpay::Request.new('payment_links')
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.edit(id, options = {})
21
+ request.patch id, options
22
+ end
23
+
24
+ def self.all(options = {})
25
+ request.all options
26
+ end
27
+
28
+ def self.cancel(id)
29
+ request.post "#{id}/cancel"
30
+ end
31
+
32
+ def self.notify_by(id,medium)
33
+ request.post "#{id}/notify_by/#{medium}"
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,17 @@
1
+ require 'razorpay/request'
2
+ require 'razorpay/refund'
3
+ require 'razorpay/entity'
4
+
5
+ module Razorpay
6
+ # Payment Methods class is allows you to create
7
+ # to fetch all payment methods
8
+ class PaymentMethods < Entity
9
+ def self.request
10
+ Razorpay::Request.new('methods')
11
+ end
12
+
13
+ def self.all(options = {})
14
+ request.all options
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,24 @@
1
+ require 'razorpay/request'
2
+ require 'razorpay/entity'
3
+
4
+ module Razorpay
5
+ # Plan API allows you to create and
6
+ # manage subscription-plans with Razorpay
7
+ class Plan < Entity
8
+ def self.request
9
+ Razorpay::Request.new('plans')
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
@@ -0,0 +1,34 @@
1
+ require 'razorpay/request'
2
+ require 'razorpay/entity'
3
+
4
+ module Razorpay
5
+ # QrCode API allows you to create, close and fetch QR codes
6
+ class QrCode < Entity
7
+ def self.request
8
+ Razorpay::Request.new('payments/qr_codes')
9
+ end
10
+
11
+ def self.create(options)
12
+ if(!options.is_a?(String) && options.key?(:fixed_amount))
13
+ options[:fixed_amount] = (options[:fixed_amount] ? 1 : 0)
14
+ end
15
+ request.create options
16
+ end
17
+
18
+ def self.fetch(id)
19
+ request.fetch id
20
+ end
21
+
22
+ def self.all(options = {})
23
+ request.all options
24
+ end
25
+
26
+ def fetch_payments(options = {})
27
+ self.class.request.get "#{id}/payments", options
28
+ end
29
+
30
+ def close
31
+ self.class.request.post "#{id}/close"
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,27 @@
1
+ require 'razorpay/request'
2
+ require 'razorpay/entity'
3
+
4
+ module Razorpay
5
+ # Refund class handles all refund objects
6
+ class Refund < Entity
7
+ def self.request
8
+ Razorpay::Request.new('refunds')
9
+ end
10
+
11
+ def self.create(options)
12
+ request.create options
13
+ end
14
+
15
+ def self.all(options = {})
16
+ request.all options
17
+ end
18
+
19
+ def self.fetch(id)
20
+ request.fetch id
21
+ end
22
+
23
+ def edit(options = {})
24
+ self.class.request.patch id, options
25
+ end
26
+ end
27
+ end