public void GetPreauthorization()
        {
            PaymillList <Preauthorization> lstPreauthorizations = _paymill.PreauthorizationService.ListAsync().Result;
            Preauthorization preauthorization = _paymill.PreauthorizationService.GetAsync(lstPreauthorizations.Data[0].Id).Result;

            Assert.IsFalse(String.IsNullOrEmpty(preauthorization.Id), "Create Preauthorization Failed");
        }
Beispiel #2
0
        public void CreatePreauthorizationWithToken()
        {
            Preauthorization newPreauthorization = _paymill.PreauthorizationService.CreateWithTokenAsync(testToken, 3500, "EUR").Result;

            Assert.IsFalse(String.IsNullOrEmpty(newPreauthorization.Id), "Create Preauthorization Failed");
            Assert.IsTrue(newPreauthorization.Amount == 3500, "Create Preauthorization Failed");
            Assert.IsTrue(newPreauthorization.Currency == "EUR", "Create Preauthorization Failed");
        }
Beispiel #3
0
 public void CreateTransactionWithPreauthorization()
 {
     Preauthorization preauthorization = _paymill.PreauthorizationService.CreateWithTokenAsync(testToken, 4200, "USD").Result;
     Transaction transaction = _paymill.TransactionService.CreateWithPreauthorizationAsync(preauthorization, 4200, "USD").Result;
     Assert.IsFalse(String.IsNullOrEmpty(transaction.Id));
     Assert.IsTrue(transaction.Currency == "USD");
     Assert.IsTrue(transaction.Amount == 4200);
     Assert.IsTrue(transaction.CreatedAt.Date == DateTime.Now.Date);
 }
        public void CreatePreauthorizationWithPayment()
        {
            Payment          payment             = _paymill.PaymentService.CreateWithTokenAsync(testToken).Result;
            Preauthorization newPreauthorization = _paymill.PreauthorizationService.CreateWithPaymentAsync(payment, 3500, "EUR", "Descr").Result;

            Assert.IsFalse(String.IsNullOrEmpty(newPreauthorization.Id), "Create Preauthorization Failed");
            Assert.IsTrue(newPreauthorization.Amount == 3500, "Create Preauthorization Failed");
            Assert.IsTrue(newPreauthorization.Currency == "EUR", "Create Preauthorization Failed");
            Assert.IsTrue(String.Compare(newPreauthorization.Description, "Descr") == 0);
        }
Beispiel #5
0
        public void CreateTransactionWithPreauthorizationAndDescription()
        {
            Preauthorization preauthorization = _paymill.PreauthorizationService.CreateWithTokenAsync(testToken, 4200, "USD", null).Result;
            Transaction      transaction      = _paymill.TransactionService.CreateWithPreauthorizationAsync(preauthorization, 4200, "USD", "Bar bar").Result;

            Assert.IsFalse(String.IsNullOrEmpty(transaction.Id));
            Assert.IsTrue(transaction.Currency == "USD");
            Assert.IsTrue(transaction.Amount == 4200);
            Assert.IsTrue(transaction.Description == "Bar bar");
        }
        public void ListOrderByOrder()
        {
            Preauthorization.Order orderDesc = Preauthorization.CreateOrder().ByCreatedAt().Desc();
            Preauthorization.Order orderAsc  = Preauthorization.CreateOrder().ByCreatedAt().Asc();

            List <Preauthorization> preauthorizationDesc = _paymill.PreauthorizationService.ListAsync(null, orderDesc).Result.Data;
            List <Preauthorization> preauthorizationAsc  = _paymill.PreauthorizationService.ListAsync(null, orderAsc).Result.Data;

            Assert.AreNotEqual(preauthorizationDesc[0].Id, preauthorizationAsc[0].Id);
            Assert.AreNotEqual(preauthorizationDesc[preauthorizationDesc.Count - 1].Id, preauthorizationAsc[0].Id);
        }
        public void RemovePreauthorization()
        {
            Payment          payment             = _paymill.PaymentService.CreateWithTokenAsync(testToken).Result;
            Preauthorization newPreauthorization = _paymill.PreauthorizationService.CreateWithPaymentAsync(payment, 3500, "EUR").Result;

            Assert.IsFalse(String.IsNullOrEmpty(newPreauthorization.Id), "Create Preauthorization Failed");
            Assert.IsTrue(newPreauthorization.Amount == 3500, "Create Preauthorization Failed");
            Assert.IsTrue(newPreauthorization.Currency == "EUR", "Create Preauthorization Failed");
            Boolean result = _paymill.PreauthorizationService.DeleteAsync(newPreauthorization.Id).Result;

            Assert.IsTrue(result);
        }
Beispiel #8
0
        public void ListOrderByFilterAmountGreaterThan()
        {
            int amount = 300;

            Preauthorization.Filter filter           = Preauthorization.CreateFilter().ByAmountGreaterThan(amount);
            List <Preauthorization> preauthorization = _paymill.PreauthorizationService.ListAsync(filter, null).Result.Data;

            Assert.IsFalse(preauthorization.Count == 0);
            foreach (var pre in preauthorization)
            {
                Assert.IsFalse(pre.Amount <= amount);
            }
        }
Beispiel #9
0
        static void getPreauthorization()
        {
            Paymill.ApiKey = Properties.Settings.Default.ApiKey;
            Paymill.ApiUrl = Properties.Settings.Default.ApiUrl;
            PreauthorizationService preauthorizationService = Paymill.GetService <PreauthorizationService>();

            Console.WriteLine("Solicitando preauthorization...");
            string           preauthorizationID = "preauth_96fe414f466f91ddb266";
            Preauthorization preauthorization   = preauthorizationService.GetPreauthorization(preauthorizationID);

            Console.WriteLine("PreauthorizationID:" + preauthorization.Id);
            Console.WriteLine("Created at:" + preauthorization.Created_At.ToShortDateString());
            Console.Read();
        }
Beispiel #10
0
        public void EncodePreauthorization()
        {
            URLEncoder urlEncoder = new URLEncoder();

            Preauthorization preauthorization = new Preauthorization();

            preauthorization.Amount   = 3500;
            preauthorization.Currency = "EUR";
            preauthorization.Payment  = new Payment()
            {
                Id = "pay_4c159fe95d3be503778a"
            };

            string expected = "amount=3500&currency=EUR&payment=pay_4c159fe95d3be503778a";
            string reply    = urlEncoder.EncodePreauthorization(preauthorization);

            Assert.AreEqual(expected, reply);
        }
        public string EncodePreauthorization(Preauthorization data)
        {
            StringBuilder sb = new StringBuilder();

            this.addKeyValuePair(sb, "amount", data.Amount);
            this.addKeyValuePair(sb, "currency", data.Currency);

            if (!string.IsNullOrEmpty(data.Token))
            {
                this.addKeyValuePair(sb, "token", data.Token);
            }

            if (data.Payment != null && !string.IsNullOrEmpty(data.Payment.Id))
            {
                this.addKeyValuePair(sb, "payment", data.Payment.Id);
            }

            return(sb.ToString());
        }
Beispiel #12
0
        public string EncodePreauthorization(Preauthorization data)
        {
            StringBuilder sb       = new StringBuilder();
            String        srcValue = String.Format("{0}-{1}", Paymill.GetProjectName(), Paymill.GetProjectVersion());

            this.addKeyValuePair(sb, "amount", data.Amount);
            this.addKeyValuePair(sb, "currency", data.Currency);
            this.addKeyValuePair(sb, "source", srcValue);
            if (!string.IsNullOrEmpty(data.Token))
            {
                this.addKeyValuePair(sb, "token", data.Token);
            }

            if (data.Payment != null && !string.IsNullOrEmpty(data.Payment.Id))
            {
                this.addKeyValuePair(sb, "payment", data.Payment.Id);
            }

            return(sb.ToString());
        }
Beispiel #13
0
        static void addPreauthorization()
        {
            Paymill.ApiKey = Properties.Settings.Default.ApiKey;
            Paymill.ApiUrl = Properties.Settings.Default.ApiUrl;
            PreauthorizationService preauthorizationService = Paymill.GetService <PreauthorizationService>();

            Preauthorization preauthorization = new Preauthorization();

            preauthorization.Amount   = 3500;
            preauthorization.Currency = "EUR";
            //preauthorization.Token = "098f6bcd4621d373cade4e832627b4f6";
            preauthorization.Payment = new Payment()
            {
                Id = "pay_4c159fe95d3be503778a"
            };

            Preauthorization newPreauthorization = preauthorizationService.AddPreauthorization(preauthorization);

            Console.WriteLine("PreauthorizationID:" + newPreauthorization.Id);
            Console.Read();
        }
Beispiel #14
0
 /// <summary>
 /// Executes a <see cref="Transaction" /> with <see cref="Preauthorization" /> for the given amount in the given currency.
 /// </summary>
 /// <param name="preauthorization">A Preauthorization, which has reserved some money from the client’s credit card.</param>
 /// <param name="amount">Amount (in cents) which will be charged.</param>
 /// <param name="currency">ISO 4217 formatted currency code.</param>
 /// <param name="description">The description.</param>
 /// <returns>Transaction object indicating whether a the call was successful or not.</returns>
 public async Task <Transaction> CreateWithPreauthorizationAsync(Preauthorization preauthorization, int amount, String currency, String description)
 {
     return(await CreateWithPreauthorizationAsync(preauthorization.Id, amount, currency, description, null));
 }