Esempio n. 1
0
        public void SearchAsync_OnMultipleValueFields()
        {
            Task.Run(async () =>
#endif
        {
            Result<Customer> customer = await gateway.Customer.CreateAsync(new CustomerRequest());
            Assert.IsTrue(customer.IsSuccess());

            var request1 = new PaymentMethodRequest
            {
                CustomerId = customer.Target.Id,
                PaymentMethodNonce = TestHelper.GenerateValidUsBankAccountNonce(gateway),
                Options = new PaymentMethodOptionsRequest
                {
                    VerificationMerchantAccountId = MerchantAccountIDs.US_BANK_MERCHANT_ACCOUNT_ID,
                    UsBankAccountVerificationMethod = UsBankAccountVerificationMethod.NETWORK_CHECK
                }
            };

            var request2 = new PaymentMethodRequest
            {
                CustomerId = customer.Target.Id,
                PaymentMethodNonce = TestHelper.GenerateValidUsBankAccountNonce(gateway),
                Options = new PaymentMethodOptionsRequest
                {
                    VerificationMerchantAccountId = MerchantAccountIDs.US_BANK_MERCHANT_ACCOUNT_ID,
                    UsBankAccountVerificationMethod = UsBankAccountVerificationMethod.INDEPENDENT_CHECK
                }
            };

            UsBankAccount result1 = (UsBankAccount) (await gateway.PaymentMethod.CreateAsync(request1)).Target;
            UsBankAccount result2 = (UsBankAccount) (await gateway.PaymentMethod.CreateAsync(request2)).Target;

            UsBankAccountVerification verification1 = gateway.UsBankAccountVerification.Find(result1.Verifications[0].Id);
            UsBankAccountVerification verification2 = gateway.UsBankAccountVerification.Find(result2.Verifications[0].Id);

            UsBankAccountVerificationSearchRequest searchRequest = new UsBankAccountVerificationSearchRequest().
                VerificationMethod.IncludedIn(UsBankAccountVerificationMethod.INDEPENDENT_CHECK,
                                              UsBankAccountVerificationMethod.NETWORK_CHECK).
                Ids.IncludedIn(verification1.Id, verification2.Id).
                Status.IncludedIn(UsBankAccountVerificationStatus.VERIFIED);

            ResourceCollection<UsBankAccountVerification> collection = await gateway.UsBankAccountVerification.SearchAsync(searchRequest);

            Assert.AreEqual(2, collection.MaximumCount);
        }
#if net452
            ).GetAwaiter().GetResult();
        }
        public void Search_OnTextFields()
        {
            Result <Customer> customer = gateway.Customer.Create(new CustomerRequest {
                Email = "*****@*****.**",
            });

            Assert.IsTrue(customer.IsSuccess());

            var request = new PaymentMethodRequest
            {
                CustomerId         = customer.Target.Id,
                PaymentMethodNonce = TestHelper.GenerateValidUsBankAccountNonce(gateway),
                Options            = new PaymentMethodOptionsRequest
                {
                    VerificationMerchantAccountId   = MerchantAccountIDs.US_BANK_MERCHANT_ACCOUNT_ID,
                    UsBankAccountVerificationMethod = UsBankAccountVerificationMethod.NETWORK_CHECK
                }
            };

            UsBankAccount result = (UsBankAccount)gateway.PaymentMethod.Create(request).Target;

            string token             = result.Token;
            string accountHolderName = result.AccountHolderName;
            string accountType       = result.AccountType;
            string customerId        = customer.Target.Id;
            string customerEmail     = customer.Target.Email;

            UsBankAccountVerificationSearchRequest searchRequest = new UsBankAccountVerificationSearchRequest().
                                                                   PaymentMethodToken.Is(token).
                                                                   CustomerId.Is(customerId).
                                                                   CustomerEmail.Is(customerEmail).
                                                                   AccountHolderName.Is(accountHolderName).
                                                                   AccountType.Is(accountType);

            ResourceCollection <UsBankAccountVerification> collection = gateway.UsBankAccountVerification.Search(searchRequest);
            UsBankAccountVerification verification = collection.FirstItem;

            Assert.AreEqual(1, collection.MaximumCount);
            Assert.AreEqual(accountHolderName, verification.UsBankAccount.AccountHolderName);
            Assert.AreEqual(accountType, verification.UsBankAccount.AccountType);
        }