@@ -174,7 +174,7 @@ def _handleValidateResponse(self, response, flwRef, request=None):
174
174
175
175
176
176
# Charge function (hasFailed is a flag that indicates there is a timeout), shouldReturnRequest indicates whether to send the request back to the _handleResponses function
177
- def charge (self , paymentDetails , requiredParameters , endpoint , shouldReturnRequest = False , isMpesa = False ):
177
+ def charge (self , feature_name , paymentDetails , requiredParameters , endpoint , shouldReturnRequest = False , isMpesa = False ):
178
178
""" This is the base charge call. It is usually overridden by implementing classes.\n
179
179
Parameters include:\n
180
180
paymentDetails (dict) -- These are the parameters passed to the function for processing\n
@@ -213,6 +213,18 @@ def charge(self, paymentDetails, requiredParameters, endpoint, shouldReturnReque
213
213
"alg" : "3DES-24"
214
214
}
215
215
response = requests .post (endpoint , headers = headers , data = json .dumps (payload ))
216
+
217
+ #feature logging
218
+ if response .ok :
219
+ tracking_endpoint = self ._trackingMap
220
+ responseTime = response .elapsed .total_seconds ()
221
+ tracking_payload = {"publicKey" : self ._getPublicKey (),"language" : "Python v2" , "version" : "1.2.5" , "title" : feature_name , "message" : responseTime }
222
+ tracking_response = requests .post (tracking_endpoint , data = json .dumps (tracking_payload ))
223
+ else :
224
+ tracking_endpoint = self ._trackingMap
225
+ responseTime = response .elapsed .total_seconds ()
226
+ tracking_payload = {"publicKey" : self ._getPublicKey (),"language" : "Python v2" , "version" : "1.2.5" , "title" : feature_name + "-error" , "message" : responseTime }
227
+ tracking_response = requests .post (tracking_endpoint , data = json .dumps (tracking_payload ))
216
228
217
229
if shouldReturnRequest :
218
230
if isMpesa :
@@ -222,9 +234,10 @@ def charge(self, paymentDetails, requiredParameters, endpoint, shouldReturnReque
222
234
if isMpesa :
223
235
return self ._handleChargeResponse (response , paymentDetails ["txRef" ], paymentDetails , True )
224
236
return self ._handleChargeResponse (response , paymentDetails ["txRef" ])
237
+
225
238
226
239
227
- def validate (self , flwRef , otp , endpoint = None ):
240
+ def validate (self , feature_name , flwRef , otp , endpoint = None ):
228
241
""" This is the base validate call.\n
229
242
Parameters include:\n
230
243
flwRef (string) -- This is the flutterwave reference returned from a successful charge call. You can access this from action["flwRef"] returned from the charge call\n
@@ -247,10 +260,23 @@ def validate(self, flwRef, otp, endpoint=None):
247
260
}
248
261
249
262
response = requests .post (endpoint , headers = headers , data = json .dumps (payload ))
263
+
264
+ #feature logging
265
+ if response .ok :
266
+ tracking_endpoint = self ._trackingMap
267
+ responseTime = response .elapsed .total_seconds ()
268
+ tracking_payload = {"publicKey" : self ._getPublicKey (),"language" : "Python v2" , "version" : "1.2.5" , "title" : feature_name , "message" : responseTime }
269
+ tracking_response = requests .post (tracking_endpoint , data = json .dumps (tracking_payload ))
270
+ else :
271
+ tracking_endpoint = self ._trackingMap
272
+ responseTime = response .elapsed .total_seconds ()
273
+ tracking_payload = {"publicKey" : self ._getPublicKey (),"language" : "Python v2" , "version" : "1.2.5" , "title" : feature_name + "-error" , "message" : responseTime }
274
+ tracking_response = requests .post (tracking_endpoint , data = json .dumps (tracking_payload ))
275
+
250
276
return self ._handleValidateResponse (response , flwRef )
251
277
252
278
# Verify charge
253
- def verify (self , txRef , endpoint = None ):
279
+ def verify (self , feature_name , txRef , endpoint = None ):
254
280
""" This is used to check the status of a transaction.\n
255
281
Parameters include:\n
256
282
txRef (string) -- This is the transaction reference that you passed to your charge call. If you didn't define a reference, you can access the auto-generated one from payload["txRef"] or action["txRef"] from the charge call\n
@@ -269,10 +295,23 @@ def verify(self, txRef, endpoint=None):
269
295
"SECKEY" : self ._getSecretKey ()
270
296
}
271
297
response = requests .post (endpoint , headers = headers , data = json .dumps (payload ))
298
+
299
+ #feature logging
300
+ if response .ok :
301
+ tracking_endpoint = self ._trackingMap
302
+ responseTime = response .elapsed .total_seconds ()
303
+ tracking_payload = {"publicKey" : self ._getPublicKey (),"language" : "Python v2" , "version" : "1.2.5" , "title" : feature_name , "message" : responseTime }
304
+ tracking_response = requests .post (tracking_endpoint , data = json .dumps (tracking_payload ))
305
+ else :
306
+ tracking_endpoint = self ._trackingMap
307
+ responseTime = response .elapsed .total_seconds ()
308
+ tracking_payload = {"publicKey" : self ._getPublicKey (),"language" : "Python v2" , "version" : "1.2.5" , "title" : feature_name + "-error" , "message" : responseTime }
309
+ tracking_response = requests .post (tracking_endpoint , data = json .dumps (tracking_payload ))
310
+
272
311
return self ._handleVerifyResponse (response , txRef )
273
312
274
313
#Refund call
275
- def refund (self , flwRef ):
314
+ def refund (self , feature_name , flwRef ):
276
315
""" This is used to refund a transaction from any of Rave's component objects.\n
277
316
Parameters include:\n
278
317
flwRef (string) -- This is the flutterwave reference returned from a successful call from any component. You can access this from action["flwRef"] returned from the charge call
@@ -288,6 +327,18 @@ def refund(self, flwRef):
288
327
289
328
response = requests .post (endpoint , headers = headers , data = json .dumps (payload ))
290
329
330
+ #feature logging
331
+ if response .ok :
332
+ tracking_endpoint = self ._trackingMap
333
+ responseTime = response .elapsed .total_seconds ()
334
+ tracking_payload = {"publicKey" : self ._getPublicKey (),"language" : "Python v2" , "version" : "1.2.5" , "title" : feature_name , "message" : responseTime }
335
+ tracking_response = requests .post (tracking_endpoint , data = json .dumps (tracking_payload ))
336
+ else :
337
+ tracking_endpoint = self ._trackingMap
338
+ responseTime = response .elapsed .total_seconds ()
339
+ tracking_payload = {"publicKey" : self ._getPublicKey (),"language" : "Python v2" , "version" : "1.2.5" , "title" : feature_name + "-error" , "message" : responseTime }
340
+ tracking_response = requests .post (tracking_endpoint , data = json .dumps (tracking_payload ))
341
+
291
342
try :
292
343
responseJson = response .json ()
293
344
except ValueError :
0 commit comments