Skip to content

Commit d2f2b27

Browse files
OthnielDonanioperas06
authored andcommitted
added try clause to verify and refund transaction
1 parent af80468 commit d2f2b27

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

kkiapay/core.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@ def __init__(self, public_key, private_key, secret, sandbox=False):
3636

3737
def verify_transaction(self, transaction_id):
3838
payload = {"transactionId": transaction_id}
39-
r = requests.post(self.transaction_url, data=payload, headers=self.headers)
39+
40+
try:
41+
r = requests.post(self.url, data=payload, headers=self.headers)
42+
except requests.exceptions.ConnectionError:
43+
return print('Sorry! There is a problem with your connection.')
4044

4145
return json.loads(
4246
r.text,
@@ -47,7 +51,11 @@ def verify_transaction(self, transaction_id):
4751

4852
def refund_transaction(self, transaction_id):
4953
payload = {"transactionId": transaction_id}
50-
r = requests.post(self.url, data=payload, headers=self.headers)
54+
55+
try:
56+
r = requests.post(self.url, data=payload, headers=self.headers)
57+
except requests.exceptions.ConnectionError:
58+
return print('Sorry! There is a problem with your connection.')
5159

5260
return json.loads(
5361
r.text,

0 commit comments

Comments
 (0)