Last active
March 13, 2022 16:30
Revisions
-
gunesmes revised this gist
Jul 19, 2018 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,6 @@ # encoding: utf-8 import requests def CompleteReturnRequest(Username, Password, merchantCode, storeCode, returnId): form = """ -
gunesmes revised this gist
Apr 14, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -33,4 +33,4 @@ def CompleteReturnRequest(Username, Password, merchantCode, storeCode, returnId) headers = {"Content-Type": "text/xml; charset=UTF-8","Content-Length": len(encoded_request)} response = requests.post(url="https://testthis.pos.com:443/pos/soap/pos",headers = headers,data = encoded_request,verify=False) return response -
gunesmes renamed this gist
Apr 14, 2015 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
gunesmes renamed this gist
Apr 14, 2015 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
gunesmes revised this gist
Apr 14, 2015 . No changes.There are no files selected for viewing
-
gunesmes revised this gist
Apr 14, 2015 . 2 changed files with 19 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,14 @@ ~/P/m/h/services python run.py test_get_session (__main__.SoapServices) ... ok test_get_token (__main__.SoapServices) ... ok test_CompleteReturnRequest (__main__.SoapServices) ... ok test_ReturnTransactionRequest (__main__.SoapServices) ... ok test_UserInfoRequest (__main__.SoapServices) ... ok test_RefundRequest (__main__.SoapServices) ... ok test_StartTransactionRequest (__main__.SoapServices) ... ok test_ReturnTransactionRequest (__main__.SoapServices) ... ok ---------------------------------------------------------------------- Ran 8 tests in 7.362s OK 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 charactersOriginal file line number Diff line number Diff line change @@ -16,8 +16,12 @@ def test_CompleteReturnRequest(self): # service should return 5xx for the second request result = test_services.CompleteReturnRequest(Username, Password, merchantCode, storeCode, returnId) self.assertIn(result.status_code, [500, 501, 502]) # or you can check inside of the response message keys = ["provisionId", "otpNeeded"] for key in keys: self.assertIn(key, unicode(result.text)) if __name__ == "__main__": suite = unittest.TestLoader().loadTestsFromTestCase(SoapServices) unittest.TextTestRunner(verbosity=2).run(suite) -
gunesmes revised this gist
Apr 14, 2015 . 1 changed file with 6 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,9 @@ #!/usr/bin/env python # encoding: utf-8 import requests from pyquery import PyQuery def CompleteReturnRequest(Username, Password, merchantCode, storeCode, returnId): form = """ <soapenv:Envelope -
gunesmes created this gist
Apr 14, 2015 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ import unittest import test_services import xml.etree.ElementTree as ET # I am using python unittest for asserting cases. # In this module, there should be test cases. # If you want to run it, you should type: python <module-name.py> class SoapServices(unittest.TestCase): def test_CompleteReturnRequest(self): # service should return 2xx for the first request result = test_services.CompleteReturnRequest(Username, Password, merchantCode, storeCode, returnId) self.assertIn(result.status_code, [200, 201, 202]) # service should return 5xx for the second request result = test_services.CompleteReturnRequest(Username, Password, merchantCode, storeCode, returnId) self.assertIn(result.status_code, [500, 501, 502]) if __name__ == "__main__": suite = unittest.TestLoader().loadTestsFromTestCase(Hopi) unittest.TextTestRunner(verbosity=2).run(suite) 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ def CompleteReturnRequest(Username, Password, merchantCode, storeCode, returnId): form = """ <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:pos="http://testthis.com/xmlschema/pos"> <soapenv:Header> <wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> <wsse:UsernameToken> <wsse:Username>%s</wsse:Username> <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">%s</wsse:Password> </wsse:UsernameToken> </wsse:Security> </soapenv:Header> <soapenv:Body> <pos:CompleteReturnRequest>" <!--Optional:--> <pos:merchantCode>%s</pos:merchantCode> <pos:storeCode>%s</pos:storeCode> <pos:returnId>%d</pos:returnTrxId> </pos:CompleteReturnRequest> </soapenv:Body> </soapenv:Envelope>""" %(Username, Password, merchantCode, storeCode, returnId) encoded_request = form.encode('utf-8') headers = {"Content-Type": "text/xml; charset=UTF-8","Content-Length": len(encoded_request)} response = requests.post(url="https://testthis.pos.com:443/pos/soap/pos",headers = headers,data = encoded_request,verify=False) return response