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.
- checksums.yaml +7 -0
- data/.DS_Store +0 -0
- data/.editorconfig +12 -0
- data/.github/dependabot.yml +8 -0
- data/.github/workflows/ruby.yml +38 -0
- data/.gitignore +23 -0
- data/.rubocop.yml +22 -0
- data/.simplecov +3 -0
- data/CHANGELOG.md +168 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +102 -0
- data/Rakefile +26 -0
- data/documents/Invoice.md +539 -0
- data/documents/addon.md +191 -0
- data/documents/card.md +610 -0
- data/documents/customer.md +163 -0
- data/documents/emandate.md +492 -0
- data/documents/fund.md +89 -0
- data/documents/items.md +208 -0
- data/documents/order.md +281 -0
- data/documents/papernach.md +738 -0
- data/documents/payment.md +826 -0
- data/documents/paymentLink.md +1063 -0
- data/documents/paymentVerification.md +79 -0
- data/documents/plan.md +184 -0
- data/documents/qrcode.md +439 -0
- data/documents/refund.md +325 -0
- data/documents/registerEmandate.md +452 -0
- data/documents/registerNach.md +653 -0
- data/documents/settlement.md +478 -0
- data/documents/subscriptions.md +752 -0
- data/documents/tokens.md +262 -0
- data/documents/transfers.md +781 -0
- data/documents/upi.md +545 -0
- data/documents/virtualAccount.md +591 -0
- data/lib/ca-bundle.crt +3988 -0
- data/lib/extensions/httparty/hash_conversions.rb +44 -0
- data/lib/razorpay/addon.rb +32 -0
- data/lib/razorpay/card.rb +17 -0
- data/lib/razorpay/collection.rb +6 -0
- data/lib/razorpay/constants.rb +6 -0
- data/lib/razorpay/customer.rb +42 -0
- data/lib/razorpay/entity.rb +46 -0
- data/lib/razorpay/errors/bad_request_error.rb +14 -0
- data/lib/razorpay/errors/gateway_error.rb +7 -0
- data/lib/razorpay/errors/razorpay_error.rb +11 -0
- data/lib/razorpay/errors/server_error.rb +7 -0
- data/lib/razorpay/errors.rb +4 -0
- data/lib/razorpay/fund_account.rb +19 -0
- data/lib/razorpay/invoice.rb +68 -0
- data/lib/razorpay/item.rb +34 -0
- data/lib/razorpay/order.rb +39 -0
- data/lib/razorpay/payment.rb +116 -0
- data/lib/razorpay/payment_link.rb +36 -0
- data/lib/razorpay/payment_method.rb +17 -0
- data/lib/razorpay/plan.rb +24 -0
- data/lib/razorpay/qr_code.rb +34 -0
- data/lib/razorpay/refund.rb +27 -0
- data/lib/razorpay/request.rb +119 -0
- data/lib/razorpay/settlement.rb +39 -0
- data/lib/razorpay/subscription.rb +60 -0
- data/lib/razorpay/subscription_registration.rb +16 -0
- data/lib/razorpay/transfer.rb +35 -0
- data/lib/razorpay/utility.rb +57 -0
- data/lib/razorpay/virtual_account.rb +49 -0
- data/lib/razorpay.rb +37 -0
- data/razorpay-ruby.gemspec +36 -0
- data/test/fixtures/addon_collection.json +60 -0
- data/test/fixtures/bad_request_error.json +7 -0
- data/test/fixtures/cancel_invoice.json +44 -0
- data/test/fixtures/cancel_subscription.json +20 -0
- data/test/fixtures/create_json_payment.json +13 -0
- data/test/fixtures/customer_collection.json +22 -0
- data/test/fixtures/delete_token.json +3 -0
- data/test/fixtures/downtimes_collection.json +21 -0
- data/test/fixtures/empty.json +2 -0
- data/test/fixtures/fake_addon.json +24 -0
- data/test/fixtures/fake_captured_payment.json +13 -0
- data/test/fixtures/fake_card.json +9 -0
- data/test/fixtures/fake_create_upi_payment.json +3 -0
- data/test/fixtures/fake_customer.json +8 -0
- data/test/fixtures/fake_customer_edited.json +8 -0
- data/test/fixtures/fake_direct_transfer.json +32 -0
- data/test/fixtures/fake_downtime.json +14 -0
- data/test/fixtures/fake_fund_account.json +18 -0
- data/test/fixtures/fake_instant_settlement.json +19 -0
- data/test/fixtures/fake_invoice.json +30 -0
- data/test/fixtures/fake_item.json +9 -0
- data/test/fixtures/fake_order.json +10 -0
- data/test/fixtures/fake_order_transfers.json +88 -0
- data/test/fixtures/fake_otp_generate.json +19 -0
- data/test/fixtures/fake_otp_resend.json +7 -0
- data/test/fixtures/fake_otp_submit.json +5 -0
- data/test/fixtures/fake_payment.json +14 -0
- data/test/fixtures/fake_payment_authorized_webhook.json +40 -0
- data/test/fixtures/fake_payment_bank_transfer.json +12 -0
- data/test/fixtures/fake_payment_link.json +40 -0
- data/test/fixtures/fake_pending_update.json +30 -0
- data/test/fixtures/fake_plan.json +26 -0
- data/test/fixtures/fake_qrcode.json +20 -0
- data/test/fixtures/fake_qrcode_close.json +22 -0
- data/test/fixtures/fake_recurring.json +5 -0
- data/test/fixtures/fake_refund.json +8 -0
- data/test/fixtures/fake_refunded_payment.json +14 -0
- data/test/fixtures/fake_settlement.json +11 -0
- data/test/fixtures/fake_settlement_on_demand.json +39 -0
- data/test/fixtures/fake_subscription.json +20 -0
- data/test/fixtures/fake_subscription_pause.json +19 -0
- data/test/fixtures/fake_subscription_registration.json +91 -0
- data/test/fixtures/fake_subscription_resume.json +19 -0
- data/test/fixtures/fake_token.json +31 -0
- data/test/fixtures/fake_transfer.json +18 -0
- data/test/fixtures/fake_transfer_reverse.json +15 -0
- data/test/fixtures/fake_update_payment.json +39 -0
- data/test/fixtures/fake_validate_vpa.json +5 -0
- data/test/fixtures/fake_virtual_account.json +21 -0
- data/test/fixtures/fake_virtual_account_allowed.json +46 -0
- data/test/fixtures/fake_virtual_account_closed.json +21 -0
- data/test/fixtures/fake_virtual_account_collection.json +48 -0
- data/test/fixtures/fake_virtual_account_receiver.json +46 -0
- data/test/fixtures/fund_collection.json +20 -0
- data/test/fixtures/hello_response.json +3 -0
- data/test/fixtures/invoice_collection.json +93 -0
- data/test/fixtures/issue_invoice.json +44 -0
- data/test/fixtures/item_collection.json +24 -0
- data/test/fixtures/order_collection.json +36 -0
- data/test/fixtures/order_payments.json +29 -0
- data/test/fixtures/payment_collection.json +32 -0
- data/test/fixtures/payment_collection_with_one_payment.json +19 -0
- data/test/fixtures/payment_link_collection.json +43 -0
- data/test/fixtures/payment_link_response.json +3 -0
- data/test/fixtures/payment_methods_collection.json +149 -0
- data/test/fixtures/plan_collection.json +32 -0
- data/test/fixtures/qrcode_collection.json +50 -0
- data/test/fixtures/qrcode_payments_collection.json +74 -0
- data/test/fixtures/refund_collection.json +30 -0
- data/test/fixtures/refund_collection_for_payment.json +22 -0
- data/test/fixtures/settlement_collection.json +26 -0
- data/test/fixtures/settlement_instant_collection.json +84 -0
- data/test/fixtures/settlement_report_collection.json +117 -0
- data/test/fixtures/subscription_collection.json +26 -0
- data/test/fixtures/success.json +3 -0
- data/test/fixtures/tokens_collection.json +36 -0
- data/test/fixtures/transfer_settlements_collection.json +38 -0
- data/test/fixtures/transfers_collection.json +41 -0
- data/test/fixtures/update_invoice.json +44 -0
- data/test/fixtures/welcome.json +3 -0
- data/test/razorpay/test_addon.rb +76 -0
- data/test/razorpay/test_card.rb +23 -0
- data/test/razorpay/test_customer.rb +69 -0
- data/test/razorpay/test_entity.rb +55 -0
- data/test/razorpay/test_fund_account.rb +42 -0
- data/test/razorpay/test_invoice.rb +143 -0
- data/test/razorpay/test_item.rb +66 -0
- data/test/razorpay/test_order.rb +71 -0
- data/test/razorpay/test_payment.rb +303 -0
- data/test/razorpay/test_payment_link.rb +83 -0
- data/test/razorpay/test_plan.rb +65 -0
- data/test/razorpay/test_qr_code.rb +63 -0
- data/test/razorpay/test_razorpay.rb +53 -0
- data/test/razorpay/test_refund.rb +56 -0
- data/test/razorpay/test_request.rb +15 -0
- data/test/razorpay/test_settlement.rb +76 -0
- data/test/razorpay/test_subscription.rb +190 -0
- data/test/razorpay/test_subscription_registration.rb +58 -0
- data/test/razorpay/test_transfer.rb +77 -0
- data/test/razorpay/test_utility.rb +84 -0
- data/test/razorpay/test_virtual_account.rb +135 -0
- data/test/test_helper.rb +54 -0
- metadata +400 -0
@@ -0,0 +1,119 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
require 'extensions/httparty/hash_conversions'
|
3
|
+
require 'razorpay/constants'
|
4
|
+
|
5
|
+
module Razorpay
|
6
|
+
# Request objects are used to create fetch
|
7
|
+
# objects, which make requests to the server
|
8
|
+
# using HTTParty
|
9
|
+
class Request
|
10
|
+
include HTTParty
|
11
|
+
|
12
|
+
ssl_ca_file File.dirname(__FILE__) + '/../ca-bundle.crt'
|
13
|
+
|
14
|
+
def initialize(entity_name = nil)
|
15
|
+
self.class.base_uri(Razorpay::BASE_URI)
|
16
|
+
@entity_name = entity_name
|
17
|
+
custom_headers = Razorpay.custom_headers || {}
|
18
|
+
predefined_headers = {
|
19
|
+
'User-Agent' => "Razorpay-Ruby/#{Razorpay::VERSION}; Ruby/#{RUBY_VERSION}"
|
20
|
+
}
|
21
|
+
# Order is important to give precedence to predefined headers
|
22
|
+
headers = custom_headers.merge(predefined_headers)
|
23
|
+
@options = {
|
24
|
+
basic_auth: Razorpay.auth,
|
25
|
+
timeout: 30,
|
26
|
+
headers: headers
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
def fetch(id)
|
31
|
+
request :get, "/#{@entity_name}/#{id}"
|
32
|
+
end
|
33
|
+
|
34
|
+
def all(options)
|
35
|
+
request :get, "/#{@entity_name}", options
|
36
|
+
end
|
37
|
+
|
38
|
+
def post(url, data = {})
|
39
|
+
request :post, "/#{@entity_name}/#{url}", data
|
40
|
+
end
|
41
|
+
|
42
|
+
def get(url, data = {})
|
43
|
+
request :get, "/#{@entity_name}/#{url}", data
|
44
|
+
end
|
45
|
+
|
46
|
+
def delete(url)
|
47
|
+
request :delete, "/#{@entity_name}/#{url}"
|
48
|
+
end
|
49
|
+
|
50
|
+
def put(id, data = {})
|
51
|
+
request :put, "/#{@entity_name}/#{id}", data
|
52
|
+
end
|
53
|
+
|
54
|
+
def patch(id, data = {})
|
55
|
+
request :patch, "/#{@entity_name}/#{id}", data
|
56
|
+
end
|
57
|
+
|
58
|
+
def create(data)
|
59
|
+
request :post, "/#{@entity_name}", data
|
60
|
+
end
|
61
|
+
|
62
|
+
def request(method, url, data = {})
|
63
|
+
create_instance raw_request(method, url, data)
|
64
|
+
end
|
65
|
+
|
66
|
+
def raw_request(method, url, data = {})
|
67
|
+
case method
|
68
|
+
when :get
|
69
|
+
@options[:query] = data
|
70
|
+
when :post, :put, :patch
|
71
|
+
@options[:body] = data
|
72
|
+
end
|
73
|
+
|
74
|
+
self.class.send(method, url, @options)
|
75
|
+
end
|
76
|
+
|
77
|
+
# Since we need to change the base route
|
78
|
+
def make_test_request
|
79
|
+
self.class.get Razorpay::TEST_URL, @options
|
80
|
+
end
|
81
|
+
|
82
|
+
# Recursively builds entity instances
|
83
|
+
# out of all hashes in the response object
|
84
|
+
def create_instance(res)
|
85
|
+
response = res.parsed_response
|
86
|
+
|
87
|
+
if response.is_a?(Array)==true || response.to_s.length == 0
|
88
|
+
return response
|
89
|
+
end
|
90
|
+
|
91
|
+
# if there was an error, throw it
|
92
|
+
raise_error(response['error'], res.code) if response.nil? || response.key?('error') && res.code !=200
|
93
|
+
# There must be a top level entity
|
94
|
+
# This is either one of payment, refund, or collection at present
|
95
|
+
begin
|
96
|
+
class_name = response['entity'].split('_').collect(&:capitalize).join
|
97
|
+
|
98
|
+
klass = Razorpay.const_get class_name
|
99
|
+
rescue NameError
|
100
|
+
# Use Entity class if we don't find any
|
101
|
+
klass = Razorpay::Entity
|
102
|
+
end
|
103
|
+
klass.new(response)
|
104
|
+
end
|
105
|
+
|
106
|
+
def raise_error(error, status)
|
107
|
+
# Get the error class name, require it and instantiate an error
|
108
|
+
class_name = error['code'].split('_').map(&:capitalize).join('')
|
109
|
+
args = [error['code'], status]
|
110
|
+
args.push error['field'] if error.key?('field')
|
111
|
+
require "razorpay/errors/#{error['code'].downcase}"
|
112
|
+
klass = Razorpay.const_get(class_name)
|
113
|
+
raise klass.new(*args), error['description']
|
114
|
+
rescue NameError, LoadError
|
115
|
+
# We got an unknown error, cast it to Error for now
|
116
|
+
raise Razorpay::Error.new, 'Unknown Error'
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'razorpay/request'
|
2
|
+
require 'razorpay/entity'
|
3
|
+
|
4
|
+
module Razorpay
|
5
|
+
# Settlement API allows you to fetch and delete
|
6
|
+
# Docs: https://razorpay.com/docs/api/settlements/
|
7
|
+
class Settlement < Entity
|
8
|
+
def self.request
|
9
|
+
Razorpay::Request.new('settlements')
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.fetch(id)
|
13
|
+
request.fetch id
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.reports(options={})
|
17
|
+
request.get "recon/combined", options
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.all(options = {})
|
21
|
+
request.all options
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.create(options={})
|
25
|
+
if(!options.is_a?(String) && options.key?(:settle_full_balance))
|
26
|
+
options[:settle_full_balance] = (options[:settle_full_balance] ? 1 : 0)
|
27
|
+
end
|
28
|
+
request.post "ondemand", options
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.fetch_all_ondemand_settlement(options={})
|
32
|
+
request.get "ondemand", options
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.fetch_ondemand_settlement_by_id(id, options={})
|
36
|
+
request.get "ondemand/#{id}", options
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'razorpay/request'
|
2
|
+
require 'razorpay/entity'
|
3
|
+
|
4
|
+
module Razorpay
|
5
|
+
# Subscription API allows you to create and
|
6
|
+
# manage subscriptions with Razorpay
|
7
|
+
class Subscription < Entity
|
8
|
+
def self.request
|
9
|
+
Razorpay::Request.new('subscriptions')
|
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.cancel(id, options = {})
|
25
|
+
request.post "#{id}/cancel", options
|
26
|
+
end
|
27
|
+
|
28
|
+
def cancel(options = {})
|
29
|
+
self.class.cancel id, options
|
30
|
+
end
|
31
|
+
|
32
|
+
def cancel!(options = {})
|
33
|
+
with_a_bang { cancel options }
|
34
|
+
end
|
35
|
+
|
36
|
+
def edit(options = {})
|
37
|
+
self.class.request.patch id, options
|
38
|
+
end
|
39
|
+
|
40
|
+
def pending_update
|
41
|
+
self.class.request.get "#{id}/retrieve_scheduled_changes"
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.cancel_scheduled_changes(id)
|
45
|
+
request.post "#{id}/cancel_scheduled_changes"
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.pause(id, options = {})
|
49
|
+
request.post "#{id}/pause", options
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.resume(id, options = {})
|
53
|
+
request.post "#{id}/resume", options
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.delete_offer(id, offerId)
|
57
|
+
request.delete "#{id}/#{offerId}"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'razorpay/request'
|
2
|
+
require 'razorpay/entity'
|
3
|
+
|
4
|
+
module Razorpay
|
5
|
+
# SubscriptionRegistration are an alternate way of
|
6
|
+
# creating an authorization transaction
|
7
|
+
class SubscriptionRegistration < Entity
|
8
|
+
def self.request
|
9
|
+
Razorpay::Request.new('subscription_registration/auth_links')
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.create(options)
|
13
|
+
request.create options
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'razorpay/request'
|
2
|
+
require 'razorpay/entity'
|
3
|
+
|
4
|
+
module Razorpay
|
5
|
+
# Transfer class handles all refund objects
|
6
|
+
class Transfer < Entity
|
7
|
+
def self.request
|
8
|
+
Razorpay::Request.new('transfers')
|
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
|
+
|
27
|
+
def reverse(options = {})
|
28
|
+
self.class.request.post "#{id}/reversals", options
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.fetch_settlements
|
32
|
+
request.get "?expand[]=recipient_settlement"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'openssl'
|
2
|
+
|
3
|
+
module Razorpay
|
4
|
+
# Helper functions are defined here
|
5
|
+
class Utility
|
6
|
+
def self.verify_payment_signature(attributes)
|
7
|
+
signature = attributes.delete(:razorpay_signature)
|
8
|
+
|
9
|
+
# Data requires the values to be in sorted order of their keys.
|
10
|
+
# attributes.sort returns a nested array, and the last
|
11
|
+
# element of each is the value. These are joined.
|
12
|
+
data = attributes.sort.map(&:last).join('|')
|
13
|
+
secret = Razorpay.auth[:password]
|
14
|
+
verify_signature(data, signature, secret)
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.verify_payment_link_signature(attributes)
|
18
|
+
signature = attributes.delete(:razorpay_signature)
|
19
|
+
# element of each is the value. These are joined.
|
20
|
+
data = attributes.values.join('|')
|
21
|
+
secret = Razorpay.auth[:password]
|
22
|
+
verify_signature(data, signature, secret)
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.verify_webhook_signature(body, signature, secret)
|
26
|
+
verify_signature(body, signature, secret)
|
27
|
+
end
|
28
|
+
|
29
|
+
class << self
|
30
|
+
private
|
31
|
+
|
32
|
+
def verify_signature(data, signature, secret)
|
33
|
+
expected_signature = OpenSSL::HMAC.hexdigest('SHA256', secret, data)
|
34
|
+
verified = secure_compare(expected_signature, signature)
|
35
|
+
|
36
|
+
raise SecurityError, 'Signature verification failed' unless verified
|
37
|
+
|
38
|
+
verified
|
39
|
+
end
|
40
|
+
|
41
|
+
def secure_compare(a, b)
|
42
|
+
return false unless a.bytesize == b.bytesize
|
43
|
+
|
44
|
+
l = a.unpack('C*')
|
45
|
+
r = 0
|
46
|
+
i = -1
|
47
|
+
|
48
|
+
b.each_byte do |v|
|
49
|
+
i += 1
|
50
|
+
r |= v ^ l[i]
|
51
|
+
end
|
52
|
+
|
53
|
+
r.zero?
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,49 @@
|
|
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.post "#{id}/close"
|
26
|
+
end
|
27
|
+
|
28
|
+
def close!
|
29
|
+
with_a_bang { close }
|
30
|
+
end
|
31
|
+
|
32
|
+
def payments(options = {})
|
33
|
+
r = self.class.request
|
34
|
+
r.request :get, "/virtual_accounts/#{id}/payments", options
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.add_receiver(id, options = {})
|
38
|
+
request.post "#{id}/receivers", options
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.allowed_payer(id, options = {})
|
42
|
+
request.post "#{id}/allowed_payers", options
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.delete_allowed_payer(id, payer_id)
|
46
|
+
request.delete "#{id}/allowed_payers/#{payer_id}"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/lib/razorpay.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'razorpay/card'
|
2
|
+
require 'razorpay/order'
|
3
|
+
require 'razorpay/errors'
|
4
|
+
require 'razorpay/refund'
|
5
|
+
require 'razorpay/invoice'
|
6
|
+
require 'razorpay/payment'
|
7
|
+
require 'razorpay/utility'
|
8
|
+
require 'razorpay/customer'
|
9
|
+
require 'razorpay/constants'
|
10
|
+
require 'razorpay/collection'
|
11
|
+
require 'razorpay/virtual_account'
|
12
|
+
require 'razorpay/plan'
|
13
|
+
require 'razorpay/subscription'
|
14
|
+
require 'razorpay/addon'
|
15
|
+
require 'razorpay/transfer'
|
16
|
+
require 'razorpay/subscription_registration'
|
17
|
+
require 'razorpay/settlement'
|
18
|
+
require 'razorpay/payment_link'
|
19
|
+
require 'razorpay/fund_account'
|
20
|
+
require 'razorpay/item'
|
21
|
+
require 'razorpay/qr_code'
|
22
|
+
require 'razorpay/payment_method'
|
23
|
+
|
24
|
+
# Base Razorpay module
|
25
|
+
module Razorpay
|
26
|
+
class << self
|
27
|
+
attr_accessor :auth, :custom_headers
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.setup(key_id, key_secret)
|
31
|
+
self.auth = { username: key_id, password: key_secret }
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.headers=(headers = {})
|
35
|
+
self.custom_headers = headers
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
lib = File.expand_path('lib', Dir.pwd)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'razorpay/constants'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'razorruby'
|
7
|
+
spec.version = Razorpay::VERSION
|
8
|
+
spec.authors = ['Abhay Rana', 'Harman Singh']
|
9
|
+
spec.email = ['nemo@razorpay.com', 'harman@razorpay.com']
|
10
|
+
spec.summary = "Razorpay's Ruby API"
|
11
|
+
spec.description = 'Official ruby bindings for the Razorpay API'
|
12
|
+
spec.homepage = 'https://razorpay.com/'
|
13
|
+
spec.license = 'MIT'
|
14
|
+
|
15
|
+
spec.files = `git ls-files`.split("\n")
|
16
|
+
spec.executables = spec.files.grep(/^bin/) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(/^(test|spec|features)/)
|
18
|
+
spec.require_paths = ['lib']
|
19
|
+
|
20
|
+
spec.add_dependency 'httparty', '~> 0.14'
|
21
|
+
|
22
|
+
spec.add_development_dependency 'coveralls', '~> 0.8'
|
23
|
+
spec.add_development_dependency 'minitest', '~> 5.11'
|
24
|
+
spec.add_development_dependency 'rake', '~> 12.0'
|
25
|
+
|
26
|
+
if RUBY_VERSION >= '2.1.0'
|
27
|
+
# rubocop is only run in the latest ruby build
|
28
|
+
# so we use the latest version and don't switch to a
|
29
|
+
# older version for 1.9.3
|
30
|
+
spec.add_development_dependency 'rubocop', '~> 0.49'
|
31
|
+
spec.add_development_dependency 'webmock', '~> 3.0'
|
32
|
+
else
|
33
|
+
# Webmock 3.0 does not support Ruby 1.9.3
|
34
|
+
spec.add_development_dependency 'webmock', '~> 2.3'
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
{
|
2
|
+
"entity":"collection",
|
3
|
+
"count":2,
|
4
|
+
"items":[
|
5
|
+
{
|
6
|
+
"id":"ao_00000000000002",
|
7
|
+
"entity":"addon",
|
8
|
+
"item":{
|
9
|
+
"id":"item_00000000000002",
|
10
|
+
"active":true,
|
11
|
+
"name":"Extra sweet",
|
12
|
+
"description":"1 extra sweet of the day with meals",
|
13
|
+
"amount":90000,
|
14
|
+
"unit_amount":90000,
|
15
|
+
"currency":"INR",
|
16
|
+
"type":"addon",
|
17
|
+
"unit":null,
|
18
|
+
"tax_inclusive":false,
|
19
|
+
"hsn_code":null,
|
20
|
+
"sac_code":null,
|
21
|
+
"tax_rate":null,
|
22
|
+
"tax_id":null,
|
23
|
+
"tax_group_id":null,
|
24
|
+
"created_at":1581597318,
|
25
|
+
"updated_at":1581597318
|
26
|
+
},
|
27
|
+
"quantity":1,
|
28
|
+
"created_at":1581597318,
|
29
|
+
"subscription_id":"sub_00000000000001",
|
30
|
+
"invoice_id":"inv_00000000000001"
|
31
|
+
},
|
32
|
+
{
|
33
|
+
"id":"ao_00000000000001",
|
34
|
+
"entity":"addon",
|
35
|
+
"item":{
|
36
|
+
"id":"item_00000000000001",
|
37
|
+
"active":true,
|
38
|
+
"name":"Extra appala (papadum)",
|
39
|
+
"description":"1 extra oil fried appala with meals",
|
40
|
+
"amount":30000,
|
41
|
+
"unit_amount":30000,
|
42
|
+
"currency":"INR",
|
43
|
+
"type":"addon",
|
44
|
+
"unit":null,
|
45
|
+
"tax_inclusive":false,
|
46
|
+
"hsn_code":null,
|
47
|
+
"sac_code":null,
|
48
|
+
"tax_rate":null,
|
49
|
+
"tax_id":null,
|
50
|
+
"tax_group_id":null,
|
51
|
+
"created_at":1581597318,
|
52
|
+
"updated_at":1581597318
|
53
|
+
},
|
54
|
+
"quantity":2,
|
55
|
+
"created_at":1581597318,
|
56
|
+
"subscription_id":"sub_00000000000001",
|
57
|
+
"invoice_id":null
|
58
|
+
}
|
59
|
+
]
|
60
|
+
}
|
@@ -0,0 +1,44 @@
|
|
1
|
+
{
|
2
|
+
"id": "inv_6vRZmJYFAG1mNq",
|
3
|
+
"entity": "invoice",
|
4
|
+
"receipt": null,
|
5
|
+
"invoice_number": null,
|
6
|
+
"customer_id": "cust_6vRXClWqnLhV14",
|
7
|
+
"customer_details": {
|
8
|
+
"customer_name": null,
|
9
|
+
"customer_email": "test@razorpay.com",
|
10
|
+
"customer_contact": "9876543210",
|
11
|
+
"customer_address": null
|
12
|
+
},
|
13
|
+
"order_id": "order_6vRZmJu7EPEMY0",
|
14
|
+
"line_items": [],
|
15
|
+
"payment_id": null,
|
16
|
+
"expire_by": null,
|
17
|
+
"status": "cancelled",
|
18
|
+
"issued_at": 1482299421,
|
19
|
+
"paid_at": null,
|
20
|
+
"cancelled_at": 1482299424,
|
21
|
+
"expired_at": null,
|
22
|
+
"sms_status": "sent",
|
23
|
+
"email_status": "sent",
|
24
|
+
"date": 1482299421,
|
25
|
+
"partial_payment": false,
|
26
|
+
"terms": null,
|
27
|
+
"gross_amount": 100,
|
28
|
+
"tax_amount": 0,
|
29
|
+
"amount": 100,
|
30
|
+
"amount_paid": 100,
|
31
|
+
"amount_due": 0,
|
32
|
+
"description": "Test description",
|
33
|
+
"notes": [],
|
34
|
+
"currency": "INR",
|
35
|
+
"short_url": "http://bit.ly/2i8kSqu",
|
36
|
+
"comment": null,
|
37
|
+
"view_less": true,
|
38
|
+
"type": "invoice",
|
39
|
+
"billing_start": null,
|
40
|
+
"billing_end": null,
|
41
|
+
"group_taxes_amounts": false,
|
42
|
+
"user_id": "fake_user_id",
|
43
|
+
"created_at": 1482299422
|
44
|
+
}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
{
|
2
|
+
"id": "fake_subscription_id",
|
3
|
+
"entity": "subscription",
|
4
|
+
"plan_id": "fake_plan_id",
|
5
|
+
"customer_id": "fake_customer_id",
|
6
|
+
"status": "cancelled",
|
7
|
+
"current_start": null,
|
8
|
+
"current_end": null,
|
9
|
+
"ended_at": 1509494400,
|
10
|
+
"quantity": 1,
|
11
|
+
"notes": [],
|
12
|
+
"charge_at": 1509494400,
|
13
|
+
"start_at": 1509494400,
|
14
|
+
"end_at": 1538332200,
|
15
|
+
"auth_attempts": 0,
|
16
|
+
"total_count": 12,
|
17
|
+
"paid_count": 0,
|
18
|
+
"customer_notify": true,
|
19
|
+
"created_at": 1509114729
|
20
|
+
}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
{
|
2
|
+
"razorpay_payment_id": "pay_FVmAstJWfsD3SO",
|
3
|
+
"next": [
|
4
|
+
{
|
5
|
+
"action": "redirect",
|
6
|
+
"url": "https://api.razorpay.com/v1/payments/FVmAtLUe9XZSGM/authorize"
|
7
|
+
},
|
8
|
+
{
|
9
|
+
"action": "otp_generate",
|
10
|
+
"url": "https://api.razorpay.com/v1/payments/pay_FVmAstJWfsD3SO/otp_generate?track_id=FVmAtLUe9XZSGM&key_id=<YOUR_KEY_ID>"
|
11
|
+
}
|
12
|
+
]
|
13
|
+
}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
{
|
2
|
+
"entity": "collection",
|
3
|
+
"count": 2,
|
4
|
+
"items": [
|
5
|
+
{
|
6
|
+
"id": "cust_6vRXClWqnLhV14",
|
7
|
+
"email": "test@razorpay.com",
|
8
|
+
"contact": "9876543210",
|
9
|
+
"notes": [],
|
10
|
+
"created_at": 1482299274,
|
11
|
+
"entity": "customer"
|
12
|
+
},
|
13
|
+
{
|
14
|
+
"id": "cust_50smJrkZ4Qb0HJ",
|
15
|
+
"email": "test2@razorpay.com",
|
16
|
+
"contact": "9876543211",
|
17
|
+
"notes": [],
|
18
|
+
"created_at": 1482299274,
|
19
|
+
"entity": "customer"
|
20
|
+
}
|
21
|
+
]
|
22
|
+
}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
{
|
2
|
+
"entity": "collection",
|
3
|
+
"count": 1,
|
4
|
+
"items": [
|
5
|
+
{
|
6
|
+
"id": "down_F7LroRQAAFuswd",
|
7
|
+
"entity": "payment.downtime",
|
8
|
+
"method": "card",
|
9
|
+
"begin": 1593196031,
|
10
|
+
"end": null,
|
11
|
+
"status": "started",
|
12
|
+
"scheduled": false,
|
13
|
+
"severity": "high",
|
14
|
+
"instrument": {
|
15
|
+
"issuer": "SBIN"
|
16
|
+
},
|
17
|
+
"created_at": 1593196089,
|
18
|
+
"updated_at": 1593196089
|
19
|
+
}
|
20
|
+
]
|
21
|
+
}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
{
|
2
|
+
"id": "ao_IrSY3UIqDRx7df",
|
3
|
+
"entity": "addon",
|
4
|
+
"item": {
|
5
|
+
"id": "item_00000000000001",
|
6
|
+
"active": true,
|
7
|
+
"name": "fake_item_name",
|
8
|
+
"description": "fake_item_description",
|
9
|
+
"amount": 500,
|
10
|
+
"unit_amount": 500,
|
11
|
+
"currency": "INR",
|
12
|
+
"type": "addon",
|
13
|
+
"unit": null,
|
14
|
+
"tax_inclusive": false,
|
15
|
+
"tax_id": null,
|
16
|
+
"tax_group_id": null,
|
17
|
+
"created_at": 1511525691,
|
18
|
+
"updated_at": 1511525691
|
19
|
+
},
|
20
|
+
"quantity": 1,
|
21
|
+
"created_at": 1511525697,
|
22
|
+
"subscription_id": "sub_00000000000001",
|
23
|
+
"invoice_id": null
|
24
|
+
}
|