Esempio n. 1
0
        public async Task <PaymentsResponse> ChargeNonce([FromBody] PaymentsModel model)
        {
            ChargeRequest body = new ChargeRequest();

            SetTestValues(body);

            HttpClient client = new HttpClient();

            client.BaseAddress = new Uri("https://connect.squareup.com");
            client.DefaultRequestHeaders.Add("Authorization", "Bearer " + _sqConfig.Token);
            client.DefaultRequestHeaders.Add("Accept", "application/json");

            string stringData  = JsonConvert.SerializeObject(body);
            var    contentData = new StringContent(stringData, System.Text.Encoding.UTF8, "application/json");
            var    response    = await client.PostAsync("/v2/locations/" + _sqConfig.LocationId + "/transactions", contentData);

            var contents = await response.Content.ReadAsStringAsync();

            var paymentResponse = JsonConvert.DeserializeObject <PaymentsResponse>(contents);

            return(paymentResponse);
        }