示例#1
0
        private void AddSandboxPayments()
        {
            if (BunqContext.ApiContext.EnvironmentType != ApiEnvironmentType.SANDBOX)
            {
                throw new InvalidOperationException("Payments can only be added in the sandbox.");
            }

            // Usually the BunqContext should be used in a separate task
            // because it is a singleton. However, since this is the sandbox,
            // it does not matter (that much).
            Task.Run(() =>
            {
                RequestInquiry.Create(
                    new Amount("500.00", "EUR"),
                    new Pointer("EMAIL", "*****@*****.**"),
                    "Requesting some spending money.",
                    false
                    );

                Thread.Sleep(1000);

                var rng = new Random();
                for (int i = 0; i < 10; i++)
                {
                    var euro = rng.Next(10, 50);
                    var cent = rng.Next(0, 100);
                    Payment.Create(
                        new Amount($"{euro}.{cent}", "EUR"),
                        new Pointer("EMAIL", "*****@*****.**"),
                        $"Test Payment {i + 1}");
                }
            });
        }
示例#2
0
        public void Post([FromBody] JObject content)
        {
            JObject config = Settings.LoadConfig();

            Console.WriteLine("Hi there, we are connecting to the bunq API...\n");

            var apiContext = ApiContext.Restore();

            BunqContext.LoadApiContext(apiContext);
            Console.WriteLine(" -- Connected as: " + BunqContext.UserContext.UserPerson.DisplayName + " (" + BunqContext.UserContext.UserId + ")\n");


            var    amount      = content["amount"].ToString();
            string recipient   = content["recipient"].ToString();
            string description = content["description"].ToString();

            Console.WriteLine("Todo:");
            Console.WriteLine("----------------------------------------------------------");
            Console.WriteLine("Description:           " + description);
            Console.WriteLine("Send to:               " + recipient);
            Console.WriteLine("Amount:                € " + amount);
            Console.WriteLine("----------------------------------------------------------");

            if (Convert.ToDouble(amount) > 0)
            {
                Console.WriteLine("Executing...");
                RequestInquiry.Create(new Amount(amount, "EUR"), new Pointer("EMAIL", recipient), description, true);
                Console.WriteLine("Yeah, this one is completed!");
            }
            else
            {
                Console.WriteLine("Bummer, nothing to do!");
            }
            Console.WriteLine("----------------------------------------------------------\n");
        }
示例#3
0
        public void Run(string[] args)
        {
            var environmentType = ShareLib.DetermineEnvironmentType(args);

            ShareLib.PrintHeader();

            var bunq = new BunqLib(environmentType);

            var amount      = ShareLib.GetAmountFromArgsOrStdIn(args);
            var recipient   = ShareLib.GetRecipientFromArgsOrStdIn(args);
            var description = ShareLib.GetDescriptionFromArgsOrStdIn(args);

            Console.Out.WriteLine();
            Console.Out.WriteLine($"  | Requesting:   € {amount}");
            Console.Out.WriteLine($"  | From:         {recipient}");
            Console.Out.WriteLine($"  | Description:  {description}");
            Console.Out.WriteLine();
            Console.Out.WriteLine("    ...");
            Console.Out.WriteLine();

            RequestInquiry.Create(new Amount(amount, "EUR"), new Pointer("EMAIL", recipient), description, true);

            Console.Out.WriteLine();
            Console.Out.WriteLine("  | Request sent");
            Console.Out.WriteLine();
            Console.Out.WriteLine("  | Check your changed overview");
            Console.Out.WriteLine();
            Console.Out.WriteLine();

            bunq.UpdateContext();
        }
示例#4
0
 private void RequestSpendingMoneyIfNeeded()
 {
     if (ShouldRequestSpendingMoney())
     {
         RequestInquiry.Create(
             new Amount(RequestSpendingMoneyAmount, CurrencyEur),
             new Pointer(AliasTypeEmail, RequestSpendingMoneyRecipient),
             RequestSpendingMoneyDescription,
             false
             );
         Thread.Sleep(RequestSpendingMoneyWaitTimeMilliseconds);
     }
 }
示例#5
0
        public void TestRequestInquiry()
        {
            SetUpTestCase();

            RequestInquiry.Create(
                new Amount(PaymentAmountEur, PaymentCurrency),
                SecondMonetaryAccountBank.Alias.First(),
                PaymentDescription,
                false
                );

            Assert.Equal(Status, AcceptRequest());
        }
示例#6
0
        public void TestRequestInquiry()
        {
            var requestMap = new Dictionary <string, object>
            {
                { RequestInquiry.FIELD_AMOUNT_INQUIRED, new Amount(AMOUNT_EUR, FIELD_CURRENCY) },
                { RequestInquiry.FIELD_COUNTERPARTY_ALIAS, COUNTER_PARTY_SELF },
                { RequestInquiry.FIELD_DESCRIPTION, FIELD_PAYMENT_DESCRIPTION },
                { RequestInquiry.FIELD_ALLOW_BUNQME, false }
            };

            RequestInquiry.Create(API_CONTEXT, requestMap, USER_ID, MONETARY_ACCOUNT_ID);

            Assert.Equal(FIELD_STATUS, AcceptRequest());
        }
示例#7
0
        public void Run()
        {
            var apiContext = ApiContext.Restore();
            var requestId  = RequestInquiry.Create(new Amount(REQUEST_AMOUNT, REQUEST_CURRENCY),
                                                   new Pointer(COUNTERPARTY_POINTER_TYPE, COUNTERPARTY_EMAIL), REQUEST_DESCRIPTION, false).Value;

            Console.WriteLine(RequestInquiry.Get(requestId));

            var requestUpdateMap = new Dictionary <string, object> {
                { RequestInquiry.FIELD_STATUS, STATUS_REVOKED }
            };
            var requestUpdated = RequestInquiry.Update(requestId, status: STATUS_REVOKED);

            Console.WriteLine(requestUpdated);
        }
示例#8
0
        private static void RequestSpendingMoney()
        {
            RequestInquiry.Create(
                new Amount(SpendingMoneyAmount, PaymentCurrency),
                new Pointer(PointerTypeEmail, EmailSuggarDaddy),
                SpendingMoneyRequestDescription,
                false
                );

            RequestInquiry.Create(
                new Amount(SpendingMoneyAmount, PaymentCurrency),
                new Pointer(PointerTypeEmail, EmailSuggarDaddy),
                SpendingMoneyRequestDescription,
                false,
                SecondMonetaryAccountBank.Id
                );
        }
示例#9
0
        public void Run()
        {
            var apiContext = ApiContext.Restore();
            var requestMap = new Dictionary <string, object>
            {
                { RequestInquiry.FIELD_AMOUNT_INQUIRED, new Amount(REQUEST_AMOUNT, REQUEST_CURRENCY) },
                { RequestInquiry.FIELD_COUNTERPARTY_ALIAS, new Pointer(COUNTERPARTY_POINTER_TYPE, COUNTERPARTY_EMAIL) },
                { RequestInquiry.FIELD_DESCRIPTION, REQUEST_DESCRIPTION },
                { RequestInquiry.FIELD_ALLOW_BUNQME, true }
            };
            var requestId = RequestInquiry.Create(apiContext, requestMap, USER_ITEM_ID, MONETARY_ACCOUNT_ITEM_ID).Value;

            Console.WriteLine(RequestInquiry.Get(apiContext, USER_ITEM_ID, MONETARY_ACCOUNT_ITEM_ID, requestId));

            var requestUpdateMap = new Dictionary <string, object> {
                { RequestInquiry.FIELD_STATUS, STATUS_REVOKED }
            };
            var requestUpdated = RequestInquiry.Update(apiContext, requestUpdateMap, USER_ITEM_ID,
                                                       MONETARY_ACCOUNT_ITEM_ID, requestId);

            Console.WriteLine(requestUpdated);
        }
示例#10
0
        public void TestRequestInquiry()
        {
            RequestInquiry.Create(new Amount(AMOUNT_EUR, FIELD_CURRENCY), COUNTER_PARTY_SELF, PAYMENT_DESCRIPTION, false);

            Assert.Equal(STATUS, AcceptRequest());
        }