-
-
Save techsharif/b04659c1d9f086f65e7b9af4e291224a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
import requests | |
import xml.etree.ElementTree as ET | |
POST_URI = 'http://116.212.108.236:802/PaymentServices.asmx?op=PaymentRequestFromECom' | |
user_id = 'ecomauser' | |
password = 'itreus#7102' | |
vendor_code = 'GP' | |
phone_number = '01989782605' | |
post_or_pre = 1 | |
current_month = datetime.datetime.today().month | |
account_no = '37150442' | |
transfer_ref = '32423' | |
amount = str(10*10) | |
terminal_name = 'CODERO' | |
terminal_type = 'APPS' | |
xml_post_data = f"""<?xml version="1.0" encoding="utf-8"?> | |
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xmlns:xsd="http://www.w3.org/2001/XMLSchema" | |
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> | |
<soap:Body> | |
<PaymentRequestFromECom xmlns="http://tempuri.org/"> | |
<UserId>{user_id}</UserId> | |
<Password>{password}</Password> | |
<VendorCode>{vendor_code}</VendorCode> | |
<Payaccno>{phone_number}</Payaccno> | |
<Accounttype>{post_or_pre}</Accounttype> | |
<Billmonth>{current_month}</Billmonth> | |
<CardNo>{account_no}</CardNo> | |
<ApprovalCode>{transfer_ref}</ApprovalCode> | |
<Amount>{amount}</Amount> | |
<Terminalname>{terminal_name}</Terminalname> | |
<Terminaltype>{terminal_type}</Terminaltype> | |
</PaymentRequestFromECom> | |
</soap:Body> | |
</soap:Envelope>""" | |
response = requests.post(POST_URI, data=xml_post_data, headers={'Content-Type': 'text/xml'}) | |
BASE_URI = '{http://schemas.xmlsoap.org/soap/envelope/}Body/{http://tempuri.org/}' \ | |
'PaymentRequestFromEComResponse/{http://tempuri.org/}PaymentRequestFromEComResult' | |
TRANSACTIONID_URI = '{http://tempuri.org/}TransId' | |
RESPONSECODE_URI = '{http://tempuri.org/}ResponseCode' | |
RESPONSETEXT_URI = '{http://tempuri.org/}ResponseText' | |
# Create your tests here. | |
xml_data = """<?xml version="1.0" encoding="utf-8"?> | |
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> | |
<soap:Body> | |
<PaymentRequestFromEComResponse xmlns="http://tempuri.org/"> | |
<PaymentRequestFromEComResult> | |
<TransId>713621</TransId> | |
<ResponseCode>201</ResponseCode> | |
<ResponseText>Processing</ResponseText> | |
</PaymentRequestFromEComResult> | |
</PaymentRequestFromEComResponse> | |
</soap:Body> | |
</soap:Envelope>""" | |
root = ET.fromstring(response.text).find(BASE_URI) | |
transaction_id = root.find(TRANSACTIONID_URI).text |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment