public async Task <JObject> GetMerchantSessionAsync( Uri requestUri, MerchantSessionRequest request, CancellationToken cancellationToken = default) { // POST the data to create a valid Apple Pay merchant session. using (var response = await _httpClient.PostAsJsonAsync(requestUri, request, cancellationToken)) { response.EnsureSuccessStatusCode(); // Read the opaque merchant session JSON from the response body. return(await response.Content.ReadAsAsync <JObject>(cancellationToken)); } }
public async Task <JsonDocument> GetMerchantSessionAsync( Uri requestUri, MerchantSessionRequest request, CancellationToken cancellationToken = default) { // POST the data to create a valid Apple Pay merchant session. string json = JsonSerializer.Serialize(request); using var content = new StringContent(json, Encoding.UTF8, MediaTypeNames.Application.Json); using var response = await _httpClient.PostAsync(requestUri, content, cancellationToken); response.EnsureSuccessStatusCode(); // Read the opaque merchant session JSON from the response body. using var stream = await response.Content.ReadAsStreamAsync(); return(await JsonDocument.ParseAsync(stream, cancellationToken : cancellationToken)); }