razorpay 3.0.1 → 3.1.0

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 (48) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +2 -2
  3. data/CHANGELOG.md +13 -0
  4. data/README.md +4 -0
  5. data/documents/account.md +449 -0
  6. data/documents/card.md +45 -0
  7. data/documents/payment.md +44 -1
  8. data/documents/productConfiguration.md +444 -0
  9. data/documents/stakeholder.md +334 -0
  10. data/documents/tokens.md +146 -1
  11. data/documents/webhook.md +224 -0
  12. data/lib/razorpay/account.rb +39 -0
  13. data/lib/razorpay/addon.rb +1 -1
  14. data/lib/razorpay/card.rb +4 -0
  15. data/lib/razorpay/constants.rb +2 -2
  16. data/lib/razorpay/iin.rb +15 -0
  17. data/lib/razorpay/order.rb +1 -1
  18. data/lib/razorpay/product.rb +37 -0
  19. data/lib/razorpay/request.rb +16 -16
  20. data/lib/razorpay/stakeholder.rb +39 -0
  21. data/lib/razorpay/token.rb +28 -0
  22. data/lib/razorpay/virtual_account.rb +1 -1
  23. data/lib/razorpay/webhook.rb +50 -0
  24. data/lib/razorpay.rb +6 -0
  25. data/test/fixtures/fake_account.json +78 -0
  26. data/test/fixtures/fake_card_reference.json +5 -0
  27. data/test/fixtures/fake_iin_token.json +23 -0
  28. data/test/fixtures/fake_product.json +138 -0
  29. data/test/fixtures/fake_stakeholder.json +29 -0
  30. data/test/fixtures/fake_tokenise_customer.json +40 -0
  31. data/test/fixtures/fake_webhook.json +79 -0
  32. data/test/fixtures/fake_webhook_by_account_id.json +22 -0
  33. data/test/fixtures/fetch_tnc.json +11 -0
  34. data/test/fixtures/stakeholder_collection.json +35 -0
  35. data/test/fixtures/webhook_by_account_collection.json +35 -0
  36. data/test/fixtures/webhook_collection.json +85 -0
  37. data/test/razorpay/test_account.rb +134 -0
  38. data/test/razorpay/test_card.rb +6 -0
  39. data/test/razorpay/test_customer.rb +8 -8
  40. data/test/razorpay/test_iin.rb +23 -0
  41. data/test/razorpay/test_order.rb +1 -1
  42. data/test/razorpay/test_product.rb +67 -0
  43. data/test/razorpay/test_settlement.rb +1 -1
  44. data/test/razorpay/test_stakeholder.rb +87 -0
  45. data/test/razorpay/test_token.rb +66 -0
  46. data/test/razorpay/test_transfer.rb +1 -1
  47. data/test/razorpay/test_webhook.rb +132 -0
  48. metadata +47 -1
@@ -0,0 +1,334 @@
1
+ ## Stakeholders
2
+
3
+ ### Create an Stakeholder
4
+ ```rb
5
+
6
+ accountId = "acc_GP4lfNA0iIMn5B"
7
+
8
+ Razorpay::Stakeholder.create(accountId, {
9
+ "percentage_ownership": 10,
10
+ "name": "Gaurav Kumar",
11
+ "email": "gaurav.kumar@example.com",
12
+ "relationship": {
13
+ "director": 1,
14
+ "executive": 0
15
+ },
16
+ "phone": {
17
+ "primary": "7474747474",
18
+ "secondary": "7474747474"
19
+ },
20
+ "addresses": {
21
+ "residential": {
22
+ "street": "506, Koramangala 1st block",
23
+ "city": "Bengaluru",
24
+ "state": "Karnataka",
25
+ "postal_code": "560034",
26
+ "country": "IN"
27
+ }
28
+ },
29
+ "kyc": {
30
+ "pan": "AVOPB1111K"
31
+ },
32
+ "notes": {
33
+ "random_key_by_partner": "random_value"
34
+ }
35
+ })
36
+ ```
37
+
38
+ **Parameters:**
39
+
40
+ | Name | Type | Description |
41
+ |---------------|-------------|---------------------------------------------|
42
+ | email | string | The sub-merchant's business email address. |
43
+ | name* | string | The stakeholder's name as per the PAN card. The maximum length is 255 characters. |
44
+ | percentage_ownership | float | The stakeholder's ownership of the business in percentage. Only two decimal places are allowed. For example, `87.55`. The maximum length is 100 characters. |
45
+ | relationship | boolean | The stakeholder's relationship with the account’s business. |
46
+ | phone | object | All keys listed [here](https://razorpay.com/docs/api/partners/stakeholder/#create-a-stakeholder) are supported |
47
+ | addresses | object | All keys listed [here](https://razorpay.com/docs/api/partners/stakeholder/#create-a-stakeholder) are supported |
48
+ | kyc | object | All keys listed [here](https://razorpay.com/docs/api/partners/stakeholder/#create-a-stakeholder) are supported |
49
+ | notes | object | A key-value pair |
50
+
51
+ **Response:**
52
+ ```json
53
+ {
54
+ "entity": "stakeholder",
55
+ "relationship": {
56
+ "director": true
57
+ },
58
+ "phone": {
59
+ "primary": "7474747474",
60
+ "secondary": "7474747474"
61
+ },
62
+ "notes": {
63
+ "random_key_by_partner": "random_value"
64
+ },
65
+ "kyc": {
66
+ "pan": "AVOPB1111K"
67
+ },
68
+ "id": "sth_GLGgm8fFCKc92m",
69
+ "name": "Gaurav Kumar",
70
+ "email": "gaurav.kumar@example.com",
71
+ "percentage_ownership": 10,
72
+ "addresses": {
73
+ "residential": {
74
+ "street": "506, Koramangala 1st block",
75
+ "city": "Bengaluru",
76
+ "state": "Karnataka",
77
+ "postal_code": "560034",
78
+ "country": "IN"
79
+ }
80
+ }
81
+ }
82
+ ```
83
+
84
+ -------------------------------------------------------------------------------------------------------
85
+
86
+ ### Edit Stakeholder
87
+
88
+ ```rb
89
+ accountId = "acc_GP4lfNA0iIMn5B";
90
+ stakeholderId = "sth_GOQ4Eftlz62TSL";
91
+
92
+ Razorpay::Stakeholder.edit(accountId, stakeholderId, {
93
+ "percentage_ownership": 20,
94
+ "name": "Gauri Kumar",
95
+ "relationship": {
96
+ "director": 0,
97
+ "executive": 1
98
+ },
99
+ "phone": {
100
+ "primary": "9898989898",
101
+ "secondary": "9898989898"
102
+ },
103
+ "addresses": {
104
+ "residential": {
105
+ "street": "507, Koramangala 1st block",
106
+ "city": "Bangalore",
107
+ "state": "Karnataka",
108
+ "postal_code": "560035",
109
+ "country": "IN"
110
+ }
111
+ },
112
+ "kyc": {
113
+ "pan": "AVOPB1111J"
114
+ },
115
+ "notes": {
116
+ "random_key_by_partner": "random_value2"
117
+ }
118
+ })
119
+ ```
120
+
121
+ **Parameters:**
122
+
123
+ | Name | Type | Description |
124
+ |---------------|-------------|---------------------------------------------|
125
+ | accountId* | string | The unique identifier of a sub-merchant account generated by Razorpay. |
126
+ | stakeholderId* | string | The unique identifier of the stakeholder whose details are to be fetched. |
127
+ | name | string | The stakeholder's name as per the PAN card. The maximum length is 255 characters. |
128
+ | percentage_ownership | float | The stakeholder's ownership of the business in percentage. Only two decimal places are allowed. For example, `87.55`. The maximum length is 100 characters. |
129
+ | relationship | boolean | The stakeholder's relationship with the account’s business. |
130
+ | phone | object | All keys listed [here](https://razorpay.com/docs/api/partners/stakeholder/#update-a-stakeholder) are supported |
131
+ | addresses | object | All keys listed [here](https://razorpay.com/docs/api/partners/stakeholder/#update-a-stakeholder) are supported |
132
+ | kyc | object | All keys listed [here](https://razorpay.com/docs/api/partners/stakeholder/#update-a-stakeholder) are supported |
133
+ | notes | object | A key-value pair |
134
+
135
+ **Response:**
136
+ ```json
137
+ {
138
+ "id": "acc_GP4lfNA0iIMn5B",
139
+ "type": "standard",
140
+ "status": "created",
141
+ "email": "gauri@example.org",
142
+ "profile": {
143
+ "category": "healthcare",
144
+ "subcategory": "clinic",
145
+ "addresses": {
146
+ "registered": {
147
+ "street1": "507, Koramangala 1st block",
148
+ "street2": "MG Road-1",
149
+ "city": "Bengalore",
150
+ "state": "KARNATAKA",
151
+ "postal_code": "560034",
152
+ "country": "IN"
153
+ }
154
+ }
155
+ },
156
+ "notes": [],
157
+ "created_at": 1610603081,
158
+ "phone": "9000090000",
159
+ "reference_id": "randomId",
160
+ "business_type": "partnership",
161
+ "legal_business_name": "Acme Corp",
162
+ "customer_facing_business_name": "ABCD Ltd"
163
+ }
164
+ ```
165
+ -------------------------------------------------------------------------------------------------------
166
+
167
+ ### Fetch all accounts
168
+ ```rb
169
+ accountId = "acc_GP4lfNA0iIMn5B";
170
+
171
+ Razorpay::Stakeholder.all(accountId);
172
+ ```
173
+
174
+ **Parameters:**
175
+
176
+ | Name | Type | Description |
177
+ |---------------|-------------|---------------------------------------------|
178
+ | accountId* | string | The unique identifier of a sub-merchant account generated by Razorpay. |
179
+
180
+ **Response:**
181
+ ```json
182
+ {
183
+ "entity": "collection",
184
+ "items": [
185
+ {
186
+ "id": "GZ13yPHLJof9IE",
187
+ "entity": "stakeholder",
188
+ "relationship": {
189
+ "director": true
190
+ },
191
+ "phone": {
192
+ "primary": "9000090000",
193
+ "secondary": "9000090000"
194
+ },
195
+ "notes": {
196
+ "random_key_by_partner": "random_value"
197
+ },
198
+ "kyc": {
199
+ "pan": "AVOPB1111K"
200
+ },
201
+ "name": "Gaurav Kumar",
202
+ "email": "gaurav.kumar@acme.org",
203
+ "percentage_ownership": 10,
204
+ "addresses": {
205
+ "residential": {
206
+ "street": "506, Koramangala 1st block",
207
+ "city": "Bengaluru",
208
+ "state": "Karnataka",
209
+ "postal_code": "560034",
210
+ "country": "in"
211
+ }
212
+ }
213
+ }
214
+ ],
215
+ "count": 1
216
+ }
217
+ ```
218
+
219
+ -------------------------------------------------------------------------------------------------------
220
+
221
+ ### Fetch an stakeholder
222
+ ```rb
223
+ accountId = "acc_GP4lfNA0iIMn5B";
224
+
225
+ stakeholderId = "sth_GOQ4Eftlz62TSL";
226
+
227
+ Razorpay::Stakeholder.fetch(accountId, stakeholderId);
228
+ ```
229
+
230
+ **Parameters:**
231
+
232
+ | Name | Type | Description |
233
+ |-------------|-------------|---------------------------------------------|
234
+ | accountId* | string | The unique identifier of a sub-merchant account generated by Razorpay. |
235
+ | stakeholderId* | string | The unique identifier of the stakeholder whose details are to be fetched. |
236
+
237
+ **Response:**
238
+ ```json
239
+ {
240
+ "entity": "stakeholder",
241
+ "relationship": {
242
+ "director": true
243
+ },
244
+ "phone": {
245
+ "primary": "9000090000",
246
+ "secondary": "9000090000"
247
+ },
248
+ "notes": {
249
+ "random_key_by_partner": "random_value2"
250
+ },
251
+ "kyc": {
252
+ "pan": "AVOPB1111J"
253
+ },
254
+ "id": "sth_GOQ4Eftlz62TSL",
255
+ "name": "Gauri Kumar",
256
+ "email": "gauri@example.com",
257
+ "percentage_ownership": 20,
258
+ "addresses": {
259
+ "residential": {
260
+ "street": "507, Koramangala 1st block",
261
+ "city": "Bangalore",
262
+ "state": "Karnataka",
263
+ "postal_code": "560035",
264
+ "country": "in"
265
+ }
266
+ }
267
+ }
268
+ ```
269
+ -------------------------------------------------------------------------------------------------------
270
+ ### Upload account documents
271
+ ```rb
272
+ account_id = "acc_0000000000001"
273
+ stakeholder_id = "sth_00000000000001"
274
+
275
+ Razorpay::Stakeholder.upload_stakeholder_doc(account_id, stakeholder_id, {
276
+ "file": File.new("/Users/your_name/Downloads/sample_uploaded.jpeg"),
277
+ "document_type": "aadhar_front"
278
+ });
279
+
280
+ ```
281
+
282
+ **Parameters:**
283
+
284
+ | Name | Type | Description |
285
+ |-------------|-------------|---------------------------------------------|
286
+ | accountId* | string | The unique identifier of a sub-merchant account generated by Razorpay. |
287
+ | stakeholderId* | string | The unique identifier of the stakeholder whose details are to be fetched. |
288
+ | file* | string | The URL generated once the business proof document is uploaded. |
289
+ | document_type* | string | The documents valid for the proof type to be shared. In case of individual_proof_of_address, both the front and back of a document proof must be uploaded. Possible values : <br> individual_proof_of_identification: `personal_pan` <br><br> individual_proof_of_address : `voter_id_back`, `voter_id_front`, `aadhar_front`, `aadhar_back`, `passport_front`, `passport_back` |
290
+
291
+ **Response:**
292
+ ```json
293
+ {
294
+ "individual_proof_of_address": [
295
+ {
296
+ "type": "aadhar_front",
297
+ "url": "https://rzp.io/i/bzDAbNg"
298
+ }
299
+ ]
300
+ }
301
+ ```
302
+ -------------------------------------------------------------------------------------------------------
303
+
304
+ ### Fetch stakeholder documents
305
+ ```rb
306
+ account_id = "acc_0000000000001"
307
+ stakeholder_id = "sth_00000000000001"
308
+
309
+ Razorpay::Stakeholder.fetch_stakeholder_doc(account_id, stakeholder_id)
310
+ ```
311
+
312
+ **Parameters:**
313
+
314
+ | Name | Type | Description |
315
+ |-------------|-------------|---------------------------------------------|
316
+ | accountId* | string | The unique identifier of a sub-merchant account generated by Razorpay. |
317
+ | stakeholderId* | string | The unique identifier of the stakeholder whose details are to be fetched. |
318
+
319
+ **Response:**
320
+ ```json
321
+ {
322
+ "individual_proof_of_address": [
323
+ {
324
+ "type": "aadhar_front",
325
+ "document_id": "doc_GOgDZbg848e6bI"
326
+ }
327
+ ]
328
+ }
329
+ ```
330
+ -------------------------------------------------------------------------------------------------------
331
+ **PN: * indicates mandatory fields**
332
+ <br>
333
+ <br>
334
+ **For reference click [here](https://razorpay.com/docs/api/partners/stakeholder)**
data/documents/tokens.md CHANGED
@@ -40,7 +40,7 @@ Razorpay::Payment.fetch(paymentId)
40
40
  "wallet": null,
41
41
  "vpa": null,
42
42
  "email": "gaurav.kumar@example.com",
43
- "contact": "+919876543210",
43
+ "contact": "9999999999",
44
44
  "customer_id": "cust_DtHaBuooGHTuyZ",
45
45
  "token_id": "token_FHfn3rIiM1Z8nr",
46
46
  "notes": {
@@ -256,6 +256,151 @@ Razorpay::Customer.fetch(customerId).fetchTokens
256
256
  ```
257
257
  -------------------------------------------------------------------------------------------------------
258
258
 
259
+ ### Create a token
260
+
261
+ ```rb
262
+
263
+ Razorpay::Token.create({
264
+ "customer_id": "cust_1Aa00000000001",
265
+ "method": "card",
266
+ "card": {
267
+ "number": "4111111111111111",
268
+ "cvv": "123",
269
+ "expiry_month": "12",
270
+ "expiry_year": "21",
271
+ "name": "Gaurav Kumar"
272
+ },
273
+ "authentication": {
274
+ "provider": "razorpay",
275
+ "provider_reference_id": "pay_123wkejnsakd",
276
+ "authentication_reference_number": "100222021120200000000742753928"
277
+ },
278
+ "notes": []
279
+ })
280
+ ```
281
+
282
+ **Parameters:**
283
+
284
+ | Name | Type | Description |
285
+ |---------------|-------------|---------------------------------------------|
286
+ | customerId* | string | The id of the customer to be fetched |
287
+ | method* | string | The type of object that needs to be tokenised. Currently, `card` is the only supported value. |
288
+ | card* | object | All keys listed [here](https://razorpay.com/docs/partners/aggregators/partner-auth/token-sharing/#create-token-on-behalf-of-a-sub-merchant) are supported
289
+ |
290
+ | authentication | object | All keys listed [here](https://razorpay.com/docs/partners/aggregators/partner-auth/token-sharing/#create-token-on-behalf-of-a-sub-merchant) are supported |
291
+
292
+ **Response:**
293
+ ```json
294
+ {
295
+ "id": "token_IJmat4GwYATMtx",
296
+ "entity": "token",
297
+ "method": "card",
298
+ "card": {
299
+ "last4": "1111",
300
+ "network": "Visa",
301
+ "type": "credit",
302
+ "issuer": "IDFB",
303
+ "international": false,
304
+ "emi": false,
305
+ "sub_type": "consumer"
306
+ },
307
+ "customer": {
308
+ "id": "cust_1Aa00000000001",
309
+ "entity": "customer",
310
+ "name": "Bob",
311
+ "email": "bob@gmail.com",
312
+ "contact": "9000090000",
313
+ "gstin": null,
314
+ "notes": {
315
+ "notes_key_1": "Tea, Earl Grey, Hot",
316
+ "notes_key_2": "Tea, Earl Grey… decaf."
317
+ },
318
+ "created_at": 1658390470
319
+ },
320
+ "expired_at": 1701368999,
321
+ "customer_id": "cust_1Aa00000000001",
322
+ "compliant_with_tokenisation_guidelines": true,
323
+ "status": "active",
324
+ "notes": []
325
+ }
326
+ ```
327
+ -------------------------------------------------------------------------------------------------------
328
+
329
+ ### Fetch token
330
+ ```rb
331
+ Razorpay::Token.fetch({"id": "token_4lsdksD31GaZ09"});
332
+ ```
333
+
334
+ **Parameters:**
335
+
336
+ | Name | Type | Description |
337
+ |-------------|-------------|---------------------------------------------|
338
+ | id* | string | The unique identifier of a sub-merchant account generated by Razorpay. |
339
+
340
+ **Response:**
341
+ ```json
342
+ {
343
+ "id": "token_4lsdksD31GaZ09",
344
+ "entity": "token",
345
+ "customer_id": "cust_1Aa00000000001",
346
+ "method": "card",
347
+ "card": {
348
+ "last4": "3335",
349
+ "network": "Visa",
350
+ "type": "debit",
351
+ "issuer": "HDFC",
352
+ "international": false,
353
+ "emi": true,
354
+ "sub_type": "consumer",
355
+ "token_iin": "453335"
356
+ },
357
+ "compliant_with_tokenisation_guidelines": true,
358
+ "expired_at": 1748716199,
359
+ "status": "active",
360
+ "status_reason": null,
361
+ "notes": []
362
+ }
363
+ ```
364
+ -------------------------------------------------------------------------------------------------------
365
+ ### Delete a token
366
+ ```rb
367
+ Razorpay::Token.delete({"id": "token_4lsdksD31GaZ09"});
368
+ ```
369
+
370
+ **Parameters:**
371
+
372
+ | Name | Type | Description |
373
+ |-------------|-------------|---------------------------------------------|
374
+ | id* | string | The unique identifier of a sub-merchant account generated by Razorpay. |
375
+
376
+ **Response:**
377
+ ```json
378
+ []
379
+ ```
380
+ -------------------------------------------------------------------------------------------------------
381
+
382
+ ### Process a Payment on another PA/PG with Token
383
+ ```rb
384
+ Razorpay::Token.process_payment_on_alternate_pa_or_pg({"id":"spt_4lsdksD31GaZ09"});
385
+ ```
386
+
387
+ **Parameters:**
388
+
389
+ | Name | Type | Description |
390
+ |-------------|-------------|---------------------------------------------|
391
+ | id* | string | The unique identifier of the token whose details are to be fetched. |
392
+
393
+ **Response:**
394
+ ```json
395
+ {
396
+ "card": {
397
+ "number": "4016981500100002",
398
+ "expiry_month" : "12",
399
+ "expiry_year" : 2021
400
+ }
401
+ }
402
+ ```
403
+ -------------------------------------------------------------------------------------------------------
259
404
  **PN: * indicates mandatory fields**
260
405
  <br>
261
406
  <br>