public void CreateSubscription()
        {
            var random = new AnetRandom();
            var counter = random.Next(1, (int)(Math.Pow(2, 24)));
            var amount = ComputeRandomAmount();
            var email = string.Format("user.{0}@authorize.net", counter);

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

            const string responseString = "<?xml version=\"1.0\" encoding=\"utf-8\"?><ARBCreateSubscriptionResponse 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><subscriptionId>2010573</subscriptionId></ARBCreateSubscriptionResponse>";
            LocalRequestObject.ResponseString = responseString;

            var target = new SubscriptionGateway(ApiLogin, TransactionKey);

            var billToAddress = new Address { First = "SomeOneCool", Last = "MoreCoolPerson" };
            ISubscriptionRequest subscription = SubscriptionRequest.CreateMonthly(email, "ARB Subscription Test", amount, 1);
            subscription.CardNumber = "4111111111111111";
            subscription.CardExpirationMonth = 3;
            subscription.CardExpirationYear = Convert.ToInt32(DateTime.Now.AddYears(3).ToString("yyyy"));
            subscription.BillingAddress = billToAddress;

            ISubscriptionRequest actual = target.CreateSubscription(subscription);

            Assert.NotNull(actual);
            Assert.AreEqual(subscription.Amount, actual.Amount);
            Assert.AreEqual(subscription.CardNumber, actual.CardNumber);
            Assert.AreEqual(subscription.SubscriptionName, actual.SubscriptionName);

            _sMonthlySubscriptionId = actual.SubscriptionID;
            Assert.IsTrue(0 < _sMonthlySubscriptionId.Trim().Length);
            Assert.IsTrue(0 < long.Parse(_sMonthlySubscriptionId));
        }
        public void CreateSubscriptionTest_eCheck()
        {
            const string responseString = "<?xml version=\"1.0\" encoding=\"utf-8\"?><ARBCreateSubscriptionResponse 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><subscriptionId>2074569</subscriptionId></ARBCreateSubscriptionResponse>";
            LocalRequestObject.ResponseString = responseString;

            var target = new SubscriptionGateway(ApiLogin, TransactionKey);

            ISubscriptionRequest subscription = SubscriptionRequest.CreateMonthly("*****@*****.**",
                                                                                  "ARB Subscription Test eCheck", _mAmount,
                                                                                  12);
            subscription.eCheckBankAccount = new BankAccount
                {
                    accountTypeSpecified = true,
                    accountType = BankAccountType.Checking,
                    routingNumber = "125000024",
                    accountNumber = "123456",
                    nameOnAccount = "Sue Zhu",
                    echeckTypeSpecified = true,
                    echeckType = EcheckType.WEB
                };

            var billToAddress = new Address {First = "Sue", Last = "Zhu"};
            subscription.BillingAddress = billToAddress;

            ISubscriptionRequest actual = target.CreateSubscription(subscription);

            Assert.AreEqual(subscription.Amount, actual.Amount);
            Assert.AreEqual(subscription.eCheckBankAccount.accountNumber, actual.eCheckBankAccount.accountNumber);
            Assert.AreEqual(subscription.SubscriptionName, actual.SubscriptionName);

            Assert.IsTrue(actual.SubscriptionID.Trim().Length > 0);
            Assert.IsTrue(0 < long.Parse(actual.SubscriptionID));
        }
        public void CreateSubscriptionTest_zeroTrial()
        {
            var random = new AnetRandom();
            var counter = random.Next(1, (int)(Math.Pow(2, 24)));
            var amount = ComputeRandomAmount();
            var email = string.Format("user.{0}@authorize.net", counter);

            const string responseString = "<?xml version=\"1.0\" encoding=\"utf-8\"?><ARBCreateSubscriptionResponse 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><subscriptionId>2074569</subscriptionId></ARBCreateSubscriptionResponse>";
            LocalRequestObject.ResponseString = responseString;

            var target = new SubscriptionGateway(ApiLogin, TransactionKey);

            var billToAddress = new Address { First = "SomeOneCool", Last = "MoreCoolPerson" };
            ISubscriptionRequest subscription = SubscriptionRequest.CreateMonthly(email, "ARB Subscription Test", amount, 10);
            subscription.CardNumber = "4111111111111111";
            subscription.CardExpirationMonth = 3;
            subscription.CardExpirationYear = Convert.ToInt32(DateTime.Now.AddYears(3).ToString("yyyy"));
            subscription.BillingAddress = billToAddress;

            //setting Trial amount/ Trial Ocurances to 0 
            subscription.SetTrialPeriod(3, 0M);

            ISubscriptionRequest actual = null;
            actual = target.CreateSubscription(subscription);
            Assert.NotNull(actual);
        }