@@ -10,7 +10,11 @@ class Payments(Base):
1010 PAYMENTS_PATH = "/v1/payments"
1111
1212 def eligibility (self , order_data ):
13- response = self .request (f"{ self .PAYMENTS_PATH } /eligibility" ).set_body (order_data ).post ()
13+ response = (
14+ self .request ("{PAYMENTS_PATH}/eligibility" .format (PAYMENTS_PATH = self .PAYMENTS_PATH ))
15+ .set_body (order_data )
16+ .post ()
17+ )
1418
1519 return Eligibility (response .json )
1620
@@ -34,11 +38,19 @@ def fetch(self, payment_id=None, limit=20, states=None):
3438 if payment_id is None :
3539 return self .fetch_all (limit = limit , states = states )
3640 else :
37- response = self .request (f"{ self .PAYMENTS_PATH } /{ payment_id } " ).get ()
41+ response = self .request (
42+ "{PAYMENTS_PATH}/{payment_id}" .format (
43+ PAYMENTS_PATH = self .PAYMENTS_PATH , payment_id = payment_id
44+ )
45+ ).get ()
3846 return Payment (response .json )
3947
4048 def flag_as_potential_fraud (self , payment_id , reason = None ):
41- request = self .request (f"{ self .PAYMENTS_PATH } /{ payment_id } /potential-fraud" )
49+ request = self .request (
50+ "{PAYMENTS_PATH}/{payment_id}/potential-fraud" .format (
51+ PAYMENTS_PATH = self .PAYMENTS_PATH , payment_id = payment_id
52+ )
53+ )
4254
4355 if reason :
4456 request .set_body ({"reason" : reason })
@@ -59,7 +71,11 @@ def add_orders_to(self, payment_id, order_data: Union[List[dict], dict]) -> List
5971 order_data = [order_data ]
6072
6173 response = (
62- self .request (f"{ self .PAYMENTS_PATH } /{ payment_id } /orders" )
74+ self .request (
75+ "{PAYMENTS_PATH}/{payment_id}/orders" .format (
76+ PAYMENTS_PATH = self .PAYMENTS_PATH , payment_id = payment_id
77+ )
78+ )
6379 .set_body ({"orders" : order_data })
6480 .put ()
6581 )
@@ -79,15 +95,23 @@ def set_orders_for(self, payment_id, order_data: Union[List[dict], dict]) -> Lis
7995 order_data = [order_data ]
8096
8197 response = (
82- self .request (f"{ self .PAYMENTS_PATH } /{ payment_id } /orders" )
98+ self .request (
99+ "{PAYMENTS_PATH}/{payment_id}/orders" .format (
100+ PAYMENTS_PATH = self .PAYMENTS_PATH , payment_id = payment_id
101+ )
102+ )
83103 .set_body ({"orders" : order_data })
84104 .post ()
85105 )
86106
87107 return [Order (o ) for o in response .json ]
88108
89109 def get_orders_for (self , payment_id ) -> List [Order ]:
90- response = self .request (f"{ self .PAYMENTS_PATH } /{ payment_id } /orders" ).get ()
110+ response = self .request (
111+ "{PAYMENTS_PATH}/{payment_id}/orders" .format (
112+ PAYMENTS_PATH = self .PAYMENTS_PATH , payment_id = payment_id
113+ )
114+ ).get ()
91115 return [Order (o ) for o in response .json ]
92116
93117 def refund (self , payment_id : str , amount : int , full_refund : bool = False , ** params ) -> Payment :
@@ -102,7 +126,11 @@ def refund(self, payment_id: str, amount: int, full_refund: bool = False, **para
102126 Default: false.
103127 :return: Updated payment object
104128 """
105- req = self .request (f"{ self .PAYMENTS_PATH } /{ payment_id } /refund" )
129+ req = self .request (
130+ "{PAYMENTS_PATH}/{payment_id}/refund" .format (
131+ PAYMENTS_PATH = self .PAYMENTS_PATH , payment_id = payment_id
132+ )
133+ )
106134
107135 refund_params = {}
108136 if not full_refund :
@@ -120,6 +148,10 @@ def send_sms(self, payment_id: str):
120148 Will raise RequestError if the SMS API is not activated on your account or
121149 in case of any other error, otherwise returns True.
122150 """
123- self .request (f"{ self .PAYMENTS_PATH } /{ payment_id } /send-sms" ).post ()
151+ self .request (
152+ "{PAYMENTS_PATH}/{payment_id}/send-sms" .format (
153+ PAYMENTS_PATH = self .PAYMENTS_PATH , payment_id = payment_id
154+ )
155+ ).post ()
124156
125157 return True
0 commit comments