Exemplo n.º 1
0
        public async Task ReturnsIndividualPayout()
        {
            // given
            var subject = new PayoutsClient(_clientConfiguration);
            var payout  = (await subject.GetPageAsync()).Items.First();

            // when
            var result = await subject.ForIdAsync(payout.Id);

            var actual = result.Item;

            // then
            Assert.That(actual, Is.Not.Null);
            Assert.That(actual.Id, Is.Not.Null.And.EqualTo(payout.Id));
            Assert.That(actual.Amount, Is.Not.Null.And.EqualTo(payout.Amount));
            Assert.That(actual.ArrivalDate, Is.Not.Null.And.EqualTo(payout.ArrivalDate));
            Assert.That(actual.CreatedAt, Is.Not.Null.And.EqualTo(payout.CreatedAt));
            Assert.That(actual.Currency, Is.Not.Null.And.EqualTo(payout.Currency));
            Assert.That(actual.DeductedFees, Is.Not.Null.And.EqualTo(payout.DeductedFees));
            Assert.That(actual.Links, Is.Not.Null);
            Assert.That(actual.Links.Creditor, Is.Not.Null.And.EqualTo(payout.Links.Creditor));
            Assert.That(actual.Links.CreditorBankAccount, Is.Not.Null.And.EqualTo(payout.Links.CreditorBankAccount));
            Assert.That(actual.PayoutType, Is.Not.Null.And.EqualTo(payout.PayoutType));
            Assert.That(actual.Reference, Is.Not.Null.And.EqualTo(payout.Reference));
            Assert.That(actual.Status, Is.Not.Null.And.EqualTo(payout.Status));
        }
Exemplo n.º 2
0
        public async Task MapsPagingProperties()
        {
            // given
            var subject = new PayoutsClient(_clientConfiguration);

            var firstPageRequest = new GetPayoutsRequest
            {
                Limit = 1
            };

            // when
            var firstPageResult = await subject.GetPageAsync(firstPageRequest);

            var secondPageRequest = new GetPayoutsRequest
            {
                After = firstPageResult.Meta.Cursors.After,
                Limit = 1
            };

            var secondPageResult = await subject.GetPageAsync(secondPageRequest);

            // then
            Assert.That(firstPageResult.Items.Count(), Is.EqualTo(firstPageRequest.Limit));
            Assert.That(firstPageResult.Meta.Limit, Is.EqualTo(firstPageRequest.Limit));
            Assert.That(firstPageResult.Meta.Cursors.Before, Is.Null);
            Assert.That(firstPageResult.Meta.Cursors.After, Is.Not.Null);

            Assert.That(secondPageResult.Items.Count(), Is.EqualTo(secondPageRequest.Limit));
            Assert.That(secondPageResult.Meta.Limit, Is.EqualTo(secondPageRequest.Limit));
            Assert.That(secondPageResult.Meta.Cursors.Before, Is.Not.Null);
            Assert.That(secondPageResult.Meta.Cursors.After, Is.Not.Null);
        }
Exemplo n.º 3
0
        public async Task ReturnsPayouts()
        {
            // given
            var subject = new PayoutsClient(_clientConfiguration);

            var request = new GetPayoutsRequest
            {
                PayoutType = PayoutType.Merchant
            };

            // when
            var result = (await subject.GetPageAsync(request)).Items.ToList();

            // then
            Assert.That(result.Any(), Is.True);
            Assert.That(result[0], Is.Not.Null);
            Assert.That(result[0].Id, Is.Not.Null);
            Assert.That(result[0].Amount, Is.Not.EqualTo(default(int)));
            Assert.That(result[0].ArrivalDate, Is.Not.Null.And.Not.EqualTo(default(DateTime)));
            Assert.That(result[0].CreatedAt, Is.Not.Null.And.Not.EqualTo(default(DateTimeOffset)));
            Assert.That(result[0].Currency, Is.Not.Null);
            Assert.That(result[0].DeductedFees, Is.Not.Null.And.Not.EqualTo(default(int)));
            Assert.That(result[0].Links, Is.Not.Null);
            Assert.That(result[0].Links.Creditor, Is.Not.Null);
            Assert.That(result[0].Links.CreditorBankAccount, Is.Not.Null);
            Assert.That(result[0].PayoutType, Is.Not.Null);
            Assert.That(result[0].Reference, Is.Not.Null);
            Assert.That(result[0].Status, Is.Not.Null);
        }
        internal async Task <Payout> Payout()
        {
            var request = new GetPayoutsRequest
            {
                PayoutType = PayoutType.Merchant
            };

            var payoutsClient = new PayoutsClient(_clientConfiguration);

            return((await payoutsClient.GetPageAsync(request)).Items.First());
        }
Exemplo n.º 5
0
        public async Task CallsGetPayoutsEndpoint()
        {
            // given
            var subject = new PayoutsClient(_clientConfiguration);

            // when
            await subject.GetPageAsync();

            // then
            _httpTest
            .ShouldHaveCalled("https://api.gocardless.com/payouts")
            .WithVerb(HttpMethod.Get);
        }
Exemplo n.º 6
0
        public void IdIsNullOrWhiteSpaceThrows(string id)
        {
            // given
            var subject = new PayoutsClient(_clientConfiguration);

            // when
            AsyncTestDelegate test = () => subject.ForIdAsync(id);

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

            Assert.That(ex.Message, Is.Not.Null);
            Assert.That(ex.ParamName, Is.EqualTo(nameof(id)));
        }
Exemplo n.º 7
0
        public async Task CallsIndividualPayoutsEndpoint()
        {
            // given
            var subject = new PayoutsClient(_clientConfiguration);
            var id      = "PO12345678";

            // when
            await subject.ForIdAsync(id);

            // then
            _httpTest
            .ShouldHaveCalled("https://api.gocardless.com/payouts/PO12345678")
            .WithVerb(HttpMethod.Get);
        }
Exemplo n.º 8
0
        public void GetPayoutsRequestIsNullThrows()
        {
            // given
            var subject = new PayoutsClient(_clientConfiguration);

            GetPayoutsRequest request = null;

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

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

            Assert.That(ex.ParamName, Is.EqualTo(nameof(request)));
        }
Exemplo n.º 9
0
        /// <summary>
        /// Creates a new instance of the QuickPayClient
        /// </summary>
        /// <param name="baseUrl">URL for API, if null it defaults to QuickPays standard URL</param>
        /// <param name="baseUrlInvoicing">URL for Invoicing API, if null it defaults to QuickPays standard URL</param>
        /// <param name="apiKey"></param>
        /// <param name="privateKey"></param>
        /// <param name="userKey"></param>
        public QuickPayClient(string baseUrl, string baseUrlInvoicing, string apiKey, string privateKey, string userKey)
        {
            _url          = baseUrl ?? "https://api.quickpay.net/";
            _urlInvoicing = baseUrlInvoicing ?? "https://invoicing.quickpay.net/";
            _apiKey       = apiKey;
            _privateKey   = privateKey;
            _userKey      = userKey;
            _httpClient   = BuildHttpClient(_url, _apiKey, null);

            Callbacks     = new CallbacksClient(_privateKey);
            Cards         = new CardsClient(_httpClient);
            Fees          = new FeesClient(_httpClient);
            Invoices      = new InvoicesClient(BuildHttpClient(_urlInvoicing, _userKey, "application/vnd.api+json"));
            Payments      = new PaymentsClient(_httpClient);
            Payouts       = new PayoutsClient(_httpClient);
            Subscriptions = new SubscriptionsClient(_httpClient);
        }
Exemplo n.º 10
0
        public async Task CallsGetPayoutsEndpointUsingRequest()
        {
            // given
            var subject = new PayoutsClient(_clientConfiguration);

            var request = new GetPayoutsRequest
            {
                Before = "before test",
                After  = "after test",
                Limit  = 5
            };

            // when
            await subject.GetPageAsync(request);

            // then
            _httpTest
            .ShouldHaveCalled("https://api.gocardless.com/payouts?before=before%20test&after=after%20test&limit=5")
            .WithVerb(HttpMethod.Get);
        }
Exemplo n.º 11
0
        public async Task ReturnsPagesIncludingAndAfterInitialRequest()
        {
            // given
            var subject = new PayoutsClient(_clientConfiguration);

            var initialRequest = new GetPayoutsRequest
            {
                Limit = 1,
            };

            // when
            var result = await subject
                         .BuildPager()
                         .StartFrom(initialRequest)
                         .AndGetAllAfterAsync();

            // then
            Assert.That(result.Count, Is.GreaterThan(1));
            Assert.That(result[0].Id, Is.Not.Null.And.Not.EqualTo(result[1].Id));
            Assert.That(result[1].Id, Is.Not.Null.And.Not.EqualTo(result[0].Id));
        }
Exemplo n.º 12
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);
        }