razorpay 3.0.0 → 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.
data/documents/upi.md CHANGED
@@ -10,6 +10,7 @@ Razorpay.setup('key_id', 'key_secret')
10
10
  para_attr = {
11
11
  "name": "Razorpay User",
12
12
  "email": "customer@razorpay.com",
13
+ "fail_existing": 0,
13
14
  "contact": 9123456780,
14
15
  "notes": {
15
16
  "notes_key_1": "Tea, Earl Grey, Hot",
@@ -52,23 +53,19 @@ Razorpay::Customer.create(para_attr)
52
53
 
53
54
  ```rb
54
55
  para_attr = {
55
- "amount": 0,
56
+ "amount": 100,
56
57
  "currency": "INR",
58
+ "customer_id": "cust_4xbQrmEoA5WJ01",
57
59
  "method": "upi",
58
- "customer_id": "cust_1Aa00000000001",
60
+ "token": {
61
+ "max_amount": 200000,
62
+ "expire_at": 2709971120,
63
+ "frequency": "monthly"
64
+ },
59
65
  "receipt": "Receipt No. 1",
60
66
  "notes": {
61
- "notes_key_1": "Beam me up Scotty",
62
- "notes_key_2": "Engage"
63
- },
64
- "token": {
65
- "auth_type": "netbanking",
66
- "max_amount": 9999900,
67
- "expire_at": 4102444799,
68
- "notes": {
69
- "notes_key_1": "Tea, Earl Grey, Hot",
70
- "notes_key_2": "Tea, Earl Grey… decaf."
71
- }
67
+ "notes_key_1": "Tea, Earl Grey, Hot",
68
+ "notes_key_2": "Tea, Earl Grey… decaf."
72
69
  }
73
70
  }
74
71
  Razorpay.Order.create(para_attr)
@@ -83,7 +80,7 @@ Razorpay.Order.create(para_attr)
83
80
  | method* | string | The authorization method. In this case the value will be `emandate` |
84
81
  | receipt | string | Your system order reference id. |
85
82
  | notes | object | A key-value pair |
86
- | token | object | A key-value pair |
83
+ | token | object | All parameters listed [here](https://razorpay.com/docs/api/payments/recurring-payments/upi/create-authorization-transaction#112-create-an-order) are supported |
87
84
 
88
85
  **Response:**
89
86
  ```json
@@ -147,17 +144,16 @@ Razorpay::SubscriptionRegistration.create(para_attr)
147
144
 
148
145
  | Name | Type | Description |
149
146
  |-----------------|---------|------------------------------------------------------------------------------|
150
- | customer | object | Details of the customer to whom the registration link will be sent. |
147
+ | customer | object | All parameters listed [here](https://razorpay.com/docs/api/payments/recurring-payments/upi/create-authorization-transaction/#121-create-a-registration-link) are supported |
151
148
  | type* | string | In this case, the value is `link`. |
152
149
  | currency* | string | The 3-letter ISO currency code for the payment. Currently, only `INR` is supported. |
153
150
  | amount* | integer | The payment amount in the smallest currency sub-unit. |
154
151
  | description* | string | A description that appears on the hosted page. For example, `12:30 p.m. Thali meals (Gaurav Kumar`). |
155
- | subscription_registration | object | Details of the authorization payment. |
156
- |sms_notify | array | Details of the line item that is billed in the invoice. |
157
- |email_notify | array | Details of the line item that is billed in the invoice. |
158
- |expire_by | array | Details of the line item that is billed in the invoice. |
159
- |receipt | string | Your system order reference id. |
160
- |notes | object | A key-value pair |
152
+ | subscription_registration | object | All parameters listed [here](https://razorpay.com/docs/api/payments/recurring-payments/upi/create-authorization-transaction/#121-create-a-registration-link) are supported |
153
+ | sms_notify | boolean | SMS notifications are to be sent by Razorpay (default : 1) |
154
+ | email_notify | boolean | Email notifications are to be sent by Razorpay (default : 1) |
155
+ | expire_by | integer | The timestamp, in Unix format, till when the customer can make the authorization payment. |
156
+ | notes | object | A key-value pair |
161
157
 
162
158
 
163
159
  **Response:**
@@ -227,7 +223,7 @@ invoiceId = "inv_JDdNb4xdf4gxQ7"
227
223
 
228
224
  medium = "email"
229
225
 
230
- Razorpay::Invoice.notifyBy(invoiceId, medium)
226
+ Razorpay::Invoice.notify_by(invoiceId, medium)
231
227
  ```
232
228
 
233
229
  **Parameters:**
@@ -322,9 +318,9 @@ Razorpay::Invoice.cancel(invoiceId)
322
318
  ### Fetch token by payment ID
323
319
 
324
320
  ```rb
325
- customerId = "cust_1Aa00000000004"
321
+ paymentId = "pay_FHfAzEJ51k8NLj"
326
322
 
327
- Razorpay::Customer.fetchTokens(customerId)
323
+ Razorpay::Payment.fetch(paymentId)
328
324
  ```
329
325
 
330
326
  **Parameters:**
@@ -382,7 +378,7 @@ Razorpay::Customer.fetchTokens(customerId)
382
378
  ```rb
383
379
  customerId = "cust_1Aa00000000004"
384
380
 
385
- Razorpay::Customer.fetchTokens(customerId)
381
+ Razorpay::Customer.fetch(customerId).fetchTokens
386
382
  ```
387
383
 
388
384
  **Parameters:**
@@ -433,7 +429,7 @@ customerId = "cust_1Aa00000000004"
433
429
 
434
430
  tokenId = "token_Hxe0skTXLeg9pF"
435
431
 
436
- Razorpay::fetch(customerId).deleteToken(tokenId)
432
+ Razorpay::Customer.fetch(customerId).deleteToken(tokenId)
437
433
  ```
438
434
 
439
435
  **Parameters:**
@@ -458,6 +454,7 @@ para_attr{
458
454
  "amount": 1000,
459
455
  "currency": "INR",
460
456
  "receipt": "Receipt No. 1",
457
+ "payment_capture": true,
461
458
  "notes": {
462
459
  "notes_key_1": "Tea, Earl Grey, Hot",
463
460
  "notes_key_2": "Tea, Earl Grey… decaf."
@@ -473,8 +470,8 @@ Razorpay::Order.create(para_attr)
473
470
  | amount* | integer | Amount of the order to be paid |
474
471
  | currency* | string | Currency of the order. Currently only `INR` is supported. |
475
472
  | receipt | string | Your system order reference id. |
473
+ | payment_capture* | boolean | Indicates whether payment status should be changed to captured automatically or not. Possible values: true - Payments are captured automatically. false - Payments are not captured automatically. |
476
474
  | notes | object | A key-value pair |
477
-
478
475
  **Response:**
479
476
  ```json
480
477
  {
@@ -512,7 +509,7 @@ para_attr = {
512
509
  "description": "Creating recurring payment for Gaurav Kumar"
513
510
  }
514
511
 
515
- Razorpay::Payment.createRecurringPayment(para_attr)
512
+ Razorpay::Payment.create_recurring_payment(para_attr)
516
513
  ```
517
514
 
518
515
  **Parameters:**
@@ -342,7 +342,7 @@ Razorpay::VirtualAccount.fetch(virtualId).payments(options)
342
342
  ```rb
343
343
  paymend_id = "pay_Di5iqCqA1WEHq6"
344
344
 
345
- Razorpay::Razorpay::Payment.fetch(paymend_id).bank_transfer
345
+ Razorpay::Payment.fetch(paymend_id).bank_transfer
346
346
  ```
347
347
 
348
348
  **Parameters:**
@@ -403,6 +403,8 @@ Razorpay::Razorpay::Payment.fetch(paymend_id).bank_transfer
403
403
 
404
404
  ### Refund payments made to a virtual account
405
405
  ```rb
406
+ paymend_id = "pay_Di5iqCqA1WEHq6"
407
+
406
408
  options = {
407
409
  "amount": "100",
408
410
  "speed": "normal",
@@ -413,7 +415,7 @@ options = {
413
415
  "receipt": "Receipt No. 31"
414
416
  }
415
417
 
416
- Razorpay::Payment.fetch(@payment_id).refund(options)
418
+ Razorpay::Payment.fetch(payment_id).refund(options)
417
419
  ```
418
420
 
419
421
  **Parameters:**
@@ -429,20 +431,22 @@ Razorpay::Payment.fetch(@payment_id).refund(options)
429
431
  **Response:**
430
432
  ```json
431
433
  {
432
- "id": "rfnd_E6j36ZEKvsWsEn",
434
+ "id": "rfnd_FP8QHiV938haTz",
433
435
  "entity": "refund",
434
- "amount": 100,
436
+ "amount": 500100,
437
+ "receipt": "Receipt No. 31",
435
438
  "currency": "INR",
436
- "payment_id": "pay_E54n391WnEAV9H",
437
- "notes": {
438
- "key_1": "value1",
439
- "key_2": "value2"
440
- },
439
+ "payment_id": "pay_FCXKPFtYfPXJPy",
440
+ "notes": [],
441
441
  "receipt": null,
442
442
  "acquirer_data": {
443
- "rrn": null
443
+ "arn": null
444
444
  },
445
- "created_at": 1579522301
445
+ "created_at": 1597078866,
446
+ "batch_id": null,
447
+ "status": "processed",
448
+ "speed_processed": "normal",
449
+ "speed_requested": "normal"
446
450
  }
447
451
  ```
448
452
  -------------------------------------------------------------------------------------------------------
@@ -469,7 +473,7 @@ Razorpay::VirtualAccount.add_receiver(virtualId, para_attr)
469
473
  |-------|-----------|--------------------------------------------------|
470
474
  | virtualId* | string | The id of the virtual to be updated |
471
475
  | types* | object | The receiver type to be added to the virtual account. Possible values are `vpa` or `bank_account` |
472
- | vpa | object | This is to be passed only when `vpa` is passed as the receiver types. |
476
+ | vpa.descriptor | string | Descriptor should be 10 characters only. |
473
477
 
474
478
  **Response:**
475
479
  For add receiver to an existing virtual account response please click [here](https://razorpay.com/docs/api/smart-collect/#add-receiver-to-an-existing-virtual-account)
@@ -560,7 +564,7 @@ Razorpay::VirtualAccount.delete_allowed_payer(virtualId,allowedPayersId)
560
564
 
561
565
  **Response:**
562
566
  ```json
563
- {}
567
+ null
564
568
  ```
565
569
  -------------------------------------------------------------------------------------------------------
566
570
  ### Close virtual account
@@ -578,6 +582,7 @@ Razorpay::VirtualAccount.close(virtualId)
578
582
 
579
583
  **Response:**
580
584
  For close virtual account response please click [here](https://razorpay.com/docs/api/smart-collect/#close-a-virtual-account)
585
+
581
586
  -------------------------------------------------------------------------------------------------------
582
587
 
583
588
  **PN: * indicates mandatory fields**
@@ -24,5 +24,9 @@ module Razorpay
24
24
  # POST subscriptions/{sub_id}/addons
25
25
  r.request :post, "/subscriptions/#{subscription_id}/addons", options
26
26
  end
27
+
28
+ def self.delete(id)
29
+ request.delete id
30
+ end
27
31
  end
28
32
  end
@@ -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 = '3.0.0'.freeze
5
+ VERSION = '3.0.1'.freeze
6
6
  end
@@ -104,5 +104,13 @@ module Razorpay
104
104
  def otp_resend
105
105
  self.class.request.post "#{id}/otp/resend"
106
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
107
115
  end
108
116
  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
data/lib/razorpay.rb CHANGED
@@ -19,6 +19,7 @@ require 'razorpay/payment_link'
19
19
  require 'razorpay/fund_account'
20
20
  require 'razorpay/item'
21
21
  require 'razorpay/qr_code'
22
+ require 'razorpay/payment_method'
22
23
 
23
24
  # Base Razorpay module
24
25
  module Razorpay
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
19
19
 
20
20
  spec.add_dependency 'httparty', '~> 0.14'
21
21
 
22
- spec.add_development_dependency 'coveralls', '~> 0.8'
22
+ spec.add_development_dependency 'coveralls_reborn', '~> 0.8'
23
23
  spec.add_development_dependency 'minitest', '~> 5.11'
24
24
  spec.add_development_dependency 'rake', '~> 12.0'
25
25
 
@@ -27,6 +27,7 @@ Gem::Specification.new do |spec|
27
27
  # rubocop is only run in the latest ruby build
28
28
  # so we use the latest version and don't switch to a
29
29
  # older version for 1.9.3
30
+ spec.add_development_dependency 'simplecov-cobertura'
30
31
  spec.add_development_dependency 'rubocop', '~> 0.49'
31
32
  spec.add_development_dependency 'webmock', '~> 3.0'
32
33
  else
@@ -0,0 +1,3 @@
1
+ {
2
+ "razorpay_payment_id": "pay_FVmAstJWfsD3SO"
3
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "vpa": "gauravkumar@exampleupi",
3
+ "success": true,
4
+ "customer_name": "Gaurav Kumar"
5
+ }
@@ -0,0 +1,149 @@
1
+ {
2
+ "entity": "methods",
3
+ "card": true,
4
+ "debit_card": true,
5
+ "credit_card": true,
6
+ "prepaid_card": true,
7
+ "card_networks": {
8
+ "AMEX": 0,
9
+ "DICL": 0,
10
+ "MC": 1,
11
+ "MAES": 1,
12
+ "VISA": 1,
13
+ "JCB": 0,
14
+ "RUPAY": 1,
15
+ "BAJAJ": 0
16
+ },
17
+ "card_subtype": {
18
+ "consumer": 1,
19
+ "business": 1,
20
+ "premium": 0
21
+ },
22
+ "amex": false,
23
+ "netbanking": {
24
+ "AUBL": "AU Small Finance Bank",
25
+ "AIRP": "Airtel Payments Bank",
26
+ "ANDB": "Andhra Bank",
27
+ "UTIB": "Axis Bank",
28
+ "BARB_R": "Bank of Baroda - Retail Banking",
29
+ "VIJB": "Bank of Baroda - Retail Banking (Erstwhile Vijaya Bank)",
30
+ "MAHB": "Bank of Maharashtra",
31
+ "CNRB": "Canara Bank",
32
+ "CSBK": "Catholic Syrian Bank",
33
+ "CBIN": "Central Bank of India",
34
+ "DCBL": "DCB Bank",
35
+ "DEUT": "Deutsche Bank",
36
+ "DLXB": "Dhanlaxmi Bank",
37
+ "ESFB": "Equitas Small Finance Bank",
38
+ "FSFB": "Fincare Small Finance Bank",
39
+ "ICIC": "ICICI Bank",
40
+ "IBKL": "IDBI",
41
+ "IDFB": "IDFC FIRST Bank",
42
+ "IDIB": "Indian Bank",
43
+ "ALLA": "Indian Bank (Erstwhile Allahabad Bank)",
44
+ "IOBA": "Indian Overseas Bank",
45
+ "INDB": "Indusind Bank",
46
+ "JAKA": "Jammu and Kashmir Bank",
47
+ "JSFB": "Jana Small Finance Bank",
48
+ "KARB": "Karnataka Bank",
49
+ "KVBL": "Karur Vysya Bank",
50
+ "KKBK": "Kotak Mahindra Bank",
51
+ "LAVB_R": "Lakshmi Vilas Bank - Retail Banking",
52
+ "NSPB": "NSDL Payments Bank",
53
+ "ORBC": "PNB (Erstwhile-Oriental Bank of Commerce)",
54
+ "UTBI": "PNB (Erstwhile-United Bank of India)",
55
+ "PSIB": "Punjab & Sind Bank",
56
+ "PUNB_R": "Punjab National Bank - Retail Banking",
57
+ "RATN": "RBL Bank",
58
+ "SVCB": "SVC Co-Operative Bank Ltd.",
59
+ "SRCB": "Saraswat Co-operative Bank",
60
+ "SIBL": "South Indian Bank",
61
+ "SCBL": "Standard Chartered Bank",
62
+ "SBBJ": "State Bank of Bikaner and Jaipur",
63
+ "SBHY": "State Bank of Hyderabad",
64
+ "SBIN": "State Bank of India",
65
+ "SBMY": "State Bank of Mysore",
66
+ "STBP": "State Bank of Patiala",
67
+ "SBTR": "State Bank of Travancore",
68
+ "TMBL": "Tamilnad Mercantile Bank",
69
+ "UCBA": "UCO Bank",
70
+ "UBIN": "Union Bank of India",
71
+ "CORP": "Union Bank of India (Erstwhile Corporation Bank)",
72
+ "YESB": "Yes Bank"
73
+ },
74
+ "wallet": {
75
+ "mobikwik": true,
76
+ "payzapp": true,
77
+ "olamoney": true,
78
+ "airtelmoney": true,
79
+ "freecharge": true,
80
+ "jiomoney": true
81
+ },
82
+ "emi": false,
83
+ "upi": true,
84
+ "cardless_emi": [],
85
+ "paylater": {
86
+ "epaylater": true,
87
+ "getsimpl": true,
88
+ "icic": true,
89
+ "hdfc": true,
90
+ "kkbk": true,
91
+ "lazypay": true
92
+ },
93
+ "google_pay_cards": false,
94
+ "app": {
95
+ "cred": 0,
96
+ "twid": 0,
97
+ "trustly": 0,
98
+ "poli": 0,
99
+ "sofort": 0,
100
+ "giropay": 0
101
+ },
102
+ "gpay": false,
103
+ "emi_types": {
104
+ "credit": false,
105
+ "debit": false
106
+ },
107
+ "debit_emi_providers": {
108
+ "HDFC": 0
109
+ },
110
+ "nach": false,
111
+ "cod": false,
112
+ "offline": false,
113
+ "recurring": {
114
+ "card": {
115
+ "credit": [
116
+ "MasterCard",
117
+ "Visa"
118
+ ],
119
+ "prepaid": [
120
+ "MasterCard",
121
+ "Visa"
122
+ ],
123
+ "debit": {
124
+ "UTIB": "Axis Bank",
125
+ "BARB": "Bank of Baroda",
126
+ "MAHB": "Bank of Maharashtra",
127
+ "CITI": "CITI Bank",
128
+ "CNRB": "Canara Bank",
129
+ "CIUB": "City Union Bank",
130
+ "ESFB": "Equitas Small Finance Bank",
131
+ "FDRL": "Federal Bank",
132
+ "HDFC": "HDFC Bank",
133
+ "HSBC": "HSBC",
134
+ "ICIC": "ICICI Bank",
135
+ "IDIB": "Indian Bank",
136
+ "ALLA": "Indian Bank (Erstwhile Allahabad Bank)",
137
+ "IOBA": "Indian Overseas Bank",
138
+ "INDB": "Indusind Bank",
139
+ "KVBL": "Karur Vysya Bank",
140
+ "KKBK": "Kotak Mahindra Bank",
141
+ "RATN": "RBL Bank",
142
+ "SBIN": "State Bank of India"
143
+ }
144
+ },
145
+ "upi": true,
146
+ "nach": false
147
+ },
148
+ "upi_intent": true
149
+ }
@@ -57,8 +57,6 @@ module Razorpay
57
57
  assert_addon_item_details(addon)
58
58
  end
59
59
 
60
- private
61
-
62
60
  def assert_addon_item_details(addon)
63
61
  addon_item = Item.new(addon.item)
64
62
 
@@ -68,5 +66,11 @@ module Razorpay
68
66
  assert_equal 'INR', addon_item.currency, 'Addon Item currency is accessible'
69
67
  assert_equal 500, addon_item.amount, 'Addon Item amount is accessible'
70
68
  end
69
+
70
+ def test_delete_addon
71
+ stub_delete(%r{addons/#{@addon_id}$}, 'empty')
72
+ addon = Razorpay::Addon.delete(@addon_id)
73
+ assert_instance_of Razorpay::Entity, addon
74
+ end
71
75
  end
72
76
  end
@@ -217,6 +217,7 @@ module Razorpay
217
217
  stub_post(%r{payments/#{@payment_id}/otp/resend$}, 'fake_otp_resend', {})
218
218
  payment = Razorpay::Payment.fetch(@payment_id).otp_resend
219
219
  assert_equal @payment_id, payment.razorpay_payment_id
220
+ end
220
221
 
221
222
  def test_payment_edit
222
223
 
@@ -253,7 +254,50 @@ module Razorpay
253
254
  stub_post(%r{payments/create/json$}, 'create_json_payment',payment_attr.to_json)
254
255
  payment = Razorpay::Payment.create_json_payment payment_attr.to_json
255
256
  assert_equal 'pay_FVmAstJWfsD3SO', payment.razorpay_payment_id
257
+ end
258
+ def test_create_upi
259
+
260
+ param_attr = {
261
+ "amount": 200,
262
+ "currency": "INR",
263
+ "order_id": "order_GAWRjlWkVcRh0V",
264
+ "email": "gaurav.kumar@example.com",
265
+ "contact": "9123456789",
266
+ "method": "upi",
267
+ "customer_id": "cust_EIW4T2etiweBmG",
268
+ "save": 1,
269
+ "ip": "192.168.0.103",
270
+ "referer": "http",
271
+ "user_agent": "Mozilla/5.0",
272
+ "description": "Test flow",
273
+ "notes": {
274
+ "note_key": "value1"
275
+ },
276
+ "upi": {
277
+ "flow": "collect",
278
+ "vpa": "gauravkumar@exampleupi",
279
+ "expiry_time": 5
280
+ }
281
+ }
282
+
283
+ stub_post(%r{payments/create/upi$}, 'fake_create_upi_payment',param_attr.to_json)
284
+ payment = Razorpay::Payment.create_upi param_attr.to_json
285
+ assert_equal 'pay_FVmAstJWfsD3SO', payment.razorpay_payment_id
286
+ end
287
+
288
+ def test_payment_methods
289
+ stub_get(/methods$/, 'payment_methods_collection')
290
+ methods = Razorpay::PaymentMethods.all
291
+ assert_equal 'methods', methods.entity
256
292
  end
257
- end
258
- end
293
+
294
+ def test_validate_vpa
295
+ param_attr = {
296
+ "vpa": "gauravkumar@exampleupi"
297
+ }
298
+ stub_post(%r{payments/validate/vpa$}, 'fake_validate_vpa',param_attr.to_json)
299
+ payment = Razorpay::Payment.validate_vpa param_attr.to_json
300
+ assert_equal param_attr[:vpa], payment.vpa
301
+ end
302
+ end
259
303
  end
data/test/test_helper.rb CHANGED
@@ -3,8 +3,10 @@ require 'simplecov'
3
3
  require 'minitest/autorun'
4
4
  require 'webmock/minitest'
5
5
  require 'razorpay'
6
+ require 'simplecov-cobertura'
6
7
 
7
8
  Coveralls.wear! if ENV['CI']
9
+ SimpleCov.formatter = SimpleCov::Formatter::CoberturaFormatter
8
10
 
9
11
  def fixture_file(filename)
10
12
  return '' if filename == ''