public async Task CreatesMandatePdfUsingMandate()
        {
            // given
            var creditor = await _resourceFactory.Creditor();

            var customer = await _resourceFactory.CreateLocalCustomer();

            var customerBankAccount = await _resourceFactory.CreateCustomerBankAccountFor(customer);

            var mandate = await _resourceFactory.CreateMandateFor(creditor, customer, customerBankAccount);

            var subject = new MandatePdfsClient(_clientConfiguration);

            var request = new CreateMandatePdfRequest
            {
                Language = "en",
                Links    = new MandatePdfLinks
                {
                    Mandate = mandate.Id
                }
            };

            // when
            var result = await subject.CreateAsync(request);

            // then
            Assert.That(result.Item, Is.Not.Null);
            Assert.That(result.Item.ExpiresAt, Is.Not.Null.And.Not.EqualTo(default(DateTimeOffset)));
            Assert.That(result.Item.Url, Is.Not.Null);
        }
Exemplo n.º 2
0
        public void CreateMandatePdfRequestIsNullThrows()
        {
            // given
            var subject = new MandatePdfsClient(_clientConfiguration);

            CreateMandatePdfRequest request = null;

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

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

            Assert.That(ex.ParamName, Is.EqualTo(nameof(request)));
        }
        public async Task CreatesMandatePdfUsingSuppliedDetails()
        {
            // given
            var creditor = await _resourceFactory.Creditor();

            var customer = await _resourceFactory.CreateLocalCustomer();

            var customerBankAccount = await _resourceFactory.CreateCustomerBankAccountFor(customer);

            var mandate = await _resourceFactory.CreateMandateFor(creditor, customer, customerBankAccount);

            var subject = new MandatePdfsClient(_clientConfiguration);

            var request = new CreateMandatePdfRequest
            {
                AccountHolderName = "Account holder",
                AccountNumber     = "44779911",
                AddressLine1      = "Address line 1",
                AddressLine2      = "Address line 2",
                AddressLine3      = "Address line 3",
                BankCode          = "Bank code",
                Bic                   = "Bic",
                City                  = "City",
                CountryCode           = "Country code",
                DanishIdentityNumber  = "2205506218",
                Iban                  = "GB18 BARC 1234 5678",
                Language              = "en",
                MandateReference      = "MR12345678",
                PhoneNumber           = "+44 20 7183 8674",
                PostalCode            = "SW1A 1AA",
                Region                = "Essex",
                Scheme                = Scheme.BecsNz,
                SignatureDate         = DateTime.Now,
                SwedishIdentityNumber = "5302256218",
            };

            // when
            var result = await subject.CreateAsync(request);

            // then
            Assert.That(result.Item, Is.Not.Null);
            Assert.That(result.Item.ExpiresAt, Is.Not.Null.And.Not.EqualTo(default(DateTimeOffset)));
            Assert.That(result.Item.Url, Is.Not.Null);
        }
Exemplo n.º 4
0
        public GoCardlessClient(ClientConfiguration configuration)
        {
            _configuration = configuration;

            BankDetailsLookups    = new BankDetailsLookupsClient(configuration);
            CreditorBankAccounts  = new CreditorBankAccountsClient(configuration);
            Creditors             = new CreditorsClient(configuration);
            CustomerBankAccounts  = new CustomerBankAccountsClient(configuration);
            CustomerNotifications = new CustomerNotificationsClient(configuration);
            Customers             = new CustomersClient(configuration);
            Events = new EventsClient(configuration);
            MandateImportEntries = new MandateImportEntriesClient(configuration);
            MandateImports       = new MandateImportsClient(configuration);
            MandatePdfs          = new MandatePdfsClient(configuration);
            Mandates             = new MandatesClient(configuration);
            Payments             = new PaymentsClient(configuration);
            PayoutItems          = new PayoutItemsClient(configuration);
            Payouts       = new PayoutsClient(configuration);
            RedirectFlows = new RedirectFlowsClient(configuration);
            Refunds       = new RefundsClient(configuration);
            Subscriptions = new SubscriptionsClient(configuration);
        }
Exemplo n.º 5
0
        public async Task CallsCreateMandatePdfEndpointWithoutAcceptsLanguageHeader()
        {
            // given
            var subject = new MandatePdfsClient(_clientConfiguration);

            var request = new CreateMandatePdfRequest
            {
                Links = new MandatePdfLinks
                {
                    Mandate = "MD12345678"
                }
            };

            // when
            await subject.CreateAsync(request);

            // then
            _httpTest
            .ShouldHaveCalled("https://api.gocardless.com/mandate_pdfs")
            .WithoutHeader("Accept-Language")
            .WithVerb(HttpMethod.Post);
        }