public async Task CreatesAndDisablesConflictingCustomerBankAccountUsingBranchCode()
        {
            // given
            var customer = await _resourceFactory.CreateLocalCustomer();

            var createRequest = new CreateCustomerBankAccountRequest
            {
                AccountHolderName = "API BANK ACCOUNT",
                AccountNumber     = "55666666",
                BranchCode        = "200000",
                CountryCode       = "GB",
                Currency          = "GBP",
                Links             = new CustomerBankAccountLinks {
                    Customer = customer.Id
                },
                Metadata = new Dictionary <string, string>
                {
                    ["Key1"] = "Value1",
                    ["Key2"] = "Value2",
                    ["Key3"] = "Value3",
                }
            };

            var subject = new CustomerBankAccountsClient(_clientConfiguration);

            // when
            await subject.CreateAsync(createRequest);

            var creationResult = await subject.CreateAsync(createRequest);

            var disableRequest = new DisableCustomerBankAccountRequest
            {
                Id = creationResult.Item.Id
            };

            var disabledResult = await subject.DisableAsync(disableRequest);

            // then
            Assert.That(creationResult.Item.Id, Is.Not.Null);
            Assert.That(creationResult.Item.AccountHolderName, Is.EqualTo(createRequest.AccountHolderName));
            Assert.That(creationResult.Item.AccountNumberEnding, Is.Not.Null);
            Assert.That(creationResult.Item.BankName, Is.Not.Null);
            Assert.That(creationResult.Item.CountryCode, Is.EqualTo(createRequest.CountryCode));
            Assert.That(creationResult.Item.Currency, Is.EqualTo(createRequest.Currency));
            Assert.That(creationResult.Item.Metadata, Is.EqualTo(createRequest.Metadata));
            Assert.That(creationResult.Item.Links.Customer, Is.EqualTo(createRequest.Links.Customer));
            Assert.That(creationResult.Item.Enabled, Is.True);

            Assert.That(disabledResult.Item.Enabled, Is.False);
        }
Пример #2
0
        public void CreateCustomerBankAccountRequestIsNullThrows()
        {
            // given
            var subject = new CustomerBankAccountsClient(_clientConfiguration);

            CreateCustomerBankAccountRequest request = null;

            // when
            AsyncTestDelegate test = () => subject.CreateAsync(request);

            // then
            var ex = Assert.ThrowsAsync <ArgumentNullException>(test);

            Assert.That(ex.ParamName, Is.EqualTo(nameof(request)));
        }
Пример #3
0
        public async Task CallsCreateCustomerBankAccountEndpoint()
        {
            // given
            var subject = new CustomerBankAccountsClient(_clientConfiguration);

            var request = new CreateCustomerBankAccountRequest
            {
                IdempotencyKey = Guid.NewGuid().ToString()
            };

            // when
            await subject.CreateAsync(request);

            // then
            _httpTest
            .ShouldHaveCalled("https://api.gocardless.com/customer_bank_accounts")
            .WithHeader("Idempotency-Key")
            .WithVerb(HttpMethod.Post);
        }
        internal async Task <CustomerBankAccount> CreateCustomerBankAccountFor(Customer customer)
        {
            var request = new CreateCustomerBankAccountRequest
            {
                AccountHolderName = "API BANK ACCOUNT",
                AccountNumber     = "55666666",
                BranchCode        = "200000",
                CountryCode       = "GB",
                Currency          = "GBP",
                Links             = new CustomerBankAccountLinks {
                    Customer = customer.Id
                },
                Metadata = new Dictionary <string, string>
                {
                    ["Key1"] = "Value1",
                    ["Key2"] = "Value2",
                    ["Key3"] = "Value3",
                }
            };

            var customerBankAccountsClient = new CustomerBankAccountsClient(_clientConfiguration);

            return((await customerBankAccountsClient.CreateAsync(request)).Item);
        }