Skip to content

Commit 098991d

Browse files
author
krgupta
committed
providing set method to user to allow them to point to the environment of their choice
1 parent 25459cc commit 098991d

File tree

1 file changed

+24
-26
lines changed

1 file changed

+24
-26
lines changed

authorizenet/apicontrollersbase.py

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ class APIOperationBase(APIOperationBaseInterface):
6969

7070
__initialized = False
7171
__merchantauthentication = "null"
72+
__environment = "null"
7273

7374
@staticmethod
7475
def __classinitialized():
@@ -80,22 +81,7 @@ def validaterequest(self):
8081

8182
def validate(self):
8283
anetapirequest = self._getrequest()
83-
84-
self.validateandsetmerchantauthentication()
85-
'''
86-
# make sure proper authentication elements are present and no extra elements are present
87-
merchantauthenticationtype = anetapirequest.merchantauthentication()
88-
if (merchantauthenticationtype.sessionToken != "null"):
89-
raise ValueError('sessionToken needs to be null')
90-
if (merchantauthenticationtype.password != "null"):
91-
raise ValueError('Password needs to be null')
92-
if (merchantauthenticationtype.mobileDeviceId != "null"):
93-
raise ValueError('MobileDeviceId needs to be null')
94-
95-
impersonationauthenticationtype = merchantauthenticationtype.impersonationAuthentication
96-
if (impersonationauthenticationtype != "null"):
97-
raise ValueError('ImpersonationAuthenticationType needs to be null')
98-
'''
84+
self.validateandsetmerchantauthentication()
9985
self.validaterequest()
10086

10187
return
@@ -121,7 +107,9 @@ def getprettyxmlrequest(self):
121107
return requestDom
122108

123109
def execute(self):
124-
self.endpoint = constants.SANDBOX_TESTMODE
110+
111+
self.endpoint = APIOperationBase.__environment
112+
125113
logging.debug('Executing http post to url: %s', self.endpoint)
126114

127115
self.beforeexecute()
@@ -201,28 +189,38 @@ def validateandsetmerchantauthentication(self):
201189
else:
202190
raise ValueError('Merchant Authentication can not be null')
203191
return
204-
205-
def __init__(self, apiRequest):
206-
self._httpResponse = "null"
207-
self._request = "null"
208-
self._response = "null"
209-
self.__endpoint = "null"
192+
193+
@staticmethod
194+
def getenvironment(self):
195+
return APIOperationBase.__environment
210196

211-
if "null" == apiRequest:
197+
198+
@staticmethod
199+
def setenvironment(userenvironment):
200+
APIOperationBase.__environment = userenvironment
201+
return
202+
203+
def __init__(self, apiRequest):
204+
self._httpResponse = None
205+
self._request = None
206+
self._response = None
207+
208+
if None == apiRequest:
212209
raise ValueError('Input request cannot be null')
213210

214211
self._request = apiRequest
215212
__merchantauthentication = apicontractsv1.merchantAuthenticationType()
213+
APIOperationBase.__environment = constants.SANDBOX_TESTMODE
216214

217215
APIOperationBase.setmerchantauthentication(__merchantauthentication)
218216

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

223-
if ("null" == loggingfilename):
221+
if (None == loggingfilename):
224222
loggingfilename = constants.defaultLogFileName
225-
if ("null" == logginglevel):
223+
if (None == logginglevel):
226224
logginglevel = constants.defaultLoggingLevel
227225

228226
logging.basicConfig(filename=loggingfilename, level=logginglevel, format=constants.defaultlogformat)

0 commit comments

Comments
 (0)
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