From 364b2f75387b40e6c21d1f4fe094a7a9f3023d61 Mon Sep 17 00:00:00 2001 From: ankitdas13 Date: Mon, 20 Jun 2022 08:58:01 +0530 Subject: [PATCH 1/2] added tpv payment --- documents/payment.md | 180 ++++++++++++++++++++++++++++++++++ razorpay/resources/payment.py | 27 +++++ 2 files changed, 207 insertions(+) diff --git a/documents/payment.md b/documents/payment.md index b9addc4a..69901bef 100644 --- a/documents/payment.md +++ b/documents/payment.md @@ -438,6 +438,186 @@ client.payment.createPaymentJson({ ``` ------------------------------------------------------------------------------------------------------- +### Create Payment Json (Third party validation) + +```py +client.payment.createPaymentJson({ + "amount": "500", + "currency": "INR", + "email": "gaurav.kumar@example.com", + "contact": "9123456789", + "order_id": "order_GAWN9beXgaqRyO", + "method": "netbanking", + "bank": "HDFC" +}) +``` + +**Parameters:** +| Name | Type | Description | +|-------------|---------|--------------------------------------| +| amount* | integer | Amount of the order to be paid | +| currency* | string | The currency of the payment (defaults to INR) | +| order_id* | string | The unique identifier of the order created. | +| email* | string | Email of the customer | +| contact* | string | Contact number of the customer | +| method* | string | Possible value is `netbanking` | +| bank | string | The customer's bank code.For example, `HDFC`.| + + please refer this [doc](https://razorpay.com/docs/payments/third-party-validation/s2s-integration/netbanking#step-3-create-a-payment) for params + +**Response:**
+```json +{ + "razorpay_payment_id": "pay_GAWOYqPlvrtPSi", + "next": [ + { + "action": "redirect", + "url": "https://api.razorpay.com/v1/payments/pay_GAWOYqPlvrtPSi/authorize" + } + ] +} +``` +------------------------------------------------------------------------------------------------------- +### Create Payment UPI s2s / VPA token (Third party validation) + +```py +client.payment.createUpi({ + "amount": 200, + "currency": "INR", + "order_id": "order_GAWRjlWkVcRh0V", + "email": "gaurav.kumar@example.com", + "contact": "9123456789", + "method": "upi", + "customer_id": "cust_EIW4T2etiweBmG", + "save": 1, + "ip": "192.168.0.103", + "referer": "http", + "user_agent": "Mozilla/5.0", + "description": "Test flow", + "notes": { + "note_key": "value1" + }, + "upi": { + "flow": "collect", + "vpa": "gauravkumar@exampleupi", + "expiry_time": 5 + } +}) +``` + +**Parameters:** +| Name | Type | Description | +|-------------|---------|--------------------------------------| +| amount* | integer | Amount of the order to be paid | +| currency* | string | The currency of the payment (defaults to INR) | +| order_id* | string | The unique identifier of the order created. | +| email* | string | Email of the customer | +| customer_id* | string | The id of the customer to be fetched | +| contact* | string | Contact number of the customer | +| notes | array | A key-value pair | +| description | string | Descriptive text of the payment. | +| save | boolean | Specifies if the VPA should be stored as tokens.Possible value is `0`, `1` | +| callback_url | string | URL where Razorpay will submit the final payment status. | +| ip* | string | The client's browser IP address. For example `117.217.74.98` | +| referer* | string | Value of `referer` header passed by the client's browser. For example, `https://example.com/` | +| 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` | +| 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 | + +**Response:**
+```json +{ + "razorpay_payment_id": "pay_EAm09NKReXi2e0" +} +``` +------------------------------------------------------------------------------------------------------- +### Create Payment UPI s2s / VPA token (Third party validation) + +```py +client.payment.createUpi({ + "amount": 100, + "currency": "INR", + "order_id": "order_Ee0biRtLOqzRjP", + "email": "gaurav.kumar@example.com", + "contact": "9090909090", + "method": "upi", + "ip": "192.168.0.103", + "referer": "http", + "user_agent": "Mozilla/5.0", + "description": "Test flow", + "notes": { + "purpose": "UPI test payment" + }, + "upi": { + "flow" : "intent" + } +}) +``` + +**Parameters:** +| Name | Type | Description | +|-------------|---------|--------------------------------------| +| amount* | integer | Amount of the order to be paid | +| currency* | string | The currency of the payment (defaults to INR) | +| order_id* | string | The unique identifier of the order created. | +| email* | string | Email of the customer | +| customer_id* | string | The id of the customer to be fetched | +| contact* | string | Contact number of the customer | +| notes | array | A key-value pair | +| description | string | Descriptive text of the payment. | +| save | boolean | Specifies if the VPA should be stored as tokens.Possible value is `0`, `1` | +| callback_url | string | URL where Razorpay will submit the final payment status. | +| ip* | string | The client's browser IP address. For example `117.217.74.98` | +| referer* | string | Value of `referer` header passed by the client's browser. For example, `https://example.com/` | +| 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` | +| 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 | + +**Response:**
+```json +{ + "razorpay_payment_id": "pay_CMeM6XvOPGFiF", + "link": "upi://pay?pa=success@razorpay&pn=xyz&tr=xxxxxxxxxxx&tn=gourav&am=1&cu=INR&mc=xyzw" +} +``` +------------------------------------------------------------------------------------------------------- + +### Valid VPA (Third party validation) + +```py +client.payment.validateVpa({ + "vpa": "gauravkumar@exampleupi" +}) +``` + +**Parameters:** +| Name | Type | Description | +|-------------|---------|--------------------------------------| +| vpa* | string | The virtual payment address (VPA) you want to validate. For example, `gauravkumar@exampleupi` | + + please refer this [doc](https://razorpay.com/docs/payments/third-party-validation/s2s-integration/upi/collect#step-13-validate-the-vpa) for params + +**Response:**
+```json +{ + "vpa": "gauravkumar@exampleupi", + "success": true, + "customer_name": "Gaurav Kumar" +} +``` +------------------------------------------------------------------------------------------------------- + +### Fetch payment methods (Third party validation) + +```py +client = razorpay.Client(auth=("key", "")) // Use Only razorpay key +client.payment.fetchPaymentMethods() +``` + +**Response:**
+ please refer this [doc](https://razorpay.com/docs/payments/third-party-validation/s2s-integration/methods-api/#fetch-payment-methods) for response + +``` +------------------------------------------------------------------------------------------------------- + **PN: * indicates mandatory fields**

diff --git a/razorpay/resources/payment.py b/razorpay/resources/payment.py index 93a448d2..bfa38764 100644 --- a/razorpay/resources/payment.py +++ b/razorpay/resources/payment.py @@ -223,3 +223,30 @@ def createRecurring(self, data={}, **kwargs): """ url = "{}/{}/recurring".format(self.base_url,'create') return self.post_url(url, data, **kwargs) + + def createUpi(self, data={}, **kwargs): + """" + Initiate a payment + Return: + Payments dict + """ + url = "{}/create/{}".format(self.base_url,'upi') + return self.post_url(url, data, **kwargs) + + def validateVpa(self, data={}, **kwargs): + """" + Validate the VPA + Return: + Payments dict + """ + url = "{}/validate/{}".format(self.base_url,'vpa') + return self.post_url(url, data, **kwargs) + + def fetchPaymentMethods(self, **kwargs): + """" + Fetch payment methods + Return: + Payments dict + """ + url = "/{}".format('methods') + return self.get_url(url, {}, **kwargs) From 86892167c96f26b748d88f24ca2c11e0eab8d13e Mon Sep 17 00:00:00 2001 From: ankitdas13 Date: Fri, 1 Jul 2022 11:58:44 +0530 Subject: [PATCH 2/2] update param --- documents/payment.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documents/payment.md b/documents/payment.md index 69901bef..b6001424 100644 --- a/documents/payment.md +++ b/documents/payment.md @@ -461,7 +461,7 @@ client.payment.createPaymentJson({ | email* | string | Email of the customer | | contact* | string | Contact number of the customer | | method* | string | Possible value is `netbanking` | -| bank | string | The customer's bank code.For example, `HDFC`.| +| bank* | string | The customer's bank code.For example, `HDFC`.| please refer this [doc](https://razorpay.com/docs/payments/third-party-validation/s2s-integration/netbanking#step-3-create-a-payment) for params