Ejemplo n.º 1
0
        static async Task MainAsync()
        {
            var configuration = GetConfiguration();
            SecureTradingConfigurationModel secureTradingConfig = new SecureTradingConfigurationModel
            {
                Alias         = configuration["SecureTrading:Alias"],
                SiteReference = configuration["SecureTrading:SiteReference"],
                Endpoint      = configuration["SecureTrading:Endpoint"],
                Username      = configuration["SecureTrading:Username"],
                Password      = configuration["SecureTrading:Password"],
                Version       = "1.00"
            };
            SecureTradingClient service = new SecureTradingClient(secureTradingConfig);

            var orderReference     = Guid.NewGuid().ToString();
            AuthResponseModel auth = await service.AuthAsync(new AuthRequestModel
            {
                BaseAmount     = "1050",
                PAN            = "4111111111111111",
                CVV            = "123",
                Expiry         = "12/2020",
                Currency       = "GBP",
                OrderReference = orderReference,
            });

            System.Console.WriteLine("Hello World!");
        }
Ejemplo n.º 2
0
        public SecureTradingClient(SecureTradingConfigurationModel config)
        {
            _httpClient = new HttpClient();
            var byteArray = Encoding.ASCII.GetBytes($"{config.Username}:{config.Password}");

            _httpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", Convert.ToBase64String(byteArray));
            _config = config;
        }