Esempio n. 1
0
        public async Task CanGetCustomerByUrlObject()
        {
            // If: We create a customer request with only the required parameters
            string           name            = "Smit";
            string           email           = "*****@*****.**";
            CustomerResponse createdCustomer = await CreateCustomer(name, email);

            // When: We try to retrieve the customer by Url object
            CustomerResponse retrievedCustomer = await CustomerClient.GetCustomerAsync(createdCustomer.Links.Self);

            // Then: Make sure it's retrieved
            Assert.AreEqual(createdCustomer.Name, retrievedCustomer.Name);
            Assert.AreEqual(createdCustomer.Email, retrievedCustomer.Email);
        }
Esempio n. 2
0
        public async Task CanCreatePaymentWithMandate()
        {
            // If: We create a payment with a mandate id
            MandateResponse validMandate = await GetFirstValidMandate();

            CustomerResponse customer = await CustomerClient.GetCustomerAsync(validMandate.Links.Customer);

            PaymentRequest paymentRequest = new PaymentRequest()
            {
                Amount       = new Amount(Currency.EUR, "100.00"),
                Description  = "Description",
                RedirectUrl  = DefaultRedirectUrl,
                SequenceType = SequenceType.Recurring,
                CustomerId   = customer.Id,
                MandateId    = validMandate.Id
            };

            // When: We send the payment request to Mollie
            PaymentResponse result = await PaymentClient.CreatePaymentAsync(paymentRequest);

            // Then: Make sure we get the mandate id back in the details
            Assert.AreEqual(validMandate.Id, result.MandateId);
        }
Esempio n. 3
0
        public async Task CanCreateRecurringPaymentAndRetrieveIt()
        {
            // If: we create a new recurring payment
            MandateResponse mandate = await GetFirstValidMandate();

            CustomerResponse customer = await CustomerClient.GetCustomerAsync(mandate.Links.Customer);

            PaymentRequest paymentRequest = new PaymentRequest()
            {
                Amount       = new Amount(Currency.EUR, "100.00"),
                Description  = "Description",
                RedirectUrl  = DefaultRedirectUrl,
                SequenceType = SequenceType.First,
                CustomerId   = customer.Id
            };

            // When: We send the payment request to Mollie and attempt to retrieve it
            PaymentResponse paymentResponse = await PaymentClient.CreatePaymentAsync(paymentRequest);

            PaymentResponse result = await PaymentClient.GetPaymentAsync(paymentResponse.Id);

            // Then: Make sure the recurringtype parameter is entered
            Assert.AreEqual(SequenceType.First, result.SequenceType);
        }
Esempio n. 4
0
        public async Task CanDeleteCustomer()
        {
            // If: We retrieve the customer list
            ListResponse <CustomerResponse> response = await CustomerClient.GetCustomerListAsync();

            if (response.Items.Count == 0)
            {
                Assert.Inconclusive("No customers found. Unable to test deleting customers");
            }

            // When: We delete one of the customers in the list
            string customerIdToDelete = response.Items.First().Id;
            await CustomerClient.DeleteCustomerAsync(customerIdToDelete);

            // Then: Make sure its deleted
            AggregateException aggregateException = Assert.ThrowsException <AggregateException>(() => CustomerClient.GetCustomerAsync(customerIdToDelete).Wait());
            MollieApiException mollieApiException = aggregateException.InnerExceptions.FirstOrDefault(x => x.GetType() == typeof(MollieApiException)) as MollieApiException;

            Assert.AreEqual((int)HttpStatusCode.Gone, mollieApiException.Details.Status);
        }
        public async Task CanDeleteCustomer()
        {
            // If: We retrieve the customer list
            var response = await CustomerClient.GetCustomerListAsync();

            if (response.Items.Count == 0)
            {
                Assert.Empty(response.Items);  //No customers found. Unable to test deleting customers
                return;
            }

            // When: We delete one of the customers in the list
            var customerIdToDelete = response.Items.First().Id;
            await CustomerClient.DeleteCustomerAsync(customerIdToDelete);

            // Then: Make sure its deleted
            var mollieApiException = await Assert.ThrowsAsync <MollieApiException>(() => CustomerClient.GetCustomerAsync(customerIdToDelete));

            Assert.Equal((int)HttpStatusCode.Gone, mollieApiException.Details.Status);
        }