/// <summary> /// Close an order transaction on the OPay cashier service. /// The order gets validated both by the SDK, and the remote OPay service. /// A successful return value indicates that the message has been successfully sent and completed. /// </summary> /// <param name="request"></param> /// <returns></returns> public async Task <BaseResponse <CloseData> > Close(CloseRequest request) { request.Validate(); var jsonRequest = JsonConvert.SerializeObject(request); var signature = Helper.EncryptData(jsonRequest, _privateKey); _httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", signature); var response = await _httpClient.SendAsync(new HttpRequestMessage { RequestUri = new Uri(ClosePath, UriKind.Relative), Method = HttpMethod.Post, Content = new StringContent(jsonRequest, Encoding.UTF8, JsonMediaType) }); var jsonResponse = await response.Content.ReadAsStringAsync(); if (!response.IsSuccessStatusCode) { throw new OpayCashierHttpException(response.StatusCode, jsonResponse); } return(JsonConvert.DeserializeObject <BaseResponse <CloseData> >(jsonResponse)); }