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,752 @@
|
|
1
|
+
## Subscriptions
|
2
|
+
|
3
|
+
```rb
|
4
|
+
require "razorpay"
|
5
|
+
|
6
|
+
Razorpay.setup('key_id', 'key_secret')
|
7
|
+
```
|
8
|
+
### Create subscription
|
9
|
+
|
10
|
+
```rb
|
11
|
+
para_attr = {
|
12
|
+
"plan_id": "plan_7wAosPWtrkhqZw",
|
13
|
+
"customer_notify": 1,
|
14
|
+
"quantity": 5,
|
15
|
+
"total_count": 6,
|
16
|
+
"start_at": 1495995837,
|
17
|
+
"addons": [
|
18
|
+
{
|
19
|
+
"item": {
|
20
|
+
"name": "Delivery charges",
|
21
|
+
"amount": 30000,
|
22
|
+
"currency": "INR"
|
23
|
+
}
|
24
|
+
}
|
25
|
+
],
|
26
|
+
"notes": {
|
27
|
+
"key1": "value3",
|
28
|
+
"key2": "value2"
|
29
|
+
}
|
30
|
+
}
|
31
|
+
|
32
|
+
Razorpay::Subscription.create(para_attr)
|
33
|
+
```
|
34
|
+
|
35
|
+
**Parameters:**
|
36
|
+
|
37
|
+
| Name | Type | Description |
|
38
|
+
|-----------------|---------|------------------------------------------------------------------------------|
|
39
|
+
| plan_id* | string | The unique identifier for a plan that should be linked to the subscription.|
|
40
|
+
| total_count* | string | The number of billing cycles for which the customer should be charged |
|
41
|
+
| customer_notify | boolean | Indicates whether the communication to the customer would be handled by you or us |
|
42
|
+
| quantity | integer | The number of times the customer should be charged the plan amount per invoice |
|
43
|
+
| start_at | integer | The timestamp, in Unix format, for when the subscription should start. If not passed, the subscription starts immediately after the authorization payment. |
|
44
|
+
| expire_by | integer | The timestamp, in Unix format, till when the customer can make the authorization payment. |
|
45
|
+
| addons | object | Object that contains details of any upfront amount you want to collect as part of the authorization transaction. |
|
46
|
+
| notes | object | Notes you can enter for the contact for future reference. |
|
47
|
+
| offer_id | string | The unique identifier of the offer that is linked to the subscription. |
|
48
|
+
|
49
|
+
**Response:**
|
50
|
+
```json
|
51
|
+
{
|
52
|
+
"id": "sub_00000000000001",
|
53
|
+
"entity": "subscription",
|
54
|
+
"plan_id": "plan_00000000000001",
|
55
|
+
"status": "created",
|
56
|
+
"current_start": null,
|
57
|
+
"current_end": null,
|
58
|
+
"ended_at": null,
|
59
|
+
"quantity": 1,
|
60
|
+
"notes":{
|
61
|
+
"notes_key_1":"Tea, Earl Grey, Hot",
|
62
|
+
"notes_key_2":"Tea, Earl Grey… decaf."
|
63
|
+
},
|
64
|
+
"charge_at": 1580453311,
|
65
|
+
"start_at": 1580626111,
|
66
|
+
"end_at": 1583433000,
|
67
|
+
"auth_attempts": 0,
|
68
|
+
"total_count": 6,
|
69
|
+
"paid_count": 0,
|
70
|
+
"customer_notify": true,
|
71
|
+
"created_at": 1580280581,
|
72
|
+
"expire_by": 1580626111,
|
73
|
+
"short_url": "https://rzp.io/i/z3b1R61A9",
|
74
|
+
"has_scheduled_changes": false,
|
75
|
+
"change_scheduled_at": null,
|
76
|
+
"source": "api",
|
77
|
+
"offer_id":"offer_JHD834hjbxzhd38d",
|
78
|
+
"remaining_count": 5
|
79
|
+
}
|
80
|
+
```
|
81
|
+
-------------------------------------------------------------------------------------------------------
|
82
|
+
|
83
|
+
### Create subscription link
|
84
|
+
|
85
|
+
```rb
|
86
|
+
para_attr = {
|
87
|
+
"plan_id": "plan_HoYg68p5kmuvzD",
|
88
|
+
"total_count": 12,
|
89
|
+
"quantity": 1,
|
90
|
+
"expire_by": 1633237807,
|
91
|
+
"customer_notify": 1,
|
92
|
+
"addons": [
|
93
|
+
{
|
94
|
+
"item": {
|
95
|
+
"name": "Delivery charges",
|
96
|
+
"amount": 30000,
|
97
|
+
"currency": "INR"
|
98
|
+
}
|
99
|
+
}
|
100
|
+
],
|
101
|
+
"notes": {
|
102
|
+
"notes_key_1": "Tea, Earl Grey, Hot",
|
103
|
+
"notes_key_2": "Tea, Earl Grey… decaf."
|
104
|
+
},
|
105
|
+
"notify_info": {
|
106
|
+
"notify_phone": 9123456789,
|
107
|
+
"notify_email": "gaurav.kumar@example.com"
|
108
|
+
}
|
109
|
+
}
|
110
|
+
|
111
|
+
Razorpay::Subscription.create(para_attr)
|
112
|
+
```
|
113
|
+
|
114
|
+
**Parameters:**
|
115
|
+
|
116
|
+
| Name | Type | Description |
|
117
|
+
|-----------------|---------|------------------------------------------------------------------------------|
|
118
|
+
| plan_id* | string | The unique identifier for a plan that should be linked to the subscription.|
|
119
|
+
| total_count* | string | The number of billing cycles for which the customer should be charged |
|
120
|
+
| customer_notify | boolean | Indicates whether the communication to the customer would be handled by you or us |
|
121
|
+
| quantity | integer | The number of times the customer should be charged the plan amount per invoice |
|
122
|
+
| start_at | integer | The timestamp, in Unix format, for when the subscription should start. If not passed, the subscription starts immediately after the authorization payment. |
|
123
|
+
| expire_by | integer | The timestamp, in Unix format, till when the customer can make the authorization payment. |
|
124
|
+
| addons | object | Object that contains details of any upfront amount you want to collect as part of the authorization transaction. |
|
125
|
+
| notes | object | Notes you can enter for the contact for future reference. |
|
126
|
+
| notify_info | object | The customer's email and phone number to which notifications are to be sent. (PN: Use this object only if you have set the `customer_notify` parameter to 1. That is, Razorpay sends notifications to the customer.) |
|
127
|
+
| offer_id | string | The unique identifier of the offer that is linked to the subscription. |
|
128
|
+
|
129
|
+
**Response:**
|
130
|
+
```json
|
131
|
+
{
|
132
|
+
"id":"sub_00000000000002",
|
133
|
+
"entity":"subscription",
|
134
|
+
"plan_id":"plan_00000000000001",
|
135
|
+
"status":"created",
|
136
|
+
"current_start":null,
|
137
|
+
"current_end":null,
|
138
|
+
"ended_at":null,
|
139
|
+
"quantity":1,
|
140
|
+
"notes":{
|
141
|
+
"notes_key_1":"Tea, Earl Grey, Hot",
|
142
|
+
"notes_key_2":"Tea, Earl Grey… decaf."
|
143
|
+
},
|
144
|
+
"charge_at":1580453311,
|
145
|
+
"start_at":1580453311,
|
146
|
+
"end_at":1587061800,
|
147
|
+
"auth_attempts":0,
|
148
|
+
"total_count":12,
|
149
|
+
"paid_count":0,
|
150
|
+
"customer_notify":true,
|
151
|
+
"created_at":1580283117,
|
152
|
+
"expire_by":1581013800,
|
153
|
+
"short_url":"https://rzp.io/i/m0y0f",
|
154
|
+
"has_scheduled_changes":false,
|
155
|
+
"change_scheduled_at":null,
|
156
|
+
"source": "api",
|
157
|
+
"offer_id":"offer_JHD834hjbxzhd38d",
|
158
|
+
"remaining_count":12
|
159
|
+
}
|
160
|
+
```
|
161
|
+
-------------------------------------------------------------------------------------------------------
|
162
|
+
|
163
|
+
### Fetch all subscriptions
|
164
|
+
|
165
|
+
```rb
|
166
|
+
options = {"count": 1}
|
167
|
+
|
168
|
+
Razorpay::Subscription.all(options)
|
169
|
+
```
|
170
|
+
|
171
|
+
**Parameters:**
|
172
|
+
|
173
|
+
| Name | Type | Description |
|
174
|
+
|-------|-----------|--------------------------------------------------|
|
175
|
+
| from | timestamp | timestamp after which the payments were created |
|
176
|
+
| to | timestamp | timestamp before which the payments were created |
|
177
|
+
| count | integer | number of payments to fetch (default: 10) |
|
178
|
+
| skip | integer | number of payments to be skipped (default: 0) |
|
179
|
+
| plan_id | string | The unique identifier of the plan for which you want to retrieve all the subscriptions |
|
180
|
+
|
181
|
+
**Response:**
|
182
|
+
```json
|
183
|
+
|
184
|
+
{
|
185
|
+
"entity": "collection",
|
186
|
+
"count": 1,
|
187
|
+
"items": [
|
188
|
+
{
|
189
|
+
"id": "sub_00000000000001",
|
190
|
+
"entity": "subscription",
|
191
|
+
"plan_id": "plan_00000000000001",
|
192
|
+
"customer_id": "cust_D00000000000001",
|
193
|
+
"status": "active",
|
194
|
+
"current_start": 1577355871,
|
195
|
+
"current_end": 1582655400,
|
196
|
+
"ended_at": null,
|
197
|
+
"quantity": 1,
|
198
|
+
"notes": {
|
199
|
+
"notes_key_1": "Tea, Earl Grey, Hot",
|
200
|
+
"notes_key_2": "Tea, Earl Grey… decaf."
|
201
|
+
},
|
202
|
+
"charge_at": 1577385991,
|
203
|
+
"offer_id": "offer_JHD834hjbxzhd38d",
|
204
|
+
"start_at": 1577385991,
|
205
|
+
"end_at": 1603737000,
|
206
|
+
"auth_attempts": 0,
|
207
|
+
"total_count": 6,
|
208
|
+
"paid_count": 1,
|
209
|
+
"customer_notify": true,
|
210
|
+
"created_at": 1577356081,
|
211
|
+
"expire_by": 1577485991,
|
212
|
+
"short_url": "https://rzp.io/i/z3b1R61A9",
|
213
|
+
"has_scheduled_changes": false,
|
214
|
+
"change_scheduled_at": null,
|
215
|
+
"remaining_count": 5
|
216
|
+
}
|
217
|
+
]
|
218
|
+
}
|
219
|
+
```
|
220
|
+
-------------------------------------------------------------------------------------------------------
|
221
|
+
|
222
|
+
### Fetch particular subscription
|
223
|
+
|
224
|
+
```rb
|
225
|
+
subscriptionId = "sub_00000000000001"
|
226
|
+
|
227
|
+
Razorpay::Subscription.fetch(subscriptionId)
|
228
|
+
```
|
229
|
+
|
230
|
+
**Parameters:**
|
231
|
+
|
232
|
+
| Name | Type | Description |
|
233
|
+
|-------|-----------|--------------------------------------------------|
|
234
|
+
| subscriptionId* | string | The id of the subscription to be fetched |
|
235
|
+
|
236
|
+
**Response:**
|
237
|
+
```json
|
238
|
+
{
|
239
|
+
"id": "sub_00000000000001",
|
240
|
+
"entity": "subscription",
|
241
|
+
"plan_id": "plan_00000000000001",
|
242
|
+
"customer_id": "cust_D00000000000001",
|
243
|
+
"status": "active",
|
244
|
+
"current_start": 1577355871,
|
245
|
+
"current_end": 1582655400,
|
246
|
+
"ended_at": null,
|
247
|
+
"quantity": 1,
|
248
|
+
"notes":{
|
249
|
+
"notes_key_1": "Tea, Earl Grey, Hot",
|
250
|
+
"notes_key_2": "Tea, Earl Grey… decaf."
|
251
|
+
},
|
252
|
+
"charge_at": 1577385991,
|
253
|
+
"start_at": 1577385991,
|
254
|
+
"end_at": 1603737000,
|
255
|
+
"auth_attempts": 0,
|
256
|
+
"total_count": 6,
|
257
|
+
"paid_count": 1,
|
258
|
+
"customer_notify": true,
|
259
|
+
"created_at": 1577356081,
|
260
|
+
"expire_by": 1577485991,
|
261
|
+
"short_url": "https://rzp.io/i/z3b1R61A9",
|
262
|
+
"has_scheduled_changes": false,
|
263
|
+
"change_scheduled_at": null,
|
264
|
+
"source": "api",
|
265
|
+
"offer_id":"offer_JHD834hjbxzhd38d",
|
266
|
+
"remaining_count": 5
|
267
|
+
}
|
268
|
+
```
|
269
|
+
|
270
|
+
-------------------------------------------------------------------------------------------------------
|
271
|
+
|
272
|
+
### Cancel particular subscription
|
273
|
+
|
274
|
+
```rb
|
275
|
+
subscriptionId = "sub_00000000000001"
|
276
|
+
|
277
|
+
options = {"cancel_at_cycle_end":0}
|
278
|
+
|
279
|
+
Razorpay::Subscription.cancel(subscriptionId,options)
|
280
|
+
```
|
281
|
+
|
282
|
+
**Parameters:**
|
283
|
+
|
284
|
+
| Name | Type | Description |
|
285
|
+
|-------|-----------|--------------------------------------------------|
|
286
|
+
| subscriptionId* | string | The id of the subscription to be cancelled |
|
287
|
+
| cancel_at_cycle_end | boolean | Possible values:<br>0 (default): Cancel the subscription immediately. <br> 1: Cancel the subscription at the end of the current billing cycle. |
|
288
|
+
|
289
|
+
**Response:**
|
290
|
+
```json
|
291
|
+
{
|
292
|
+
"id": "sub_00000000000001",
|
293
|
+
"entity": "subscription",
|
294
|
+
"plan_id": "plan_00000000000001",
|
295
|
+
"customer_id": "cust_D00000000000001",
|
296
|
+
"status": "cancelled",
|
297
|
+
"current_start": 1580453311,
|
298
|
+
"current_end": 1581013800,
|
299
|
+
"ended_at": 1580288092,
|
300
|
+
"quantity": 1,
|
301
|
+
"notes":{
|
302
|
+
"notes_key_1": "Tea, Earl Grey, Hot",
|
303
|
+
"notes_key_2": "Tea, Earl Grey… decaf."
|
304
|
+
},
|
305
|
+
"charge_at": 1580453311,
|
306
|
+
"start_at": 1577385991,
|
307
|
+
"end_at": 1603737000,
|
308
|
+
"auth_attempts": 0,
|
309
|
+
"total_count": 6,
|
310
|
+
"paid_count": 1,
|
311
|
+
"customer_notify": true,
|
312
|
+
"created_at": 1580283117,
|
313
|
+
"expire_by": 1581013800,
|
314
|
+
"short_url": "https://rzp.io/i/z3b1R61A9",
|
315
|
+
"has_scheduled_changes": false,
|
316
|
+
"change_scheduled_at": null,
|
317
|
+
"source": "api",
|
318
|
+
"offer_id":"offer_JHD834hjbxzhd38d",
|
319
|
+
"remaining_count": 5
|
320
|
+
}
|
321
|
+
```
|
322
|
+
-------------------------------------------------------------------------------------------------------
|
323
|
+
|
324
|
+
### Update particular subscription
|
325
|
+
|
326
|
+
```rb
|
327
|
+
|
328
|
+
subscriptionId = "sub_00000000000002"
|
329
|
+
|
330
|
+
options = {
|
331
|
+
"plan_id":"plan_00000000000002",
|
332
|
+
"offer_id":"offer_JHD834hjbxzhd38d",
|
333
|
+
"quantity":5,
|
334
|
+
"remaining_count":5,
|
335
|
+
"start_at":1496000432,
|
336
|
+
"schedule_change_at":"now",
|
337
|
+
"customer_notify":1
|
338
|
+
}
|
339
|
+
|
340
|
+
Razorpay::Subscription.fetch(subscriptionId).edit(options)
|
341
|
+
```
|
342
|
+
|
343
|
+
**Parameters:**
|
344
|
+
|
345
|
+
| Name | Type | Description |
|
346
|
+
|-------|-----------|--------------------------------------------------|
|
347
|
+
| subscriptionId* | string | The id of the subscription to be updated |
|
348
|
+
| options | object | All parameters listed [here](https://razorpay.com/docs/api/subscriptions/#update-a-subscription) for update |
|
349
|
+
|
350
|
+
**Response:**
|
351
|
+
```json
|
352
|
+
{
|
353
|
+
"id":"sub_00000000000002",
|
354
|
+
"entity":"subscription",
|
355
|
+
"plan_id":"plan_00000000000002",
|
356
|
+
"customer_id":"cust_00000000000002",
|
357
|
+
"status":"authenticated",
|
358
|
+
"current_start":null,
|
359
|
+
"current_end":null,
|
360
|
+
"ended_at":null,
|
361
|
+
"quantity":3,
|
362
|
+
"notes":{
|
363
|
+
"notes_key_1":"Tea, Earl Grey, Hot",
|
364
|
+
"notes_key_2":"Tea, Earl Grey… decaf."
|
365
|
+
},
|
366
|
+
"charge_at":1580453311,
|
367
|
+
"start_at":1580453311,
|
368
|
+
"end_at":1606588200,
|
369
|
+
"auth_attempts":0,
|
370
|
+
"total_count":6,
|
371
|
+
"paid_count":0,
|
372
|
+
"customer_notify":true,
|
373
|
+
"created_at":1580283807,
|
374
|
+
"expire_by":1580626111,
|
375
|
+
"short_url":"https://rzp.io/i/yeDkUKy",
|
376
|
+
"has_scheduled_changes":false,
|
377
|
+
"change_scheduled_at":null,
|
378
|
+
"source": "api",
|
379
|
+
"offer_id":"offer_JHD834hjbxzhd38d",
|
380
|
+
"remaining_count":6
|
381
|
+
}
|
382
|
+
```
|
383
|
+
|
384
|
+
-------------------------------------------------------------------------------------------------------
|
385
|
+
|
386
|
+
### Fetch details of pending update
|
387
|
+
|
388
|
+
```rb
|
389
|
+
subscriptionId = "sub_00000000000001"
|
390
|
+
|
391
|
+
Razorpay::Subscription.fetch(subscriptionId).pending_update
|
392
|
+
```
|
393
|
+
|
394
|
+
**Parameters:**
|
395
|
+
|
396
|
+
| Name | Type | Description |
|
397
|
+
|-------|-----------|--------------------------------------------------|
|
398
|
+
| subscriptionId* | string | The id of the subscription to fetch pending update |
|
399
|
+
|
400
|
+
**Response:**
|
401
|
+
```json
|
402
|
+
{
|
403
|
+
"id":"sub_00000000000001",
|
404
|
+
"entity":"subscription",
|
405
|
+
"plan_id":"plan_00000000000003",
|
406
|
+
"customer_id":"cust_00000000000001",
|
407
|
+
"status":"active",
|
408
|
+
"current_start":1580284732,
|
409
|
+
"current_end":1580841000,
|
410
|
+
"ended_at":null,
|
411
|
+
"quantity":25,
|
412
|
+
"notes":{
|
413
|
+
"notes_key_1":"Tea, Earl Grey, Hot",
|
414
|
+
"notes_key_2":"Tea, Earl Grey… decaf."
|
415
|
+
},
|
416
|
+
"charge_at":1580841000,
|
417
|
+
"start_at":1580284732,
|
418
|
+
"end_at":1611081000,
|
419
|
+
"auth_attempts":0,
|
420
|
+
"total_count":6,
|
421
|
+
"paid_count":1,
|
422
|
+
"customer_notify":true,
|
423
|
+
"created_at":1580284702,
|
424
|
+
"expire_by":1580626111,
|
425
|
+
"short_url":"https://rzp.io/i/fFWTkbf",
|
426
|
+
"has_scheduled_changes":true,
|
427
|
+
"change_scheduled_at":1557253800,
|
428
|
+
"source": "api",
|
429
|
+
"offer_id":"offer_JHD834hjbxzhd38d",
|
430
|
+
"remaining_count":5
|
431
|
+
}
|
432
|
+
```
|
433
|
+
-------------------------------------------------------------------------------------------------------
|
434
|
+
|
435
|
+
### Cancel a update
|
436
|
+
|
437
|
+
```rb
|
438
|
+
subscriptionId = "sub_00000000000001"
|
439
|
+
|
440
|
+
Razorpay::Subscription.cancel_scheduled_changes(subscriptionId)
|
441
|
+
```
|
442
|
+
|
443
|
+
**Parameters:**
|
444
|
+
|
445
|
+
| Name | Type | Description |
|
446
|
+
|-------|-----------|--------------------------------------------------|
|
447
|
+
| subscriptionId* | string | The id of the subscription to be cancel an update |
|
448
|
+
|
449
|
+
**Response:**
|
450
|
+
```json
|
451
|
+
{
|
452
|
+
"id": "sub_00000000000001",
|
453
|
+
"entity": "subscription",
|
454
|
+
"plan_id": "plan_00000000000003",
|
455
|
+
"customer_id": "cust_00000000000001",
|
456
|
+
"status": "active",
|
457
|
+
"current_start": 1580284732,
|
458
|
+
"current_end": 1580841000,
|
459
|
+
"ended_at": null,
|
460
|
+
"quantity": 1,
|
461
|
+
"notes": {
|
462
|
+
"notes_key_1": "Tea, Earl Grey, Hot",
|
463
|
+
"notes_key_2": "Tea, Earl Grey… decaf."
|
464
|
+
},
|
465
|
+
"charge_at": 1580841000,
|
466
|
+
"start_at": 1580284732,
|
467
|
+
"end_at": 1611081000,
|
468
|
+
"auth_attempts": 0,
|
469
|
+
"total_count": 6,
|
470
|
+
"paid_count": 1,
|
471
|
+
"customer_notify": true,
|
472
|
+
"created_at": 1580284702,
|
473
|
+
"expire_by": 1580626111,
|
474
|
+
"short_url": "https://rzp.io/i/fFWTkbf",
|
475
|
+
"has_scheduled_changes": false,
|
476
|
+
"change_scheduled_at": 1527858600,
|
477
|
+
"source": "api",
|
478
|
+
"offer_id":"offer_JHD834hjbxzhd38d",
|
479
|
+
"remaining_count": 5
|
480
|
+
}
|
481
|
+
```
|
482
|
+
-------------------------------------------------------------------------------------------------------
|
483
|
+
|
484
|
+
### Pause a subscription
|
485
|
+
|
486
|
+
```rb
|
487
|
+
subscriptionId = "sub_00000000000001"
|
488
|
+
|
489
|
+
options = {"pause_at": "now"}
|
490
|
+
|
491
|
+
Razorpay::Subscription.pause(subscriptionId,options)
|
492
|
+
```
|
493
|
+
|
494
|
+
**Parameters:**
|
495
|
+
|
496
|
+
| Name | Type | Description |
|
497
|
+
|-------|-----------|--------------------------------------------------|
|
498
|
+
| subscriptionId* | string | The id of the subscription to be paused |
|
499
|
+
| pause_at | string | To pause the subscription, possible values: `now` |
|
500
|
+
|
501
|
+
**Response:**
|
502
|
+
```json
|
503
|
+
{
|
504
|
+
"id": "sub_00000000000001",
|
505
|
+
"entity": "subscription",
|
506
|
+
"plan_id": "plan_00000000000001",
|
507
|
+
"status": "paused",
|
508
|
+
"current_start": null,
|
509
|
+
"current_end": null,
|
510
|
+
"ended_at": null,
|
511
|
+
"quantity": 1,
|
512
|
+
"notes":{
|
513
|
+
"notes_key_1":"Tea, Earl Grey, Hot",
|
514
|
+
"notes_key_2":"Tea, Earl Grey… decaf."
|
515
|
+
},
|
516
|
+
"charge_at": null,
|
517
|
+
"start_at": 1580626111,
|
518
|
+
"end_at": 1583433000,
|
519
|
+
"auth_attempts": 0,
|
520
|
+
"total_count": 6,
|
521
|
+
"paid_count": 0,
|
522
|
+
"customer_notify": true,
|
523
|
+
"created_at": 1580280581,
|
524
|
+
"paused_at": 1590280581,
|
525
|
+
"expire_by": 1580626111,
|
526
|
+
"pause_initiated_by": "self",
|
527
|
+
"short_url": "https://rzp.io/i/z3b1R61A9",
|
528
|
+
"has_scheduled_changes": false,
|
529
|
+
"change_scheduled_at": null,
|
530
|
+
"source": "api",
|
531
|
+
"offer_id":"offer_JHD834hjbxzhd38d",
|
532
|
+
"remaining_count": 6
|
533
|
+
}
|
534
|
+
```
|
535
|
+
-------------------------------------------------------------------------------------------------------
|
536
|
+
|
537
|
+
### Resume a subscription
|
538
|
+
|
539
|
+
```rb
|
540
|
+
subscriptionId = "sub_00000000000001"
|
541
|
+
|
542
|
+
options = {"resume_at": "now"}
|
543
|
+
|
544
|
+
Razorpay::Subscription.resume(subscriptionId,options)
|
545
|
+
```
|
546
|
+
|
547
|
+
**Parameters:**
|
548
|
+
|
549
|
+
| Name | Type | Description |
|
550
|
+
|-------|-----------|--------------------------------------------------|
|
551
|
+
| subscriptionId* | string | The id of the subscription to be resumed |
|
552
|
+
| resume_at | string | To resume the subscription, possible values: `now` |
|
553
|
+
|
554
|
+
**Response:**
|
555
|
+
```json
|
556
|
+
{
|
557
|
+
"id": "sub_00000000000001",
|
558
|
+
"entity": "subscription",
|
559
|
+
"plan_id": "plan_00000000000001",
|
560
|
+
"status": "active",
|
561
|
+
"current_start": null,
|
562
|
+
"current_end": null,
|
563
|
+
"ended_at": null,
|
564
|
+
"quantity": 1,
|
565
|
+
"notes":{
|
566
|
+
"notes_key_1":"Tea, Earl Grey, Hot",
|
567
|
+
"notes_key_2":"Tea, Earl Grey… decaf."
|
568
|
+
},
|
569
|
+
"charge_at": 1580453311,
|
570
|
+
"start_at": 1580626111,
|
571
|
+
"end_at": 1583433000,
|
572
|
+
"auth_attempts": 0,
|
573
|
+
"total_count": 6,
|
574
|
+
"paid_count": 0,
|
575
|
+
"customer_notify": true,
|
576
|
+
"created_at": 1580280581,
|
577
|
+
"paused_at": 1590280581,
|
578
|
+
"expire_by": 1580626111,
|
579
|
+
"pause_initiated_by": null,
|
580
|
+
"short_url": "https://rzp.io/i/z3b1R61A9",
|
581
|
+
"has_scheduled_changes": false,
|
582
|
+
"change_scheduled_at": null,
|
583
|
+
"source": "api",
|
584
|
+
"offer_id":"offer_JHD834hjbxzhd38d",
|
585
|
+
"remaining_count": 6
|
586
|
+
}
|
587
|
+
```
|
588
|
+
-------------------------------------------------------------------------------------------------------
|
589
|
+
|
590
|
+
### Fetch all invoices for a subscription
|
591
|
+
|
592
|
+
```rb
|
593
|
+
|
594
|
+
para_attr = {"subscription_id": "sub_IUtnvzIeC9qwiY"}
|
595
|
+
|
596
|
+
Razorpay::Invoice.all(para_attr)
|
597
|
+
```
|
598
|
+
|
599
|
+
**Parameters:**
|
600
|
+
|
601
|
+
| Name | Type | Description |
|
602
|
+
|-------|-----------|--------------------------------------------------|
|
603
|
+
| subscriptionId* | string | The id of the subscription to fetch invoices |
|
604
|
+
|
605
|
+
**Response:**
|
606
|
+
```json
|
607
|
+
{
|
608
|
+
"entity": "collection",
|
609
|
+
"count": 1,
|
610
|
+
"items": [
|
611
|
+
{
|
612
|
+
"id": "inv_00000000000003",
|
613
|
+
"entity": "invoice",
|
614
|
+
"receipt": null,
|
615
|
+
"invoice_number": null,
|
616
|
+
"customer_id": "cust_00000000000001",
|
617
|
+
"customer_details": {
|
618
|
+
"id": "cust_00000000000001",
|
619
|
+
"name": null,
|
620
|
+
"email": "gaurav.kumar@example.com",
|
621
|
+
"contact": "+919876543210",
|
622
|
+
"gstin": null,
|
623
|
+
"billing_address": null,
|
624
|
+
"shipping_address": null,
|
625
|
+
"customer_name": null,
|
626
|
+
"customer_email": "gaurav.kumar@example.com",
|
627
|
+
"customer_contact": "+919876543210"
|
628
|
+
},
|
629
|
+
"order_id": "order_00000000000002",
|
630
|
+
"subscription_id": "sub_00000000000001",
|
631
|
+
"line_items": [
|
632
|
+
{
|
633
|
+
"id": "li_00000000000003",
|
634
|
+
"item_id": null,
|
635
|
+
"ref_id": null,
|
636
|
+
"ref_type": null,
|
637
|
+
"name": "Monthly Plan",
|
638
|
+
"description": null,
|
639
|
+
"amount": 99900,
|
640
|
+
"unit_amount": 99900,
|
641
|
+
"gross_amount": 99900,
|
642
|
+
"tax_amount": 0,
|
643
|
+
"taxable_amount": 99900,
|
644
|
+
"net_amount": 99900,
|
645
|
+
"currency": "INR",
|
646
|
+
"type": "plan",
|
647
|
+
"tax_inclusive": false,
|
648
|
+
"hsn_code": null,
|
649
|
+
"sac_code": null,
|
650
|
+
"tax_rate": null,
|
651
|
+
"unit": null,
|
652
|
+
"quantity": 1,
|
653
|
+
"taxes": []
|
654
|
+
}
|
655
|
+
],
|
656
|
+
"payment_id": "pay_00000000000002",
|
657
|
+
"status": "paid",
|
658
|
+
"expire_by": null,
|
659
|
+
"issued_at": 1593344888,
|
660
|
+
"paid_at": 1593344889,
|
661
|
+
"cancelled_at": null,
|
662
|
+
"expired_at": null,
|
663
|
+
"sms_status": null,
|
664
|
+
"email_status": null,
|
665
|
+
"date": 1593344888,
|
666
|
+
"terms": null,
|
667
|
+
"partial_payment": false,
|
668
|
+
"gross_amount": 99900,
|
669
|
+
"tax_amount": 0,
|
670
|
+
"taxable_amount": 99900,
|
671
|
+
"amount": 99900,
|
672
|
+
"amount_paid": 99900,
|
673
|
+
"amount_due": 0,
|
674
|
+
"currency": "INR",
|
675
|
+
"currency_symbol": "₹",
|
676
|
+
"description": null,
|
677
|
+
"notes": [],
|
678
|
+
"comment": null,
|
679
|
+
"short_url": "https://rzp.io/i/Ys4feGqEp",
|
680
|
+
"view_less": true,
|
681
|
+
"billing_start": 1594405800,
|
682
|
+
"billing_end": 1597084200,
|
683
|
+
"type": "invoice",
|
684
|
+
"group_taxes_discounts": false,
|
685
|
+
"created_at": 1593344888,
|
686
|
+
"idempotency_key": null
|
687
|
+
}
|
688
|
+
]
|
689
|
+
}
|
690
|
+
```
|
691
|
+
-------------------------------------------------------------------------------------------------------
|
692
|
+
|
693
|
+
### Delete offer linked to a subscription
|
694
|
+
|
695
|
+
```rb
|
696
|
+
subscriptionId = "sub_I3GGEs7Xgmnozy"
|
697
|
+
|
698
|
+
offerId = "offer_JCTD1XMlUmzF6Z"
|
699
|
+
|
700
|
+
Razorpay::Subscription.delete_offer(subscriptionId, offerId)
|
701
|
+
```
|
702
|
+
|
703
|
+
**Parameters:**
|
704
|
+
|
705
|
+
| Name | Type | Description |
|
706
|
+
|-------|-----------|--------------------------------------------------|
|
707
|
+
| subscriptionId* | string | The id of the subscription to offer need to be deleted |
|
708
|
+
| offerId* | string | The id of the offer linked to subscription |
|
709
|
+
|
710
|
+
**Response:**
|
711
|
+
```json
|
712
|
+
{
|
713
|
+
"id": "sub_I3GGEs7Xgmnozy",
|
714
|
+
"entity": "subscription",
|
715
|
+
"plan_id": "plan_HuXrfsI0ZZ3peu",
|
716
|
+
"customer_id": "cust_I3FToKbnExwDLu",
|
717
|
+
"status": "active",
|
718
|
+
"current_start": 1632914901,
|
719
|
+
"current_end": 1635445800,
|
720
|
+
"ended_at": null,
|
721
|
+
"quantity": 1,
|
722
|
+
"notes": [],
|
723
|
+
"charge_at": 1635445800,
|
724
|
+
"start_at": 1632914901,
|
725
|
+
"end_at": 1645986600,
|
726
|
+
"auth_attempts": 0,
|
727
|
+
"total_count": 6,
|
728
|
+
"paid_count": 1,
|
729
|
+
"customer_notify": true,
|
730
|
+
"created_at": 1632914246,
|
731
|
+
"expire_by": 1635532200,
|
732
|
+
"short_url": "https://rzp.io/i/SOvRWaYP81",
|
733
|
+
"has_scheduled_changes": false,
|
734
|
+
"change_scheduled_at": null,
|
735
|
+
"source": "dashboard",
|
736
|
+
"payment_method": "card",
|
737
|
+
"offer_id": null,
|
738
|
+
"remaining_count": 5
|
739
|
+
}
|
740
|
+
```
|
741
|
+
-------------------------------------------------------------------------------------------------------
|
742
|
+
|
743
|
+
### Authentication Transaction
|
744
|
+
|
745
|
+
Please refer this [doc](https://razorpay.com/docs/api/subscriptions/#authentication-transaction) for authentication of transaction
|
746
|
+
|
747
|
+
-------------------------------------------------------------------------------------------------------
|
748
|
+
|
749
|
+
**PN: * indicates mandatory fields**
|
750
|
+
<br>
|
751
|
+
<br>
|
752
|
+
**For reference click [here](https://razorpay.com/docs/api/subscriptions/#subscriptions)**
|