コード例 #1
0
        public static async Task <string> SendRequest(
            string accountKey,
            PaymentHandler.Gateway gateway,
            string payloadPath    = "payload.xml",
            string privateKeyPath = "private-key.xml",
            string hostname       = "paymentapi.contact-world.net")
        {
            var payload    = File.ReadAllText(payloadPath).Trim();
            var privateKey = RsaKeyLoader.FromXmlFile(privateKeyPath);
            var handler    = new PaymentHandler(accountKey, gateway, hostname, privateKey, TimeSpan.FromSeconds(1));

            return(await handler.MakePayment(payload, Console.WriteLine));
        }
コード例 #2
0
        public static async Task <string> RelayRequest(
            string accountKey,
            PaymentHandler.Gateway gateway,
            string privateKeyPath = "private-key.xml",
            string hostname       = "paymentapi.contact-world.net")
        {
            var    payload = new StringBuilder();
            string line;

            while ((line = Console.ReadLine()) != null)
            {
                payload.AppendLine(line);
            }
            var privateKey = RsaKeyLoader.FromXmlFile(privateKeyPath);
            var handler    = new PaymentHandler(accountKey, gateway, hostname, privateKey, TimeSpan.FromSeconds(1));

            return(await handler.MakePayment(payload.ToString(), Console.WriteLine));
        }