-
Notifications
You must be signed in to change notification settings - Fork 0
/
confirmationMessages.py
41 lines (30 loc) · 1.21 KB
/
confirmationMessages.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from datetime import datetime
import requests
def sendMessage(amount=None, updatedBalance=None, contactNumber=None, accountNumber=None, msg=None):
'''
To send a text message
:param amount:amount changed
:param updatedBalance: Final Balance
:param contactNumber: Phone number of receiver
:param accountNumber: account number of receiver
:param msg: message to be sent (None for failed transaction )
:return: None
'''
if contactNumber is None:
return
url = "https://www.fast2sms.com/dev/bulk"
if msg is None:
transaction = ' credit '
if amount < 0:
transaction = ' debit '
msg = 'Last Transaction in A/C ' + str(accountNumber) + ' at ' + str(datetime.now()) + transaction + str(
abs(amount)) + ' Balance ' + str(updatedBalance)
# enter fast2sms authorization key in authorization value
querystring = {"authorization": ""
, "sender_id": "FSTSMS", "message": msg, "language": "english",
"route": "p", "numbers": str(contactNumber)}
headers = {
'cache-control': "no-cache"
}
response = requests.request("GET", url, headers=headers, params=querystring)
# print(response.text)