Skip to content

Commit 53a8bb4

Browse files
authored
Merge pull request #199 from razorpay/third_party_validation
Third party validation
2 parents 17eb991 + c6dec90 commit 53a8bb4

File tree

4 files changed

+309
-2
lines changed

4 files changed

+309
-2
lines changed

documents/order.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,54 @@ client.order.create({
4646

4747
-------------------------------------------------------------------------------------------------------
4848

49+
### Create order (Third party validation)
50+
51+
```py
52+
client.order.create({
53+
"amount": 500,
54+
"method": "netbanking",
55+
"receipt": "BILL13375649",
56+
"currency": "INR",
57+
"bank_account": {
58+
"account_number": "765432123456789",
59+
"name": "Gaurav Kumar",
60+
"ifsc": "HDFC0000053"
61+
}
62+
})
63+
```
64+
65+
**Parameters:**
66+
67+
| Name | Type | Description |
68+
|-----------------|---------|------------------------------------------------------------------------------|
69+
| amount* | integer | Amount of the order to be paid |
70+
| method | string | The payment method used to make the payment. If this parameter is not passed, customers will be able to make payments using both netbanking and UPI payment methods. Possible values is `netbanking` or `upi`|
71+
| currency* | string | Currency of the order. Currently only `INR` is supported. |
72+
| receipt | string | Your system order reference id. |
73+
| notes | array | A key-value pair |
74+
|bank_account | array | All keys listed [here](https://razorpay.com/docs/payments/third-party-validation/#step-2-create-an-order) are supported |
75+
76+
**Response:**
77+
78+
```json
79+
{
80+
"id": "order_GAWN9beXgaqRyO",
81+
"entity": "order",
82+
"amount": 500,
83+
"amount_paid": 0,
84+
"amount_due": 500,
85+
"currency": "INR",
86+
"receipt": "BILL13375649",
87+
"offer_id": null,
88+
"status": "created",
89+
"attempts": 0,
90+
"notes": [],
91+
"created_at": 1573044247
92+
}
93+
```
94+
95+
-------------------------------------------------------------------------------------------------------
96+
4997
### Fetch all orders
5098

5199
```py

documents/payment.md

Lines changed: 177 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,146 @@ client.payment.createPaymentJson({
447447
```
448448
-------------------------------------------------------------------------------------------------------
449449

450+
### Create Payment Json (Third party validation)
451+
452+
```py
453+
client.payment.createPaymentJson({
454+
"amount": "500",
455+
"currency": "INR",
456+
"email": "gaurav.kumar@example.com",
457+
"contact": "9123456789",
458+
"order_id": "order_GAWN9beXgaqRyO",
459+
"method": "netbanking",
460+
"bank": "HDFC"
461+
})
462+
```
463+
464+
**Parameters:**
465+
| Name | Type | Description |
466+
|-------------|---------|--------------------------------------|
467+
| amount* | integer | Amount of the order to be paid |
468+
| currency* | string | The currency of the payment (defaults to INR) |
469+
| order_id* | string | The unique identifier of the order created. |
470+
| email* | string | Email of the customer |
471+
| contact* | string | Contact number of the customer |
472+
| method* | string | Possible value is `netbanking` |
473+
| bank* | string | The customer's bank code.For example, `HDFC`.|
474+
475+
please refer this [doc](https://razorpay.com/docs/payments/third-party-validation/s2s-integration/netbanking#step-3-create-a-payment) for params
476+
477+
**Response:** <br>
478+
```json
479+
{
480+
"razorpay_payment_id": "pay_GAWOYqPlvrtPSi",
481+
"next": [
482+
{
483+
"action": "redirect",
484+
"url": "https://api.razorpay.com/v1/payments/pay_GAWOYqPlvrtPSi/authorize"
485+
}
486+
]
487+
}
488+
```
489+
-------------------------------------------------------------------------------------------------------
490+
### Create Payment UPI s2s / VPA token (Third party validation)
491+
492+
```py
493+
client.payment.createUpi({
494+
"amount": 200,
495+
"currency": "INR",
496+
"order_id": "order_GAWRjlWkVcRh0V",
497+
"email": "gaurav.kumar@example.com",
498+
"contact": "9123456789",
499+
"method": "upi",
500+
"customer_id": "cust_EIW4T2etiweBmG",
501+
"save": 1,
502+
"ip": "192.168.0.103",
503+
"referer": "http",
504+
"user_agent": "Mozilla/5.0",
505+
"description": "Test flow",
506+
"notes": {
507+
"note_key": "value1"
508+
},
509+
"upi": {
510+
"flow": "collect",
511+
"vpa": "gauravkumar@exampleupi",
512+
"expiry_time": 5
513+
}
514+
})
515+
```
516+
517+
**Parameters:**
518+
| Name | Type | Description |
519+
|-------------|---------|--------------------------------------|
520+
| amount* | integer | Amount of the order to be paid |
521+
| currency* | string | The currency of the payment (defaults to INR) |
522+
| order_id* | string | The unique identifier of the order created. |
523+
| email* | string | Email of the customer |
524+
| customer_id* | string | The id of the customer to be fetched |
525+
| contact* | string | Contact number of the customer |
526+
| notes | array | A key-value pair |
527+
| description | string | Descriptive text of the payment. |
528+
| save | boolean | Specifies if the VPA should be stored as tokens.Possible value is `0`, `1` |
529+
| callback_url | string | URL where Razorpay will submit the final payment status. |
530+
| ip* | string | The client's browser IP address. For example `117.217.74.98` |
531+
| referer* | string | Value of `referer` header passed by the client's browser. For example, `https://example.com/` |
532+
| user_agent* | string | Value of `user_agent` header passed by the client's browser. For example, `Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36` |
533+
| upi* (for Upi only) | array | All keys listed [here](https://razorpay.com/docs/payments/third-party-validation/s2s-integration/upi/collect#step-14-initiate-a-payment) are supported |
534+
535+
**Response:** <br>
536+
```json
537+
{
538+
"razorpay_payment_id": "pay_EAm09NKReXi2e0"
539+
}
540+
```
541+
-------------------------------------------------------------------------------------------------------
542+
### Create Payment UPI s2s / VPA token (Third party validation)
543+
544+
```py
545+
client.payment.createUpi({
546+
"amount": 100,
547+
"currency": "INR",
548+
"order_id": "order_Ee0biRtLOqzRjP",
549+
"email": "gaurav.kumar@example.com",
550+
"contact": "9090909090",
551+
"method": "upi",
552+
"ip": "192.168.0.103",
553+
"referer": "http",
554+
"user_agent": "Mozilla/5.0",
555+
"description": "Test flow",
556+
"notes": {
557+
"purpose": "UPI test payment"
558+
},
559+
"upi": {
560+
"flow" : "intent"
561+
}
562+
})
563+
```
564+
565+
**Parameters:**
566+
| Name | Type | Description |
567+
|-------------|---------|--------------------------------------|
568+
| amount* | integer | Amount of the order to be paid |
569+
| currency* | string | The currency of the payment (defaults to INR) |
570+
| order_id* | string | The unique identifier of the order created. |
571+
| email* | string | Email of the customer |
572+
| customer_id* | string | The id of the customer to be fetched |
573+
| contact* | string | Contact number of the customer |
574+
| notes | array | A key-value pair |
575+
| description | string | Descriptive text of the payment. |
576+
| save | boolean | Specifies if the VPA should be stored as tokens.Possible value is `0`, `1` |
577+
| callback_url | string | URL where Razorpay will submit the final payment status. |
578+
| ip* | string | The client's browser IP address. For example `117.217.74.98` |
579+
| referer* | string | Value of `referer` header passed by the client's browser. For example, `https://example.com/` |
580+
| user_agent* | string | Value of `user_agent` header passed by the client's browser. For example, `Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36` |
581+
| upi* (for Upi only) | array | All keys listed [here](https://razorpay.com/docs/payments/third-party-validation/s2s-integration/upi/intent/#step-2-initiate-a-payment) are supported |
582+
583+
**Response:** <br>
584+
```json
585+
{
586+
"razorpay_payment_id": "pay_CMeM6XvOPGFiF",
587+
"link": "upi://pay?pa=success@razorpay&pn=xyz&tr=xxxxxxxxxxx&tn=gourav&am=1&cu=INR&mc=xyzw"
588+
}
589+
-------------------------------------------------------------------------------------------------------
450590
### OTP Generate
451591

452592
```py
@@ -514,6 +654,43 @@ Success
514654
```
515655
-------------------------------------------------------------------------------------------------------
516656

657+
### Valid VPA (Third party validation)
658+
659+
```py
660+
client.payment.validateVpa({
661+
"vpa": "gauravkumar@exampleupi"
662+
})
663+
```
664+
665+
**Parameters:**
666+
| Name | Type | Description |
667+
|-------------|---------|--------------------------------------|
668+
| vpa* | string | The virtual payment address (VPA) you want to validate. For example, `gauravkumar@exampleupi` |
669+
670+
please refer this [doc](https://razorpay.com/docs/payments/third-party-validation/s2s-integration/upi/collect#step-13-validate-the-vpa) for params
671+
672+
**Response:** <br>
673+
```json
674+
{
675+
"vpa": "gauravkumar@exampleupi",
676+
"success": true,
677+
"customer_name": "Gaurav Kumar"
678+
}
679+
```
680+
-------------------------------------------------------------------------------------------------------
681+
682+
### Fetch payment methods (Third party validation)
683+
684+
```py
685+
client = razorpay.Client(auth=("key", "")) // Use Only razorpay key
686+
client.payment.fetchPaymentMethods()
687+
```
688+
689+
**Response:** <br>
690+
please refer this [doc](https://razorpay.com/docs/payments/third-party-validation/s2s-integration/methods-api/#fetch-payment-methods) for response
691+
692+
```
693+
=======
517694
### OTP Resend
518695
519696
```py
@@ -539,7 +716,6 @@ Doc reference [doc](https://razorpay.com/docs/payments/payment-methods/cards/aut
539716
"razorpay_payment_id": "pay_JWaNvYmrx75sXo"
540717
}
541718
```
542-
543719
-------------------------------------------------------------------------------------------------------
544720

545721
**PN: * indicates mandatory fields**

documents/token.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,63 @@ client.token.delete(customerId, tokenId)
196196
```
197197
-------------------------------------------------------------------------------------------------------
198198

199+
### Fetch VPA tokens of a customer id
200+
201+
```js
202+
client.token.all(customerId)
203+
```
204+
205+
**Parameters:**
206+
207+
| Name | Type | Description |
208+
|---------------|-------------|---------------------------------------------|
209+
| customerId* | string | The id of the customer to be fetched |
210+
211+
please refer this [doc](https://razorpay.com/docs/payments/third-party-validation/s2s-integration/upi/collect/#step-22-fetch-vpa-tokens-of-a-customer)
212+
213+
**Response:**
214+
```json
215+
{
216+
"entity": "collection",
217+
"count": 1,
218+
"items": [
219+
{
220+
"id": "token_EeroOjvOvorT5L",
221+
"entity": "token",
222+
"token": "4ydxm47GQjrIEx",
223+
"bank": null,
224+
"wallet": null,
225+
"method": "card",
226+
"card": {
227+
"entity": "card",
228+
"name": "Gaurav Kumar",
229+
"last4": "8430",
230+
"network": "Visa",
231+
"type": "credit",
232+
"issuer": "HDFC",
233+
"international": false,
234+
"emi": true,
235+
"expiry_month": 12,
236+
"expiry_year": 2022,
237+
"flows": {
238+
"otp": true,
239+
"recurring": true
240+
}
241+
},
242+
"vpa": null,
243+
"recurring": false,
244+
"auth_type": null,
245+
"mrn": null,
246+
"used_at": 1586976724,
247+
"created_at": 1586976724,
248+
"expired_at": 1672511399,
249+
"dcc_enabled": false
250+
}
251+
]
252+
}
253+
```
254+
-------------------------------------------------------------------------------------------------------
255+
199256
**PN: * indicates mandatory fields**
200257
<br>
201258
<br>

razorpay/resources/payment.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,33 @@ def createRecurring(self, data={}, **kwargs):
223223
"""
224224
url = "{}/{}/recurring".format(self.base_url,'create')
225225
return self.post_url(url, data, **kwargs)
226+
227+
def createUpi(self, data={}, **kwargs):
228+
""""
229+
Initiate a payment
230+
Return:
231+
Payments dict
232+
"""
233+
url = "{}/create/{}".format(self.base_url,'upi')
234+
return self.post_url(url, data, **kwargs)
235+
236+
def validateVpa(self, data={}, **kwargs):
237+
""""
238+
Validate the VPA
239+
Return:
240+
Payments dict
241+
"""
242+
url = "{}/validate/{}".format(self.base_url,'vpa')
243+
return self.post_url(url, data, **kwargs)
244+
245+
def fetchPaymentMethods(self, **kwargs):
246+
""""
247+
Fetch payment methods
248+
Return:
249+
Payments dict
250+
"""
251+
url = "/{}".format('methods')
252+
return self.get_url(url, {}, **kwargs)
226253

227254
def otpGenerate(self, payment_id, data={}, **kwargs):
228255
""""
@@ -262,4 +289,3 @@ def otpResend(self, payment_id, data={}, **kwargs):
262289
"""
263290
url = "{}/{}/otp/resend".format(self.base_url, payment_id)
264291
return self.post_url(url, data, **kwargs)
265-

0 commit comments

Comments
 (0)