| Line 4... |
Line 4... |
| 4 |
import logging
|
4 |
import logging
|
| 5 |
from datetime import datetime
|
5 |
from datetime import datetime
|
| 6 |
import time
|
6 |
import time
|
| 7 |
from shop2020.config.client.ConfigClient import ConfigClient
|
7 |
from shop2020.config.client.ConfigClient import ConfigClient
|
| 8 |
from decimal import Decimal
|
8 |
from decimal import Decimal
|
| - |
|
9 |
from shop2020.thriftpy.model.v1.order.ttypes import RechargeMode
|
| 9 |
logging.basicConfig(level=logging.INFO)
|
10 |
logging.basicConfig(level=logging.INFO)
|
| 10 |
|
11 |
|
| 11 |
username = base64.b64encode('saholic20')
|
12 |
username = base64.b64encode('ashish')
|
| 12 |
password = base64.b64encode('ap2020sh')
|
13 |
password = base64.b64encode('ashish@20')
|
| 13 |
account_url = 'https://api.spicesafar.com/McommWebServices/AccountApiMcomm?wsdl'
|
14 |
account_url = 'https://apistaging.spicesafar.com/McommWebServices/AccountApiMcomm?wsdl'
|
| 14 |
recharge_url = 'https://api.spicesafar.com/McommWebServices/RechargeApiMcomm?wsdl'
|
15 |
recharge_url = 'https://apistaging.spicesafar.com/McommWebServices/RechargeApiMcomm?wsdl'
|
| 15 |
aclient = None
|
16 |
aclient = None
|
| 16 |
raclient = None
|
17 |
raclient = None
|
| 17 |
allow_recharge = False
|
18 |
allow_recharge = False
|
| 18 |
|
19 |
|
| 19 |
allow_recharge_string = ConfigClient().get_property('allow_recharge')
|
20 |
allow_recharge_string = ConfigClient().get_property('allow_recharge')
|
| Line 31... |
Line 32... |
| 31 |
global raclient
|
32 |
global raclient
|
| 32 |
if raclient is None:
|
33 |
if raclient is None:
|
| 33 |
raclient = Client(recharge_url, timeout=70)
|
34 |
raclient = Client(recharge_url, timeout=70)
|
| 34 |
return raclient
|
35 |
return raclient
|
| 35 |
|
36 |
|
| 36 |
def rechargeDevice(transactionId, rechargeType, strProviderCode, deviceNumber, amount, plan, storeCode = ''):
|
37 |
def rechargeDevice(transactionId, rechargeType, strProviderCode, deviceNumber, amount, plan, storeCode = '', rechargeMode=None):
|
| 37 |
if not allow_recharge:
|
38 |
if not allow_recharge:
|
| 38 |
return 'S', '00', 'spiceTID', 'SUCCESS', 'aggTID', 'providerTID'
|
39 |
return 'S', '00', 'spiceTID', 'SUCCESS', 'aggTID', 'providerTID'
|
| 39 |
spString = getRechargeClient().service.getRecharge(username, password, '919650889334', 'SOAP', '115.249.47.66', transactionId, rechargeType, strProviderCode, deviceNumber, amount, 'DEBIT', plan, storeCode)
|
40 |
spString = getRechargeClient().service.getRecharge(username, password, '919650889334', 'SOAP', '115.249.47.66', transactionId, rechargeType, strProviderCode, deviceNumber, amount, 'DEBIT', plan, storeCode)
|
| 40 |
print spString
|
41 |
print spString
|
| 41 |
spString = re.sub('<\?.*\?>','',spString)
|
42 |
spString = re.sub('<\?.*\?>','',spString)
|
| Line 44... |
Line 45... |
| 44 |
response = dom.getElementsByTagName('ActiveServicesPojo')[0]
|
45 |
response = dom.getElementsByTagName('ActiveServicesPojo')[0]
|
| 45 |
retStatus = response.getElementsByTagName('resStatus')[0].childNodes[0].data
|
46 |
retStatus = response.getElementsByTagName('resStatus')[0].childNodes[0].data
|
| 46 |
retCode = response.getElementsByTagName('respCode')[0].childNodes[0].data
|
47 |
retCode = response.getElementsByTagName('respCode')[0].childNodes[0].data
|
| 47 |
spiceTID = response.getElementsByTagName('SpiceTID')[0].childNodes[0].data
|
48 |
spiceTID = response.getElementsByTagName('SpiceTID')[0].childNodes[0].data
|
| 48 |
retDesc = response.getElementsByTagName('shotDesc')[0].childNodes[0].data
|
49 |
retDesc = response.getElementsByTagName('shotDesc')[0].childNodes[0].data
|
| 49 |
|
50 |
|
| 50 |
try:
|
51 |
try:
|
| 51 |
aggTID = response.getElementsByTagName('aggregatorId')[0].childNodes[0].data
|
52 |
aggTID = response.getElementsByTagName('aggregatorId')[0].childNodes[0].data
|
| 52 |
providerTID = response.getElementsByTagName('ProviderTID')[0].childNodes[0].data
|
53 |
providerTID = response.getElementsByTagName('ProviderTID')[0].childNodes[0].data
|
| 53 |
except:
|
54 |
except:
|
| 54 |
aggTID = ''
|
55 |
aggTID = ''
|
| 55 |
providerTID = ''
|
56 |
providerTID = ''
|
| 56 |
|
57 |
|
| 57 |
if retCode !='00' or retStatus !='S':
|
58 |
if (retCode !='00' or retStatus !='S') and rechargeMode == RechargeMode._NAMES_TO_VALUES.get('SYNC'):
|
| 58 |
try:
|
59 |
try:
|
| 59 |
if (checkTransactionStatus('',transactionId))[0]:
|
60 |
if (checkTransactionStatus('',transactionId))[0]:
|
| 60 |
return 'S','00', spiceTID, retDesc, aggTID, providerTID
|
61 |
return 'S','00', spiceTID, retDesc, aggTID, providerTID
|
| 61 |
except:
|
62 |
except:
|
| 62 |
pass
|
63 |
pass
|
| Line 77... |
Line 78... |
| 77 |
except:
|
78 |
except:
|
| 78 |
responseDescription = ""
|
79 |
responseDescription = ""
|
| 79 |
aggregatorRespCode = response.getElementsByTagName('aggregatorRespCode')[0].childNodes[0].data
|
80 |
aggregatorRespCode = response.getElementsByTagName('aggregatorRespCode')[0].childNodes[0].data
|
| 80 |
if responseCode == '00' and transStatus == 'S':
|
81 |
if responseCode == '00' and transStatus == 'S':
|
| 81 |
return True, responseDescription
|
82 |
return True, responseDescription
|
| - |
|
83 |
elif responseCode == 'STP' and transStatus == 'S':
|
| - |
|
84 |
raise Exception(111, "Still status is not known")
|
| 82 |
elif responseCode in ('STO','US', 'UP') and transStatus == 'S':
|
85 |
elif responseCode in ('STO','US', 'UP') and transStatus == 'S':
|
| 83 |
if aggregatorRespCode == '00':
|
86 |
if aggregatorRespCode == '00':
|
| 84 |
return True, responseDescription
|
87 |
return True, responseDescription
|
| 85 |
if aggregatorRespCode != 'NA':
|
88 |
if aggregatorRespCode != 'NA':
|
| 86 |
return False, responseDescription
|
89 |
return False, responseDescription
|
| Line 219... |
Line 222... |
| 219 |
try:
|
222 |
try:
|
| 220 |
responseDescription = response.getElementsByTagName('ResponseDescription')[0].childNodes[0].data
|
223 |
responseDescription = response.getElementsByTagName('ResponseDescription')[0].childNodes[0].data
|
| 221 |
except:
|
224 |
except:
|
| 222 |
responseDescription = ""
|
225 |
responseDescription = ""
|
| 223 |
return responseCode, responseDescription
|
226 |
return responseCode, responseDescription
|
| - |
|
227 |
|
| - |
|
228 |
def main():
|
| - |
|
229 |
#print rechargeDevice(20141031157,'MTP','BSP','9459060666',1,'')
|
| - |
|
230 |
print checkTransactionStatus('','201410282200')
|
| - |
|
231 |
|
| - |
|
232 |
if __name__=='__main__':
|
| - |
|
233 |
main()
|
| 224 |
|
234 |
|