Exemple #1
0
        public async Task ChangeAccountPaymentMethod()
        {
            bool bUpdate = false;
            BillingPaymentMethodTypes pMethod = BillingPaymentMethodTypes.ACH;

            ownerId = EnrollTestSettings.Default.AccountUpdateTestOwnerId;
            // change to ACH
            pMethod = BillingPaymentMethodTypes.ACH;
            bUpdate = await billingRestClient.PostAccountUpdatesChangeDefaultPaymentMethod(ownerId, pMethod);

            Assert.IsTrue(bUpdate, $"failed to change default payment method to ACH for owner {ownerId}");
            await billingDataVerifiers.verifyAccountDefaultPaymentMethod(ownerId, pMethod);

            // change to credit card
            pMethod = BillingPaymentMethodTypes.CreditCard;
            bUpdate = await billingRestClient.PostAccountUpdatesChangeDefaultPaymentMethod(ownerId, pMethod);

            Assert.IsTrue(bUpdate, $"failed to change default payment method to credit card for owner {ownerId}");
            await billingDataVerifiers.verifyAccountDefaultPaymentMethod(ownerId, pMethod);
        }
Exemple #2
0
        public async Task <PaymentMethod> verifyAccountDefaultPaymentMethod(int ownerId, BillingPaymentMethodTypes method)
        {
            List <PaymentMethod> methods   = new List <PaymentMethod>();
            PaymentMethod        curMethod = new PaymentMethod();

            try
            {
                ownerCollection = testDataManager.GetEnrolledOwnerCollection(ownerId);
                accounts        = await billingRestClient.GetBillingAccountByPolicyHolderId(ownerCollection.OwnerInformation.UniqueId.ToString());

                methods = await billingRestClient.GetAccountPaymentMethods(ownerId);

                curMethod = methods.Where(m => m.Id == accounts.First().DefaultPaymentMethodId).First();
            }
            catch (Exception ex)
            {
                Logger.Log.Fatal(ex);
            }
            Assert.IsTrue(curMethod.Type.Equals(method.ToString()), $"default payment method {curMethod.Type} doesn't match expencted {method.ToString()}");
            return(curMethod);
        }
        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);
        }