11import requests
2- import datetime
32from .auth import generate_setu_headers
43from .errors import handle_setu_errors
54
65
76class URLS :
8-
97 class Sandbox :
108 url = "https://uat.setu.co/api"
119
@@ -14,20 +12,29 @@ class Prod:
1412
1513
1614class Deeplink :
17-
18- def __init__ (self , schemeId , secret , productInstance , authType = "JWT" , mode = "SANDBOX" ):
15+ def __init__ (
16+ self ,
17+ schemeId ,
18+ secret ,
19+ productInstance ,
20+ authType = "JWT" ,
21+ mode = "SANDBOX" ,
22+ ):
1923 self .schemeId = schemeId
2024 self .secret = secret
2125 self .productInstance = productInstance
2226 self .url = URLS .Sandbox .url if mode != "PRODUCTION" else URLS .Prod .url
2327 self .mode = mode
2428 self .authType = authType
25-
26-
29+
2730 if self .authType != 'JWT' :
2831 # Generate required headers
2932 self .headers = generate_setu_headers (
30- self .schemeId , self .secret , self .productInstance , self .url , self .authType
33+ self .schemeId ,
34+ self .secret ,
35+ self .productInstance ,
36+ self .url ,
37+ self .authType ,
3138 )
3239 # Set the url to v2
3340 self .url = self .url + '/v2'
@@ -42,7 +49,8 @@ def create_payment_link(
4249 expiryDate = None ,
4350 payeeName = None ,
4451 settlement = None ,
45- validationRules = None
52+ validationRules = None ,
53+ additionalInfo = None ,
4654 ):
4755
4856 path = "/payment-links"
@@ -70,15 +78,24 @@ def create_payment_link(
7078 if validationRules is not None :
7179 payload .update ({"validationRules" : validationRules })
7280
81+ if additionalInfo is not None :
82+ payload .update ({"additionalInfo" : additionalInfo })
83+
7384 # In case of JWT the token expires often enough to warrant creation of new tokens
7485 if self .authType == 'JWT' :
7586 self .headers = generate_setu_headers (
76- self .schemeId , self .secret , self .productInstance , self .url , self .authType
87+ self .schemeId ,
88+ self .secret ,
89+ self .productInstance ,
90+ self .url ,
91+ self .authType ,
7792 )
7893
7994 # Call API with required parameters
8095 response = requests .post (
81- self .url + path , json = payload , headers = self .headers
96+ self .url + path ,
97+ json = payload ,
98+ headers = self .headers ,
8299 )
83100
84101 # Handle errors
@@ -87,22 +104,21 @@ def create_payment_link(
87104 return response .json ()
88105
89106 # Check status of UPI payment link method
90- def check_payment_status (
91- self ,
92- platformBillID
93- ):
107+ def check_payment_status (self , platformBillID ):
94108 path = "/payment-links/{}" .format (platformBillID )
95-
109+
96110 # In case of JWT the token expires often enough to warrant creation of new tokens
97111 if self .authType == 'JWT' :
98112 self .headers = generate_setu_headers (
99- self .schemeId , self .secret , self .productInstance , self .url , self .authType
113+ self .schemeId ,
114+ self .secret ,
115+ self .productInstance ,
116+ self .url ,
117+ self .authType ,
100118 )
101119
102120 # Call API with required parameters
103- response = requests .get (
104- self .url + path , headers = self .headers
105- )
121+ response = requests .get (self .url + path , headers = self .headers )
106122
107123 return response .json ()
108124
@@ -130,12 +146,18 @@ def trigger_mock_payment(self, amountValue, upiID):
130146 # In case of JWT the token expires often enough to warrant creation of new tokens
131147 if self .authType == 'JWT' :
132148 self .headers = generate_setu_headers (
133- self .schemeId , self .secret , self .productInstance , self .url , self .authType
149+ self .schemeId ,
150+ self .secret ,
151+ self .productInstance ,
152+ self .url ,
153+ self .authType ,
134154 )
135155
136156 # Call API with required parameters
137157 response = requests .post (
138- self .url + path , json = payload , headers = self .headers
158+ self .url + path ,
159+ json = payload ,
160+ headers = self .headers ,
139161 )
140162
141163 return response
0 commit comments