public void TestPostLegalEntityPrincipalCreateRequestManualReview()
 {
     legalEntityId = "201820";
     request       = new legalEntityPrincipalCreateRequest
     {
         principal = new legalEntityPrincipal
         {
             title        = "Mr.",
             firstName    = "Jon",
             lastName     = "Snow",
             emailAddress = "*****@*****.**",
             dateOfBirth  = new DateTime(1980, 10, 12),
             address      = new principalAddress
             {
                 streetAddress1 = "p2 street address 1",
                 streetAddress2 = "p2 street address 2",
                 city           = "Boston",
                 stateProvince  = "MA",
                 postalCode     = "01892",
                 countryCode    = "USA"
             },
             stakePercent = 31,
         }
     };
     response = request.PostLegalEntityPrincipalCreateRequest(legalEntityId);
     Assert.AreEqual(legalEntityId, response.legalEntityId);
     Assert.NotNull(response.principal.principalId);
     Assert.AreEqual("Jon", response.principal.firstName);
     Assert.AreEqual("Snow", response.principal.lastName);
     Assert.AreEqual(20, response.principal.responseCode);
     Assert.AreEqual("Manual Review", response.principal.responseDescription);
 }
        public void TestPostLegalEntityPrincipalCreateRequest()
        {
            legalEntityId = "2018";
            var xmlReq = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" +
                         "<legalEntityPrincipalCreateRequest xmlns=\"http://payfac.vantivcnp.com/api/merchant/onboard\">" +
                         "<principal>" +
                         "<title>Mr.</title>" +
                         "<firstName>Jon</firstName>" +
                         "<lastName>Snow</lastName>" +
                         "<emailAddress>[email protected]</emailAddress>" +
                         "<ssn>123450015</ssn>" +
                         "<dateOfBirth>1980-10-12</dateOfBirth>" +
                         "<address>" +
                         "<streetAddress1>p2 street address 1</streetAddress1>" +
                         "<streetAddress2>p2 street address 2</streetAddress2>" +
                         "<city>Boston</city>" +
                         "<stateProvince>MA</stateProvince>" +
                         "<postalCode>01892</postalCode>" +
                         "<countryCode>USA</countryCode>" +
                         "</address>" +
                         "<stakePercent>31</stakePercent>" +
                         "</principal>" +
                         "<sdkVersion>" + Versions.SDK_VERSION + "</sdkVersion>" +
                         "<language>" + Versions.LANGUAGE + "</language>" +
                         "</legalEntityPrincipalCreateRequest>";

            var expectedResponse = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" +
                                   "<principalCreateResponse xmlns=\"http://payfac.vantivcnp.com/api/merchant/onboard\">" +
                                   "    <legalEntityId>2018</legalEntityId>" +
                                   "    <principal>" +
                                   "        <principalId>8</principalId>" +
                                   "        <firstName>Jon</firstName>" +
                                   "        <lastName>Snow</lastName>" +
                                   "        <responseCode>10</responseCode>" +
                                   "        <responseDescription>Approved</responseDescription>" +
                                   "    </principal>" +
                                   "    <transactionId>9251158686</transactionId>" +
                                   "</principalCreateResponse>";

            var mock = new Mock <Communication>();

            mock.Setup(Communication => Communication.Post("/legalentity/2018/principal", xmlReq)).Returns(expectedResponse);

            Communication communicationMock = mock.Object;

            request.Communication = communicationMock;
            response = request.PostLegalEntityPrincipalCreateRequest(legalEntityId);

            Assert.AreEqual(legalEntityId, response.legalEntityId);
            Assert.NotNull(response.principal);
            Assert.NotNull(response.transactionId);
        }
 public void TestPostLegalEntityPrincipalCreateRequestErrorResponse400()
 {
     legalEntityId = "201400";
     request       = new legalEntityPrincipalCreateRequest
     {
         principal = new legalEntityPrincipal
         {
             title        = "Mr.",
             firstName    = "Jon",
             lastName     = "Snow",
             emailAddress = "*****@*****.**",
             dateOfBirth  = new DateTime(1980, 10, 12),
             address      = new principalAddress
             {
                 streetAddress1 = "p2 street address 1",
                 streetAddress2 = "p2 street address 2",
                 city           = "Boston",
                 stateProvince  = "MA",
                 postalCode     = "01892",
                 countryCode    = "USA"
             },
             stakePercent = 31,
         }
     };
     try
     {
         response = request.PostLegalEntityPrincipalCreateRequest(legalEntityId);
         Assert.Fail("PayfacWebException expected, None thrown");
     }
     catch (PayFacWebException ex)
     {
         errorResponse errorResponse = ex.errorResponse;
         Assert.NotNull(errorResponse.transactionId);
         Assert.AreEqual("Could not find requested object.", errorResponse.errors[0]);
     }
 }
 public void TestGetLegalEntityRetrievalRequestErrorResponse500()
 {
     legalEntityId = "201500";
     request       = new legalEntityPrincipalCreateRequest
     {
         principal = new legalEntityPrincipal
         {
             title        = "Mr.",
             firstName    = "Jon",
             lastName     = "Snow",
             emailAddress = "*****@*****.**",
             dateOfBirth  = new DateTime(1980, 10, 12),
             address      = new principalAddress
             {
                 streetAddress1 = "p2 street address 1",
                 streetAddress2 = "p2 street address 2",
                 city           = "Boston",
                 stateProvince  = "MA",
                 postalCode     = "01892",
                 countryCode    = "USA"
             },
             stakePercent = 31,
         }
     };
     try
     {
         response = request.PostLegalEntityPrincipalCreateRequest(legalEntityId);
         Assert.Fail("PayfacWebException expected, None thrown");
     }
     catch (PayFacWebException ex)
     {
         errorResponse errorResponse = ex.errorResponse;
         Assert.NotNull(errorResponse.transactionId);
         Assert.AreEqual("Internal Error. This error has already been escalated to Vantiv for resolution. Please contact support with questions.", errorResponse.errors[0]);
     }
 }
 public void TestGetLegalEntityRetrievalRequestErrorResponse401()
 {
     legalEntityId = "201401";
     request       = new legalEntityPrincipalCreateRequest
     {
         principal = new legalEntityPrincipal
         {
             title        = "Mr.",
             firstName    = "Jon",
             lastName     = "Snow",
             emailAddress = "*****@*****.**",
             dateOfBirth  = new DateTime(1980, 10, 12),
             address      = new principalAddress
             {
                 streetAddress1 = "p2 street address 1",
                 streetAddress2 = "p2 street address 2",
                 city           = "Boston",
                 stateProvince  = "MA",
                 postalCode     = "01892",
                 countryCode    = "USA"
             },
             stakePercent = 31,
         }
     };
     try
     {
         response = request.PostLegalEntityPrincipalCreateRequest(legalEntityId);
         Assert.Fail("PayfacWebException expected, None thrown");
     }
     catch (PayFacWebException ex)
     {
         errorResponse errorResponse = ex.errorResponse;
         Assert.NotNull(errorResponse.transactionId);
         Assert.AreEqual("You are not authorized to access this resource. Please check your credentials.", errorResponse.errors[0]);
     }
 }