def test_http_put_request_with_PayfacError(self):
     legalEntityPutRequest = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><legalEntityUpdateRequest xmlns="http://payfac.vantivcnp.com/api/merchant/onboard"><address><streetAddress1>LE Street Address 1</streetAddress1><streetAddress2>LE Street Address 2</streetAddress2><city>LE City</city><stateProvince>MA</stateProvince><postalCode>01730</postalCode><countryCode>USA</countryCode></address><contactPhone>9785550101</contactPhone><doingBusinessAs>Other Name Co.</doingBusinessAs><annualCreditCardSalesVolume>10000000</annualCreditCardSalesVolume><hasAcceptedCreditCards>true</hasAcceptedCreditCards><principal><principalId>9</principalId><title>CEO</title><emailAddress>[email protected]</emailAddress><contactPhone>9785551234</contactPhone><address><streetAddress1>p street address 1</streetAddress1><streetAddress2>p street address 2</streetAddress2><city>Boston</city><stateProvince>MA</stateProvince><postalCode>01890</postalCode><countryCode>USA</countryCode></address><backgroundCheckFields><firstName>p first</firstName><lastName>p last</lastName><ssn>123459876</ssn><dateOfBirth>1980-10-12</dateOfBirth><driversLicense>892327409832</driversLicense><driversLicenseState>MA</driversLicenseState></backgroundCheckFields></principal><backgroundCheckFields><legalEntityName>Company Name</legalEntityName><legalEntityType>INDIVIDUAL_SOLE_PROPRIETORSHIP</legalEntityType><taxId>123456789</taxId></backgroundCheckFields><legalEntityOwnershipType>PUBLIC</legalEntityOwnershipType><yearsInBusiness>10</yearsInBusiness></legalEntityUpdateRequest>'
     new_conf = utils.Configuration()
     new_conf.__setattr__("url", "https://")
     self.assertRaises(utils.PayfacError, communication.http_put_request,
                       "/legalentity/1000293".encode('utf-8'),
                       legalEntityPutRequest, new_conf)
 def test_http_post_request_with_PayfacError(self):
     agreementPostRequest = '<legalEntityAgreementCreateRequest xmlns="http://payfac.vantivcnp.com/api/merchant/onboard"><legalEntityAgreement><legalEntityAgreementType>MERCHANT_AGREEMENT</legalEntityAgreementType><agreementVersion>agreementVersion1</agreementVersion><userFullName>userFullName</userFullName><userSystemName>systemUserName</userSystemName><userIPAddress>196.198.100.100</userIPAddress><manuallyEntered>false</manuallyEntered><acceptanceDateTime>2017-02-11T12:00:00-06:00</acceptanceDateTime></legalEntityAgreement></legalEntityAgreementCreateRequest>'
     new_conf = utils.Configuration()
     new_conf.__setattr__("url", "https://")
     self.assertRaises(utils.PayfacError, communication.http_post_request,
                       "/legalentity/21003/agreement".encode('utf-8'),
                       agreementPostRequest, new_conf)
class TestLegalEntity(unittest.TestCase):
    conf = utils.Configuration()

    def test_convert_to_dict(self):
        http_response = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><approvedMccResponse xmlns="http://payfac.vantivcnp.com/api/merchant/onboard"><transactionId>99010</transactionId><approvedMccs><approvedMcc>5967</approvedMcc><approvedMcc>5970</approvedMcc></approvedMccs></approvedMccResponse>'
        dict = utils.convert_to_dict(http_response)
        expect_dict = {'@xmlns': 'http://payfac.vantivcnp.com/api/merchant/onboard', u'transactionId': 99010, u'approvedMccs': {u'approvedMcc': [u'5967', u'5970']}}

        self.assertEquals(expect_dict,dict)
        http_response_without_xmlns = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><approvedMccResponse xmlns=""><transactionId>99010</transactionId><approvedMccs><approvedMcc>5967</approvedMcc><approvedMcc>5970</approvedMcc></approvedMccs></approvedMccResponse>'
        self.assertRaises(utils.PayfacSchemaError, utils.convert_to_dict, http_response_without_xmlns)
Example #4
0
    from StringIO import StringIO
else:
    from io import StringIO

from payfacMPSdk import communication, utils, version as SdkVersion

SERVICE_ROUTE = "/legalentity"
"""
/////////////////////////////////////////////////////
            legalEntity APIs:
/////////////////////////////////////////////////////
"""

package_root = os.path.dirname(os.path.abspath(os.path.dirname(__file__)))
sys.path.insert(0, package_root)
version = utils.Configuration().VERSION
xsd_name = 'merchant-onboard-api-v%s.xsd' % version
xsd_path = pkg_resources.resource_filename('payfacMPSdk', 'schema/' + xsd_name)
my_schema = xmlschema.XMLSchema(xsd_path)


def get_by_legalEntityId(legalEntityId):
    url_suffix = SERVICE_ROUTE + "/" + legalEntityId
    return communication.http_get_retrieval_request(url_suffix)


def post_by_legalEntity(legalEntityCreateRequest):
    legalEntityCreateRequest.set_sdkVersion(SdkVersion.RELEASE)
    legalEntityCreateRequest.set_language(SdkVersion.LANGUAGE)
    stringIO = StringIO()
    legalEntityCreateRequest.export(stringIO, 0, pretty_print=False)
from __future__ import absolute_import, print_function, unicode_literals
from __future__ import absolute_import, print_function, unicode_literals

import re

import requests
import traceback
import sys

from requests.auth import HTTPBasicAuth

from payfacMPSdk import (utils)

conf = utils.Configuration()

PAYFAC_CONTENT_TYPE = "application/com.vantivcnp.payfac-v13.1+xml"

PAYFAC_API_HEADERS = {
    "Accept": PAYFAC_CONTENT_TYPE,
    "Content-Type": PAYFAC_CONTENT_TYPE
}

HTTP_ERROR_MESSAGE = "Error with Https Request, Please Check Proxy and Url configuration"


def http_get_retrieval_request(url_suffix, config=conf):

    url = getattr(config, 'url')
    # print("url -> "+url+"\n")
    request_url = url + url_suffix
    # request_url = "https://www.testvantivcnp.com/sandbox/payfac" + url_suffix
def ask_user():
    attrs = [
        'username', 'password', 'merchant_id', 'proxy', 'printXml', 'neuterXml'
    ]
    attr_dict = {
        'username': '',
        'password': '',
        'merchant_id': '',
        'url': '',
        'proxy': '',
        'printXml': 'n',
        'neuterXml': 'n'
    }
    attr_valid_dict = {
        'neuterXml': {
            'y': True,
            'n': False,
        },
        'printXml': {
            'y': True,
            'n': False,
        }
    }
    attr_des_dict = {
        'username':
        '******',
        'password':
        '******',
        'merchant_id':
        'Please input your merchantId: ',
        'proxy':
        'If you want to using https proxy, please input your proxy server address. Must start with "https://"',
        'printXml':
        'Do you want to print xml in console? y for Yes, n for No.',
        'neuterXml':
        'Do you want to hide sensitive data in printed xml? y for Yes, n for No.'
    }
    print(
        CC.bpurple('"Welcome to the Merchant Provisioner PayFac Python SDK"'))
    print('''    Please enter values for the following settings
    (just press Enter to accept a default value, if one is given in brackets).'''
          )

    for attr in attrs:
        while True:
            print(gene_prompt(attr, attr_dict, attr_valid_dict, attr_des_dict))
            if six.PY3:
                x = input('')
            else:
                x = input('')
            if not x:
                x = attr_dict[attr]
            if attr in attr_valid_dict:
                if x.lower() in attr_valid_dict[attr]:
                    x = attr_valid_dict[attr][x.lower()]
                else:
                    print('Invalid input for "%s" = "%s"' % (attr, x))
                    continue
            attr_dict[attr] = x
            break
    environmentConfig(attr_dict)
    conf = utils.Configuration()
    for k in attr_dict:
        setattr(conf, k, attr_dict[k])
    print(CC.bgreen('Configurations have saved at: %s ' % conf.save()))
    print(CC.bpurple('Successful!'))
 def test_http_delete_request_with_PayfacError(self):
     new_conf = utils.Configuration()
     new_conf.__setattr__("url", "https://")
     self.assertRaises(utils.PayfacError, communication.http_delete_request,
                       "/legalentity/2018/principal/9", new_conf)
 def test_http_get_retrieval_request_with_PayfacError(self):
     new_conf = utils.Configuration()
     new_conf.__setattr__("url", "https://")
     self.assertRaises(utils.PayfacError,
                       communication.http_get_retrieval_request,
                       "/legalentity/1000293", new_conf)
class TestCertification(unittest.TestCase):

    conf = utils.Configuration()
    conf.__setattr__("url", "https://payfac.vantivprelive.com")
    conf.__setattr__("username", "")
    conf.__setattr__("password", "")

    legalEntityPostRequest1 = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' \
                              '<legalEntityCreateRequest xmlns="http://payfac.vantivcnp.com/api/merchant/onboard">' \
                              '<legalEntityName>Legal Entity Name</legalEntityName>' \
                              '<legalEntityType>'
    legalEntityPostRequest2 = '</legalEntityType>' \
                              '<legalEntityOwnershipType>PRIVATE</legalEntityOwnershipType>' \
                              '<doingBusinessAs>Alternate Business Name</doingBusinessAs>' \
                              '<taxId>'
    legalEntityPostRequest3 = '</taxId>' \
                              '<contactPhone>7817659800</contactPhone>' \
                              '<annualCreditCardSalesVolume>80000000</annualCreditCardSalesVolume>' \
                              '<hasAcceptedCreditCards>true</hasAcceptedCreditCards>' \
                              '<address>' \
                               '<streetAddress1>'
    legalEntityPostRequest4 =  '</streetAddress1>' \
                                    '<streetAddress2>Street Address 2</streetAddress2>' \
                                    '<city>City</city>' \
                                    '<stateProvince>MA</stateProvince>' \
                                    '<postalCode>01730</postalCode>' \
                                    '<countryCode>USA</countryCode>' \
                                 '</address>' \
                                 '<principal>' \
                                    '<title>Chief Financial Officer</title>' \
                                    '<firstName>p first</firstName>' \
                                    '<lastName>p last</lastName>' \
                                    '<emailAddress>emailAddress</emailAddress>' \
                                    '<ssn>123459876</ssn>' \
                                    '<contactPhone>7817659800</contactPhone>' \
                                    '<dateOfBirth>1980-10-12</dateOfBirth>' \
                                    '<driversLicense>892327409832</driversLicense>' \
                                    '<driversLicenseState>MA</driversLicenseState>' \
                                    '<address>' \
                                        '<streetAddress1>p street address 1</streetAddress1>' \
                                        '<streetAddress2>p street address 2</streetAddress2>' \
                                        '<city>Boston</city>' \
                                        '<stateProvince>MA</stateProvince>' \
                                        '<postalCode>01890</postalCode>' \
                                        '<countryCode>USA</countryCode>' \
                                    '</address>' \
                                    '<stakePercent>100</stakePercent>' \
                                 '</principal>' \
                                 '<yearsInBusiness>12</yearsInBusiness>' \
                                 '</legalEntityCreateRequest>'

    legalEntityPutRequest1 = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' \
                            '<legalEntityUpdateRequest xmlns="http://payfac.vantivcnp.com/api/merchant/onboard">' \
                            '<address>' \
                                '<streetAddress1>Street Address 1</streetAddress1>' \
                                 '<streetAddress2>Street Address 2</streetAddress2>' \
                                '<city>City</city>' \
                                '<stateProvince>MA</stateProvince>' \
                                '<postalCode>01730</postalCode>' \
                                '<countryCode>USA</countryCode>' \
                            '</address>' \
                            '<contactPhone>776498</contactPhone>' \
                            '<doingBusinessAs>Alternate Business Name</doingBusinessAs>' \
                            '<annualCreditCardSalesVolume>100000000</annualCreditCardSalesVolume>' \
                            '<hasAcceptedCreditCards>true</hasAcceptedCreditCards>' \
                            '<principal>' \
                                '<principalId>1</principalId>' \
                                '<title>CEO</title>' \
                                '<emailAddress>[email protected]</emailAddress>' \
                                '<contactPhone>118484</contactPhone>' \
                                '<address>' \
                                    '<streetAddress1>p street address 1</streetAddress1>' \
                                    '<streetAddress2>p street address 2</streetAddress2>' \
                                    '<city>Boston</city>' \
                                    '<stateProvince>MA</stateProvince>' \
                                    '<postalCode>01890</postalCode>' \
                                    '<countryCode>USA</countryCode>' \
                                '</address>' \
                                '<backgroundCheckFields>' \
                                    '<firstName>p first</firstName>' \
                                    '<lastName>p last</lastName>' \
                                    '<ssn>123459876</ssn>' \
                                    '<dateOfBirth>1980-10-12</dateOfBirth>' \
                                    '<driversLicense>892327409832</driversLicense>' \
                                    '<driversLicenseState>MA</driversLicenseState>' \
                                '</backgroundCheckFields>' \
                            '</principal>' \
                            '<backgroundCheckFields>' \
                                '<legalEntityName>Company Name2</legalEntityName>' \
                                '<legalEntityType>INDIVIDUAL_SOLE_PROPRIETORSHIP</legalEntityType>' \
                                '<taxId>'
    legalEntityPutRequest2 = '</taxId>' \
                            '</backgroundCheckFields>' \
                            '<legalEntityOwnershipType>PRIVATE</legalEntityOwnershipType>' \
                            '<yearsInBusiness>10</yearsInBusiness>' \
                            '</legalEntityUpdateRequest>'

    submerchant_post_request1 = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' \
                               '<subMerchantCreateRequest xmlns="http://payfac.vantivcnp.com/api/merchant/onboard">' \
                               '<merchantName>Merchant Name</merchantName>' \
                               '<amexMid>1234567890</amexMid>' \
                               '<url>URL</url>' \
                               '<customerServiceNumber>1234567894</customerServiceNumber>' \
                               '<hardCodedBillingDescriptor>SDK*</hardCodedBillingDescriptor>' \
                               '<maxTransactionAmount>123</maxTransactionAmount>' \
                               '<merchantCategoryCode>5137</merchantCategoryCode>' \
                               '<bankRoutingNumber>211370545</bankRoutingNumber>' \
                               '<bankAccountNumber>84012312415</bankAccountNumber>' \
                               '<pspMerchantId>'

    submerchant_post_request2 = '</pspMerchantId>' \
                               '<fraud enabled="false"></fraud>' \
                               '<amexAcquired enabled="false"></amexAcquired>' \
                               '<address>' \
                                    '<streetAddress1>Street Address 1</streetAddress1>' \
                                    '<streetAddress2>Street Address 2</streetAddress2>' \
                                    '<city>City</city>' \
                                    '<stateProvince>MA</stateProvince>' \
                                    '<postalCode>01970</postalCode>' \
                                    '<countryCode>USA</countryCode>' \
                               '</address>' \
                               '<primaryContact>' \
                                    '<firstName>John</firstName>' \
                                    '<lastName>Doe</lastName>' \
                                    '<emailAddress>[email protected]</emailAddress>' \
                                    '<phone>9785552222</phone>' \
                               '</primaryContact>' \
                               '<createCredentials>true</createCredentials>' \
                               '<eCheck enabled="true">' \
                                    '<eCheckCompanyName>Company Name</eCheckCompanyName>' \
                                    '<eCheckBillingDescriptor>9785552222</eCheckBillingDescriptor>' \
                               '</eCheck>' \
                               '<subMerchantFunding enabled="true">' \
                                    '<fundingSubmerchantId>AUTO_GENERATE</fundingSubmerchantId>'\
                               '</subMerchantFunding>' \
                               '<settlementCurrency>USD</settlementCurrency>' \
                               '</subMerchantCreateRequest>'

    submerchant_put_request1 = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' \
                              '<subMerchantUpdateRequest xmlns="http://payfac.vantivcnp.com/api/merchant/onboard">' \
                              '<amexMid>1234567890</amexMid>' \
                              '<discoverConveyedMid>123456789012345</discoverConveyedMid>' \
                              '<url>http://merchantUrl</url>' \
                              '<customerServiceNumber>8407809000</customerServiceNumber>' \
                              '<hardCodedBillingDescriptor>SDK*</hardCodedBillingDescriptor>' \
                              '<maxTransactionAmount>8400</maxTransactionAmount>' \
                              '<bankRoutingNumber>211370545</bankRoutingNumber>' \
                              '<bankAccountNumber>84012312415</bankAccountNumber>' \
                              '<pspMerchantId>'
    submerchant_put_request2 = '</pspMerchantId>' \
                              '<purchaseCurrency>USD</purchaseCurrency>' \
                              '<address>' \
                                    '<streetAddress1>Street Address 1</streetAddress1>' \
                                    '<streetAddress2>Street Address 2</streetAddress2>' \
                                    '<city>City</city>' \
                                    '<stateProvince>MA</stateProvince>' \
                                    '<postalCode>01970</postalCode>' \
                                    '<countryCode>USA</countryCode>' \
                              '</address>' \
                              '<primaryContact>' \
                                    '<firstName>John</firstName>' \
                                    '<lastName>Doe</lastName>' \
                                    '<phone>9785552222</phone>' \
                              '</primaryContact>' \
                              '</subMerchantUpdateRequest>'

    #==========================================================================================
    #                             Legalentity certification Tests
    #==========================================================================================

    def test1(self):
        legalEntityType = "INDIVIDUAL_SOLE_PROPRIETORSHIP"
        taxId = random.randint(100000000, 999999999)
        streetAddress1 = "900 Chelmsford St"
        legalEntityPostRequest = self.legalEntityPostRequest1 + legalEntityType + self.legalEntityPostRequest2 + str(
            taxId
        ) + self.legalEntityPostRequest3 + streetAddress1 + self.legalEntityPostRequest4
        expected_url_suffix = "/legalentity"
        response = communication.http_post_request(expected_url_suffix,
                                                   legalEntityPostRequest,
                                                   self.conf)
        self.assertEquals("10", response["responseCode"])
        self.assertEquals("Approved", response["responseDescription"])

    def test2(self):
        legalEntityType = "INDIVIDUAL_SOLE_PROPRIETORSHIP"
        taxId = random.randint(100000000, 999999999)
        streetAddress1 = "912 Chelmsford St"
        legalEntityPostRequest = self.legalEntityPostRequest1 + legalEntityType + self.legalEntityPostRequest2 + str(
            taxId
        ) + self.legalEntityPostRequest3 + streetAddress1 + self.legalEntityPostRequest4
        expected_url_suffix = "/legalentity"
        response = communication.http_post_request(expected_url_suffix,
                                                   legalEntityPostRequest,
                                                   self.conf)
        self.assertEquals("20", response["responseCode"])

    # wait a minimum of two hours after submitting test #2
    def test2and2a(self):
        legalEntityType = "INDIVIDUAL_SOLE_PROPRIETORSHIP"
        taxId = random.randint(100000000, 999999999)
        streetAddress1 = "900 Chelmsford St"
        legalEntityPostRequest = self.legalEntityPostRequest1 + legalEntityType + self.legalEntityPostRequest2 + str(
            taxId
        ) + self.legalEntityPostRequest3 + streetAddress1 + self.legalEntityPostRequest4
        expected_url_suffix = "/legalentity"
        response = communication.http_post_request(expected_url_suffix,
                                                   legalEntityPostRequest,
                                                   self.conf)

        legalEntityIdFromTest2 = response["legalEntityId"]
        expected_url_suffix2 = expected_url_suffix + "/" + legalEntityIdFromTest2
        response2 = communication.http_get_retrieval_request(
            expected_url_suffix2, self.conf)

    # wait a minimum of two hours after submitting test #2
    def test2and2a(self):
        legalEntityType = "INDIVIDUAL_SOLE_PROPRIETORSHIP"
        taxId = random.randint(100000000, 999999999)
        streetAddress1 = "900 Chelmsford St"
        legalEntityPostRequest = self.legalEntityPostRequest1 + legalEntityType + self.legalEntityPostRequest2 + str(
            taxId
        ) + self.legalEntityPostRequest3 + streetAddress1 + self.legalEntityPostRequest4
        expected_url_suffix = "/legalentity"
        response = communication.http_post_request(expected_url_suffix,
                                                   legalEntityPostRequest,
                                                   self.conf)

        legalEntityIdFromTest2 = response["legalEntityId"]
        expected_url_suffix2 = expected_url_suffix + "/" + legalEntityIdFromTest2
        response2 = communication.http_get_retrieval_request(
            expected_url_suffix2, self.conf)

        self.assertEquals("10", response2["responseCode"])
        self.assertEquals("Approved", response2["responseDescription"])

    def test3(self):
        legalEntityType = "LIMITED_LIABILITY_COMPANY"
        taxId = random.randint(100000000, 999999999)
        streetAddress1 = "914 Chelmsford St"
        legalEntityPostRequest = self.legalEntityPostRequest1 + legalEntityType + self.legalEntityPostRequest2 + str(
            taxId
        ) + self.legalEntityPostRequest3 + streetAddress1 + self.legalEntityPostRequest4
        expected_url_suffix = "/legalentity"
        response = communication.http_post_request(expected_url_suffix,
                                                   legalEntityPostRequest,
                                                   self.conf)
        self.assertEquals("10", response["responseCode"])
        self.assertEquals("Approved", response["responseDescription"])

    def test1and4(self):
        legalEntityType = "INDIVIDUAL_SOLE_PROPRIETORSHIP"
        taxId = random.randint(100000000, 999999999)
        streetAddress1 = "900 Chelmsford St"
        legalEntityPostRequest = self.legalEntityPostRequest1 + legalEntityType + self.legalEntityPostRequest2 + str(
            taxId
        ) + self.legalEntityPostRequest3 + streetAddress1 + self.legalEntityPostRequest4
        expected_url_suffix = "/legalentity"
        response = communication.http_post_request(expected_url_suffix,
                                                   legalEntityPostRequest,
                                                   self.conf)

        legalEntityIdFromTest1 = response["legalEntityId"]
        expected_url_suffix2 = expected_url_suffix + "/" + legalEntityIdFromTest1
        taxId = random.randint(100000000, 999999999)
        legalEntityPutRequest = self.legalEntityPutRequest1 + str(
            taxId) + self.legalEntityPutRequest2
        response2 = communication.http_put_request(expected_url_suffix2,
                                                   legalEntityPutRequest,
                                                   self.conf)

        self.assertEquals("10", response2["responseCode"])
        self.assertEquals("Approved", response2["responseDescription"])

    def test5(self):
        expected_url_suffix = "/legalentity/0"
        taxId = random.randint(100000000, 999999999)
        legalEntityPutRequest = self.legalEntityPutRequest1 + str(
            taxId) + self.legalEntityPutRequest2
        self.assertRaises(utils.PayfacWebError, communication.http_put_request,
                          expected_url_suffix, legalEntityPutRequest,
                          self.conf)

    def test2and6(self):
        legalEntityType = "INDIVIDUAL_SOLE_PROPRIETORSHIP"
        taxId = random.randint(100000000, 999999999)
        streetAddress1 = "912 Chelmsford St"
        legalEntityPostRequest = self.legalEntityPostRequest1 + legalEntityType + self.legalEntityPostRequest2 + str(
            taxId
        ) + self.legalEntityPostRequest3 + streetAddress1 + self.legalEntityPostRequest4
        expected_url_suffix = "/legalentity"
        response = communication.http_post_request(expected_url_suffix,
                                                   legalEntityPostRequest,
                                                   self.conf)

        legalEntityIdFromTest2 = response["legalEntityId"]
        expected_url_suffix2 = expected_url_suffix + "/" + legalEntityIdFromTest2
        response2 = communication.http_get_retrieval_request(
            expected_url_suffix2, self.conf)
        self.assertEquals("20", response2["responseCode"])

    def test7(self):
        expected_url_suffix = "/legalentity/0"
        self.assertRaises(utils.PayfacWebError,
                          communication.http_get_retrieval_request,
                          expected_url_suffix, self.conf)

    #==========================================================================================
    #                             Submerchant certification Tests
    #==========================================================================================

    def test1and8(self):
        legalEntityType = "INDIVIDUAL_SOLE_PROPRIETORSHIP"
        taxId = random.randint(100000000, 999999999)
        streetAddress1 = "900 Chelmsford St"
        legalEntityPostRequest = self.legalEntityPostRequest1 + legalEntityType + self.legalEntityPostRequest2 + str(
            taxId
        ) + self.legalEntityPostRequest3 + streetAddress1 + self.legalEntityPostRequest4
        expected_url_suffix = "/legalentity"
        response = communication.http_post_request(expected_url_suffix,
                                                   legalEntityPostRequest,
                                                   self.conf)

        legalEntityIdFromTest1 = response["legalEntityId"]

        pspMerchantId = random.randint(100, 999)
        submerchant_post_request = self.submerchant_post_request1 + str(
            pspMerchantId) + self.submerchant_post_request2
        expected_url_suffix2 = expected_url_suffix + "/" + legalEntityIdFromTest1 + "/submerchant"
        response2 = communication.http_post_request(expected_url_suffix2,
                                                    submerchant_post_request,
                                                    self.conf)

    def test9(self):
        pspMerchantId = random.randint(100, 999)
        submerchant_post_request = self.submerchant_post_request1 + str(
            pspMerchantId) + self.submerchant_post_request2
        expected_url_suffix = "/legalentity/0/submerchant"
        self.assertRaises(utils.PayfacWebError,
                          communication.http_post_request, expected_url_suffix,
                          submerchant_post_request, self.conf)

    def test2and10(self):
        legalEntityType = "INDIVIDUAL_SOLE_PROPRIETORSHIP"
        taxId = random.randint(100000000, 999999999)
        streetAddress1 = "912 Chelmsford St"
        legalEntityPostRequest = self.legalEntityPostRequest1 + legalEntityType + self.legalEntityPostRequest2 + str(
            taxId
        ) + self.legalEntityPostRequest3 + streetAddress1 + self.legalEntityPostRequest4
        expected_url_suffix = "/legalentity"
        response = communication.http_post_request(expected_url_suffix,
                                                   legalEntityPostRequest,
                                                   self.conf)

        legalEntityIdFromTest2 = response["legalEntityId"]
        pspMerchantId = random.randint(100, 999)
        submerchant_post_request = self.submerchant_post_request1 + str(
            pspMerchantId) + self.submerchant_post_request2
        expected_url_suffix = "/legalentity/" + legalEntityIdFromTest2 + "/submerchant"
        self.assertRaises(utils.PayfacWebError,
                          communication.http_post_request, expected_url_suffix,
                          submerchant_post_request, self.conf)

    def test1and8and11(self):
        legalEntityType = "INDIVIDUAL_SOLE_PROPRIETORSHIP"
        taxId = random.randint(100000000, 999999999)
        streetAddress1 = "900 Chelmsford St"
        legalEntityPostRequest = self.legalEntityPostRequest1 + legalEntityType + self.legalEntityPostRequest2 + str(
            taxId
        ) + self.legalEntityPostRequest3 + streetAddress1 + self.legalEntityPostRequest4
        expected_url_suffix = "/legalentity"
        response = communication.http_post_request(expected_url_suffix,
                                                   legalEntityPostRequest,
                                                   self.conf)

        legalEntityIdFromTest1 = response["legalEntityId"]

        pspMerchantId = random.randint(100, 999)
        submerchant_post_request = self.submerchant_post_request1 + str(
            pspMerchantId) + self.submerchant_post_request2
        expected_url_suffix2 = expected_url_suffix + "/" + legalEntityIdFromTest1 + "/submerchant"
        response2 = communication.http_post_request(expected_url_suffix2,
                                                    submerchant_post_request,
                                                    self.conf)

        merchantIdFromTest8 = response2["subMerchantId"]
        pspMerchantId = random.randint(100, 999)
        submerchant_put_request = self.submerchant_put_request1 + str(
            pspMerchantId) + self.submerchant_put_request2
        expected_url_suffix3 = "/legalentity/" + legalEntityIdFromTest1 + "/submerchant/" + merchantIdFromTest8
        response3 = communication.http_put_request(expected_url_suffix3,
                                                   submerchant_put_request,
                                                   self.conf)

    def test1and8and12(self):
        legalEntityType = "INDIVIDUAL_SOLE_PROPRIETORSHIP"
        taxId = random.randint(100000000, 999999999)
        streetAddress1 = "900 Chelmsford St"
        legalEntityPostRequest = self.legalEntityPostRequest1 + legalEntityType + self.legalEntityPostRequest2 + str(
            taxId
        ) + self.legalEntityPostRequest3 + streetAddress1 + self.legalEntityPostRequest4
        expected_url_suffix = "/legalentity"
        response = communication.http_post_request(expected_url_suffix,
                                                   legalEntityPostRequest,
                                                   self.conf)

        legalEntityIdFromTest1 = response["legalEntityId"]

        pspMerchantId = random.randint(100, 999)
        submerchant_post_request = self.submerchant_post_request1 + str(
            pspMerchantId) + self.submerchant_post_request2
        expected_url_suffix2 = expected_url_suffix + "/" + legalEntityIdFromTest1 + "/submerchant"
        response2 = communication.http_post_request(expected_url_suffix2,
                                                    submerchant_post_request,
                                                    self.conf)

        merchantIdFromTest8 = response2["subMerchantId"]
        pspMerchantId = random.randint(100, 999)
        submerchant_put_request = self.submerchant_put_request1 + str(
            pspMerchantId) + self.submerchant_put_request2
        expected_url_suffix3 = "/legalentity/0/submerchant/" + merchantIdFromTest8
        self.assertRaises(utils.PayfacWebError, communication.http_put_request,
                          expected_url_suffix3, submerchant_put_request,
                          self.conf)

    def test1adn13(self):
        legalEntityType = "INDIVIDUAL_SOLE_PROPRIETORSHIP"
        taxId = random.randint(100000000, 999999999)
        streetAddress1 = "900 Chelmsford St"
        legalEntityPostRequest = self.legalEntityPostRequest1 + legalEntityType + self.legalEntityPostRequest2 + str(
            taxId
        ) + self.legalEntityPostRequest3 + streetAddress1 + self.legalEntityPostRequest4
        expected_url_suffix = "/legalentity"
        response = communication.http_post_request(expected_url_suffix,
                                                   legalEntityPostRequest,
                                                   self.conf)

        legalEntityIdFromTest1 = response["legalEntityId"]

        pspMerchantId = random.randint(100, 999)
        submerchant_put_request = self.submerchant_put_request1 + str(
            pspMerchantId) + self.submerchant_put_request2
        expected_url_suffix3 = "/legalentity/" + legalEntityIdFromTest1 + "/submerchant/0"
        self.assertRaises(utils.PayfacWebError, communication.http_put_request,
                          expected_url_suffix3, submerchant_put_request,
                          self.conf)

    def test1and8and14(self):
        legalEntityType = "INDIVIDUAL_SOLE_PROPRIETORSHIP"
        taxId = random.randint(100000000, 999999999)
        streetAddress1 = "900 Chelmsford St"
        legalEntityPostRequest = self.legalEntityPostRequest1 + legalEntityType + self.legalEntityPostRequest2 + str(
            taxId
        ) + self.legalEntityPostRequest3 + streetAddress1 + self.legalEntityPostRequest4
        expected_url_suffix = "/legalentity"
        response = communication.http_post_request(expected_url_suffix,
                                                   legalEntityPostRequest,
                                                   self.conf)

        legalEntityIdFromTest1 = response["legalEntityId"]

        pspMerchantId = random.randint(100, 999)
        submerchant_post_request = self.submerchant_post_request1 + str(
            pspMerchantId) + self.submerchant_post_request2
        expected_url_suffix2 = expected_url_suffix + "/" + legalEntityIdFromTest1 + "/submerchant"
        response2 = communication.http_post_request(expected_url_suffix2,
                                                    submerchant_post_request,
                                                    self.conf)

        subMerchantId = response2["subMerchantId"]
        expected_url_suffix3 = expected_url_suffix2 + "/" + subMerchantId
        response3 = communication.http_get_retrieval_request(
            expected_url_suffix3, self.conf)

    def test1and8and15(self):
        legalEntityType = "INDIVIDUAL_SOLE_PROPRIETORSHIP"
        taxId = random.randint(100000000, 999999999)
        streetAddress1 = "900 Chelmsford St"
        legalEntityPostRequest = self.legalEntityPostRequest1 + legalEntityType + self.legalEntityPostRequest2 + str(
            taxId
        ) + self.legalEntityPostRequest3 + streetAddress1 + self.legalEntityPostRequest4
        expected_url_suffix = "/legalentity"
        response = communication.http_post_request(expected_url_suffix,
                                                   legalEntityPostRequest,
                                                   self.conf)

        legalEntityIdFromTest1 = response["legalEntityId"]

        pspMerchantId = random.randint(100, 999)
        submerchant_post_request = self.submerchant_post_request1 + str(
            pspMerchantId) + self.submerchant_post_request2
        expected_url_suffix2 = expected_url_suffix + "/" + legalEntityIdFromTest1 + "/submerchant"
        response2 = communication.http_post_request(expected_url_suffix2,
                                                    submerchant_post_request,
                                                    self.conf)

        subMerchantId = response2["subMerchantId"]
        expected_url_suffix3 = "/legalentity/0/submerchant/" + subMerchantId
        self.assertRaises(utils.PayfacWebError,
                          communication.http_get_retrieval_request,
                          expected_url_suffix3, self.conf)

    def test1and8and16(self):
        legalEntityType = "INDIVIDUAL_SOLE_PROPRIETORSHIP"
        taxId = random.randint(100000000, 999999999)
        streetAddress1 = "900 Chelmsford St"
        legalEntityPostRequest = self.legalEntityPostRequest1 + legalEntityType + self.legalEntityPostRequest2 + str(
            taxId
        ) + self.legalEntityPostRequest3 + streetAddress1 + self.legalEntityPostRequest4
        expected_url_suffix = "/legalentity"
        response = communication.http_post_request(expected_url_suffix,
                                                   legalEntityPostRequest,
                                                   self.conf)

        legalEntityIdFromTest1 = response["legalEntityId"]

        pspMerchantId = random.randint(100, 999)
        submerchant_post_request = self.submerchant_post_request1 + str(
            pspMerchantId) + self.submerchant_post_request2
        expected_url_suffix2 = expected_url_suffix + "/" + legalEntityIdFromTest1 + "/submerchant"
        response2 = communication.http_post_request(expected_url_suffix2,
                                                    submerchant_post_request,
                                                    self.conf)

        subMerchantId = response2["subMerchantId"]
        expected_url_suffix3 = expected_url_suffix2 + "/0"
        self.assertRaises(utils.PayfacWebError,
                          communication.http_get_retrieval_request,
                          expected_url_suffix3, self.conf)