Пример #1
0
        public static string GetHistory(LRAccount acc, DateTime startDate,
			DateTime tillDate, string direction = "incoming")
        {
            string startString = string.Format ("{0:yyyy}-{0:dd}-{0:MM} {0:HH}:{0:mm}:{0:ss}", startDate);
            string endString = string.Format ("{0:yyyy}-{0:dd}-{0:MM} {0:HH}:{0:mm}:{0:ss}", tillDate);

            var reqString = new StringBuilder ();
            reqString.Append ("<HistoryRequest id=\"999999\">");
            reqString.Append (GetAuth (acc.ApiName, acc.Secret));
            reqString.Append ("<History>");
            reqString.Append ("<CurrencyId>" + acc.Currency.ToString () + "</CurrencyId>");
            reqString.Append ("<AccountId>" + acc.AccountIdentifier + "</AccountId>");
            reqString.Append ("<From>" + startString + "</From>");
            reqString.Append ("<Till>" + endString + "</Till>");
            reqString.Append ("<Direction>" + direction + "</Direction>");
            reqString.Append ("<Pager><PageSize>99999</PageSize></Pager>");
            reqString.Append ("</History></HistoryRequest>");

            ServicePointManager.CertificatePolicy = new CertificatePolicy ();
            string Url = "https://api.libertyreserve.com/xml/history.aspx?req=" + reqString.ToString ();

            log.Debug ("retrieving history, from: " + startString + ", to: " + endString);
            log.Debug ("Calling LR API at Url: " + Url);
            HttpWebRequest req = (HttpWebRequest)WebRequest.Create (Url);
            req.Method = "GET";

            WebResponse resp = req.GetResponse ();
            var answer = new StreamReader (resp.GetResponseStream ());
            var ret = answer.ReadToEnd ();
            log.Debug (ret);
            return ret;
        }
Пример #2
0
        public static string GetBalance(LRAccount account)
        {
            var reqString = new StringBuilder();

            reqString.Append("<BalanceRequest id=\"999999\">");
            reqString.Append(GetAuth(account.ApiName, account.Secret));
            reqString.Append("<Balance>");
            reqString.Append("<CurrencyId>" + account.Currency + "</CurrencyId>");
            reqString.Append("<AccountId>" + account.AccountIdentifier + "</AccountId>");
            reqString.Append("</Balance>");
            reqString.Append("</BalanceRequest>");

            ServicePointManager.CertificatePolicy = new CertificatePolicy();
            string Url = "https://api.libertyreserve.com/xml/balance.aspx?req=" + reqString.ToString();

            log.Debug("retrieving balance for account: " + account.AccountIdentifier + ", API: " + account.ApiName);
            log.Debug("Calling LR API at Url: " + Url);
            HttpWebRequest req = (HttpWebRequest)WebRequest.Create(Url);

            req.Method = "GET";

            WebResponse resp        = req.GetResponse();
            var         answer      = new StreamReader(resp.GetResponseStream());
            var         responseXML = answer.ReadToEnd();

            log.Debug(responseXML);
            return(responseXML);
        }
Пример #3
0
        public static string GetBalance(LRAccount account)
        {
            var reqString = new StringBuilder ();
            reqString.Append ("<BalanceRequest id=\"999999\">");
            reqString.Append (GetAuth (account.ApiName, account.Secret));
            reqString.Append ("<Balance>");
            reqString.Append ("<CurrencyId>" + account.Currency + "</CurrencyId>");
            reqString.Append ("<AccountId>" + account.AccountIdentifier + "</AccountId>");
            reqString.Append ("</Balance>");
            reqString.Append ("</BalanceRequest>");

            ServicePointManager.CertificatePolicy = new CertificatePolicy ();
            string Url = "https://api.libertyreserve.com/xml/balance.aspx?req=" + reqString.ToString ();

            log.Debug ("retrieving balance for account: " + account.AccountIdentifier + ", API: " + account.ApiName);
            log.Debug ("Calling LR API at Url: " + Url);
            HttpWebRequest req = (HttpWebRequest)WebRequest.Create (Url);
            req.Method = "GET";

            WebResponse resp = req.GetResponse ();
            var answer = new StreamReader (resp.GetResponseStream ());
            var responseXML = answer.ReadToEnd ();
            log.Debug (responseXML);
            return responseXML;
        }
Пример #4
0
        public static string GetHistory(LRAccount acc, DateTime startDate,
                                        DateTime tillDate, string direction = "incoming")
        {
            string startString = string.Format("{0:yyyy}-{0:dd}-{0:MM} {0:HH}:{0:mm}:{0:ss}", startDate);
            string endString   = string.Format("{0:yyyy}-{0:dd}-{0:MM} {0:HH}:{0:mm}:{0:ss}", tillDate);

            var reqString = new StringBuilder();

            reqString.Append("<HistoryRequest id=\"999999\">");
            reqString.Append(GetAuth(acc.ApiName, acc.Secret));
            reqString.Append("<History>");
            reqString.Append("<CurrencyId>" + acc.Currency.ToString() + "</CurrencyId>");
            reqString.Append("<AccountId>" + acc.AccountIdentifier + "</AccountId>");
            reqString.Append("<From>" + startString + "</From>");
            reqString.Append("<Till>" + endString + "</Till>");
            reqString.Append("<Direction>" + direction + "</Direction>");
            reqString.Append("<Pager><PageSize>99999</PageSize></Pager>");
            reqString.Append("</History></HistoryRequest>");

            ServicePointManager.CertificatePolicy = new CertificatePolicy();
            string Url = "https://api.libertyreserve.com/xml/history.aspx?req=" + reqString.ToString();

            log.Debug("retrieving history, from: " + startString + ", to: " + endString);
            log.Debug("Calling LR API at Url: " + Url);
            HttpWebRequest req = (HttpWebRequest)WebRequest.Create(Url);

            req.Method = "GET";

            WebResponse resp   = req.GetResponse();
            var         answer = new StreamReader(resp.GetResponseStream());
            var         ret    = answer.ReadToEnd();

            log.Debug(ret);
            return(ret);
        }
Пример #5
0
 public LRTransaction()
 {
     Currency      = "LRUSD";
     Purposes      = new List <string> ();
     LRFromAccount = new LRAccount();
     LRToAccount   = new LRAccount();
 }
Пример #6
0
        public void Init(ProviderConfig config)
        {
            this.Accounts = new List <IBankAccount> ();
            var acc = new LRAccount();

            this.Config = config;

            // retrieve list of accounts is not supported in LR, we only know of
            // one if its specified in config
            if (config.Settings ["Account"] == null)
            {
                throw new Exception("Account MUST be specified for LR");
            }
            acc.AccountIdentifier = config.Settings ["Account"].Value as string;

            if (config.Settings ["ApiName"] == null)
            {
                throw new Exception("ApiName is required");
            }
            acc.ApiName = config.Settings ["ApiName"].Value as string;

            if (config.Settings ["Secret"] == null)
            {
                throw new Exception("An API Secret must be set");
            }
            acc.Secret = config.Settings ["Secret"].Value;

            if (config.Settings ["Currency"] != null)
            {
                acc.Currency = config.Settings ["Currency"].Value;
            }

            // end configuration

            Accounts.Add(acc);
        }
Пример #7
0
 public LRTransaction()
 {
     Currency = "LRUSD";
     Purposes = new List<string> ();
     LRFromAccount = new LRAccount ();
     LRToAccount = new LRAccount ();
 }
Пример #8
0
        public void Init(ProviderConfig config)
        {
            this.Accounts = new List<IBankAccount> ();
            var acc = new LRAccount ();

            this.Config = config;

            // retrieve list of accounts is not supported in LR, we only know of
            // one if its specified in config
            if (config.Settings ["Account"] == null)
                throw new Exception ("Account MUST be specified for LR");
            acc.AccountIdentifier = config.Settings ["Account"].Value as string;

            if (config.Settings ["ApiName"] == null)
                throw new Exception ("ApiName is required");
            acc.ApiName = config.Settings ["ApiName"].Value as string;

            if (config.Settings ["Secret"] == null)
                throw new Exception ("An API Secret must be set");
            acc.Secret = config.Settings ["Secret"].Value;

            if (config.Settings ["Currency"] != null)
                acc.Currency = config.Settings ["Currency"].Value;

            // end configuration

            Accounts.Add (acc);
        }