Ejemplo n.º 1
0
        // GET api/<controller>
        public static string Get(string accountno)
        {
            var token          = "Bearer" + GetToken.GetAsync().access_token;
            var client_id      = WebConfigurationManager.AppSettings["client_id"];
            var client_secret  = WebConfigurationManager.AppSettings["client_secret"];
            var subscriptionid = "Subid000001-1571396841719";

            string URI = "https://sandbox-apis.bankofcyprus.com/df-boc-org-sb/sb/psd2/v1/accounts/" + accountno + "/balance?client_id=" + client_id + "&client_secret=" + client_secret;

            HttpWebRequest myHttpWebRequest = (HttpWebRequest)HttpWebRequest.Create(URI);

            myHttpWebRequest.Method = "GET";

            //byte[] data = Encoding.ASCII.GetBytes("{}");
            //Stream requestStream = myHttpWebRequest.GetRequestStream();
            //requestStream.Write(data, 0, 2);
            //requestStream.Close();

            myHttpWebRequest.ContentType = "application/json";
            myHttpWebRequest.Headers.Add("Authorization", token);
            myHttpWebRequest.Headers.Add("journeyId", "1");
            myHttpWebRequest.Headers.Add("originUserId", "1");
            myHttpWebRequest.Headers.Add("timeStamp", "1");
            myHttpWebRequest.Headers.Add("subscriptionId", subscriptionid);
            HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();

            Stream responseStream = myHttpWebResponse.GetResponseStream();

            StreamReader myStreamReader = new StreamReader(responseStream, Encoding.Default);

            string pageContent = myStreamReader.ReadToEnd();

            List <AccountsResponse> bal = new List <AccountsResponse>();

            bal = JsonConvert.DeserializeObject <List <AccountsResponse> >(pageContent);
            //    var availableamt = bal.Where(o => o.Balances.BalanceType == "AVAILABLE").FirstOrDefault();
            Balances availableamt = new Balances();

            foreach (var item in bal)
            {
                foreach (var bala in item.Balances)
                {
                    if (bala.BalanceType == "AVAILABLE")
                    {
                        availableamt.Amount = bala.Amount;
                    }
                }
            }
            myStreamReader.Close();
            responseStream.Close();

            myHttpWebResponse.Close();
            return(availableamt.Amount);
        }
Ejemplo n.º 2
0
        // GET api/<controller>
        public static List <AccountsResponse> Get()
        {
            List <AccountsResponse> accounts = null;

            var token = "Bearer" + GetToken.GetAsync().access_token;

            //here we go
            var client_id     = WebConfigurationManager.AppSettings["client_id"];
            var client_secret = WebConfigurationManager.AppSettings["client_secret"];

            var subscriptionid = "Subid000001-1571396841719";// GetSubscription.GetSubscriptionid(token).subscriptionId;

            var URI = new Uri("https://sandbox-apis.bankofcyprus.com/df-boc-org-sb/sb/psd2/v1/accounts?client_secret=" + client_secret + "&client_id=" + client_id + "");
            //HTTP GET
            HttpWebRequest myHttpWebRequest = (HttpWebRequest)HttpWebRequest.Create(URI);

            myHttpWebRequest.Method = "GET";

            //byte[] data = Encoding.ASCII.GetBytes("{}");
            //Stream requestStream = myHttpWebRequest.GetRequestStream();
            //requestStream.Write(data, 0, 2);
            //requestStream.Close();

            myHttpWebRequest.ContentType = "application/json";
            myHttpWebRequest.Headers.Add("Authorization", token);
            myHttpWebRequest.Headers.Add("journeyId", "1");
            myHttpWebRequest.Headers.Add("originUserId", "1");
            myHttpWebRequest.Headers.Add("timeStamp", "1");
            myHttpWebRequest.Headers.Add("subscriptionId", subscriptionid);
            HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();

            Stream responseStream = myHttpWebResponse.GetResponseStream();

            StreamReader myStreamReader = new StreamReader(responseStream, Encoding.Default);

            string pageContent = myStreamReader.ReadToEnd();

            accounts = JsonConvert.DeserializeObject <List <AccountsResponse> >(pageContent);

            myStreamReader.Close();
            responseStream.Close();

            myHttpWebResponse.Close();

            return(accounts);
        }
Ejemplo n.º 3
0
        // GET api/<controller>
        public static void Get(string paymentid)
        {
            var client_id      = WebConfigurationManager.AppSettings["client_id"];
            var client_secret  = WebConfigurationManager.AppSettings["client_secret"];
            var subscriptionid = "Subid000001-1571396841719";// GetSubscription.GetSubscriptionid(token).subscriptionId;
            var token          = "Bearer" + GetToken.GetAsync().access_token;
            var URI            = new Uri("https://sandbox-apis.bankofcyprus.com/df-boc-org-sb/sb/psd2/v1/payments/" + paymentid + "/authorize?client_secret=" + client_secret + "&client_id=" + client_id + "");

            HttpWebRequest myHttpWebRequesta = (HttpWebRequest)HttpWebRequest.Create(URI);

            myHttpWebRequesta.Method = "POST";

            myHttpWebRequesta.ContentType = "application/json";
            myHttpWebRequesta.Headers.Add("Authorization", token);
            myHttpWebRequesta.Headers.Add("subscriptionId", subscriptionid);
            myHttpWebRequesta.Headers.Add("originUserId", "1");
            myHttpWebRequesta.Headers.Add("tppId", "singpaymentdata");
            myHttpWebRequesta.Headers.Add("journeyId", "1");
            myHttpWebRequesta.Headers.Add("timeStamp", "1");

            using (var streamWriter = new StreamWriter(myHttpWebRequesta.GetRequestStream()))
            {
                var postData = "{\"transactionTime\":\"1515051381394\"," +
                               "\"authCode\":\"123456\"}";
                streamWriter.Write(postData);
            }


            HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequesta.GetResponse();

            Stream responseStream = myHttpWebResponse.GetResponseStream();

            StreamReader myStreamReader = new StreamReader(responseStream, Encoding.Default);

            string pageContent = myStreamReader.ReadToEnd();

            return;
        }
Ejemplo n.º 4
0
        // GET api/<controller>
        public IEnumerable <string> Get(string accountno)
        {
            var token          = "Bearer" + GetToken.GetAsync().access_token;
            var client_id      = WebConfigurationManager.AppSettings["client_id"];
            var client_secret  = WebConfigurationManager.AppSettings["client_secret"];
            var subscriptionid = "Subid000001-1571396841719";

            string         URI = "https://sandbox-apis.bankofcyprus.com/df-boc-org-sb/sb/psd2/v1/payments?client_id=" + client_id + "&client_secret=" + client_secret;
            HttpWebRequest myHttpWebRequest = (HttpWebRequest)HttpWebRequest.Create(URI);

            myHttpWebRequest.Method = "POST";

            //byte[] data = Encoding.ASCII.GetBytes("{}");
            //Stream requestStream = myHttpWebRequest.GetRequestStream();
            //requestStream.Write(data, 0, 2);
            //requestStream.Close();

            myHttpWebRequest.ContentType = "application/json";
            myHttpWebRequest.Headers.Add("Authorization", token);
            myHttpWebRequest.Headers.Add("journeyId", "1");
            myHttpWebRequest.Headers.Add("originUserId", "1");
            myHttpWebRequest.Headers.Add("timeStamp", "1");
            myHttpWebRequest.Headers.Add("subscriptionId", subscriptionid);
            HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();

            Stream responseStream = myHttpWebResponse.GetResponseStream();

            //StreamReader myStreamReader = new StreamReader(responseStream, Encoding.Default);

            //string pageContent = myStreamReader.ReadToEnd();

            //List<AccountsResponse> bal = new List<AccountsResponse>();
            //bal = JsonConvert.DeserializeObject<List<AccountsResponse>>(pageContent);

            return(new string[] { "value1", "value2" });
        }
Ejemplo n.º 5
0
        // GET api/<controller>
        public static string Get()
        {
            var client_id      = WebConfigurationManager.AppSettings["client_id"];
            var client_secret  = WebConfigurationManager.AppSettings["client_secret"];
            var subscriptionid = "Subid000001-1571396841719";

            string URI = "https://sandbox-apis.bankofcyprus.com/df-boc-org-sb/sb/jwssignverifyapi/sign";

            HttpWebRequest myHttpWebRequest = (HttpWebRequest)HttpWebRequest.Create(URI);

            myHttpWebRequest.Method = "POST";

            myHttpWebRequest.ContentType = "application/json";
            myHttpWebRequest.Headers.Add("tppId", "singpaymentdata");

            var postData = "{ \"debtor\" : { \"bankId\" : \"\", \"accountId\" : \"351012345671\" }, \"creditor\" : { \"bankId\" : \"\", \"accountId\" : \"351092345671\"  }, \"transactionAmount\" : {  \"amount\": \"2.55\", \"currency\" :  \"EUR\", \"currencyRate\" : \"string\" }, \"endToEndId\" : \"string\" ,  \"paymentDetails\" : \"test sandbox\" ,  \"terminalId\": \"string\", \"branch\" : \"\", \"executionDate\": \"\", \"valueDate\" : \"\"}";

            using (var streamWriter = new StreamWriter(myHttpWebRequest.GetRequestStream()))
            {
                streamWriter.Write(postData);
            }


            HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();

            Stream responseStream = myHttpWebResponse.GetResponseStream();

            StreamReader myStreamReader = new StreamReader(responseStream, Encoding.Default);

            string pageContent = myStreamReader.ReadToEnd();

            URI = "https://sandbox-apis.bankofcyprus.com/df-boc-org-sb/sb/psd2/v1/payments?client_id=" + client_id + "&client_secret=" + client_secret + "";

            HttpWebRequest myHttpWebRequesta = (HttpWebRequest)HttpWebRequest.Create(URI);

            myHttpWebRequesta.Method = "POST";

            var token = "Bearer" + GetToken.GetAsync().access_token;

            myHttpWebRequesta.ContentType = "application/json";
            myHttpWebRequesta.Headers.Add("Authorization", token);
            myHttpWebRequesta.Headers.Add("subscriptionId", subscriptionid);
            myHttpWebRequesta.Headers.Add("originUserId", "1");
            myHttpWebRequesta.Headers.Add("tppId", "singpaymentdata");
            myHttpWebRequesta.Headers.Add("journeyId", "1");
            myHttpWebRequesta.Headers.Add("timeStamp", "1");
            myHttpWebRequesta.Headers.Add("lang", "1");

            using (var streamWriter = new StreamWriter(myHttpWebRequesta.GetRequestStream()))
            {
                streamWriter.Write(pageContent);
            }
            HttpWebResponse myHttpWebResponsea = (HttpWebResponse)myHttpWebRequesta.GetResponse();

            Stream responseStreama = myHttpWebResponsea.GetResponseStream();

            StreamReader myStreamReadera = new StreamReader(responseStreama, Encoding.Default);

            pageContent = myStreamReadera.ReadToEnd();

            var paymentId = JsonConvert.DeserializeObject <GePayment>(pageContent).payment;
            var res       = paymentId.paymentId;

            return(res);
        }