예제 #1
0
        public async Task <CollectPaymentResponse> PostPayAccountPaymentCollections(int ownerId)
        {
            CollectPaymentResponse ret = null;

            try
            {
                ownerCollection = testDataManager.GetEnrolledOwnerCollection(ownerId);
                IReadOnlyList <Account> accounts = await GetBillingAccountByPolicyHolderId(ownerCollection.OwnerInformation.UniqueId.ToString());

                CollectPaymentCommand command = new CollectPaymentCommand();
                command.AccountId = accounts.First().Id;

                RestRequestSpecification req = new RestRequestSpecification();
                req.Verb        = HttpMethod.Post;
                req.Headers     = Headers;
                req.ContentType = "application/json";
                req.RequestUri  = $"v2/paymentcollections";
                req.Content     = JsonSerializer.Serialize(command);
                var returnPost = await asyncRestClientBilling.ExecuteAsync <string>(req);

                ret = JsonSerializer.Deserialize <CollectPaymentResponse>(returnPost.Value);
            }
            catch (Exception ex)
            {
                log.Fatal(ex);
            }
            return(ret);
        }
예제 #2
0
        public async Task <bool> PostAccountUpdatesChangeDefaultPaymentMethod(int ownerId, BillingPaymentMethodTypes method)
        {
            bool ret = false;

            try
            {
                ownerCollection = testDataManager.GetEnrolledOwnerCollection(ownerId);
                IReadOnlyList <Account> accounts = await GetBillingAccountByPolicyHolderId(ownerCollection.OwnerInformation.UniqueId.ToString());

                List <PaymentMethod> methods = await GetAccountPaymentMethods(ownerId);

                PaymentMethod        newMethod = methods.Where(e => e.Type.Equals(method.ToString())).First();
                UpdateAccountCommand command   = GetUpdateAccountCommandFromAccount(accounts.First());
                command.DefaultPaymentMethodId = newMethod.Id;
                RestRequestSpecification req = new RestRequestSpecification();
                req.Verb        = HttpMethod.Post;
                req.Headers     = Headers;
                req.ContentType = "application/json";
                req.RequestUri  = $"v2/AccountUpdates";
                req.Content     = JsonSerializer.Serialize(command);
                var returnPost = await asyncRestClientBilling.ExecuteAsync <string>(req);

                ret = returnPost.Success;
            }
            catch (Exception ex)
            {
                log.Fatal(ex);
            }
            return(ret);
        }
예제 #3
0
        public async Task <List <PaymentMethod> > PostPaymentMethodsAccountEtfs(string accountId)
        {
            List <PaymentMethod> ret = new List <PaymentMethod>();

            try
            {
                SaveEftPaymentMethodCommand command = new SaveEftPaymentMethodCommand();

                RestRequestSpecification req = new RestRequestSpecification();
                req.Verb        = HttpMethod.Post;
                req.Headers     = Headers;
                req.ContentType = "application/json";
                req.Content     = JsonSerializer.Serialize(command);
                req.RequestUri  = $"v2/paymentmethods?accountId={accountId}";
                var returnPost = await asyncRestClientBilling.ExecuteAsync <string>(req);

                if (returnPost.Success)
                {
                    ret = JsonSerializer.Deserialize <List <PaymentMethod> >(returnPost.Value);
                }
                else
                {
                    ret = null;
                }
            }
            catch (Exception ex)
            {
                log.Fatal(ex);
                ret = null;
            }
            return(ret);
        }
예제 #4
0
        public async Task <List <Invoice> > GetInvoices(string accountId)
        {
            List <Invoice>        ret      = new List <Invoice>();
            InvoiceFilterCriteria criteria = new InvoiceFilterCriteria();

            try
            {
                criteria.AccountId = accountId;
                RestRequestSpecification req = new RestRequestSpecification();
                req.Verb        = HttpMethod.Get;
                req.RequestUri  = $"/v2/invoices?criteria.accountId={accountId}";
                req.Headers     = Headers;
                req.ContentType = "application/json";
                var returnPost = await asyncRestClientBilling.ExecuteAsync <string>(req);

                if (returnPost.Success)
                {
                    ret = JsonSerializer.Deserialize <List <Invoice> >(returnPost.Value.ToString());
                }
                else
                {
                    ret = null;
                }
            }
            catch (Exception ex)
            {
                log.Fatal(ex);
                ret = null;
            }
            return(ret);
        }
예제 #5
0
        public async Task <List <InvoiceItem> > GetInvoicesItems(string invoiceId)
        {
            List <InvoiceItem> ret = new List <InvoiceItem>();

            try
            {
                RestRequestSpecification req = new RestRequestSpecification();
                req.Verb        = HttpMethod.Get;
                req.RequestUri  = $"v2/invoices/{invoiceId}/items";
                req.Headers     = Headers;
                req.ContentType = "application/json";
                var returnPost = await asyncRestClientBilling.ExecuteAsync <string>(req);

                if (returnPost.Success)
                {
                    ret = JsonSerializer.Deserialize <List <InvoiceItem> >(returnPost.Value);
                }
                else
                {
                    ret = null;
                }
            }
            catch (Exception ex)
            {
                log.Fatal(ex);
                ret = null;
            }
            return(ret);
        }
예제 #6
0
        public async Task <InvoiceWithItems> GetAccountInvoicesNext(string accountId)
        {
            InvoiceWithItems ret = new InvoiceWithItems();

            try
            {
                RestRequestSpecification req = new RestRequestSpecification();
                req.Verb        = HttpMethod.Get;
                req.RequestUri  = $"/v2/accounts/{accountId}/invoices/next";
                req.Headers     = Headers;
                req.ContentType = "application/json";
                var returnPost = await asyncRestClientBilling.ExecuteAsync <string>(req);

                if (returnPost.Success)
                {
                    ret = JsonSerializer.Deserialize <InvoiceWithItems>(returnPost.Value);
                }
                else
                {
                    ret = null;
                }
            }
            catch (Exception ex)
            {
                log.Fatal(ex);
                ret = null;
            }
            return(ret);
        }
예제 #7
0
        public async Task <IEnumerable <Subscription> > GetSubscription(SubscriptionFilterCriteria criteria)
        {
            IEnumerable <Subscription> ret = null;

            try
            {
                RestRequestSpecification req = new RestRequestSpecification();
                req.Verb       = HttpMethod.Get;
                req.RequestUri = $"/apps/Subscription.do?method=view&id={criteria.AccountId}";
                //req.Headers = Headers;
                req.ContentType = "application/json";
                //var returnPost = await asyncRestClientZuora.ExecuteAsync<IEnumerable<Persistence.Subscription>>(req);
                var returnPost = await asyncRestClientZuora.ExecuteAsync <string>(req);

                if (returnPost.Success)
                {
                    ret = JsonSerializer.Deserialize <IEnumerable <Subscription> >(returnPost.Value.ToString());
                }
                else
                {
                    ret = null;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                ret = null;
            }
            return(ret);
        }
예제 #8
0
        public async Task <bool> PostAccountUpdateCharity(int ownerId, int charityId)
        {
            bool ret = false;

            try
            {
                ownerCollection = testDataManager.GetEnrolledOwnerCollection(ownerId);
                IReadOnlyList <Account> accounts = await GetBillingAccountByPolicyHolderId(ownerCollection.OwnerInformation.UniqueId.ToString());

                UpdateAccountCommand command = GetUpdateAccountCommandFromAccount(accounts.First());
                CharityIds           charity = Charity.Charities.Where(i => i.Id == charityId).First();
                if (charity != null)
                {
                    command.CharityId = charity.UniqueId;
                    RestRequestSpecification req = new RestRequestSpecification();
                    req.Verb        = HttpMethod.Post;
                    req.Headers     = Headers;
                    req.ContentType = "application/json";
                    req.RequestUri  = $"v2/AccountUpdates";
                    req.Content     = JsonSerializer.Serialize(command);
                    var returnPost = await asyncRestClientBilling.ExecuteAsync <string>(req);

                    ret = returnPost.Success;
                }
            }
            catch (Exception ex)
            {
                log.Fatal(ex);
            }
            return(ret);
        }
예제 #9
0
        public async Task <bool> PostCreditBalanceRefunds(int ownerId)
        {
            bool ret = false;

            try
            {
                ownerCollection = testDataManager.GetEnrolledOwnerCollection(ownerId);
                IReadOnlyList <Account> accounts = await GetBillingAccountByPolicyHolderId(ownerCollection.OwnerInformation.UniqueId.ToString());

                RefundCreditBalanceCommand command = new RefundCreditBalanceCommand();
                command.AccountId = accounts.First().Id;

                RestRequestSpecification req = new RestRequestSpecification();
                req.Verb        = HttpMethod.Post;
                req.Headers     = Headers;
                req.ContentType = "application/json";
                req.RequestUri  = $"v2/creditbalancerefunds";
                req.Content     = JsonSerializer.Serialize(command);
                var returnPost = await asyncRestClientBilling.ExecuteAsync <string>(req);

                ret = returnPost.Success;
            }
            catch (Exception ex)
            {
                log.Fatal(ex);
            }
            return(ret);
        }
예제 #10
0
        public void InitTestClass()
        {
            try
            {
                ServiceFactory.InitializeServiceFactory(new ContainerConfiguration(ApplicationProfileType.TestFramework));

                billingServiceBaseUrl = BillingApiTestSettings.Default.BillingServiceBaseUrlTestEnvironment;

                var asyncRestClientFactory = ServiceFactory.Instance.Create <IAsyncRestClientFactory>();
                asyncRestClientBilling = asyncRestClientFactory.CreateClient(RestClientDefinitionBuilder.Build()
                                                                             .ForServiceUri(billingServiceBaseUrl)
                                                                             .Create());

                Headers = new Dictionary <string, string>();
                Headers.Add("Authorization", BillingApiTestSettings.Default.BillingServiceAuthorizationTokenTestEnvironment);

                request             = new RestRequestSpecification();
                request.Headers     = Headers;
                request.ContentType = "application/json";
            }
            catch (Exception ex)
            {
                log.Fatal(ex);
            }
        }
예제 #11
0
        public async Task <InvoicePreview> PostInvoicesPreview(int ownerId, string IsoAlpha3Code = "USA")
        {
            InvoicePreview ret = new InvoicePreview();

            try
            {
                // get a invoice
                ownerCollection = testDataManager.GetEnrolledOwnerCollection(ownerId);
                IReadOnlyList <Account> accounts = await GetBillingAccountByPolicyHolderId(ownerCollection.OwnerInformation.UniqueId.ToString());

                List <InvoiceWithItems> invoices = await GetAccountInvoices(accounts.First().Id.ToString());

                // preview invoice
                InvoicePreviewCriteria   crtieria = BuildInvoicePreviewCriteriaFromInvoice(ownerCollection, invoices.First(), IsoAlpha3Code);
                RestRequestSpecification req      = new RestRequestSpecification();
                req.Verb        = HttpMethod.Post;
                req.Headers     = Headers;
                req.ContentType = "application/json";
                req.RequestUri  = $"v2/invoices/previews";
                req.Content     = JsonSerializer.Serialize(crtieria);
                var returnPost = await asyncRestClientBilling.ExecuteAsync <string>(req);

                ret = JsonSerializer.Deserialize <InvoicePreview>(returnPost.Value);
            }
            catch (Exception ex)
            {
                log.Fatal(ex);
            }
            return(ret);
        }
예제 #12
0
        public async Task <SaveBankAccountResponse> PostSaveCanadaBankAccount(int ownerId, BillingParameters billingParam)
        {
            SaveBankAccountResponse   ret     = null;
            SaveUsaBankAccountCommand command = new SaveUsaBankAccountCommand();

            try
            {
                ownerCollection = testDataManager.GetEnrolledOwnerCollection(ownerId);
                IReadOnlyList <Account> accounts = await GetBillingAccountByPolicyHolderId(ownerCollection.OwnerInformation.UniqueId.ToString());

                command               = GetSaveUsaBankAccountCommandFromBillingParameter(accounts.First(), billingParam);
                command.AccountId     = BillingTestCommonSettings.Default.SaveUsaBankAccountBillingAccountId;
                command.NameOnAccount = $"bat{billingParam.BankAccountNameOnAccount}";

                RestRequestSpecification req = new RestRequestSpecification();
                req.Verb        = HttpMethod.Post;
                req.Headers     = Headers;
                req.ContentType = "application/json";
                req.RequestUri  = $"v2/bankaccounts/canada";
                req.Content     = JsonSerializer.Serialize(command);
                var returnPost = await asyncRestClientBilling.ExecuteAsync <string>(req);

                ret = JsonSerializer.Deserialize <SaveBankAccountResponse>(returnPost.Value);
            }
            catch (Exception ex)
            {
                log.Fatal(ex);
            }
            return(ret);
        }
예제 #13
0
        public async Task <PaymentMethod> PostPaymentMethodsETFS(int ownerId, BillingParameters billingParam)
        {
            PaymentMethod ret = null;
            SaveEftPaymentMethodCommand command = new SaveEftPaymentMethodCommand();

            try
            {
                ownerCollection = testDataManager.GetEnrolledOwnerCollection(ownerId);
                IReadOnlyList <Account> accounts = await GetBillingAccountByPolicyHolderId(ownerCollection.OwnerInformation.UniqueId.ToString());

                command             = GetSaveEftPaymentMethodCommandFromBillingParameter(accounts.First(), billingParam);
                command.AccountName = $"bat{billingParam.BankAccountNameOnAccount}";

                RestRequestSpecification req = new RestRequestSpecification();
                req.Verb        = HttpMethod.Post;
                req.Headers     = Headers;
                req.ContentType = "application/json";
                req.RequestUri  = $"v2/paymentmethods/efts";
                req.Content     = JsonSerializer.Serialize(command);
                var returnPost = await asyncRestClientBilling.ExecuteAsync <string>(req);

                ret = JsonSerializer.Deserialize <PaymentMethod>(returnPost.Value);
            }
            catch (Exception ex)
            {
                log.Fatal(ex);
            }
            return(ret);
        }
예제 #14
0
        public async Task <List <Refund> > GetAccountRefund(int ownerId)
        {
            List <Refund> ret = new List <Refund>();

            try
            {
                ownerCollection = testDataManager.GetEnrolledOwnerCollection(ownerId);
                IReadOnlyList <Account> accounts = await GetBillingAccountByPolicyHolderId(ownerCollection.OwnerInformation.UniqueId.ToString());

                RestRequestSpecification req = new RestRequestSpecification();
                req.Verb        = HttpMethod.Get;
                req.Headers     = Headers;
                req.ContentType = "application/json";
                req.RequestUri  = $"v2/refunds?accountId={accounts.First().Id}";
                var returnPost = await asyncRestClientBilling.ExecuteAsync <string>(req);

                ret = JsonSerializer.Deserialize <List <Refund> >(returnPost.Value);
            }
            catch (Exception ex)
            {
                log.Fatal(ex);
                ret = new List <Refund>();
            }
            return(ret);
        }
예제 #15
0
        //[TestMethod]
        public async Task BillingService_withoutAuthorizationToken()
        {
            request             = new RestRequestSpecification();
            request.Verb        = HttpMethod.Get;
            request.ContentType = "application/json";
            request.RequestUri  = $"v2/products";
            accountResult       = await asyncRestClientBilling.ExecuteAsync <string>(request);

            Assert.IsFalse(accountResult.Success, $"successed get account with invalid token");
            Assert.IsTrue(accountResult.Message.Contains($"An error occurred (URL=http://"), $"unexpected message - {accountResult.Message}");
        }
예제 #16
0
        public async Task <List <PaymentMethodType> > GetPaymentTypes()
        {
            List <PaymentMethodType> ret = new List <PaymentMethodType>();

            try
            {
                RestRequestSpecification req = new RestRequestSpecification();
                req.Verb        = HttpMethod.Get;
                req.Headers     = Headers;
                req.ContentType = "application/json";
                req.RequestUri  = $"v2/paymentmethodtypes";
                var returnPost = await asyncRestClientBilling.ExecuteAsync <string>(req);

                ret = JsonSerializer.Deserialize <List <PaymentMethodType> >(returnPost.Value);
            }
            catch (Exception ex)
            {
                log.Fatal(ex);
            }
            return(ret);
        }
예제 #17
0
        //public static void InitTestClass(TestContext context)
        public void InitTestClass()
        {
            try
            {
                ServiceFactory.InitializeServiceFactory(new ContainerConfiguration(ApplicationProfileType.TestFramework));

                var asyncRestClientFactory = ServiceFactory.Instance.Create <IAsyncRestClientFactory>();
                asyncRestClientZuora = asyncRestClientFactory.CreateClient(RestClientDefinitionBuilder.Build()
                                                                           .ForServiceUri(zuoraServiceBaseUrl)
                                                                           .Create());
                request = new RestRequestSpecification();

                Headers = new Dictionary <string, string>();
                //Headers.Add("Authorization", authorizationTokenV2);

                serializer = ServiceFactory.Instance.Create <IJsonSerialization>();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
예제 #18
0
        public async Task <bool> PostExpirationDate(int ownerId, DateTime date)
        {
            bool ret = false;

            try
            {
                ownerCollection = testDataManager.GetEnrolledOwnerCollection(ownerId);
                IReadOnlyList <Account> accounts = await GetBillingAccountByPolicyHolderId(ownerCollection.OwnerInformation.UniqueId.ToString());

                // get payment method
                List <PaymentMethod> methods = await GetAccountPaymentMethods(ownerId);

                PaymentMethod method = methods.First();
                if (method.Type == BillingPaymentMethodTypes.CreditCard.ToString())
                {
                    // update date
                    UpdateCreditCardExpirationCommand command = new UpdateCreditCardExpirationCommand();
                    command.PaymentMethodId = method.Id;
                    command.Year            = date.Year;
                    command.Month           = date.Month;

                    RestRequestSpecification req = new RestRequestSpecification();
                    req.Verb        = HttpMethod.Post;
                    req.Headers     = Headers;
                    req.ContentType = "application/json";
                    req.RequestUri  = $"v2/creditcards/expirationupdates";
                    req.Content     = JsonSerializer.Serialize(command);
                    var returnPost = await asyncRestClientBilling.ExecuteAsync <string>(req);

                    ret = returnPost.Success;
                }
            }
            catch (Exception ex)
            {
                log.Fatal(ex);
            }
            return(ret);
        }
예제 #19
0
        public async Task <string> CancelATrialPet(int ownerId, PetParameters petParams)
        {
            string ret = string.Empty;
            RestRequestSpecification request = null;

            try
            {
                request             = new RestRequestSpecification();
                request.Verb        = HttpMethod.Post;
                request.RequestUri  = $"Enrollment/PetParameters/AddATrialPet/{ownerId}";
                request.ContentType = "application/json";
                request.Content     = JsonSerializer.Serialize(petParams);

                var returnPost = await asyncRestClientQALib.ExecuteAsync <string>(request);

                ret = returnPost.Value.ToString();
            }
            catch (Exception ex)
            {
                BillingTestCommon.log.Fatal(ex);
            }
            return(ret);
        }
예제 #20
0
        public async Task <bool> ConvertTrialPet(int ownerId, string petName, EnrollmentParameters iep)
        {
            bool ret = false;
            RestRequestSpecification request = null;

            try
            {
                request             = new RestRequestSpecification();
                request.Verb        = HttpMethod.Post;
                request.RequestUri  = $"Enrollment/ConvertTrials/ConverPet/{ownerId}/{petName}";
                request.ContentType = "application/json";
                request.Content     = JsonSerializer.Serialize(iep);

                var returnPost = await asyncRestClientQALib.ExecuteAsync <string>(request);

                ret = bool.Parse(returnPost.Value.ToString());
            }
            catch (Exception ex)
            {
                BillingTestCommon.log.Fatal(ex);
            }
            return(ret);
        }
예제 #21
0
        public async Task <int> EnrollSingleOwner(EnrollmentParameters iep)
        {
            int ret = 0;
            RestRequestSpecification request = null;

            try
            {
                request             = new RestRequestSpecification();
                request.Verb        = HttpMethod.Post;
                request.RequestUri  = $"Enrollment/EnrollmentParameters/FullEnrollOwner";
                request.ContentType = "application/json";
                request.Content     = JsonSerializer.Serialize(iep);

                var returnPost = await asyncRestClientQALib.ExecuteAsync <RestResult <EnrollmentParameters> >(request);

                ret = int.Parse(returnPost.Value.ToString());
            }
            catch (Exception ex)
            {
                BillingTestCommon.log.Fatal(ex);
            }
            return(ret);
        }
예제 #22
0
        public async Task <Account> GetAccountById(string billingAccountId)
        {
            Account ret = null;

            try
            {
                RestRequestSpecification req = new RestRequestSpecification();
                req.Verb        = HttpMethod.Get;
                req.RequestUri  = $"v2/accounts/{billingAccountId}";
                req.Headers     = Headers;
                req.ContentType = "application/json";
                var returnPost = await asyncRestClientBilling.ExecuteAsync <string>(req);

                if (string.IsNullOrEmpty(returnPost?.Message))
                {
                    ret = JsonSerializer.Deserialize <Account>(returnPost.Value);
                }
            }
            catch (Exception ex)
            {
                log.Fatal(ex);
            }
            return(ret);
        }