Skip to content

providing set method to user to allow them to point to the environmen… #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 5, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 24 additions & 26 deletions authorizenet/apicontrollersbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class APIOperationBase(APIOperationBaseInterface):

__initialized = False
__merchantauthentication = "null"
__environment = "null"

@staticmethod
def __classinitialized():
Expand All @@ -80,22 +81,7 @@ def validaterequest(self):

def validate(self):
anetapirequest = self._getrequest()

self.validateandsetmerchantauthentication()
'''
# make sure proper authentication elements are present and no extra elements are present
merchantauthenticationtype = anetapirequest.merchantauthentication()
if (merchantauthenticationtype.sessionToken != "null"):
raise ValueError('sessionToken needs to be null')
if (merchantauthenticationtype.password != "null"):
raise ValueError('Password needs to be null')
if (merchantauthenticationtype.mobileDeviceId != "null"):
raise ValueError('MobileDeviceId needs to be null')

impersonationauthenticationtype = merchantauthenticationtype.impersonationAuthentication
if (impersonationauthenticationtype != "null"):
raise ValueError('ImpersonationAuthenticationType needs to be null')
'''
self.validateandsetmerchantauthentication()
self.validaterequest()

return
Expand All @@ -121,7 +107,9 @@ def getprettyxmlrequest(self):
return requestDom

def execute(self):
self.endpoint = constants.SANDBOX_TESTMODE

self.endpoint = APIOperationBase.__environment

logging.debug('Executing http post to url: %s', self.endpoint)

self.beforeexecute()
Expand Down Expand Up @@ -201,28 +189,38 @@ def validateandsetmerchantauthentication(self):
else:
raise ValueError('Merchant Authentication can not be null')
return

def __init__(self, apiRequest):
self._httpResponse = "null"
self._request = "null"
self._response = "null"
self.__endpoint = "null"

@staticmethod
def getenvironment(self):
return APIOperationBase.__environment

if "null" == apiRequest:

@staticmethod
def setenvironment(userenvironment):
APIOperationBase.__environment = userenvironment
return

def __init__(self, apiRequest):
self._httpResponse = None
self._request = None
self._response = None

if None == apiRequest:
raise ValueError('Input request cannot be null')

self._request = apiRequest
__merchantauthentication = apicontractsv1.merchantAuthenticationType()
APIOperationBase.__environment = constants.SANDBOX_TESTMODE

APIOperationBase.setmerchantauthentication(__merchantauthentication)

if ( False == APIOperationBase.__classinitialized()):
loggingfilename = utility.helper.getproperty(constants.propertiesloggingfilename)
logginglevel = utility.helper.getproperty(constants.propertiesexecutionlogginglevel)

if ("null" == loggingfilename):
if (None == loggingfilename):
loggingfilename = constants.defaultLogFileName
if ("null" == logginglevel):
if (None == logginglevel):
logginglevel = constants.defaultLoggingLevel

logging.basicConfig(filename=loggingfilename, level=logginglevel, format=constants.defaultlogformat)
Expand Down
2 changes: 1 addition & 1 deletion authorizenet/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class constants(object):

'''Environments'''
SANDBOX_TESTMODE = 'https://apitest.authorize.net/xml/v1/request.api'
PRODUCTION = 'https://api.authorize.net/xml/v1/request.api'
PRODUCTION = 'https://api2.authorize.net/xml/v1/request.api'

'''xml encoding'''
xml_encoding = 'utf-8'
Expand Down
46 changes: 41 additions & 5 deletions tests/testssample.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
@author: krgupta
'''
from authorizenet import apicontractsv1
from authorizenet import constants
from decimal import *
from authorizenet.apicontractsv1 import CTD_ANON
#from controller.CreateTransactionController import CreateTransactionController
Expand All @@ -20,16 +21,16 @@
from authorizenet.apicontrollers import *
import test
from authorizenet import utility
from authorizenet.apicontrollersbase import APIOperationBase

class test_ReadProperty(apitestbase.ApiTestBase):
def testPropertyFromFile(self):
login= utility.helper.getproperty("api_login_id")
transactionkey = utility.helper.getproperty("transaction_key")
self.assertIsNotNone(login)
self.assertIsNotNone(transactionkey)

class test_TransactionReportingUnitTest(apitestbase.ApiTestBase):

def testGetTransactionDetails(self):

gettransactiondetailsrequest = apicontractsv1.getTransactionDetailsRequest()
Expand All @@ -38,8 +39,8 @@ def testGetTransactionDetails(self):
gettransactiondetailscontroller = getTransactionDetailsController(gettransactiondetailsrequest)
gettransactiondetailscontroller.execute()
response = gettransactiondetailscontroller.getresponse()
self.assertEquals('Ok', response.messages.resultCode)

self.assertEquals('Ok', response.messages.resultCode)
class test_RecurringBillingTest(apitestbase.ApiTestBase):

def testCreateSubscription(self):
Expand Down Expand Up @@ -120,6 +121,41 @@ def testauthOnlyContinueTransaction(self):
response = createtransactioncontroller.getresponse()
self.assertIsNotNone(response.transactionResponse)
self.assertIsNotNone(response.transactionResponse.transId)


'''
class test_ProductionURL(apitestbase.ApiTestBase):
'' '' ''Tests will run only with production credentials
'' '' ''

def testGetSettledBatchList(self):
settledBatchListRequest = apicontractsv1.getSettledBatchListRequest()
settledBatchListRequest.merchantAuthentication = self.merchantAuthentication
settledBatchListController = getSettledBatchListController(settledBatchListRequest)
customEndpoint = constants.PRODUCTION
apicontrollersbase.APIOperationBase.setenvironment(customEndpoint)
settledBatchListController.execute()
response = settledBatchListController.getresponse()
self.assertEquals('Ok', response.messages.resultCode)

def testGetListofSubscriptions(self):
sorting = apicontractsv1.ARBGetSubscriptionListSorting()
sorting.orderBy = apicontractsv1.ARBGetSubscriptionListOrderFieldEnum.id
sorting.orderDescending = "false"
paging = apicontractsv1.Paging()
paging.limit = 1000
paging.offset = 1
GetListofSubscriptionRequest = apicontractsv1.ARBGetSubscriptionListRequest()
GetListofSubscriptionRequest.merchantAuthentication = self.merchantAuthentication
GetListofSubscriptionRequest.refId = "Sample"
GetListofSubscriptionRequest.searchType = apicontractsv1.ARBGetSubscriptionListSearchTypeEnum.subscriptionInactive
GetListofSubscriptionRequest.sorting = sorting
GetListofSubscriptionRequest.paging = paging
arbgetsubscriptionlistcontroller = ARBGetSubscriptionListController(GetListofSubscriptionRequest)
customEndpoint = constants.PRODUCTION
apicontrollersbase.APIOperationBase.setenvironment(customEndpoint)
arbgetsubscriptionlistcontroller.execute()
response = arbgetsubscriptionlistcontroller.getresponse()
self.assertEquals('Ok', response.messages.resultCode)
'''
if __name__ =='__main__':
unittest.main()
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy