Esempio n. 1
0
        public void testCreateUpdateDeletePayment()
        {
            FigoPayment payment = new FigoPayment { Type = "Transfer", AccountNumber = "4711951501", BankCode = "90090042", Name = "figo", Purpose = "Thanks for all the fish.", Amount = 0.89F };
            Task<FigoPayment> task_add = sut.AddPayment("A1.1", payment);
            task_add.Wait();
            FigoPayment addedPayment = task_add.Result;
            Assert.IsNotNull(addedPayment);
            Assert.IsNotNull(addedPayment.PaymentId);
            Assert.AreEqual("A1.1", addedPayment.AccountId);
            Assert.AreEqual("Demobank", addedPayment.BankName);
            Assert.AreEqual(0.89F, addedPayment.Amount);

            addedPayment.Amount = 2.39F;
            Task<FigoPayment> task_update = sut.UpdatePayment(addedPayment);
            task_update.Wait();

            Task<FigoPayment> task_get = sut.GetPayment(addedPayment.AccountId, addedPayment.PaymentId);
            task_get.Wait();
            FigoPayment updatedPayment = task_get.Result;
            Assert.IsNotNull(updatedPayment);
            Assert.AreEqual(addedPayment.PaymentId, updatedPayment.PaymentId);
            Assert.AreEqual("A1.1", updatedPayment.AccountId);
            Assert.AreEqual("Demobank", updatedPayment.BankName);
            Assert.AreEqual(2.39F, updatedPayment.Amount);

            Task<bool> task_delete = sut.RemovePayment(updatedPayment);
            task_delete.Wait();

            Task<FigoPayment> task_test = sut.GetPayment(addedPayment.AccountId, addedPayment.PaymentId);
            task_test.Wait();
            Assert.IsNull(task_test.Result);
        }
Esempio n. 2
0
        /// <summary>
        /// Remove a stored payment from the server. This is only possible if it has not been submitted yet.
        /// </summary>
        /// <param name="payment">Payment to be removed</param>
        public async Task <bool> RemovePayment(FigoPayment payment)
        {
            await this.DoRequest("/rest/accounts/" + payment.AccountId + "/payments/" + payment.PaymentId, "DELETE");

            return(true);
        }
Esempio n. 3
0
        /// <summary>
        /// Submit a stored payment to the bank. This is only possible if it has not been submitted yet.
        /// </summary>
        /// <param name="payment">Payment to be submitted</param>
        /// <returns>Updated payment</returns>
        public async Task <string> SubmitPayment(FigoPayment payment)
        {
            var response = await this.DoRequest <TaskTokenResponse>("/rest/accounts/" + payment.AccountId + "/payments/" + payment.PaymentId + "/submit", "POST");

            return(ApiEndpoint + "/task/start?id=" + response.TaskToken);
        }
Esempio n. 4
0
 /// <summary>
 /// Update a stored payment. This is only possible if it has not been submitted yet.
 /// </summary>
 /// <param name="payment">Payment with updated values</param>
 /// <returns>Updated payment</returns>
 public async Task <FigoPayment> UpdatePayment(FigoPayment payment)
 {
     return(await this.DoRequest <FigoPayment>("/rest/accounts/" + payment.AccountId + "/payments/" + payment.PaymentId, "PUT", payment));
 }
Esempio n. 5
0
 /// <summary>
 /// Create a new payment
 /// </summary>
 /// <param name="accountId">ID of the account to be used for the new payment</param>
 /// <param name="payment">Payment which should be created</param>
 /// <returns>created payment including its figo ID</returns>
 public async Task <FigoPayment> AddPayment(string accountId, FigoPayment payment)
 {
     return(await this.DoRequest <FigoPayment>("/rest/accounts/" + accountId + "/payments", "POST", payment));
 }