public void Reporting_GetTransactionDetailsTest_WithSolutionID()
        {
            const string transId = "???"; // A transaction id with solution.

            string sError = CheckApiLoginTransactionKey();
            Assert.IsTrue(sError == "", sError);

            const string responseString = "<?xml version=\"1.0\" encoding=\"utf-8\"?> <getTransactionDetailsResponse xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns=\"AnetApi/xml/v1/schema/AnetApiSchema.xsd\"> <messages> <resultCode>Ok</resultCode> <message> <code>I00001</code> <text>Successful.</text> </message> </messages> <transaction> <transId>2148855368</transId> <submitTimeUTC>2014-04-26T00:23:36.98Z</submitTimeUTC> <submitTimeLocal>2014-04-25T19:23:36.98</submitTimeLocal> <transactionType>authCaptureTransaction</transactionType> <transactionStatus>settledSuccessfully</transactionStatus> <responseCode>1</responseCode> <responseReasonCode>1</responseReasonCode> <responseReasonDescription>Approval</responseReasonDescription> <AVSResponse>P</AVSResponse> <batch> <batchId>10151391</batchId> <settlementTimeUTC>2014-04-26T00:24:00.99Z</settlementTimeUTC> <settlementTimeLocal>2014-04-25T19:24:00.99</settlementTimeLocal> <settlementState>settledSuccessfully</settlementState> </batch> <order> <invoiceNumber>QaInv01sjijwtbpomd</invoiceNumber> </order> <authAmount>1.00</authAmount> <settleAmount>1.00</settleAmount> <taxExempt>false</taxExempt> <payment> <bankAccount> <routingNumber>XXXX0505</routingNumber> <accountNumber>XXXX7120</accountNumber> <nameOnAccount>Account Owner</nameOnAccount> <echeckType>WEB</echeckType> </bankAccount> </payment> <recurringBilling>false</recurringBilling> <solution> <id>A1000002</id> <name>Miva Merchant 5.5</name> </solution> </transaction> </getTransactionDetailsResponse>";
            LocalRequestObject.ResponseString = responseString;

            var target = new ReportingGateway(ApiLogin, TransactionKey);
            Transaction actual = null;
            string sErr = "";

            // if choose "USELOCAL", the test should pass with no exception
            // Otherwise, the test might fail for error, i.e. duplicated request.
            try
            {
                actual = target.GetTransactionDetails(transId);
            }
            catch (Exception e)
            {
                sErr = e.Message;
            }

            Assert.IsNotNull(actual);
            Assert.IsNotNull(actual.TransactionID);

            Assert.IsNotNull(actual.BatchSettledOn);
            Assert.IsNotNull(actual.BatchSettlementID);

            // This is a settled transaction. The status does not have to be "settledSuccessfully" though.
            // For instance, it can be "void", or "refundSuccessfully" etc
            Assert.IsNotNull(actual.BatchSettlementState);
            Assert.IsNotNull(actual.Status);

            Assert.IsNotNull(actual.Solution);
            Assert.IsNotNull(actual.Solution.id);
            Assert.IsNotNull(actual.Solution.name); 
        }
        public void Reporting_GetTransactionDetailsTest_WithReturnedItems()
        {
            const string transId = "???"; // A transaction id with returned items

            //check ApiLoginid / TransactionKey
            string sError = CheckApiLoginTransactionKey();
            Assert.IsTrue(sError == "", sError);

            const string responseString = "<?xml version=\"1.0\" encoding=\"utf-8\"?> <getTransactionDetailsResponse xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns=\"AnetApi/xml/v1/schema/AnetApiSchema.xsd\"> <messages> <resultCode>Ok</resultCode> <message> <code>I00001</code> <text>Successful.</text> </message> </messages> <transaction> <transId>2148382212</transId> <submitTimeUTC>2012-01-12T02:21:53.42Z</submitTimeUTC> <submitTimeLocal>2012-01-11T20:21:53.42</submitTimeLocal> <transactionType>authCaptureTransaction</transactionType> <transactionStatus>settledSuccessfully</transactionStatus> <responseCode>1</responseCode> <responseReasonCode>1</responseReasonCode> <responseReasonDescription>Approval</responseReasonDescription> <AVSResponse>P</AVSResponse> <batch> <batchId>10097820</batchId> <settlementTimeUTC>2012-01-12T02:21:55.237Z</settlementTimeUTC> <settlementTimeLocal>2012-01-11T20:21:55.237</settlementTimeLocal> <settlementState>settledSuccessfully</settlementState> </batch> <order> <invoiceNumber>QaInv01waegphqvlcyj</invoiceNumber> </order> <authAmount>12.10</authAmount> <settleAmount>12.10</settleAmount> <taxExempt>false</taxExempt> <payment> <bankAccount> <routingNumber>XXXX0204</routingNumber> <accountNumber>XXXX2152</accountNumber> <nameOnAccount>Account Owner</nameOnAccount> <echeckType>TEL</echeckType> </bankAccount> </payment> <recurringBilling>false</recurringBilling> <returnedItems> <returnedItem> <id>2148382213</id> <dateUTC>2012-01-12T02:22:15Z</dateUTC> <dateLocal>2012-01-11T20:22:15</dateLocal> <code>R03</code> <description>No account/unable to locate account</description> </returnedItem> </returnedItems> </transaction> </getTransactionDetailsResponse>";
            LocalRequestObject.ResponseString = responseString;

            var target = new ReportingGateway(ApiLogin, TransactionKey);
            Transaction actual = null;
            string sErr = "";

            // if choose "USELOCAL", the test should pass with no exception
            // Otherwise, the test might fail for error, i.e. duplicated request.
            try
            {
                actual = target.GetTransactionDetails(transId);
            }
            catch (Exception e)
            {
                sErr = e.Message;
            }

            Assert.IsNotNull(actual);
            Assert.IsNotNull(actual.TransactionID);

            Assert.IsNotNull(actual.BatchSettledOn);
            Assert.IsNotNull(actual.BatchSettlementID);

            // This is a settled transaction. The status does not have to be "settledSuccessfully" though.
            // For instance, it can be "void", or "refundSuccessfully" etc
            Assert.IsNotNull(actual.BatchSettlementState);
            Assert.IsNotNull(actual.Status);

            Assert.AreEqual(actual.HasReturnedItems, NullableBooleanEnum.True);
            Assert.IsNotNull(actual.ReturnedItems);
            Assert.AreEqual(actual.ReturnedItems.Length, 1);
            Assert.IsNotNull(actual.ReturnedItems[0].id);
            Assert.IsNotNull(actual.ReturnedItems[0].code);
            Assert.IsNotNull(actual.ReturnedItems[0].description);
        }
        public void Reporting_GetTransactionDetailsTest()
        {
            //check ApiLoginid / TransactionKey
            string sError = CheckApiLoginTransactionKey();
            Assert.IsTrue(sError == "", sError);

            const string responseString = "<?xml version=\"1.0\" encoding=\"utf-8\"?><getTransactionDetailsResponse xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns=\"AnetApi/xml/v1/schema/AnetApiSchema.xsd\"><messages><resultCode>Ok</resultCode><message><code>I00001</code><text>Successful.</text></message></messages><transaction><transId>2209067941</transId><submitTimeUTC>2014-03-21T23:16:25.797Z</submitTimeUTC><submitTimeLocal>2014-03-21T16:16:25.797</submitTimeLocal><transactionType>authCaptureTransaction</transactionType><transactionStatus>settledSuccessfully</transactionStatus><responseCode>1</responseCode><responseReasonCode>1</responseReasonCode><responseReasonDescription>Approval</responseReasonDescription><authCode>UUV1S1</authCode><AVSResponse>Y</AVSResponse><cardCodeResponse>P</cardCodeResponse><batch><batchId>3282059</batchId><settlementTimeUTC>2014-03-22T15:21:44.343Z</settlementTimeUTC><settlementTimeLocal>2014-03-22T08:21:44.343</settlementTimeLocal><settlementState>settledSuccessfully</settlementState></batch><authAmount>3.99</authAmount><settleAmount>3.99</settleAmount><taxExempt>false</taxExempt><payment><creditCard><cardNumber>XXXX1111</cardNumber><expirationDate>XXXX</expirationDate><cardType>Visa</cardType></creditCard></payment><recurringBilling>false</recurringBilling><customerIP>10.1.186.51</customerIP><product>Card Not Present</product><marketType>eCommerce</marketType></transaction></getTransactionDetailsResponse>";
            LocalRequestObject.ResponseString = responseString;

            var target = new ReportingGateway(ApiLogin, TransactionKey);
            var sErr = "";

            List<Transaction> settledTransactions = null;
            try
            {
                // Get the last 30-day settled transactions.
                settledTransactions = target.GetTransactionList();
            }
            catch (Exception e)
            {
                sErr = e.Message;
            }

            Assert.IsNotNull(settledTransactions);
            Assert.Greater(settledTransactions.Count, 0); // pre-condition
	    
            Transaction actual = null;

            // if choose "USELOCAL", the test should pass with no exception
            // Otherwise, the test might fail for error, i.e. duplicated request.
            try
            {
                // Get the transaction details of the settled transaction.
                actual = target.GetTransactionDetails(settledTransactions[0].TransactionID);
            }
            catch (Exception e)
            {
                sErr = e.Message;
            }

            Assert.IsNotNull(actual);
            Assert.IsNotNull(actual.TransactionID);

            Assert.IsNotNull(actual.BatchSettledOn);
            Assert.IsNotNull(actual.BatchSettlementID);

            // This is a settled transaction. The status does not have to be "settledSuccessfully" though.
            // For instance, it can be "void", or "refundSuccessfully" etc
            Assert.IsNotNull(actual.BatchSettlementState);
            Assert.IsNotNull(actual.Status);

            Assert.IsNotNull(actual.AVSCode);
            Assert.IsNotNull(actual.AVSResponse);
            Assert.IsNotNull(actual.AuthorizationCode);
            Assert.IsNotNull(actual.AuthorizationAmount);
            Assert.IsNotNull(actual.ResponseCode);
            Assert.IsNotNull(actual.SettleAmount);
            Assert.IsNotNull(actual.CardNumber);
            Assert.IsNotNull(actual.CardExpiration);
            Assert.IsNotNull(actual.CardType);

            var subscription = actual.Subscription;
            if (subscription != null)
            {
                Assert.Greater(subscription.ID,  0);
                Assert.Greater(subscription.PayNum, 0);
            }
        }
        public void Reporting_GetTransactionDetailsTest_WithSubscription()
        {
            const string transId = "???"; // A transaction id with subscription

            //check ApiLoginid / TransactionKey
            string sError = CheckApiLoginTransactionKey();
            Assert.IsTrue(sError == "", sError);

            const string responseString = "<?xml version=\"1.0\" encoding=\"utf-8\"?><getTransactionDetailsResponse xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns=\"AnetApi/xml/v1/schema/AnetApiSchema.xsd\"><messages><resultCode>Ok</resultCode><message><code>I00001</code><text>Successful.</text></message></messages><transaction><transId>2210248566</transId><submitTimeUTC>2014-04-07T08:53:45.063Z</submitTimeUTC><submitTimeLocal>2014-04-07T01:53:45.063</submitTimeLocal><transactionType>authCaptureTransaction</transactionType><transactionStatus>settledSuccessfully</transactionStatus><responseCode>1</responseCode><responseReasonCode>1</responseReasonCode><subscription><id>2017665</id><payNum>2</payNum></subscription><responseReasonDescription>Approval</responseReasonDescription><authCode>9QW0L9</authCode><AVSResponse>Y</AVSResponse><batch><batchId>3323130</batchId><settlementTimeUTC>2014-04-07T15:20:19.703Z</settlementTimeUTC><settlementTimeLocal>2014-04-07T08:20:19.703</settlementTimeLocal><settlementState>settledSuccessfully</settlementState></batch><authAmount>1.31</authAmount><settleAmount>1.31</settleAmount><taxExempt>false</taxExempt><payment><creditCard><cardNumber>XXXX1111</cardNumber><expirationDate>XXXX</expirationDate><cardType>Visa</cardType></creditCard></payment><customer><type>individual</type><email>[email protected]</email></customer><billTo><firstName>Sue</firstName><lastName>Zhu</lastName></billTo><recurringBilling>true</recurringBilling></transaction></getTransactionDetailsResponse>";
            LocalRequestObject.ResponseString = responseString;

            var target = new ReportingGateway(ApiLogin, TransactionKey);
            Transaction actual = null;
            string sErr = "";

            // if choose "USELOCAL", the test should pass with no exception
            // Otherwise, the test might fail for error, i.e. duplicated request.
            try
            {
                actual = target.GetTransactionDetails(transId);
            }
            catch (Exception e)
            {
                sErr = e.Message;
            }

            Assert.IsNotNull(actual);
            Assert.IsNotNull(actual.TransactionID);

            Assert.IsNotNull(actual.BatchSettledOn);
            Assert.IsNotNull(actual.BatchSettlementID);

            // This is a settled transaction. The status does not have to be "settledSuccessfully" though.
            // For instance, it can be "void", or "refundSuccessfully" etc
            Assert.IsNotNull(actual.BatchSettlementState);
            Assert.IsNotNull(actual.Status);

            var subscription = actual.Subscription;
            Assert.IsNotNull(subscription);
            Assert.Greater(subscription.ID,  0);
            Assert.Greater(subscription.PayNum, 0);
        }
        public void Reporting_GetTransactionDetailsTest_AccessDenied()
        {
            //check ApiLoginid / TransactionKey
            string sError = CheckApiLoginTransactionKey();
            Assert.IsTrue(sError == "", sError);

            const string responseString = "<?xml version=\"1.0\" encoding=\"utf-8\"?><getTransactionDetailsResponse xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns=\"AnetApi/xml/v1/schema/AnetApiSchema.xsd\"><messages><resultCode>Error</resultCode><message><code>E00011</code><text>Access denied. You do not have permissions to call the Transaction Details API.</text></message></messages></getTransactionDetailsResponse>";
            LocalRequestObject.ResponseString = responseString;
            
            var target = new ReportingGateway(ApiLogin, TransactionKey);
            Transaction actual = null;
            var sErr = "";

            // if choose "USELOCAL", the test should generate Access Denied error.
            try
            {
                // Get a transaction details. Ok to use any value, since your "Transaction Details API" permission has been revoked.
                actual = target.GetTransactionDetails("2210248566");
            }
            catch (Exception e)
            {
                sErr = e.Message;
            }

            Assert.IsNull(actual);
            Assert.AreEqual(sErr, "Error processing request: E00011 - Access denied. You do not have permissions to call the Transaction Details API.");
        }