@@ -22,6 +22,14 @@ def __init__(self, schemeId, secret, productInstance, authType="JWT", mode="SAND
2222 self .url = URLS .Sandbox .url if mode != "PRODUCTION" else URLS .Prod .url
2323 self .mode = mode
2424 self .authType = authType
25+
26+ # Generate required headers
27+ self .headers = generate_setu_headers (
28+ self .schemeId , self .secret , self .productInstance , self .url , self .authType
29+ )
30+
31+ if self .authType != 'JWT' :
32+ self .url = self .url + '/v2'
2533
2634 # Generate UPI payment link method
2735 def create_payment_link (
@@ -61,18 +69,9 @@ def create_payment_link(
6169 if validationRules is not None :
6270 payload .update ({"validationRules" : validationRules })
6371
64- # Generate required headers
65- headers = generate_setu_headers (
66- self .schemeId , self .secret , self .productInstance , self .url , self .authType
67- )
68-
6972 # Call API with required parameters
70-
71- if self .authType != 'JWT' :
72- url = self .url + '/v2' + path
73-
7473 response = requests .post (
75- url , json = payload , headers = headers
74+ self . url + path , json = payload , headers = self . headers
7675 )
7776
7877 # Handle errors
@@ -86,15 +85,10 @@ def check_payment_status(
8685 platformBillID
8786 ):
8887 path = "/payment-links/{}" .format (platformBillID )
89-
90- # Generate required headers
91- headers = generate_setu_headers (
92- self .schemeId , self .secret , self .productInstance
93- )
94-
88+
9589 # Call API with required parameters
9690 response = requests .get (
97- self .url + path , headers = headers
91+ self .url + path , headers = self . headers
9892 )
9993
10094 return response .json ()
@@ -120,14 +114,9 @@ def trigger_mock_payment(self, amountValue, upiID):
120114 "type" : "UPI" ,
121115 }
122116
123- # Generate required headers
124- headers = generate_setu_headers (
125- self .schemeId , self .secret , self .productInstance
126- )
127-
128117 # Call API with required parameters
129118 response = requests .post (
130- self .url + path , json = payload , headers = headers
119+ self .url + path , json = payload , headers = self . headers
131120 )
132121
133122 return response
0 commit comments