コード例 #1
0
        public async Task <PaymentResponse> SendAsync(PaymentRequest request, CancellationToken cancellationToken = default)
        {
            if (request is null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            string baseUri = ApiBaseUri.Get(request.Mode);

            string requestUri = $"{baseUri}/request.json";
            string json       = request.ToJson();
            var    content    = new StringContent(json, Encoding.UTF8, "application/json");

            using var httpClient = new HttpClient();

            var response = await httpClient.PostAsync(requestUri, content, cancellationToken);

            json = await response.Content.ReadAsStringAsync();

            var model = JObject.Parse(json);

            return(PaymentResponse(model, request.Mode));
        }